use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
use Symfony\Component\Security\Core\User\InMemoryUser;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
class SecurityTest extends AbstractWebTestCase
{ public function testServiceIsFunctional() { $kernel = self::
createKernel(['test_case' => 'SecurityHelper', 'root_config' => 'config.yml'
]);
$kernel->
boot();
$container =
$kernel->
getContainer();
// put a token into the storage so the final calls can function
$user =
new InMemoryUser('foo', 'pass'
);
$token =
new UsernamePasswordToken($user, 'provider',
['ROLE_USER'
]);
$container->
get('functional.test.security.token_storage'
)->
setToken($token);
$security =
$container->
get('functional_test.security.helper'
);
$this->
assertTrue($security->
isGranted('ROLE_USER'
));
$this->
assertSame($token,
$security->
getToken());