/** * Creates a bearer token according to an OAuth response. * * @param \Widop\Twitter\OAuth\OAuthResponse $response The OAuth response. * * @throws \Widop\Twitter\OAuth\OAuthException If the token cannot be created. * * @return \Widop\Twitter\OAuth\Token\BearerToken The Bearer token. */ private function createBearerToken(OAuthResponse $response) { if (!$response->hasData('token_type') || !$response->hasData('access_token')) { throw new OAuthException('An error occured when creating the bearer token.', $response); } return new BearerToken($response->getData('access_token')); }
public function testIsValidWithInvalidResponse() { $this->httpResponse->expects($this->any())->method('getBody')->will($this->returnValue('{"errors":"foo"}')); $this->oauthResponse = new OAuthResponse($this->httpResponse); $this->assertFalse($this->oauthResponse->isValid()); }