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
|
|
|
|