Completed
Push — EZP-31681 ( 54659b...e049ce )
by
unknown
18:38 queued 10s
created

HostElementNormalizerTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
dl 32
loc 32
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testNormalization() 21 21 1
A testSupportsNormalization() 7 7 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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
namespace eZ\Publish\Core\MVC\Symfony\Component\Tests\Serializer;
8
9
use eZ\Publish\Core\MVC\Symfony\Component\Serializer\HostElementNormalizer;
10
use eZ\Publish\Core\MVC\Symfony\Component\Tests\Serializer\Stubs\SerializerStub;
11
use eZ\Publish\Core\MVC\Symfony\Routing\SimplifiedRequest;
12
use eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher;
13
use eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\HostElement;
14
use PHPUnit\Framework\TestCase;
15
16 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...
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