Exemple #1
0
 /**
  * @covers OAuth\OAuth2\Service\Mailchimp::__construct
  * @covers OAuth\OAuth2\Service\Mailchimp::getAuthorizationMethod
  */
 public function testGetAuthorizationMethod()
 {
     $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface');
     $client->expects($this->once())->method('retrieveResponse')->will($this->returnArgument(0));
     $token = $this->getMock('\\OAuth\\OAuth2\\Token\\StdOAuth2Token');
     $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 Mailchimp($this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), $client, $storage, array(), new Uri('https://us1.api.mailchimp.com/2.0/'));
     $uri = $service->request('https://pieterhordijk.com/my/awesome/path');
     $absoluteUri = parse_url($uri->getAbsoluteUri());
     $this->assertSame('apikey=foo', $absoluteUri['query']);
 }