forked from php-censor/php-censor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProjectTest.php
More file actions
63 lines (54 loc) · 1.81 KB
/
Copy pathProjectTest.php
File metadata and controls
63 lines (54 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
namespace Tests\PHPCensor\Model;
use PHPCensor\Common\Exception\InvalidArgumentException;
use PHPCensor\Model;
use PHPCensor\Model\Project;
use PHPCensor\StoreRegistry;
use PHPUnit\Framework\TestCase;
/**
* Unit tests for the Project model class.
*
* @author Dan Cryer <dan@block8.co.uk>
*/
class ProjectTest extends TestCase
{
protected StoreRegistry $storeRegistry;
protected function setUp(): void
{
$configuration = $this->getMockBuilder('PHPCensor\ConfigurationInterface')->getMock();
$databaseManager = $this
->getMockBuilder('PHPCensor\DatabaseManager')
->setConstructorArgs([$configuration])
->getMock();
$this->storeRegistry = $this
->getMockBuilder('PHPCensor\StoreRegistry')
->setConstructorArgs([$databaseManager])
->getMock();
}
public function testExecute_TestIsAValidModel()
{
$project = new Project($this->storeRegistry);
self::assertTrue($project instanceof Model);
try {
$project->setArchived('true');
} catch (InvalidArgumentException $e) {
self::assertEquals(
'Column "archived" must be a bool.',
$e->getMessage()
);
}
}
public function testExecute_TestProjectAccessInformation()
{
$info = [
'item1' => 'Item One',
'item2' => 2,
];
$project = new Project($this->storeRegistry);
$project->setAccessInformation($info);
self::assertEquals('Item One', $project->getAccessInformation('item1'));
self::assertEquals(2, $project->getAccessInformation('item2'));
self::assertNull($project->getAccessInformation('item3'));
self::assertEquals($info, $project->getAccessInformation());
}
}