39
39
use Symfony \Component \Routing \RouterInterface ;
40
40
use Symfony \Component \Security \Core \Authentication \Token \Storage \TokenStorageInterface ;
41
41
use Symfony \Component \Security \Core \Authentication \Token \UsernamePasswordToken ;
42
+ use Symfony \Component \Security \Core \Authorization \Voter \AuthenticatedVoter ;
42
43
use Symfony \Component \Security \Core \Security ;
43
44
use Symfony \Component \Security \Core \User \UserInterface ;
44
45
use Symfony \Component \Security \Guard \Token \PostAuthenticationGuardToken ;
@@ -1081,7 +1082,10 @@ public function seeAuthentication(): void
1081
1082
$ this ->fail ('There is no user in session ' );
1082
1083
}
1083
1084
1084
- $ this ->assertTrue ($ security ->isGranted ('IS_AUTHENTICATED_FULLY ' ), 'There is no authenticated user ' );
1085
+ $ this ->assertTrue (
1086
+ $ security ->isGranted (AuthenticatedVoter::IS_AUTHENTICATED_FULLY ),
1087
+ 'There is no authenticated user '
1088
+ );
1085
1089
}
1086
1090
1087
1091
/**
@@ -1134,7 +1138,14 @@ public function seeRememberedAuthentication(): void
1134
1138
$ this ->fail ('There is no user in session ' );
1135
1139
}
1136
1140
1137
- $ this ->assertTrue ($ security ->isGranted ('IS_AUTHENTICATED_REMEMBERED ' ), 'There is no authenticated user ' );
1141
+ $ hasRememberMeCookie = $ this ->client ->getCookieJar ()->get ('REMEMBERME ' );
1142
+ $ hasRememberMeRole = $ security ->isGranted (AuthenticatedVoter::IS_AUTHENTICATED_REMEMBERED );
1143
+
1144
+ $ isRemembered = $ hasRememberMeCookie && $ hasRememberMeRole ;
1145
+ $ this ->assertTrue (
1146
+ $ isRemembered ,
1147
+ 'User does not have remembered authentication '
1148
+ );
1138
1149
}
1139
1150
1140
1151
/**
@@ -1150,9 +1161,13 @@ public function dontSeeRememberedAuthentication(): void
1150
1161
/** @var Security $security */
1151
1162
$ security = $ this ->grabService ('security.helper ' );
1152
1163
1164
+ $ hasRememberMeCookie = $ this ->client ->getCookieJar ()->get ('REMEMBERME ' );
1165
+ $ hasRememberMeRole = $ security ->isGranted (AuthenticatedVoter::IS_AUTHENTICATED_REMEMBERED );
1166
+
1167
+ $ isRemembered = $ hasRememberMeCookie && $ hasRememberMeRole ;
1153
1168
$ this ->assertFalse (
1154
- $ security -> isGranted ( ' IS_AUTHENTICATED_REMEMBERED ' ) ,
1155
- 'There is an user authenticated '
1169
+ $ isRemembered ,
1170
+ 'User does have remembered authentication '
1156
1171
);
1157
1172
}
1158
1173
@@ -1201,7 +1216,7 @@ public function dontSeeAuthentication(): void
1201
1216
$ security = $ this ->grabService ('security.helper ' );
1202
1217
1203
1218
$ this ->assertFalse (
1204
- $ security ->isGranted (' IS_AUTHENTICATED_FULLY ' ),
1219
+ $ security ->isGranted (AuthenticatedVoter:: IS_AUTHENTICATED_FULLY ),
1205
1220
'There is an user authenticated '
1206
1221
);
1207
1222
}
0 commit comments