[FrameworkBundle] Make the TestBrowserToken interchangeable with other tokens
This commit is contained in:
parent
f72d5165fd
commit
a4958ae7ad
@ -120,7 +120,7 @@ class KernelBrowser extends HttpKernelBrowser
|
||||
throw new \LogicException(sprintf('The first argument of "%s" must be instance of "%s", "%s" provided.', __METHOD__, UserInterface::class, \is_object($user) ? \get_class($user) : \gettype($user)));
|
||||
}
|
||||
|
||||
$token = new TestBrowserToken($user->getRoles(), $user);
|
||||
$token = new TestBrowserToken($user->getRoles(), $user, $firewallContext);
|
||||
$token->setAuthenticated(true);
|
||||
$session = $this->getContainer()->get('session');
|
||||
$session->set('_security_'.$firewallContext, serialize($token));
|
||||
|
@ -21,13 +21,22 @@ use Symfony\Component\Security\Core\User\UserInterface;
|
||||
*/
|
||||
class TestBrowserToken extends AbstractToken
|
||||
{
|
||||
public function __construct(array $roles = [], UserInterface $user = null)
|
||||
private $firewallName;
|
||||
|
||||
public function __construct(array $roles = [], UserInterface $user = null, string $firewallName = 'main')
|
||||
{
|
||||
parent::__construct($roles);
|
||||
|
||||
if (null !== $user) {
|
||||
$this->setUser($user);
|
||||
}
|
||||
|
||||
$this->firewallName = $firewallName;
|
||||
}
|
||||
|
||||
public function getFirewallName(): string
|
||||
{
|
||||
return $this->firewallName;
|
||||
}
|
||||
|
||||
public function getCredentials()
|
||||
|
Reference in New Issue
Block a user