Completed
Push — EZP-31779-patch-1 ( 5b8c64...1888bf )
by
unknown
18:52
created

RegexNormalizerTest::testSupportsNormalization()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 7
rs 10
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
namespace eZ\Publish\Core\MVC\Symfony\Component\Tests\Serializer;
8
9
use eZ\Publish\Core\MVC\Symfony\Component\Serializer\RegexNormalizer;
10
use eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher;
11
use eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Regex as RegexMatcher;
12
use eZ\Publish\Core\MVC\Symfony\Component\Tests\Serializer\Stubs\RegexMatcher as RegexMatcherStub;
13
use PHPUnit\Framework\TestCase;
14
15
final class RegexNormalizerTest extends TestCase
16
{
17
    public function testNormalize()
18
    {
19
        $normalizer = new RegexNormalizer();
20
        $matcher = new RegexMatcherStub('/^Foo(.*)/(.*)/', 2);
21
22
        $this->assertEquals(
23
            [
24
                'regex' => '/^Foo(.*)/(.*)/',
25
                'itemNumber' => 2,
26
                'matchedSiteAccess' => null,
27
            ],
28
            $normalizer->normalize($matcher)
29
        );
30
    }
31
32
    public function testSupportsNormalization()
33
    {
34
        $normalizer = new RegexNormalizer();
35
36
        $this->assertTrue($normalizer->supportsNormalization($this->createMock(RegexMatcher::class)));
37
        $this->assertFalse($normalizer->supportsNormalization($this->createMock(Matcher::class)));
38
    }
39
}
40