Completed
Push — ezp_30827 ( c6ab75...809fcf )
by
unknown
14:52
created

SiteAccessMatcherRegistryPassTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 6 6 1
A registerCompilerPass() 4 4 1
A testSetMatcher() 18 18 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
declare(strict_types=1);
8
9
namespace eZ\Bundle\EzPublishCoreBundle\Tests\DependencyInjection\Compiler;
10
11
use eZ\Bundle\EzPublishCoreBundle\DependencyInjection\Compiler\SiteAccessMatcherRegistryPass;
12
use eZ\Bundle\EzPublishCoreBundle\SiteAccess\SiteAccessMatcherRegistry;
13
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractCompilerPassTestCase;
14
use Symfony\Component\DependencyInjection\ContainerBuilder;
15
use Symfony\Component\DependencyInjection\Definition;
16
use Symfony\Component\DependencyInjection\Reference;
17
18 View Code Duplication
class SiteAccessMatcherRegistryPassTest extends AbstractCompilerPassTestCase
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
    protected function setUp(): void
21
    {
22
        parent::setUp();
23
24
        $this->setDefinition(SiteAccessMatcherRegistry::class, new Definition());
25
    }
26
27
    protected function registerCompilerPass(ContainerBuilder $container): void
28
    {
29
        $container->addCompilerPass(new SiteAccessMatcherRegistryPass());
30
    }
31
32
    public function testSetMatcher(): void
33
    {
34
        $def = new Definition();
35
        $def->addTag(SiteAccessMatcherRegistryPass::MATCHER_TAG);
36
        $serviceId = 'service_id';
37
        $this->setDefinition($serviceId, $def);
38
39
        $this->compile();
40
41
        $this->assertContainerBuilderHasServiceDefinitionWithMethodCall(
42
            SiteAccessMatcherRegistry::class,
43
            'setMatcher',
44
            [
45
                $serviceId,
46
                new Reference($serviceId),
47
            ]
48
        );
49
    }
50
}
51