onSuccessfulLogin example

protected function setUp(): void
    {
        $this->listener = new CheckRememberMeConditionsListener();
    }

    public function testSuccessfulHttpLoginWithoutSupportingAuthenticator()
    {
        $this->createHttpRequest();

        $passport = $this->createPassport([]);

        $this->listener->onSuccessfulLogin($this->createLoginSuccessfulEvent($passport));

        $this->assertFalse($passport->hasBadge(RememberMeBadge::class));
    }

    public function testSuccessfulJsonLoginWithoutSupportingAuthenticator()
    {
        $this->createJsonRequest();

        $passport = $this->createPassport([]);
        $this->listener->onSuccessfulLogin($this->createLoginSuccessfulEvent($passport));

        
$this->listener = new RememberMeListener($this->rememberMeHandler);
        $this->request = Request::create('/login');
        $this->request->request->set('_remember_me', true);
        $this->response = new Response();
    }

    public function testSuccessfulLoginWithoutSupportingAuthenticator()
    {
        $this->rememberMeHandler->expects($this->never())->method('createRememberMeCookie');

        $event = $this->createLoginSuccessfulEvent($this->createPassport([]));
        $this->listener->onSuccessfulLogin($event);
    }

    public function testSuccessfulLoginWithRememberMeDisabled()
    {
        $this->rememberMeHandler->expects($this->never())->method('createRememberMeCookie');

        $event = $this->createLoginSuccessfulEvent($this->createPassport([new RememberMeBadge()]));
        $this->listener->onSuccessfulLogin($event);
    }

    public function testCredentialsInvalid()
    {
$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'));
    }

    public function testRequestWithoutPreviousSession()
    {
        $this->sessionAuthenticationStrategy->expects($this->never())->method('onAuthentication')->with($this->request, $this->token);

        $this->listener->onSuccessfulLogin($this->createEvent('main_firewall'));
    }

    public function testStatelessFirewalls()
    {
        
Home | Imprint | This part of the site doesn't use cookies.