File tree Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -376,6 +376,20 @@ For checking the raw source code, use `seeInSource()`.
376376 * ` param array|string ` $selector optional
377377
378378
379+ ### dontSeeAuthentication
380+
381+ Check that user is not authenticated.
382+ You can specify whether users logged in with the 'remember me' option should be ignored by passing 'false' as a parameter.
383+
384+ ``` php
385+ <?php
386+ $I->dontSeeAuthentication();
387+ $I->dontSeeAuthentication(false);
388+ ```
389+
390+ * ` param bool ` $remembered
391+
392+
379393### dontSeeCheckboxIsChecked
380394
381395Check that the specified checkbox is unchecked.
Original file line number Diff line number Diff line change @@ -998,4 +998,38 @@ public function seeUserHasRole($role)
998998 )
999999 );
10001000 }
1001+
1002+ /**
1003+ * Check that user is not authenticated.
1004+ * You can specify whether users logged in with the 'remember me' option should be ignored by passing 'false' as a parameter.
1005+ *
1006+ * ```php
1007+ * <?php
1008+ * $I->dontSeeAuthentication();
1009+ * ```
1010+ *
1011+ * @param bool $remembered
1012+ */
1013+ public function dontSeeAuthentication ($ remembered = true )
1014+ {
1015+ $ container = $ this ->_getContainer ();
1016+
1017+ if (!$ container ->has ('security.helper ' )) {
1018+ $ this ->fail ("Symfony container doesn't have 'security.helper' service " );
1019+ return ;
1020+ }
1021+
1022+ $ security = $ this ->grabService ('security.helper ' );
1023+
1024+ if ($ remembered ) {
1025+ $ role = 'IS_AUTHENTICATED_REMEMBERED ' ;
1026+ } else {
1027+ $ role = 'IS_AUTHENTICATED_FULLY ' ;
1028+ }
1029+
1030+ $ this ->assertFalse (
1031+ $ security ->isGranted ($ role ),
1032+ 'There is an user authenticated '
1033+ );
1034+ }
10011035}
You can’t perform that action at this time.
0 commit comments