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
|
|
|
|