Completed
Push — master ( fce4b8...13b6da )
by Tomasz
02:27
created

NormalizerTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 1
dl 0
loc 34
rs 10
c 1
b 1
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testReflectionSkip() 0 7 1
A testReflectionInheritance() 0 10 1
A testGetObjectVarsNormalizer() 0 12 1
1
<?php
2
namespace Thunder\Serializard\Tests;
3
4
use Thunder\Serializard\Normalizer\GetObjectVarsNormalizer;
5
use Thunder\Serializard\Normalizer\ReflectionNormalizer;
6
use Thunder\Serializard\Tests\Fake\Inheritance\FakeClass;
7
use Thunder\Serializard\Tests\Fake\FakeTag;
8
use Thunder\Serializard\Tests\Fake\FakeUser;
9
10
/**
11
 * @author Tomasz Kowalczyk <[email protected]>
12
 */
13
class NormalizerTest extends \PHPUnit_Framework_TestCase
14
{
15
    public function testReflectionSkip()
16
    {
17
        $normalizer = new ReflectionNormalizer(array('tag', 'tags'));
18
        $object = new FakeUser(12, 'XXX', new FakeTag(144, 'YYY'));
19
20
        $this->assertSame(array('id' => 12, 'name' => 'XXX'), $normalizer($object));
21
    }
22
23
    public function testReflectionInheritance()
24
    {
25
        $normalizer = new ReflectionNormalizer();
26
27
        $this->assertSame(array(
28
            'property' => 'property',
29
            'parentProperty' => 'parent',
30
            'parentParentProperty' => 'parentParent',
31
        ), $normalizer(new FakeClass('parentParent', 'parent', 'property')));
32
    }
33
34
    public function testGetObjectVarsNormalizer()
35
    {
36
        $normalizer = new GetObjectVarsNormalizer();
37
38
        $this->assertSame(array(
39
            'public' => 'public',
40
        ), $normalizer(new class {
41
            public $public = 'public';
42
            protected $protected = 'protected';
43
            private $private = 'private';
44
        }));
45
    }
46
}
47