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