testParentNormalizerContext()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 9.6666
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
namespace Thunder\Serializard\Tests;
3
4
use Thunder\Serializard\NormalizerContext\ParentNormalizerContext;
5
6
/**
7
 * @author Tomasz Kowalczyk <[email protected]>
8
 */
9
final class NormalizerContextTest extends AbstractTestCase
10
{
11
    public function testParentNormalizerContext()
12
    {
13
        $ctx = new ParentNormalizerContext();
14
        $this->assertSame(0, $ctx->getLevel());
15
        $this->assertNull($ctx->getParent());
16
        $this->assertNull($ctx->getFormat());
17
        $this->assertNull($ctx->getRoot());
18
19
        $object = new \stdClass();
20
        /** @var ParentNormalizerContext $ctx */
21
        $ctx = $ctx->withRoot($object)->withFormat('json');
22
23
        $ctx = $ctx->withParent($object);
24
        $this->assertSame(1, $ctx->getLevel());
25
        $this->assertSame($object, $ctx->getParent());
26
        $this->assertSame($object, $ctx->getRoot());
27
        $this->assertSame('json', $ctx->getFormat());
28
    }
29
}
30