Conditions | 1 |
Paths | 1 |
Total Lines | 50 |
Code Lines | 32 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
15 | public function testInvokeWillCreateAnAkismetServiceInstance() |
||
16 | { |
||
17 | $containerMock = $this->createMock(ContainerInterface::class); |
||
18 | |||
19 | $viewHelperManagerMock = |
||
20 | $this->getMockBuilder('ViewHelperManager') |
||
21 | ->setMethods(['get']) |
||
22 | ->getMock(); |
||
23 | |||
24 | $serverUrlMock = |
||
25 | $this->getMockBuilder(ServerUrl::class) |
||
26 | ->setMethods(['__invoke']) |
||
27 | ->getMock(); |
||
28 | |||
29 | $configMock = [ |
||
30 | 'rb_comment' => [ |
||
31 | 'akismet' => [ |
||
32 | 'api_key' => uniqid(), |
||
33 | ], |
||
34 | ], |
||
35 | ]; |
||
36 | |||
37 | $factory = new AkismetServiceFactory(); |
||
38 | |||
39 | // Expectations |
||
40 | $containerMock->expects($this->exactly(2)) |
||
41 | ->method('get') |
||
42 | ->withConsecutive( |
||
43 | ['Config'], |
||
44 | ['ViewHelperManager'] |
||
45 | ) |
||
46 | ->willReturnOnConsecutiveCalls( |
||
47 | $configMock, |
||
48 | $viewHelperManagerMock |
||
49 | ); |
||
50 | |||
51 | $viewHelperManagerMock->expects($this->once()) |
||
52 | ->method('get') |
||
53 | ->with('serverUrl') |
||
54 | ->willReturn($serverUrlMock); |
||
55 | |||
56 | $serverUrlMock->expects($this->once()) |
||
57 | ->method('__invoke') |
||
58 | ->willReturn('http://test.com'); |
||
59 | |||
60 | $table = $factory($containerMock, Akismet::class); |
||
61 | |||
62 | // Assertions |
||
63 | $this->assertInstanceOf(Akismet::class, $table); |
||
64 | } |
||
65 | } |
||
66 |