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

GoAopExtensionTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 82
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A itLoadsServices() 0 23 2
A itNormalizesAndSetsAspectKernelOptions() 0 13 1
A itDisablesCacheWarmer() 0 10 1
A itEnablesDoctrineSupport() 0 8 1
A getContainerExtensions() 0 6 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;
12
13
use Go\Symfony\GoAopBundle\DependencyInjection\GoAopExtension;
14
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionTestCase;
15
use Symfony\Component\DependencyInjection\Definition;
16
17
/**
18
 * Class GoAopExtensionTest
19
 */
20
class GoAopExtensionTest extends AbstractExtensionTestCase
21
{
22
    /**
23
     * @test
24
     */
25
    public function itLoadsServices()
26
    {
27
        $this->load();
28
29
        $expectedServices = [
30
            'goaop.aspect.kernel',
31
            'goaop.aspect.container',
32
            'goaop.cache.path.manager',
33
            'goaop.cache.warmer',
34
            'goaop.command.warmup',
35
            'goaop.command.debug_advisor',
36
            'goaop.command.debug_aspect',
37
            'goaop.bridge.doctrine.metadata_load_interceptor',
38
        ];
39
40
        foreach ($expectedServices as $id) {
41
            $this->assertContainerBuilderHasService($id);
42
        }
43
44
        $this->assertEquals(count($expectedServices), count(array_filter($this->container->getDefinitions(), function ($id) {
45
            return 0 === strpos($id, 'goaop.');
46
        }, ARRAY_FILTER_USE_KEY)));
47
    }
48
49
    /**
50
     * @test
51
     */
52
    public function itNormalizesAndSetsAspectKernelOptions()
53
    {
54
        $this->load();
55
56
        $this->assertEquals([
57
            'features'     => 0,
58
            'appDir'       => '%kernel.root_dir%/../src',
59
            'cacheDir'     => '%kernel.cache_dir%/aspect',
60
            'debug'        => '%kernel.debug%',
61
            'includePaths' => [],
62
            'excludePaths' => [],
63
        ], $this->container->getParameter('goaop.options'));
64
    }
65
66
    /**
67
     * @test
68
     */
69
    public function itDisablesCacheWarmer()
70
    {
71
        $this->load([
72
            'cache_warmer' => false,
73
        ]);
74
75
        $definition = $this->container->getDefinition('goaop.cache.warmer');
76
77
        $this->assertFalse($definition->hasTag('kernel.cache_warmer'));
78
    }
79
80
    /**
81
     * @test
82
     */
83
    public function itEnablesDoctrineSupport()
84
    {
85
        $this->load([
86
            'doctrine_support' => true,
87
        ]);
88
89
        $this->assertContainerBuilderHasServiceDefinitionWithTag('goaop.bridge.doctrine.metadata_load_interceptor', 'doctrine.event_subscriber');
90
    }
91
92
    /**
93
     * {@inheritdoc}
94
     */
95
    protected function getContainerExtensions()
96
    {
97
        return [
98
            new GoAopExtension(),
99
        ];
100
    }
101
}
102