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

URIElementNormalizerTest::testNormalization()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18

Duplication

Lines 18
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 18
loc 18
rs 9.6666
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\URIElementNormalizer;
12
use eZ\Publish\Core\MVC\Symfony\Component\Tests\Serializer\Stubs\SerializerStub;
13
use eZ\Publish\Core\MVC\Symfony\Routing\SimplifiedRequest;
14
use eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher;
15
use eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\URIElement;
16
use PHPUnit\Framework\TestCase;
17
18 View Code Duplication
final class URIElementNormalizerTest extends TestCase
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
19
{
20
    public function testNormalization(): void
21
    {
22
        $normalizer = new URIElementNormalizer();
23
        $normalizer->setSerializer(new SerializerStub());
24
25
        $matcher = new URIElement(2);
26
        // Set request and invoke match to initialize HostElement::$hostElements
27
        $matcher->setRequest(SimplifiedRequest::fromUrl('http://ezpublish.dev/foo/bar'));
28
        $matcher->match();
29
30
        $this->assertEquals(
31
            [
32
                'elementNumber' => 2,
33
                'uriElements' => ['foo', 'bar'],
34
            ],
35
            $normalizer->normalize($matcher)
36
        );
37
    }
38
39
    public function testSupportsNormalization(): void
40
    {
41
        $normalizer = new URIElementNormalizer();
42
43
        $this->assertTrue($normalizer->supportsNormalization($this->createMock(URIElement::class)));
44
        $this->assertFalse($normalizer->supportsNormalization($this->createMock(Matcher::class)));
45
    }
46
}
47