-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aeaf521
commit 26ec99c
Showing
2 changed files
with
20 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
use App\Entity\User; | ||
use App\Tests\Support\FunctionalTester; | ||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; | ||
use Symfony\Component\Security\Http\Authenticator\Token\PostAuthenticationToken; | ||
|
||
final class SessionCest | ||
{ | ||
|
@@ -24,6 +25,21 @@ public function amLoggedInAs(FunctionalTester $I) | |
$I->see('You are in the Dashboard!'); | ||
} | ||
|
||
public function amLoggedInWithToken(FunctionalTester $I) | ||
{ | ||
$user = $I->grabEntityFromRepository(User::class, [ | ||
'email' => '[email protected]' | ||
]); | ||
$token = new PostAuthenticationToken($user, 'main', $user->getRoles()); | ||
$I->amLoggedInWithToken($token); | ||
$I->amOnPage('/dashboard'); | ||
$I->seeAuthentication(); | ||
/** @var TokenStorageInterface $tokenStorage */ | ||
$tokenStorage = $I->grabService('security.token_storage'); | ||
$I->assertNotNull($tokenStorage->getToken()); | ||
$I->see('You are in the Dashboard!'); | ||
} | ||
|
||
public function dontSeeInSession(FunctionalTester $I) | ||
{ | ||
$I->amOnPage('/'); | ||
|