Call this to avoid using and checking "state".
public setAsStateless ( ) |
public function testGetAccessTokenFromPOST() { $this->request->request->set('code', 'CODE_ABC'); $expectedToken = $this->prophesize('League\\OAuth2\\Client\\Token\\AccessToken'); $this->provider->getAccessToken('authorization_code', ['code' => 'CODE_ABC'])->willReturn($expectedToken->reveal()); $client = new OAuth2Client($this->provider->reveal(), $this->requestStack); $client->setAsStateless(); $actualToken = $client->getAccessToken(); $this->assertSame($expectedToken->reveal(), $actualToken); }
public function testRedirectWithoutState() { $requestStack = $this->prophesize('Symfony\\Component\\HttpFoundation\\RequestStack'); $requestStack->getCurrentRequest()->shouldNotBeCalled(); $this->provider->getAuthorizationUrl([])->willReturn('http://example.com'); $client = new OAuth2Client($this->provider->reveal(), $requestStack->reveal()); $client->setAsStateless(); $response = $client->redirect(); // don't need other checks - the fact that it didn't fail // by asking for the request and session is enough $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\RedirectResponse', $response); }