Completed
Pull Request — master (#16)
by Nikola
01:29
created

AspectCollectorPassTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A itRegistersAspects() 0 17 1
A registerCompilerPass() 0 4 1
1
<?php
2
/**
3
 * Go! AOP framework
4
 *
5
 * @copyright Copyright 2015, Lisachenko Alexander <[email protected]>
6
 *
7
 * This source file is subject to the license that is bundled
8
 * with this source code in the file LICENSE.
9
 */
10
11
namespace Go\Symfony\GoAopBundle\Tests\DependencyInjection\Compiler;
12
13
use Go\Symfony\GoAopBundle\DependencyInjection\Compiler\AspectCollectorPass;
14
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractCompilerPassTestCase;
15
use Symfony\Component\DependencyInjection\ContainerBuilder;
16
use Symfony\Component\DependencyInjection\Definition;
17
use Symfony\Component\DependencyInjection\Reference;
18
19
/**
20
 * Class AspectCollectorPassTest
21
 */
22
class AspectCollectorPassTest extends AbstractCompilerPassTestCase
23
{
24
    /**
25
     * @test
26
     */
27
    public function itRegistersAspects()
28
    {
29
        $this->setDefinition('goaop.aspect.container', new Definition());
30
31
        $someAspect = new Definition();
32
        $someAspect->addTag('goaop.aspect');
33
        $this->setDefinition('some_aspect', $someAspect);
34
35
        $someOtherAspect = new Definition();
36
        $someOtherAspect->addTag('goaop.aspect');
37
        $this->setDefinition('some_other_aspect', $someOtherAspect);
38
39
        $this->compile();
40
41
        $this->assertContainerBuilderHasServiceDefinitionWithMethodCall('goaop.aspect.container', 'registerAspect', [new Reference('some_aspect')], 0);
42
        $this->assertContainerBuilderHasServiceDefinitionWithMethodCall('goaop.aspect.container', 'registerAspect', [new Reference('some_other_aspect')], 1);
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    protected function registerCompilerPass(ContainerBuilder $container)
49
    {
50
        $container->addCompilerPass(new AspectCollectorPass());
51
    }
52
}
53