Completed
Push — 6.13 ( fb0043...d86c76 )
by André
18:03
created

CompoundMatcherNormalizerTest::testNormalization()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 25
rs 9.52
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
5
 * @license For full copyright and license information view LICENSE file distributed with this source code.
6
 */
7
declare(strict_types=1);
8
9
namespace eZ\Publish\Core\MVC\Symfony\Component\Tests\Serializer;
10
11
use eZ\Publish\Core\MVC\Symfony\Component\Serializer\CompoundMatcherNormalizer;
12
use eZ\Publish\Core\MVC\Symfony\Component\Tests\Serializer\Stubs\CompoundStub;
13
use eZ\Publish\Core\MVC\Symfony\Component\Tests\Serializer\Stubs\MatcherStub;
14
use eZ\Publish\Core\MVC\Symfony\Component\Tests\Serializer\Stubs\SerializerStub;
15
use eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher;
16
use eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Compound;
17
use PHPUnit\Framework\TestCase;
18
19
final class CompoundMatcherNormalizerTest extends TestCase
20
{
21
    public function testNormalization(): void
22
    {
23
        $matcher = new CompoundStub([]);
24
        $matcher->setSubMatchers([
25
            'foo' => new MatcherStub('foo'),
26
            'bar' => new MatcherStub('bar'),
27
            'baz' => new MatcherStub('baz'),
28
        ]);
29
30
        $normalizer = new CompoundMatcherNormalizer();
31
        $normalizer->setSerializer(new SerializerStub());
32
33
        $this->assertEquals(
34
            [
35
                'subMatchers' => [
36
                    'foo' => ['data' => 'foo'],
37
                    'bar' => ['data' => 'bar'],
38
                    'baz' => ['data' => 'baz'],
39
                ],
40
                'config' => [],
41
                'matchersMap' => [],
42
            ],
43
            $normalizer->normalize($matcher)
44
        );
45
    }
46
47
    public function testSupportsNormalization(): void
48
    {
49
        $normalizer = new CompoundMatcherNormalizer();
50
51
        $this->assertTrue($normalizer->supportsNormalization($this->createMock(Compound::class)));
52
        $this->assertFalse($normalizer->supportsNormalization($this->createMock(Matcher::class)));
53
    }
54
}
55