/** * @covers OAuth\OAuth2\Service\AbstractService::__construct * @covers OAuth\OAuth2\Service\AbstractService::isValidScope * @covers OAuth\OAuth2\Service\AbstractService::getAuthorizationUri * @covers OAuth\OAuth2\Service\AbstractService::getAuthorizationEndpoint */ public function testGetAuthorizationUriWithParametersAndScopes() { $credentials = $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'); $credentials->expects($this->once())->method('getConsumerId')->will($this->returnValue('foo')); $credentials->expects($this->once())->method('getCallbackUrl')->will($this->returnValue('bar')); $service = new Mock($credentials, $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), array('mock', 'mock2')); $this->assertSame('http://pieterhordijk.com/auth?foo=bar&baz=beer&type=web_server&client_id=foo&redirect_uri=bar&response_type=code&scope=mock+mock2', $service->getAuthorizationUri(array('foo' => 'bar', 'baz' => 'beer'))->getAbsoluteUri()); }
/** * @covers OAuth\OAuth2\Service\AbstractService::__construct * @covers OAuth\OAuth2\Service\AbstractService::getAuthorizationUri * @covers OAuth\OAuth2\Service\AbstractService::getAuthorizationEndpoint */ public function testGetAuthorizationUriWithInjectedVersion() { $credentials = $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'); $credentials->expects($this->once())->method('getConsumerId')->will($this->returnValue('foo')); $credentials->expects($this->once())->method('getCallbackUrl')->will($this->returnValue('bar')); $service = new Mock($credentials, $this->getMock('\\Buzz\\Browser'), $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), [], null, '1.1'); $this->assertSame('http://pieterhordijk.com/auth/1.1?type=web_server&client_id=foo&redirect_uri=bar&response_type=code&scope=', (string) $service->getAuthorizationUri()); }