Completed
Push — EZP-31287 ( fe8c5c...af9523 )
by
unknown
34:01
created

RegexHostNormalizerTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testNormalize() 20 20 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\RegexHostNormalizer;
10
use eZ\Publish\Core\MVC\Symfony\Component\Tests\Serializer\Stubs\SerializerStub;
11
use eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher;
12
use eZ\Publish\Core\MVC\Symfony\SiteAccess\Matcher\Regex\Host;
13
use eZ\Publish\Core\Search\Tests\TestCase;
14
15 View Code Duplication
final class RegexHostNormalizerTest 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...
16
{
17
    public function testNormalize()
18
    {
19
        $normalizer = new RegexHostNormalizer();
20
        $normalizer->setSerializer(new SerializerStub());
21
22
        $matcher = new Host([
0 ignored issues
show
Deprecated Code introduced by
The class eZ\Publish\Core\MVC\Symf...cess\Matcher\Regex\Host has been deprecated with message: since 5.3 as it cannot be reverted.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
23
            'regex' => '/^Foo(.*)/(.*)/',
24
            'itemNumber' => 2,
25
        ]);
26
27
        $this->assertEquals(
28
            [
29
                'siteAccessesConfiguration' => [
30
                    'regex' => '/^Foo(.*)/(.*)/',
31
                    'itemNumber' => 2,
32
                ],
33
            ],
34
            $normalizer->normalize($matcher)
35
        );
36
    }
37
38
    public function testSupportsNormalization()
39
    {
40
        $normalizer = new RegexHostNormalizer();
41
42
        $this->assertTrue($normalizer->supportsNormalization($this->createMock(Host::class)));
43
        $this->assertFalse($normalizer->supportsNormalization($this->createMock(Matcher::class)));
44
    }
45
}
46