Completed
Push — ezp_31810 ( 8f2282 )
by
unknown
19:03
created

CompoundMatcherNormalizerTest::testNormalization()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 22
rs 9.568
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\MatcherStub;
13
use eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher;
14
use eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Compound;
15
use PHPUnit\Framework\TestCase;
16
17
final class CompoundMatcherNormalizerTest extends TestCase
18
{
19
    public function testNormalization(): void
20
    {
21
        $matcher = $this->createMock(Compound::class);
22
        $matcher->method('getSubMatchers')->willReturn([
23
            new MatcherStub('foo'),
24
            new MatcherStub('bar'),
25
            new MatcherStub('baz'),
26
        ]);
27
28
        $normalizer = new CompoundMatcherNormalizer();
29
30
        $this->assertEquals(
31
            [
32
                'subMatchers' => [
33
                    ['data' => 'foo'],
34
                    ['data' => 'bar'],
35
                    ['data' => 'baz'],
36
                ],
37
            ],
38
            $normalizer->normalize($matcher)
39
        );
40
    }
41
42
    public function testSupportsNormalization(): void
43
    {
44
        $normalizer = new CompoundMatcherNormalizer();
45
46
        $this->assertTrue($normalizer->supportsNormalization($this->createMock(Compound::class)));
47
        $this->assertFalse($normalizer->supportsNormalization($this->createMock(Matcher::class)));
48
    }
49
}
50