|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the BenGorUser package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Beñat Espiña <[email protected]> |
|
7
|
|
|
* (c) Gorka Laucirica <[email protected]> |
|
8
|
|
|
* |
|
9
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
10
|
|
|
* file that was distributed with this source code. |
|
11
|
|
|
*/ |
|
12
|
|
|
|
|
13
|
|
|
namespace spec\BenGorUser\SymfonySecurityBridgeBundle\DependencyInjection\Compiler; |
|
14
|
|
|
|
|
15
|
|
|
use BenGorUser\SymfonySecurityBridgeBundle\DependencyInjection\Compiler\SecurityServicesPass; |
|
16
|
|
|
use PhpSpec\ObjectBehavior; |
|
17
|
|
|
use Prophecy\Argument; |
|
18
|
|
|
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; |
|
19
|
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder; |
|
20
|
|
|
use Symfony\Component\DependencyInjection\Definition; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Spec file of SecurityServicesPass class. |
|
24
|
|
|
* |
|
25
|
|
|
* @author Beñat Espiña <[email protected]> |
|
26
|
|
|
*/ |
|
27
|
|
|
class SecurityServicesPassSpec extends ObjectBehavior |
|
28
|
|
|
{ |
|
29
|
|
|
function it_is_initializable() |
|
30
|
|
|
{ |
|
31
|
|
|
$this->shouldHaveType(SecurityServicesPass::class); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
function it_implements_compiler_pass_interface() |
|
35
|
|
|
{ |
|
36
|
|
|
$this->shouldImplement(CompilerPassInterface::class); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
function it_processes(ContainerBuilder $container, Definition $definition) |
|
40
|
|
|
{ |
|
41
|
|
|
$container->getParameter('bengor_user.config')->shouldBeCalled()->willReturn([ |
|
42
|
|
|
'user_class' => [ |
|
43
|
|
|
'user' => [ |
|
44
|
|
|
'class' => 'AppBundle\Entity\User', |
|
45
|
|
|
'firewall' => 'main', |
|
46
|
|
|
'persistence' => 'doctrine_orm', |
|
47
|
|
|
'default_roles' => [ |
|
48
|
|
|
'ROLE_USER', |
|
49
|
|
|
], |
|
50
|
|
|
'use_cases' => [ |
|
51
|
|
|
'security' => [ |
|
52
|
|
|
'enabled' => true, |
|
53
|
|
|
], |
|
54
|
|
|
'sign_up' => [ |
|
55
|
|
|
'enabled' => true, |
|
56
|
|
|
'type' => 'default', |
|
57
|
|
|
], |
|
58
|
|
|
'change_password' => [ |
|
59
|
|
|
'enabled' => true, |
|
60
|
|
|
'type' => 'default', |
|
61
|
|
|
], |
|
62
|
|
|
'remove' => [ |
|
63
|
|
|
'enabled' => true, |
|
64
|
|
|
], |
|
65
|
|
|
], |
|
66
|
|
|
'routes' => [ |
|
67
|
|
|
'security' => [ |
|
68
|
|
|
'login' => [ |
|
69
|
|
|
'name' => 'bengor_user_user_login', |
|
70
|
|
|
'path' => '/user/login', |
|
71
|
|
|
], |
|
72
|
|
|
'login_check' => [ |
|
73
|
|
|
'name' => 'bengor_user_user_login_check', |
|
74
|
|
|
'path' => '/user/login_check', |
|
75
|
|
|
], |
|
76
|
|
|
'logout' => [ |
|
77
|
|
|
'name' => 'bengor_user_user_logout', |
|
78
|
|
|
'path' => '/user/logout', |
|
79
|
|
|
], |
|
80
|
|
|
'success_redirection_route' => 'bengor_user_user_homepage', |
|
81
|
|
|
], |
|
82
|
|
|
'sign_up' => [ |
|
83
|
|
|
'name' => 'bengor_user_user_sign_up', |
|
84
|
|
|
'path' => '/user/sign-up', |
|
85
|
|
|
'success_redirection_route' => 'bengor_user_user_homepage', |
|
86
|
|
|
], |
|
87
|
|
|
'invite' => [ |
|
88
|
|
|
'name' => 'bengor_user_user_invite', |
|
89
|
|
|
'path' => '/user/invite', |
|
90
|
|
|
'success_redirection_route' => null, |
|
91
|
|
|
], |
|
92
|
|
|
'enable' => [ |
|
93
|
|
|
'name' => 'bengor_user_user_enable', |
|
94
|
|
|
'path' => '/user/confirmation-token', |
|
95
|
|
|
'success_redirection_route' => null, |
|
96
|
|
|
], |
|
97
|
|
|
'change_password' => [ |
|
98
|
|
|
'name' => 'bengor_user_user_change_password', |
|
99
|
|
|
'path' => '/user/change-password', |
|
100
|
|
|
'success_redirection_route' => null, |
|
101
|
|
|
], |
|
102
|
|
|
'request_remember_password' => [ |
|
103
|
|
|
'name' => 'bengor_user_user_request_remember_password', |
|
104
|
|
|
'path' => '/user/remember-password', |
|
105
|
|
|
'success_redirection_route' => null, |
|
106
|
|
|
], |
|
107
|
|
|
'remove' => [ |
|
108
|
|
|
'name' => 'bengor_user_user_remove', |
|
109
|
|
|
'path' => '/user/remove', |
|
110
|
|
|
'success_redirection_route' => null, |
|
111
|
|
|
], |
|
112
|
|
|
], |
|
113
|
|
|
], |
|
114
|
|
|
], |
|
115
|
|
|
]); |
|
116
|
|
|
|
|
117
|
|
|
$container->setDefinition( |
|
118
|
|
|
'user_password_encoder', |
|
119
|
|
|
Argument::type(Definition::class) |
|
120
|
|
|
)->shouldBeCalled()->willReturn($definition); |
|
121
|
|
|
$container->getDefinition('user_password_encoder')->shouldBeCalled()->willReturn($definition); |
|
122
|
|
|
|
|
123
|
|
|
$container->setDefinition( |
|
124
|
|
|
'bengor.user.infrastructure.security.symfony.user_password_encoder', |
|
125
|
|
|
Argument::type(Definition::class) |
|
126
|
|
|
)->shouldBeCalled()->willReturn($definition); |
|
127
|
|
|
|
|
128
|
|
|
$container->setAlias( |
|
129
|
|
|
'bengor_user.user.symfony_password_encoder', |
|
130
|
|
|
'bengor.user.infrastructure.security.symfony.user_password_encoder' |
|
131
|
|
|
)->shouldBeCalled(); |
|
132
|
|
|
|
|
133
|
|
|
$this->process($container); |
|
134
|
|
|
} |
|
135
|
|
|
} |
|
136
|
|
|
|