Completed
Push — master ( c5c0e9...29e67b )
by David
14s
created

ServiceTest::testCheckValidity()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace TheAentMachine\Registry;
4
5
6
use PHPUnit\Framework\TestCase;
7
use TheAentMachine\Service\Exception\ServiceException;
8
use TheAentMachine\Service\Service;
9
10
class ServiceTest extends TestCase
11
{
12
    private const PAYLOAD = <<< 'JSON'
13
{
14
  "serviceName" : "foo",
15
  "service": {
16
    "image"         : "foo",
17
    "internalPorts" : [1, 2, 3],
18
    "dependsOn"     : ["foo", "bar"],
19
    "ports"         : [{"source": 80, "target": 8080}],
20
    "environment"   : {
21
                        "FOO": {
22
                          "value": "fooo",
23
                          "type": "containerEnvVariable"
24
                        }
25
                      },
26
    "labels"        : {
27
                        "foo": {"value": "fooo"},
28
                        "bar": {"value": "baar"}
29
                      },               
30
    "volumes"       : [
31
                        {
32
                          "type"      : "volume",
33
                          "source"    : "foo",
34
                          "target"    : "bar",
35
                          "readOnly"  : true
36
                        }
37
                      ]
38
  }
39
}
40
JSON;
41
42
    /**
43
     * @throws ServiceException
44
     */
45
    public function testCheckValidity() : void
46
    {
47
        $p = json_decode(self::PAYLOAD, true);
48
        $service = Service::parsePayload($p);
49
        $json = json_encode($service->jsonSerialize(), JSON_PRETTY_PRINT);
50
        $this->assertNotEmpty($json);
51
    }
52
}
53