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

HostElementNormalizerTest::testNormalization()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 21

Duplication

Lines 21
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 21
loc 21
rs 9.584
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\HostElementNormalizer;
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\HostElement;
16
use PHPUnit\Framework\TestCase;
17
18 View Code Duplication
final class HostElementNormalizerTest 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 HostElementNormalizer();
23
        $normalizer->setSerializer(new SerializerStub());
24
25
        $matcher = new HostElement(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
                'hostElements' => [
34
                    'ezpublish',
35
                    'dev',
36
                ],
37
            ],
38
            $normalizer->normalize($matcher)
39
        );
40
    }
41
42
    public function testSupportsNormalization(): void
43
    {
44
        $normalizer = new HostElementNormalizer();
45
46
        $this->assertTrue($normalizer->supportsNormalization($this->createMock(HostElement::class)));
47
        $this->assertFalse($normalizer->supportsNormalization($this->createMock(Matcher::class)));
48
    }
49
}
50