KnpU\OAuth2ClientBundle\Tests\Client\OAuth2ClientTest::testRedirectWithState PHP Method

testRedirectWithState() public method

    public function testRedirectWithState()
    {
        $this->provider->getAuthorizationUrl(['scope' => ['scope1', 'scope2']])->willReturn('http://coolOAuthServer.com/authorize');
        $this->provider->getState()->willReturn('SOME_RANDOM_STATE');
        $this->session->set(OAuth2Client::OAUTH2_SESSION_STATE_KEY, 'SOME_RANDOM_STATE')->shouldBeCalled();
        $client = new OAuth2Client($this->provider->reveal(), $this->requestStack);
        $response = $client->redirect(['scope1', 'scope2']);
        $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\RedirectResponse', $response);
        $this->assertEquals('http://coolOAuthServer.com/authorize', $response->getTargetUrl());
    }