/**
  * @covers OAuth\OAuth2\Service\AbstractService::__construct
  * @covers OAuth\OAuth2\Service\AbstractService::request
  * @covers OAuth\OAuth2\Service\AbstractService::determineRequestUriFromPath
  * @covers OAuth\OAuth2\Service\AbstractService::getAuthorizationMethod
  * @covers OAuth\OAuth2\Service\AbstractService::parseAccessTokenResponse
  * @covers OAuth\OAuth2\Service\AbstractService::service
  * @covers OAuth\OAuth2\Service\AbstractService::getExtraApiHeaders
  */
 public function testRequestBearerMethod()
 {
     $token = $this->getMock('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', ['getEndOfLife', 'getAccessToken']);
     $token->expects($this->once())->method('getEndOfLife')->will($this->returnValue(TokenInterface::EOL_NEVER_EXPIRES));
     $token->expects($this->once())->method('getAccessToken')->will($this->returnValue('foo'));
     $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface');
     $storage->expects($this->once())->method('retrieveAccessToken')->will($this->returnValue($token));
     $service = new Mock($this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), new Browser(), $storage);
     $service->setAuthorizationMethod(Mock::AUTHORIZATION_METHOD_HEADER_BEARER);
     $headers = $service->request('https://pieterhordijk.com/my/awesome/path')['headers'];
     $this->assertTrue(array_key_exists('Authorization', $headers));
     $this->assertTrue(in_array('Bearer foo', $headers, true));
 }
 /**
  * @covers OAuth\OAuth2\Service\AbstractService::__construct
  * @covers OAuth\OAuth2\Service\AbstractService::request
  * @covers OAuth\OAuth2\Service\AbstractService::determineRequestUriFromPath
  * @covers OAuth\OAuth2\Service\AbstractService::getAuthorizationMethod
  * @covers OAuth\OAuth2\Service\AbstractService::parseAccessTokenResponse
  * @covers OAuth\OAuth2\Service\AbstractService::service
  * @covers OAuth\OAuth2\Service\AbstractService::getExtraApiHeaders
  */
 public function testRequestBearerMethod()
 {
     $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface');
     $client->expects($this->once())->method('retrieveResponse')->will($this->returnArgument(2));
     $token = $this->getMock('\\OAuth\\OAuth2\\Token\\TokenInterface');
     $token->expects($this->once())->method('getEndOfLife')->will($this->returnValue(TokenInterface::EOL_NEVER_EXPIRES));
     $token->expects($this->once())->method('getAccessToken')->will($this->returnValue('foo'));
     $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface');
     $storage->expects($this->once())->method('retrieveAccessToken')->will($this->returnValue($token));
     $service = new Mock($this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), $client, $storage);
     $service->setAuthorizationMethod('bearer');
     $headers = $service->request('https://pieterhordijk.com/my/awesome/path');
     $this->assertTrue(array_key_exists('Authorization', $headers));
     $this->assertTrue(in_array('Bearer foo', $headers, true));
 }