Esempio n. 1
0
 /**
  * @covers OAuth\OAuth1\Service\AbstractService::requestAccessToken
  * @covers OAuth\OAuth1\Service\AbstractService::service
  * @covers OAuth\OAuth1\Service\AbstractService::buildAuthorizationHeaderForAPIRequest
  * @covers OAuth\OAuth1\Service\AbstractService::getBasicAuthorizationHeaderInfo
  * @covers OAuth\OAuth1\Service\AbstractService::generateNonce
  * @covers OAuth\OAuth1\Service\AbstractService::getSignatureMethod
  * @covers OAuth\OAuth1\Service\AbstractService::getVersion
  * @covers OAuth\OAuth1\Service\AbstractService::getAccessTokenEndpoint
  * @covers OAuth\OAuth1\Service\AbstractService::getExtraOAuthHeaders
  * @covers OAuth\OAuth1\Service\AbstractService::parseAccessTokenResponse
  */
 public function testRequestAccessTokenWithSecret()
 {
     $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface');
     $client->expects($this->once())->method('retrieveResponse')->will($this->returnCallback(function ($endpoint, $array, $headers) {
         \PHPUnit_Framework_Assert::assertSame('http://pieterhordijk.com/access', $endpoint->getAbsoluteUri());
     }));
     $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface');
     $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface');
     $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token));
     $service = new Mock($this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), $client, $storage, $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'), $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'));
     $this->assertInstanceOf('\\OAuth\\OAuth1\\Token\\StdOAuth1Token', $service->requestAccessToken('foo', 'bar', $token));
 }
Esempio n. 2
0
 /**
  * @covers OAuth\OAuth1\Service\AbstractService::requestAccessToken
  * @covers OAuth\OAuth1\Service\AbstractService::service
  * @covers OAuth\OAuth1\Service\AbstractService::buildAuthorizationHeaderForAPIRequest
  * @covers OAuth\OAuth1\Service\AbstractService::getBasicAuthorizationHeaderInfo
  * @covers OAuth\OAuth1\Service\AbstractService::generateNonce
  * @covers OAuth\OAuth1\Service\AbstractService::getSignatureMethod
  * @covers OAuth\OAuth1\Service\AbstractService::getVersion
  * @covers OAuth\OAuth1\Service\AbstractService::getAccessTokenEndpoint
  * @covers OAuth\OAuth1\Service\AbstractService::getExtraOAuthHeaders
  * @covers OAuth\OAuth1\Service\AbstractService::parseAccessTokenResponse
  */
 public function testRequestAccessTokenWithSecret()
 {
     $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface');
     $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface');
     $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token));
     $service = new Mock($this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), new Browser(), $storage, $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'));
     $accessToken = $service->requestAccessToken('foo', 'bar', $token);
     $this->assertInstanceOf('\\OAuth\\OAuth1\\Token\\StdOAuth1Token', $accessToken);
     $this->assertSame('http://pieterhordijk.com/access', (string) $accessToken->getAccessToken()['uri']);
 }