-
Notifications
You must be signed in to change notification settings - Fork 145
Expand file tree
/
Copy pathEnvironmentTest.php
More file actions
97 lines (75 loc) · 2.95 KB
/
Copy pathEnvironmentTest.php
File metadata and controls
97 lines (75 loc) · 2.95 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
declare(strict_types=1);
namespace Tests\PHPCensor\Model\Base;
use PHPCensor\DatabaseManager;
use PHPCensor\Model;
use PHPCensor\Model\Base\Environment;
use PHPCensor\StoreRegistry;
use PHPUnit\Framework\TestCase;
use PHPCensor\Common\Application\ConfigurationInterface;
class EnvironmentTest extends TestCase
{
private StoreRegistry $storeRegistry;
protected function setUp(): void
{
$configuration = $this->getMockBuilder(ConfigurationInterface::class)->getMock();
$databaseManager = $this
->getMockBuilder(DatabaseManager::class)
->setConstructorArgs([$configuration])
->getMock();
$this->storeRegistry = $this
->getMockBuilder(StoreRegistry::class)
->setConstructorArgs([$databaseManager])
->getMock();
}
public function testConstruct(): void
{
$environment = new Environment($this->storeRegistry);
self::assertInstanceOf(Model::class, $environment);
self::assertInstanceOf(Environment::class, $environment);
self::assertEquals([
'id' => null,
'project_id' => null,
'name' => null,
'branches' => [],
], $environment->getDataArray());
}
public function testId(): void
{
$environment = new Environment($this->storeRegistry);
$result = $environment->setId(100);
self::assertEquals(true, $result);
self::assertEquals(100, $environment->getId());
$result = $environment->setId(100);
self::assertEquals(false, $result);
}
public function testProjectId(): void
{
$environment = new Environment($this->storeRegistry);
$result = $environment->setProjectId(200);
self::assertEquals(true, $result);
self::assertEquals(200, $environment->getProjectId());
$result = $environment->setProjectId(200);
self::assertEquals(false, $result);
}
public function testName(): void
{
$environment = new Environment($this->storeRegistry);
$result = $environment->setName('name');
self::assertEquals(true, $result);
self::assertEquals('name', $environment->getName());
$result = $environment->setName('name');
self::assertEquals(false, $result);
}
public function testBranches(): void
{
$environment = new Environment($this->storeRegistry);
$result = $environment->setBranches(['branch-1', 'branch-2']);
self::assertEquals(true, $result);
self::assertEquals(['branch-1', 'branch-2'], $environment->getBranches());
$result = $environment->setBranches(['branch-1', 'branch-2']);
self::assertEquals(false, $result);
$environment = new Environment($this->storeRegistry, ['branches' => "branch-1\nbranch-2\nbranch-3\n\nbranch-4"]);
self::assertEquals(['branch-1', 'branch-2', 'branch-3', 'branch-4'], $environment->getBranches());
}
}