Completed
Push — master ( a4bf69...fd2f49 )
by Yaroslav
09:49
created

testProcessWithExtraBundle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 10
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/*
4
 *
5
 * (c) Yaroslav Honcharuk <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Yarhon\RouteGuardBundle\Tests\DependencyInjection\Compiler;
12
13
use PHPUnit\Framework\TestCase;
14
use Symfony\Component\DependencyInjection\ContainerBuilder;
15
use Yarhon\RouteGuardBundle\DependencyInjection\Compiler\SensioFrameworkExtraBundlePass;
16
use Yarhon\RouteGuardBundle\Security\TestProvider\SensioSecurityProvider;
17
use Yarhon\RouteGuardBundle\Security\TestResolver\SensioSecurityResolver;
18
19
/**
20
 * @author Yaroslav Honcharuk <[email protected]>
21
 */
22
class SensioFrameworkExtraBundlePassTest extends TestCase
23
{
24
    /**
25
     * @var ContainerBuilder
26
     */
27
    private $container;
28
29
    /**
30
     * @var SensioFrameworkExtraBundlePass
31
     */
32
    private $pass;
33
34
    public function setUp()
35
    {
36
        $this->container = new ContainerBuilder();
37
        $this->container->register(SensioSecurityProvider::class);
38
        $this->container->register(SensioSecurityResolver::class);
39
        $this->pass = new SensioFrameworkExtraBundlePass();
40
    }
41
42
    public function testProcessWithoutExtraBundle()
43
    {
44
        $this->pass->process($this->container);
45
46
        $this->assertFalse($this->container->hasDefinition(SensioSecurityProvider::class));
47
        $this->assertFalse($this->container->hasDefinition(SensioSecurityResolver::class));
48
    }
49
50
    public function testProcessWithExtraBundleSecurityListener()
51
    {
52
        $this->container->register('sensio_framework_extra.security.listener');
53
54
        $this->pass->process($this->container);
55
56
        $this->assertTrue($this->container->hasDefinition(SensioSecurityProvider::class));
57
        $this->assertTrue($this->container->hasDefinition(SensioSecurityResolver::class));
58
    }
59
60
    public function testProcessWithExtraBundleIsGrantedListener()
61
    {
62
        $this->container->register('framework_extra_bundle.event.is_granted');
63
64
        $this->pass->process($this->container);
65
66
        $this->assertTrue($this->container->hasDefinition(SensioSecurityProvider::class));
67
        $this->assertTrue($this->container->hasDefinition(SensioSecurityResolver::class));
68
    }
69
}
70