3939use Symfony \Component \Routing \RouterInterface ;
4040use Symfony \Component \Security \Core \Authentication \Token \Storage \TokenStorageInterface ;
4141use Symfony \Component \Security \Core \Authentication \Token \UsernamePasswordToken ;
42+ use Symfony \Component \Security \Core \Authorization \Voter \AuthenticatedVoter ;
4243use Symfony \Component \Security \Core \Security ;
4344use Symfony \Component \Security \Core \User \UserInterface ;
4445use Symfony \Component \Security \Guard \Token \PostAuthenticationGuardToken ;
@@ -1081,7 +1082,10 @@ public function seeAuthentication(): void
10811082 $ this ->fail ('There is no user in session ' );
10821083 }
10831084
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+ );
10851089 }
10861090
10871091 /**
@@ -1134,7 +1138,14 @@ public function seeRememberedAuthentication(): void
11341138 $ this ->fail ('There is no user in session ' );
11351139 }
11361140
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+ );
11381149 }
11391150
11401151 /**
@@ -1150,9 +1161,13 @@ public function dontSeeRememberedAuthentication(): void
11501161 /** @var Security $security */
11511162 $ security = $ this ->grabService ('security.helper ' );
11521163
1164+ $ hasRememberMeCookie = $ this ->client ->getCookieJar ()->get ('REMEMBERME ' );
1165+ $ hasRememberMeRole = $ security ->isGranted (AuthenticatedVoter::IS_AUTHENTICATED_REMEMBERED );
1166+
1167+ $ isRemembered = $ hasRememberMeCookie && $ hasRememberMeRole ;
11531168 $ this ->assertFalse (
1154- $ security -> isGranted ( ' IS_AUTHENTICATED_REMEMBERED ' ) ,
1155- 'There is an user authenticated '
1169+ $ isRemembered ,
1170+ 'User does have remembered authentication '
11561171 );
11571172 }
11581173
@@ -1201,7 +1216,7 @@ public function dontSeeAuthentication(): void
12011216 $ security = $ this ->grabService ('security.helper ' );
12021217
12031218 $ this ->assertFalse (
1204- $ security ->isGranted (' IS_AUTHENTICATED_FULLY ' ),
1219+ $ security ->isGranted (AuthenticatedVoter:: IS_AUTHENTICATED_FULLY ),
12051220 'There is an user authenticated '
12061221 );
12071222 }
0 commit comments