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

RegexNormalizerTest::testNormalize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 20
rs 9.6
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A RegexNormalizerTest.php$0 ➔ getName() 0 4 1
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\API\Repository\Exceptions\NotImplementedException;
12
use eZ\Publish\Core\MVC\Symfony\Component\Serializer\RegexNormalizer;
13
use eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher;
14
use eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Regex as RegexMatcher;
15
use PHPUnit\Framework\TestCase;
16
17
final class RegexNormalizerTest extends TestCase
18
{
19
    public function testNormalize(): void
20
    {
21
        $normalizer = new RegexNormalizer();
22
23
        $matcher = new class('/^Foo(.*)/(.*)/', 2) extends RegexMatcher {
24
            public function getName()
25
            {
26
                throw new NotImplementedException(__METHOD__);
27
            }
28
        };
29
30
        $this->assertEquals(
31
            [
32
                'regex' => '/^Foo(.*)/(.*)/',
33
                'itemNumber' => 2,
34
                'matchedSiteAccess' => null,
35
            ],
36
            $normalizer->normalize($matcher)
37
        );
38
    }
39
40
    public function testSupportsNormalization(): void
41
    {
42
        $normalizer = new RegexNormalizer();
43
44
        $this->assertTrue($normalizer->supportsNormalization($this->createMock(RegexMatcher::class)));
45
        $this->assertFalse($normalizer->supportsNormalization($this->createMock(Matcher::class)));
46
    }
47
}
48