Completed
Push — master ( 0136c1...94aca9 )
by Lukas Kahwe
03:29
created

FiltersCompilerPassTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 24
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
lcom 0
cbo 4
dl 24
loc 24
rs 10

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
namespace Liip\ImagineBundle\Tests\DependencyInjection\Compiler;
4
5
use Liip\ImagineBundle\DependencyInjection\Compiler\FiltersCompilerPass;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Definition;
8
9
/**
10
 * @covers Liip\ImagineBundle\DependencyInjection\Compiler\FiltersCompilerPass
11
 */
12
class FiltersCompilerPassTest extends \PHPUnit_Framework_TestCase
13
{
14
    public function testProcess()
15
    {
16
        $managerDefinition = new Definition();
17
        $loaderDefinition = new Definition();
18
        $loaderDefinition->addTag('liip_imagine.filter.loader', array(
19
            'loader' => 'foo',
20
        ));
21
22
        $container = new ContainerBuilder();
23
        $container->setDefinition('liip_imagine.filter.manager', $managerDefinition);
24
        $container->setDefinition('a.loader', $loaderDefinition);
25
26
        $pass = new FiltersCompilerPass();
27
28
        //guard
29
        $this->assertCount(0, $managerDefinition->getMethodCalls());
30
31
        $pass->process($container);
32
33
        $this->assertCount(1, $managerDefinition->getMethodCalls());
34
    }
35
}
36