/** * @covers OAuth\OAuth2\Service\Dailymotion::__construct * @covers OAuth\OAuth2\Service\Dailymotion::getAccessTokenEndpoint */ public function testGetAccessTokenEndpoint() { $service = new Dailymotion($this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), $this->getMock('\\Buzz\\Browser'), $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface')); $this->assertSame('https://api.dailymotion.com/oauth/token', (string) $service->getAccessTokenEndpoint()); }
/** * @covers OAuth\OAuth2\Service\Dailymotion::__construct * @covers OAuth\OAuth2\Service\Dailymotion::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('Accept', $extraHeaders)); \PHPUnit_Framework_Assert::assertTrue(in_array('application/json', $extraHeaders, true)); return '{"access_token":"foo","expires_in":"bar"}'; })); $service = new Dailymotion($this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), $client, $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface')); $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); }