Completed
Pull Request — 5.3 (#2593)
by Jeroen
06:29
created

testSeoRequestCacheMethodCallWithNullValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.9
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
    /**
27
     * @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...
28
     */
29
    protected function getContainerExtensions()
30
    {
31
        return [new KunstmaanSeoExtension()];
32
    }
33
34
    public function testSeoRequestCacheMethodCall()
35
    {
36
        $this->setDefinition('kunstmaan_seo.twig.extension', new Definition());
37
        $this->setDefinition('cache.app', new Definition());
38
39
        $this->load(['request_cache' => 'cache.app']);
40
41
        $this->compile();
42
43
        $this->assertContainerBuilderHasServiceDefinitionWithMethodCall(
44
            'kunstmaan_seo.twig.extension',
45
            'setRequestCache',
46
            [
47
                new Reference('cache.app'),
48
            ]
49
        );
50
    }
51
52
    public function testSeoRequestCacheMethodCallWithNullValue()
53
    {
54
        $this->setDefinition('kunstmaan_seo.twig.extension', new Definition());
55
        $this->setDefinition('cache.app', new Definition());
56
57
        $this->load(['request_cache' => null]);
58
59
        $this->compile();
60
61
        $this->assertFalse($this->container->getDefinition('kunstmaan_seo.twig.extension')->hasMethodCall('setRequestCache'));
62
    }
63
}
64