Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,20 @@ For checking the raw source code, use `seeInSource()`.
* `param array|string` $selector optional


### dontSeeAuthentication

Check that user is not authenticated.
You can specify whether users logged in with the 'remember me' option should be ignored by passing 'false' as a parameter.

```php
<?php
$I->dontSeeAuthentication();
$I->dontSeeAuthentication(false);
```

* `param bool` $remembered


### dontSeeCheckboxIsChecked

Check that the specified checkbox is unchecked.
Expand Down
34 changes: 34 additions & 0 deletions src/Codeception/Module/Symfony.php
Original file line number Diff line number Diff line change
Expand Up @@ -770,4 +770,38 @@ private function getPossibleKernelClasses()

return [$this->config['kernel_class']];
}

/**
* Check that user is not authenticated.
* You can specify whether users logged in with the 'remember me' option should be ignored by passing 'false' as a parameter.
*
* ```php
* <?php
* $I->dontSeeAuthentication();
* ```
*
* @param bool $remembered
*/
public function dontSeeAuthentication($remembered = true)
{
$container = $this->_getContainer();

if (!$container->has('security.helper')) {
$this->fail("Symfony container doesn't have 'security.helper' service");
return;
}

$security = $this->grabService('security.helper');

if ($remembered) {
$role = 'IS_AUTHENTICATED_REMEMBERED';
} else {
$role = 'IS_AUTHENTICATED_FULLY';
}

$this->assertFalse(
$security->isGranted($role),
'There is an user authenticated'
);
}
}