Passed
Push — master ( 9280cd...76fe10 )
by Simon
02:08
created

ReportPatternCompilerTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 28
loc 28
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A registerCompilerPass() 4 4 1
A reportPatternTest() 20 20 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
 * This file is part of
5
 * 
6
 * (c) symball <http://simonball.me>
7
 * 
8
 * For the full copyright and license information, please view the LICENSE file 
9
 * that was distributed with this source code.
10
 */
11
12
namespace Symball\ReportBundle\Tests\Extension;
13
14
use Symfony\Component\DependencyInjection\ContainerBuilder;
15
use Symfony\Component\DependencyInjection\Definition;
16
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractCompilerPassTestCase;
17
use Symball\ReportBundle\DependencyInjection\Compiler\ReportPatternPass;
18
/**
19
 * Description of CompilerTest
20
 *
21
 * @author Simon Ball <simonball at simonball dot me>
22
 */
23 View Code Duplication
class ReportPatternCompilerTest 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...
24
{
25
    protected function registerCompilerPass(ContainerBuilder $container)
26
    {
27
        $container->addCompilerPass(new ReportPatternPass());
28
    }
29
    
30
    public function reportPatternTest()
31
    {
32
        $collectingService = new Definition();
33
        $this->setDefinition('symball_report.pattern', $collectingService);
34
        
35
        $collectedService = new Definition();
36
        $collectedService->addTag('symball_report.pattern', ['alias' => 'test_alias']);
37
        $this->setDefinition('some_unimportant_service_id', $collectedService);
38
        
39
        $this->compile();
40
        
41
        $this->assertContainerBuilderHasServiceDefinitionWithMethodCall(
42
            'symball_report.pattern',
43
            'add',
44
            array(
45
                new Reference('some_unimportant_service_id')
46
            )
47
        );
48
        
49
    }
50
}