66
77use Codeception \Test \Unit ;
88use PHPUnit \Framework \MockObject \MockObject ;
9+ use stdClass ;
910use WebProject \DockerApi \Library \Generated \Client ;
1011use WebProject \DockerApi \Library \Generated \Model \ContainerConfig ;
1112use WebProject \DockerApi \Library \Generated \Model \ContainerInspectResponse ;
@@ -24,9 +25,9 @@ final class DockerServiceTest extends Unit
2425
2526 protected function _before (): void
2627 {
27- $ this ->client = $ this ->createMock (Client::class);
28+ $ this ->client = $ this ->createMock (Client::class);
2829 $ this ->apiClientWrapper = new DockerApiClientWrapper ('http://mocked-uri ' , '/mocked/socket ' , $ this ->client );
29- $ this ->service = new DockerService ($ this ->apiClientWrapper );
30+ $ this ->service = new DockerService ($ this ->apiClientWrapper );
3031 }
3132
3233 public function testFindAllContainer (): void
@@ -39,11 +40,11 @@ public function testFindAllContainer(): void
3940 ->willReturn ([$ containerSummary ]);
4041
4142 $ inspectResponse = $ this ->createConfiguredMock (ContainerInspectResponse::class, [
42- 'getId ' => '123 ' ,
43- 'getName ' => '/test-container ' ,
44- 'getImage ' => 'nginx:latest ' ,
45- 'getState ' => $ this ->createConfiguredMock (ContainerState::class, ['getRunning ' => true ]),
46- 'getConfig ' => $ this ->createConfiguredMock (ContainerConfig::class, ['getEnv ' => ['FOO=bar ' ]]),
43+ 'getId ' => '123 ' ,
44+ 'getName ' => '/test-container ' ,
45+ 'getImage ' => 'nginx:latest ' ,
46+ 'getState ' => $ this ->createConfiguredMock (ContainerState::class, ['getRunning ' => true ]),
47+ 'getConfig ' => $ this ->createConfiguredMock (ContainerConfig::class, ['getEnv ' => ['FOO=bar ' ]]),
4748 'getNetworkSettings ' => $ this ->createConfiguredMock (NetworkSettings::class, ['getNetworks ' => [], 'getPorts ' => []]),
4849 ]);
4950
@@ -53,7 +54,7 @@ public function testFindAllContainer(): void
5354 ->willReturn ($ inspectResponse );
5455
5556 $ result = $ this ->service ->findAllContainer ();
56- $ dtos = iterator_to_array ($ result );
57+ $ dtos = iterator_to_array ($ result );
5758
5859 $ this ->assertCount (1 , $ dtos );
5960 $ this ->assertArrayHasKey ('123 ' , $ dtos );
@@ -65,11 +66,11 @@ public function testFindAllContainer(): void
6566 public function testFindContainer (): void
6667 {
6768 $ inspectResponse = $ this ->createConfiguredMock (ContainerInspectResponse::class, [
68- 'getId ' => '456 ' ,
69- 'getName ' => '/single-container ' ,
70- 'getImage ' => 'php:8.3 ' ,
71- 'getState ' => $ this ->createConfiguredMock (ContainerState::class, ['getRunning ' => false ]),
72- 'getConfig ' => $ this ->createConfiguredMock (ContainerConfig::class, ['getEnv ' => []]),
69+ 'getId ' => '456 ' ,
70+ 'getName ' => '/single-container ' ,
71+ 'getImage ' => 'php:8.3 ' ,
72+ 'getState ' => $ this ->createConfiguredMock (ContainerState::class, ['getRunning ' => false ]),
73+ 'getConfig ' => $ this ->createConfiguredMock (ContainerConfig::class, ['getEnv ' => []]),
7374 'getNetworkSettings ' => $ this ->createConfiguredMock (NetworkSettings::class, ['getNetworks ' => [], 'getPorts ' => []]),
7475 ]);
7576
@@ -89,10 +90,10 @@ public function testFindContainerNotFound(): void
8990 $ this ->client ->expects ($ this ->once ())
9091 ->method ('containerInspect ' )
9192 ->with ('999 ' )
92- ->willReturn (new \ stdClass ());
93+ ->willReturn (new stdClass ());
9394
9495 $ dto = $ this ->service ->findContainer ('999 ' );
9596
9697 $ this ->assertNull ($ dto );
9798 }
98- }
99+ }
0 commit comments