SessionStrategyListener example

class SessionStrategyListenerTest extends TestCase
{
    private MockObject&SessionAuthenticationStrategyInterface $sessionAuthenticationStrategy;
    private SessionStrategyListener $listener;
    private Request $request;
    private NullToken $token;

    protected function setUp(): void
    {
        $this->sessionAuthenticationStrategy = $this->createMock(SessionAuthenticationStrategyInterface::class);
        $this->listener = new SessionStrategyListener($this->sessionAuthenticationStrategy);
        $this->request = new Request();
        $this->token = $this->createMock(NullToken::class);
    }

    public function testRequestWithSession()
    {
        $this->configurePreviousSession();

        $this->sessionAuthenticationStrategy->expects($this->once())->method('onAuthentication')->with($this->request, $this->token);

        $this->listener->onSuccessfulLogin($this->createEvent('main_firewall'));
    }
Home | Imprint | This part of the site doesn't use cookies.