@@ -130,52 +130,51 @@ public function testDeprecatedGetSecurityIdentities($user, array $roles, string
130
130
131
131
public function getSecurityIdentityRetrievalTests (): array
132
132
{
133
- $ anonymousRole = \defined ('\Symfony\Component\Security\Core\Authorization\Voter\AuthenticatedVoter::PUBLIC_ACCESS ' ) ? AuthenticatedVoter::PUBLIC_ACCESS : AuthenticatedVoter::IS_AUTHENTICATED_ANONYMOUSLY ;
133
+ $ anonymousRoles = [new RoleSecurityIdentity ('IS_AUTHENTICATED_ANONYMOUSLY ' )];
134
+ if (\defined ('\Symfony\Component\Security\Core\Authorization\Voter\AuthenticatedVoter::PUBLIC_ACCESS ' )) {
135
+ $ anonymousRoles [] = new RoleSecurityIdentity (AuthenticatedVoter::PUBLIC_ACCESS );
136
+ }
134
137
135
138
return [
136
- [new Account ('johannes ' ), ['ROLE_USER ' , 'ROLE_SUPERADMIN ' ], 'fullFledged ' , [
139
+ [new Account ('johannes ' ), ['ROLE_USER ' , 'ROLE_SUPERADMIN ' ], 'fullFledged ' , array_merge ( [
137
140
new UserSecurityIdentity ('johannes ' , Account::class),
138
141
new RoleSecurityIdentity ('ROLE_USER ' ),
139
142
new RoleSecurityIdentity ('ROLE_SUPERADMIN ' ),
140
143
new RoleSecurityIdentity ('IS_AUTHENTICATED_FULLY ' ),
141
144
new RoleSecurityIdentity ('IS_AUTHENTICATED_REMEMBERED ' ),
142
- new RoleSecurityIdentity ($ anonymousRole ),
143
- ]],
144
- [new CustomUserImpl ('johannes ' ), ['ROLE_FOO ' ], 'fullFledged ' , [
145
+ ], $ anonymousRoles )],
146
+ [new CustomUserImpl ('johannes ' ), ['ROLE_FOO ' ], 'fullFledged ' , array_merge ([
145
147
new UserSecurityIdentity ('johannes ' , CustomUserImpl::class),
146
148
new RoleSecurityIdentity ('ROLE_FOO ' ),
147
149
new RoleSecurityIdentity ('IS_AUTHENTICATED_FULLY ' ),
148
150
new RoleSecurityIdentity ('IS_AUTHENTICATED_REMEMBERED ' ),
149
- new RoleSecurityIdentity ($ anonymousRole ),
150
- ]],
151
- [new Account ('foo ' ), ['ROLE_FOO ' ], 'rememberMe ' , [
151
+ ], $ anonymousRoles )],
152
+ [new Account ('foo ' ), ['ROLE_FOO ' ], 'rememberMe ' , array_merge ([
152
153
new UserSecurityIdentity ('foo ' , Account::class),
153
154
new RoleSecurityIdentity ('ROLE_FOO ' ),
154
155
new RoleSecurityIdentity ('IS_AUTHENTICATED_REMEMBERED ' ),
155
- new RoleSecurityIdentity ($ anonymousRole ),
156
- ]],
157
- ['guest ' , [], 'anonymous ' , [
158
- new RoleSecurityIdentity ($ anonymousRole ),
159
- ]],
156
+ ], $ anonymousRoles )],
157
+ ['guest ' , [], 'anonymous ' , $ anonymousRoles ],
160
158
];
161
159
}
162
160
163
161
public function getDeprecatedSecurityIdentityRetrievalTests ()
164
162
{
165
- $ anonymousRole = \defined ('\Symfony\Component\Security\Core\Authorization\Voter\AuthenticatedVoter::PUBLIC_ACCESS ' ) ? AuthenticatedVoter::PUBLIC_ACCESS : AuthenticatedVoter::IS_AUTHENTICATED_ANONYMOUSLY ;
163
+ $ anonymousRoles = [new RoleSecurityIdentity ('IS_AUTHENTICATED_ANONYMOUSLY ' )];
164
+ if (\defined ('\Symfony\Component\Security\Core\Authorization\Voter\AuthenticatedVoter::PUBLIC_ACCESS ' )) {
165
+ $ anonymousRoles [] = new RoleSecurityIdentity (AuthenticatedVoter::PUBLIC_ACCESS );
166
+ }
166
167
167
168
return [
168
- ['johannes ' , ['ROLE_FOO ' ], 'fullFledged ' , [
169
+ ['johannes ' , ['ROLE_FOO ' ], 'fullFledged ' , array_merge ( [
169
170
new UserSecurityIdentity ('johannes ' , 'MyCustomTokenImpl ' ),
170
171
new RoleSecurityIdentity ('ROLE_FOO ' ),
171
172
new RoleSecurityIdentity ('IS_AUTHENTICATED_FULLY ' ),
172
173
new RoleSecurityIdentity ('IS_AUTHENTICATED_REMEMBERED ' ),
173
- new RoleSecurityIdentity ($ anonymousRole ),
174
- ]],
175
- ['guest ' , ['ROLE_FOO ' ], 'anonymous ' , [
174
+ ], $ anonymousRoles )],
175
+ ['guest ' , ['ROLE_FOO ' ], 'anonymous ' , array_merge ([
176
176
new RoleSecurityIdentity ('ROLE_FOO ' ),
177
- new RoleSecurityIdentity ($ anonymousRole ),
178
- ]],
177
+ ], $ anonymousRoles )],
179
178
];
180
179
}
181
180
0 commit comments