Code Duplication    Length = 29-32 lines in 2 locations

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

@@ 16-47 (lines=32) @@
13
use eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\HostElement;
14
use PHPUnit\Framework\TestCase;
15
16
final class HostElementNormalizerTest extends TestCase
17
{
18
    public function testNormalization()
19
    {
20
        $normalizer = new HostElementNormalizer();
21
        $normalizer->setSerializer(new SerializerStub());
22
23
        $matcher = new HostElement(2);
24
        // Set request and invoke match to initialize HostElement::$hostElements
25
        $matcher->setRequest(SimplifiedRequest::fromUrl('http://ezpublish.dev/foo/bar'));
26
        $matcher->match();
27
28
        $this->assertEquals(
29
            [
30
                'elementNumber' => 2,
31
                'hostElements' => [
32
                    'ezpublish',
33
                    'dev',
34
                ],
35
            ],
36
            $normalizer->normalize($matcher)
37
        );
38
    }
39
40
    public function testSupportsNormalization()
41
    {
42
        $normalizer = new HostElementNormalizer();
43
44
        $this->assertTrue($normalizer->supportsNormalization($this->createMock(HostElement::class)));
45
        $this->assertFalse($normalizer->supportsNormalization($this->createMock(Matcher::class)));
46
    }
47
}
48

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

@@ 16-44 (lines=29) @@
13
use eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\URIElement;
14
use PHPUnit\Framework\TestCase;
15
16
final class URIElementNormalizerTest extends TestCase
17
{
18
    public function testNormalization()
19
    {
20
        $normalizer = new URIElementNormalizer();
21
        $normalizer->setSerializer(new SerializerStub());
22
23
        $matcher = new URIElement(2);
24
        // Set request and invoke match to initialize HostElement::$hostElements
25
        $matcher->setRequest(SimplifiedRequest::fromUrl('http://ezpublish.dev/foo/bar'));
26
        $matcher->match();
27
28
        $this->assertEquals(
29
            [
30
                'elementNumber' => 2,
31
                'uriElements' => ['foo', 'bar'],
32
            ],
33
            $normalizer->normalize($matcher)
34
        );
35
    }
36
37
    public function testSupportsNormalization()
38
    {
39
        $normalizer = new URIElementNormalizer();
40
41
        $this->assertTrue($normalizer->supportsNormalization($this->createMock(URIElement::class)));
42
        $this->assertFalse($normalizer->supportsNormalization($this->createMock(Matcher::class)));
43
    }
44
}
45