Scheb\TwoFactorBundle\Tests\Security\TwoFactor\Trusted\TrustedFilterTest::requestAuthenticationCode_authenticatedAndTrustedChecked_setTrustedCookie PHP Метод

requestAuthenticationCode_authenticatedAndTrustedChecked_setTrustedCookie() публичный Метод

    public function requestAuthenticationCode_authenticatedAndTrustedChecked_setTrustedCookie()
    {
        $request = $this->getRequest();
        $request->expects($this->any())->method('get')->with('trustedName')->willReturn(true);
        //Trusted option checked
        $user = $this->getUser();
        //Stub the context
        $context = $this->getAuthenticationContext($request, $user);
        $context->expects($this->any())->method('isAuthenticated')->willReturn(true);
        $context->expects($this->once())->method('useTrustedOption')->willReturn(true);
        //Stub the authentication handler
        $response = $this->getResponse();
        $this->authHandler->expects($this->once())->method('requestAuthenticationCode')->willReturn($response);
        //Mock the TrustedCookieManager
        $cookie = new Cookie('someCookie');
        $this->cookieManager->expects($this->once())->method('createTrustedCookie')->with($request, $user)->willReturn($cookie);
        //Expect cookie be set in response headers
        $response->headers->expects($this->once())->method('setCookie')->with($cookie);
        $this->trustedFilter->requestAuthenticationCode($context);
    }