Completed
Pull Request — 5.3 (#2593)
by Jeroen
11:24 queued 05:08
created

getContainerExtensions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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[]
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use KunstmaanSeoExtension[].

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
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