Code Duplication    Length = 29-32 lines in 2 locations

eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/HostElementNormalizerTest.php 1 location

@@ 18-49 (lines=32) @@
15
use eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\HostElement;
16
use PHPUnit\Framework\TestCase;
17
18
final class HostElementNormalizerTest extends TestCase
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

eZ/Publish/Core/MVC/Symfony/Component/Tests/Serializer/URIElementNormalizerTest.php 1 location

@@ 18-46 (lines=29) @@
15
use eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\URIElement;
16
use PHPUnit\Framework\TestCase;
17
18
final class URIElementNormalizerTest extends TestCase
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