1 | <?php |
||
13 | class RegistryTest extends \PHPUnit_Framework_TestCase |
||
14 | { |
||
15 | private $testedInstance; |
||
16 | |||
17 | public function setUp() |
||
18 | { |
||
19 | $this->testedInstance = new Registry(); |
||
20 | } |
||
21 | |||
22 | public function testGetProvidersEmptyIfNoProviders() |
||
23 | { |
||
24 | $this->assertEquals( |
||
25 | [], |
||
26 | $this->testedInstance->get() |
||
27 | ); |
||
28 | } |
||
29 | |||
30 | public function testGetReturnMatchingEntries() |
||
31 | { |
||
32 | $entry1 = $this->newRegistryMatching(true); |
||
33 | $entry2 = $this->newRegistryMatching(false); |
||
34 | $entry3 = $this->newRegistryMatching(true); |
||
35 | |||
36 | $this->testedInstance |
||
37 | ->add($entry1) |
||
38 | ->add($entry2) |
||
39 | ->add($entry3) |
||
40 | ; |
||
41 | |||
42 | $entries = $this->testedInstance->get(); |
||
43 | |||
44 | $this->assertCount(2, $entries); |
||
45 | |||
46 | $this->assertContains($entry1, $entries); |
||
47 | $this->assertNotContains($entry2, $entries); |
||
48 | $this->assertContains($entry3, $entries); |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * @return RegistryEntry |
||
53 | */ |
||
54 | private function newRegistryMatching($matching) |
||
55 | { |
||
56 | $entry = $this |
||
57 | ->getMockBuilder(RegistryEntry::class) |
||
58 | ->disableOriginalConstructor() |
||
59 | ->getMock() |
||
60 | ; |
||
61 | |||
62 | $entry |
||
63 | ->expects($this->any()) |
||
64 | ->method('match') |
||
65 | ->willReturn($matching) |
||
66 | ; |
||
67 | |||
68 | return $entry; |
||
69 | } |
||
70 | } |