public function testDataWithStrFormat() { $this->httpResponse->expects($this->any())->method('getBody')->will($this->returnValue('foo=bar')); $this->oauthResponse = new OAuthResponse($this->httpResponse, OAuthResponse::FORMAT_STR); $this->assertTrue($this->oauthResponse->hasData()); $this->assertSame(array('foo' => 'bar'), $this->oauthResponse->getData()); $this->assertTrue($this->oauthResponse->hasData('foo')); $this->assertSame('bar', $this->oauthResponse->getData('foo')); }
/** * 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')); }