public function testLogout() { $client =
$this->
createClient(['test_case' => 'SecurityHelper', 'root_config' => 'config.yml', 'debug' => true
]);
$client->
loginUser(new InMemoryUser('chalasr', 'the-password',
['ROLE_FOO'
]), 'main'
);
$client->
request('GET', '/main/force-logout'
);
$response =
$client->
getResponse();
$this->
assertSame(200,
$response->
getStatusCode());
$this->
assertNull(static::
getContainer()->
get('security.helper'
)->
getUser());
$this->
assertSame(['message' => 'Logout successful'
],
json_decode($response->
getContent(), true
));
} public function testLogoutWithCsrf() { $client =
$this->
createClient(['test_case' => 'SecurityHelper', 'root_config' => 'config_logout_csrf.yml', 'debug' => true
]);
$client->
loginUser(new InMemoryUser('chalasr', 'the-password',
['ROLE_FOO'
]), 'main'
);
// put a csrf token in the storage
/** @var EventDispatcherInterface $eventDispatcher */
$eventDispatcher =
static::
getContainer()->
get(EventDispatcherInterface::
class);