예제 #1
0
 /**
  * @covers OAuth\OAuth2\Service\Spotify::__construct
  * @covers OAuth\OAuth2\Service\Spotify::getExtraOAuthHeaders
  */
 public function testGetExtraOAuthHeaders()
 {
     $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface');
     $client->expects($this->once())->method('retrieveResponse')->will($this->returnCallback(function ($uri, $params, $extraHeaders) {
         \PHPUnit_Framework_Assert::assertTrue(array_key_exists('Authorization', $extraHeaders));
         \PHPUnit_Framework_Assert::assertSame('Basic ' . base64_encode('foo:bar'), $extraHeaders['Authorization']);
         return '{"access_token":"foo","expires_in":"bar"}';
     }));
     $credentials = $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface');
     $credentials->expects($this->any())->method('getConsumerId')->will($this->returnValue('foo'));
     $credentials->expects($this->any())->method('getConsumerSecret')->will($this->returnValue('bar'));
     $service = new Spotify($credentials, $client, $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'));
     $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo'));
 }
예제 #2
0
 /**
  * @covers OAuth\OAuth2\Service\Spotify::__construct
  * @covers OAuth\OAuth2\Service\Spotify::getAccessTokenEndpoint
  */
 public function testGetAccessTokenEndpoint()
 {
     $service = new Spotify($this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), $this->getMock('\\Buzz\\Browser'), $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'));
     $this->assertSame('https://accounts.spotify.com/api/token', (string) $service->getAccessTokenEndpoint());
 }