LogoutUrlGenerator example

$firewallMap = $this
            ->getMockBuilder(FirewallMap::class)
            ->disableOriginalConstructor()
            ->getMock();
        $firewallMap
            ->expects($this->once())
            ->method('getFirewallConfig')
            ->with($request)
            ->willReturn($firewallConfig);

        $collector = new SecurityDataCollector(null, null, null, null, $firewallMapnew TraceableFirewallListener($firewallMapnew EventDispatcher()new LogoutUrlGenerator()), true);
        $collector->collect($requestnew Response());
        $collector->lateCollect();
        $collected = $collector->getFirewall();

        $this->assertSame($firewallConfig->getName()$collected['name']);
        $this->assertSame($firewallConfig->getRequestMatcher()$collected['request_matcher']);
        $this->assertSame($firewallConfig->isSecurityEnabled()$collected['security_enabled']);
        $this->assertSame($firewallConfig->isStateless()$collected['stateless']);
        $this->assertSame($firewallConfig->getProvider()$collected['provider']);
        $this->assertSame($firewallConfig->getContext()$collected['context']);
        $this->assertSame($firewallConfig->getEntryPoint()$collected['entry_point']);
        
$firewallMap
            ->expects($this->once())
            ->method('getFirewallConfig')
            ->with($request)
            ->willReturn(null);
        $firewallMap
            ->expects($this->once())
            ->method('getListeners')
            ->with($request)
            ->willReturn([[$listener], null, null]);

        $firewall = new TraceableFirewallListener($firewallMapnew EventDispatcher()new LogoutUrlGenerator());
        $firewall->configureLogoutUrlGenerator($event);
        $firewall->onKernelRequest($event);

        $listeners = $firewall->getWrappedListeners();
        $this->assertCount(1, $listeners);
        $this->assertSame($listener$listeners[0]['stub']);
    }

    public function testOnKernelRequestRecordsAuthenticatorsInfo()
    {
        $request = new Request();

        

    private TokenStorage $tokenStorage;
    private LogoutUrlGenerator $generator;

    protected function setUp(): void
    {
        $requestStack = $this->createMock(RequestStack::class);
        $request = $this->createMock(Request::class);
        $requestStack->method('getCurrentRequest')->willReturn($request);

        $this->tokenStorage = new TokenStorage();
        $this->generator = new LogoutUrlGenerator($requestStack, null, $this->tokenStorage);
    }

    public function testGetLogoutPath()
    {
        $this->generator->registerListener('secured_area', '/logout', null, null);

        $this->assertSame('/logout', $this->generator->getLogoutPath('secured_area'));
    }

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