|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Kunstmaan\SeoBundle\Tests\DependencyInjection; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\ORM\EntityManager; |
|
6
|
|
|
use Kunstmaan\AdminBundle\Helper\CloneHelper; |
|
7
|
|
|
use Kunstmaan\SeoBundle\DependencyInjection\KunstmaanSeoExtension; |
|
8
|
|
|
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionTestCase; |
|
9
|
|
|
use Symfony\Component\DependencyInjection\Definition; |
|
10
|
|
|
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; |
|
11
|
|
|
use Symfony\Component\DependencyInjection\Reference; |
|
12
|
|
|
use Symfony\Component\Security\Core\Authorization\AuthorizationChecker; |
|
13
|
|
|
|
|
14
|
|
|
class KunstmaanSeoExtensionTest extends AbstractExtensionTestCase |
|
15
|
|
|
{ |
|
16
|
|
|
protected function setUp() |
|
17
|
|
|
{ |
|
18
|
|
|
parent::setUp(); |
|
19
|
|
|
|
|
20
|
|
|
$this->registerService('doctrine.orm.entity_manager', EntityManager::class); |
|
21
|
|
|
$this->registerService('kunstmaan_admin.clone.helper', CloneHelper::class); |
|
22
|
|
|
$this->registerService('security.authorization_checker', AuthorizationChecker::class); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @return ExtensionInterface[] |
|
|
|
|
|
|
27
|
|
|
*/ |
|
28
|
|
|
protected function getContainerExtensions() |
|
29
|
|
|
{ |
|
30
|
|
|
return [new KunstmaanSeoExtension()]; |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
public function testSeoRequestCacheMethodCall() |
|
34
|
|
|
{ |
|
35
|
|
|
$this->setDefinition('kunstmaan_seo.twig.extension', new Definition()); |
|
36
|
|
|
$this->setDefinition('cache.app', new Definition()); |
|
37
|
|
|
|
|
38
|
|
|
$this->load(['request_cache' => 'cache.app']); |
|
39
|
|
|
|
|
40
|
|
|
$this->compile(); |
|
41
|
|
|
|
|
42
|
|
|
$this->assertContainerBuilderHasServiceDefinitionWithMethodCall( |
|
43
|
|
|
'kunstmaan_seo.twig.extension', |
|
44
|
|
|
'setRequestCache', |
|
45
|
|
|
[ |
|
46
|
|
|
new Reference('cache.app'), |
|
47
|
|
|
] |
|
48
|
|
|
); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
public function testSeoRequestCacheMethodCallWithNullValue() |
|
52
|
|
|
{ |
|
53
|
|
|
$this->setDefinition('kunstmaan_seo.twig.extension', new Definition()); |
|
54
|
|
|
$this->setDefinition('cache.app', new Definition()); |
|
55
|
|
|
|
|
56
|
|
|
$this->load(['request_cache' => null]); |
|
57
|
|
|
|
|
58
|
|
|
$this->compile(); |
|
59
|
|
|
|
|
60
|
|
|
$this->assertFalse($this->container->getDefinition('kunstmaan_seo.twig.extension')->hasMethodCall('setRequestCache')); |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|
This check looks for the generic type
arrayas a return type and suggests a more specific type. This type is inferred from the actual code.