Passed
Pull Request — master (#103)
by David
02:17
created

ImageServiceTest::testGetInternalPorts()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace TheAentMachine\Docker;
4
5
use Docker\API\Exception\ImageDeleteNotFoundException;
6
use Gamez\Psr\Log\TestLogger;
7
use PHPUnit\Framework\TestCase;
8
9
class ImageServiceTest extends TestCase
10
{
11
    public function testPull(): void
12
    {
13
        $logger = new TestLogger();
14
        $imageService = new ImageService($logger);
15
16
        try {
17
            $imageService->rmi('busybox:1.29.2');
18
        } catch(ImageDeleteNotFoundException $e) {
19
            // Try to delete. If this fails, it's ok.
20
        }
21
22
        $imageService->pull('busybox:1.29.2');
23
        $log = $logger->log;
24
        $this->assertTrue($log->has('Pulling from library/busybox'));
25
    }
26
27
    public function testGetInternalPorts(): void
28
    {
29
        $logger = new TestLogger();
30
        $imageService = new ImageService($logger);
31
32
        $ports = $imageService->getInternalPorts('php:7.2-apache');
33
        $this->assertSame([80], $ports);
34
    }
35
36
    public function testGetVolumes(): void
37
    {
38
        $logger = new TestLogger();
39
        $imageService = new ImageService($logger);
40
41
        $ports = $imageService->getVolumes('mysql:5.7');
42
        $this->assertSame(['/var/lib/mysql'], $ports);
43
    }
44
}
45