diff options
author | Frédéric Guillot <fred@kanboard.net> | 2014-11-06 06:57:39 -0500 |
---|---|---|
committer | Frédéric Guillot <fred@kanboard.net> | 2014-11-06 06:57:39 -0500 |
commit | 420d0ca4dd6cf075204867de28c2e6d5b1b68184 (patch) | |
tree | e7723f4b0687d82300ca5b4d38e3ab0ff3fc13cf /vendor/lusitanian/oauth/tests/Unit/OAuth2/Service | |
parent | cfe1e13d4a2b964c950b5e3daa8cafab207f1158 (diff) |
Remove vendor again
Diffstat (limited to 'vendor/lusitanian/oauth/tests/Unit/OAuth2/Service')
23 files changed, 0 insertions, 4780 deletions
diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/AbstractServiceTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/AbstractServiceTest.php deleted file mode 100644 index 595db2a3..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/AbstractServiceTest.php +++ /dev/null @@ -1,401 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuthTest\Mocks\OAuth2\Service\Mock; -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Token\TokenInterface; - -class AbstractServiceTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\AbstractService::__construct - */ - public function testConstructCorrectInterface() - { - $service = $this->getMockForAbstractClass( - '\\OAuth\\OAuth2\\Service\\AbstractService', - array( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - ) - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\AbstractService::__construct - */ - public function testConstructCorrectParent() - { - $service = $this->getMockForAbstractClass( - '\\OAuth\\OAuth2\\Service\\AbstractService', - array( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - ) - ); - - $this->assertInstanceOf('\\OAuth\\Common\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\AbstractService::__construct - */ - public function testConstructCorrectParentCustomUri() - { - $service = $this->getMockForAbstractClass( - '\\OAuth\\OAuth2\\Service\\AbstractService', - array( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'), - ) - ); - - $this->assertInstanceOf('\\OAuth\\Common\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\AbstractService::__construct - * @covers OAuth\OAuth2\Service\AbstractService::isValidScope - */ - public function testConstructThrowsExceptionOnInvalidScope() - { - $this->setExpectedException('\\OAuth\\OAuth2\\Service\\Exception\\InvalidScopeException'); - - $service = new Mock( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array('invalidscope') - ); - } - - /** - * @covers OAuth\OAuth2\Service\AbstractService::__construct - * @covers OAuth\OAuth2\Service\AbstractService::getAuthorizationUri - * @covers OAuth\OAuth2\Service\AbstractService::getAuthorizationEndpoint - */ - public function testGetAuthorizationUriWithoutParametersOrScopes() - { - $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') - ); - - $this->assertSame( - 'http://pieterhordijk.com/auth?type=web_server&client_id=foo&redirect_uri=bar&response_type=code&scope=', - $service->getAuthorizationUri()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth2\Service\AbstractService::__construct - * @covers OAuth\OAuth2\Service\AbstractService::getAuthorizationUri - * @covers OAuth\OAuth2\Service\AbstractService::getAuthorizationEndpoint - */ - public function testGetAuthorizationUriWithParametersWithoutScopes() - { - $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') - ); - - $this->assertSame( - 'http://pieterhordijk.com/auth?foo=bar&baz=beer&type=web_server&client_id=foo&redirect_uri=bar&response_type=code&scope=', - $service->getAuthorizationUri(array('foo' => 'bar', 'baz' => 'beer'))->getAbsoluteUri() - ); - } - - /** - * @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::requestAccessToken - * @covers OAuth\OAuth2\Service\AbstractService::getAccessTokenEndpoint - * @covers OAuth\OAuth2\Service\AbstractService::getExtraOAuthHeaders - * @covers OAuth\OAuth2\Service\AbstractService::parseAccessTokenResponse - * @covers OAuth\OAuth2\Service\AbstractService::service - */ - public function testRequestAccessToken() - { - $service = new Mock( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceof('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('code')); - } - - /** - * @covers OAuth\OAuth2\Service\AbstractService::__construct - * @covers OAuth\OAuth2\Service\AbstractService::request - * @covers OAuth\OAuth2\Service\AbstractService::determineRequestUriFromPath - */ - public function testRequestThrowsExceptionWhenTokenIsExpired() - { - $tokenExpiration = new \DateTime('26-03-1984 00:00:00'); - - $token = $this->getMock('\\OAuth\\OAuth2\\Token\\TokenInterface'); - $token->expects($this->any())->method('getEndOfLife')->will($this->returnValue($tokenExpiration->format('U'))); - - $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'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $storage - ); - - $this->setExpectedException('\\OAuth\\Common\\Token\\Exception\\ExpiredTokenException', 'Token expired on 03/26/1984 at 12:00:00 AM'); - - $service->request('https://pieterhordijk.com/my/awesome/path'); - } - - /** - * @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 testRequestOauthAuthorizationMethod() - { - $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 - ); - - $headers = $service->request('https://pieterhordijk.com/my/awesome/path'); - - $this->assertTrue(array_key_exists('Authorization', $headers)); - $this->assertTrue(in_array('OAuth 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 testRequestQueryStringMethod() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnArgument(0)); - - $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('querystring'); - - $uri = $service->request('https://pieterhordijk.com/my/awesome/path'); - $absoluteUri = parse_url($uri->getAbsoluteUri()); - - $this->assertSame('access_token=foo', $absoluteUri['query']); - } - - /** - * @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 testRequestQueryStringTwoMethod() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnArgument(0)); - - $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('querystring2'); - - $uri = $service->request('https://pieterhordijk.com/my/awesome/path'); - $absoluteUri = parse_url($uri->getAbsoluteUri()); - - $this->assertSame('oauth2_access_token=foo', $absoluteUri['query']); - } - - /** - * @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)); - } - - /** - * @covers OAuth\OAuth2\Service\AbstractService::__construct - * @covers OAuth\OAuth2\Service\AbstractService::getStorage - */ - public function testGetStorage() - { - $service = new Mock( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\Common\\Storage\\TokenStorageInterface', $service->getStorage()); - } - - /** - * @covers OAuth\OAuth2\Service\AbstractService::__construct - * @covers OAuth\OAuth2\Service\AbstractService::refreshAccessToken - * @covers OAuth\OAuth2\Service\AbstractService::getAccessTokenEndpoint - * @covers OAuth\OAuth2\Service\AbstractService::getExtraOAuthHeaders - * @covers OAuth\OAuth2\Service\AbstractService::parseAccessTokenResponse - */ - public function testRefreshAccessTokenSuccess() - { - $service = new Mock( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $token = $this->getMock('\\OAuth\\OAuth2\\Token\\StdOAuth2Token'); - $token->expects($this->once())->method('getRefreshToken')->will($this->returnValue('foo')); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->refreshAccessToken($token)); - } - - /** - * @covers OAuth\OAuth2\Service\AbstractService::__construct - * @covers OAuth\OAuth2\Service\AbstractService::isValidScope - */ - public function testIsValidScopeTrue() - { - $service = new Mock( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertTrue($service->isValidScope('mock')); - } - - /** - * @covers OAuth\OAuth2\Service\AbstractService::__construct - * @covers OAuth\OAuth2\Service\AbstractService::isValidScope - */ - public function testIsValidScopeFalse() - { - $service = new Mock( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertFalse($service->isValidScope('invalid')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/AmazonTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/AmazonTest.php deleted file mode 100644 index f70fe401..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/AmazonTest.php +++ /dev/null @@ -1,207 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuth\OAuth2\Service\Amazon; -use OAuth\Common\Token\TokenInterface; - -class AmazonTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\Amazon::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Amazon( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Amazon::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Amazon( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Amazon::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Amazon( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Amazon::__construct - * @covers OAuth\OAuth2\Service\Amazon::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Amazon( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://www.amazon.com/ap/oa', $service->getAuthorizationEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\Amazon::__construct - * @covers OAuth\OAuth2\Service\Amazon::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Amazon( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://www.amazon.com/ap/oatoken', $service->getAccessTokenEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\Amazon::__construct - * @covers OAuth\OAuth2\Service\Amazon::getAuthorizationMethod - */ - public function testGetAuthorizationMethod() - { - $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 Amazon( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $headers = $service->request('https://pieterhordijk.com/my/awesome/path'); - - $this->assertTrue(array_key_exists('Authorization', $headers)); - $this->assertTrue(in_array('Bearer foo', $headers, true)); - } - - /** - * @covers OAuth\OAuth2\Service\Amazon::__construct - * @covers OAuth\OAuth2\Service\Amazon::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new Amazon( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Amazon::__construct - * @covers OAuth\OAuth2\Service\Amazon::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnErrorDescription() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error_description=some_error')); - - $service = new Amazon( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Amazon::__construct - * @covers OAuth\OAuth2\Service\Amazon::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=some_error')); - - $service = new Amazon( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Amazon::__construct - * @covers OAuth\OAuth2\Service\Amazon::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithoutRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar"}')); - - $service = new Amazon( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\Amazon::__construct - * @covers OAuth\OAuth2\Service\Amazon::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar","refresh_token":"baz"}')); - - $service = new Amazon( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/BitlyTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/BitlyTest.php deleted file mode 100644 index 9944b260..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/BitlyTest.php +++ /dev/null @@ -1,150 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuth\OAuth2\Service\Bitly; -use OAuth\Common\Token\TokenInterface; - -class BitlyTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\Bitly::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Bitly( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Bitly::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Bitly( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Bitly::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Bitly( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Bitly::__construct - * @covers OAuth\OAuth2\Service\Bitly::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Bitly( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://bitly.com/oauth/authorize', $service->getAuthorizationEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\Bitly::__construct - * @covers OAuth\OAuth2\Service\Bitly::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Bitly( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://api-ssl.bitly.com/oauth/access_token', $service->getAccessTokenEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\Bitly::__construct - * @covers OAuth\OAuth2\Service\Bitly::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\\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 Bitly( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $uri = $service->request('https://pieterhordijk.com/my/awesome/path'); - $absoluteUri = parse_url($uri->getAbsoluteUri()); - - $this->assertSame('access_token=foo', $absoluteUri['query']); - } - - /** - * @covers OAuth\OAuth2\Service\Bitly::__construct - * @covers OAuth\OAuth2\Service\Bitly::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=some_error')); - - $service = new Bitly( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Bitly::__construct - * @covers OAuth\OAuth2\Service\Bitly::parseAccessTokenResponse - * @covers OAuth\OAuth2\Service\Bitly::requestAccessToken - */ - public function testParseAccessTokenResponseValid() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('access_token=foo')); - - $service = new Bitly( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/BoxTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/BoxTest.php deleted file mode 100644 index b5b2a789..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/BoxTest.php +++ /dev/null @@ -1,207 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuth\OAuth2\Service\Box; -use OAuth\Common\Token\TokenInterface; - -class BoxTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\Box::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Box( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Box::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Box( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Box::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Box( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Box::__construct - * @covers OAuth\OAuth2\Service\Box::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Box( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://www.box.com/api/oauth2/authorize', $service->getAuthorizationEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\Box::__construct - * @covers OAuth\OAuth2\Service\Box::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Box( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://www.box.com/api/oauth2/token', $service->getAccessTokenEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\Box::__construct - * @covers OAuth\OAuth2\Service\Box::getAuthorizationMethod - */ - public function testGetAuthorizationMethod() - { - $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 Box( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $headers = $service->request('https://pieterhordijk.com/my/awesome/path'); - - $this->assertTrue(array_key_exists('Authorization', $headers)); - $this->assertTrue(in_array('Bearer foo', $headers, true)); - } - - /** - * @covers OAuth\OAuth2\Service\Box::__construct - * @covers OAuth\OAuth2\Service\Box::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new Box( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Box::__construct - * @covers OAuth\OAuth2\Service\Box::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnErrorDescription() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error_description=some_error')); - - $service = new Box( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Box::__construct - * @covers OAuth\OAuth2\Service\Box::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=some_error')); - - $service = new Box( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Box::__construct - * @covers OAuth\OAuth2\Service\Box::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithoutRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar"}')); - - $service = new Box( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\Box::__construct - * @covers OAuth\OAuth2\Service\Box::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar","refresh_token":"baz"}')); - - $service = new Box( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/BufferTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/BufferTest.php deleted file mode 100644 index 29726d0a..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/BufferTest.php +++ /dev/null @@ -1,150 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuth\OAuth2\Service\Buffer; -use OAuth\Common\Token\TokenInterface; - -class BufferTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\Buffer::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Buffer( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Buffer::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Buffer( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Buffer::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Buffer( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Buffer::__construct - * @covers OAuth\OAuth2\Service\Buffer::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Buffer( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://bufferapp.com/oauth2/authorize', $service->getAuthorizationEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\Buffer::__construct - * @covers OAuth\OAuth2\Service\Buffer::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Buffer( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://api.bufferapp.com/1/oauth2/token.json', $service->getAccessTokenEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\Buffer::__construct - * @covers OAuth\OAuth2\Service\Buffer::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\\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 Buffer( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $uri = $service->request('https://pieterhordijk.com/my/awesome/path'); - $absoluteUri = parse_url($uri->getAbsoluteUri()); - - $this->assertSame('access_token=foo', $absoluteUri['query']); - } - - /** - * @covers OAuth\OAuth2\Service\Buffer::__construct - * @covers OAuth\OAuth2\Service\Buffer::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=some_error')); - - $service = new Buffer( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Buffer::__construct - * @covers OAuth\OAuth2\Service\Buffer::parseAccessTokenResponse - * @covers OAuth\OAuth2\Service\Buffer::requestAccessToken - */ - public function testParseAccessTokenResponseValid() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo"}')); - - $service = new Buffer( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } -}
\ No newline at end of file diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/DailymotionTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/DailymotionTest.php deleted file mode 100644 index f3fbaa8e..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/DailymotionTest.php +++ /dev/null @@ -1,230 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuth\OAuth2\Service\Dailymotion; -use OAuth\Common\Token\TokenInterface; - -class DailymotionTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\Dailymotion::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Dailymotion( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Dailymotion::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Dailymotion( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Dailymotion::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Dailymotion( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Dailymotion::__construct - * @covers OAuth\OAuth2\Service\Dailymotion::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Dailymotion( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://api.dailymotion.com/oauth/authorize', $service->getAuthorizationEndpoint()->getAbsoluteUri()); - } - - /** - * @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('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://api.dailymotion.com/oauth/token', $service->getAccessTokenEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\Dailymotion::__construct - * @covers OAuth\OAuth2\Service\Dailymotion::getAuthorizationMethod - */ - public function testGetAuthorizationMethod() - { - $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 Dailymotion( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $headers = $service->request('https://pieterhordijk.com/my/awesome/path'); - - $this->assertTrue(array_key_exists('Authorization', $headers)); - $this->assertTrue(in_array('OAuth foo', $headers, true)); - } - - /** - * @covers OAuth\OAuth2\Service\Dailymotion::__construct - * @covers OAuth\OAuth2\Service\Dailymotion::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new Dailymotion( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Dailymotion::__construct - * @covers OAuth\OAuth2\Service\Dailymotion::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnErrorDescription() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error_description=some_error')); - - $service = new Dailymotion( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Dailymotion::__construct - * @covers OAuth\OAuth2\Service\Dailymotion::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=some_error')); - - $service = new Dailymotion( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Dailymotion::__construct - * @covers OAuth\OAuth2\Service\Dailymotion::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithoutRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"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')); - } - - /** - * @covers OAuth\OAuth2\Service\Dailymotion::__construct - * @covers OAuth\OAuth2\Service\Dailymotion::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar","refresh_token":"baz"}')); - - $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')); - } - - /** - * @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')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/DropboxTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/DropboxTest.php deleted file mode 100644 index 8f052c6b..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/DropboxTest.php +++ /dev/null @@ -1,231 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuth\OAuth2\Service\Dropbox; -use OAuth\Common\Token\TokenInterface; - -class DropboxTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\Dropbox::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Dropbox( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Dropbox::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Dropbox( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Dropbox::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Dropbox( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Dropbox::__construct - * @covers OAuth\OAuth2\Service\Dropbox::getAuthorizationUri - */ - public function testGetAuthorizationUriWithoutAdditionalParams() - { - $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 Dropbox( - $credentials, - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame( - 'https://www.dropbox.com/1/oauth2/authorize?client_id=foo&redirect_uri=bar&response_type=code&scope=', - $service->getAuthorizationUri()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth2\Service\Dropbox::__construct - * @covers OAuth\OAuth2\Service\Dropbox::getAuthorizationUri - */ - public function testGetAuthorizationUriWithAdditionalParams() - { - $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 Dropbox( - $credentials, - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame( - 'https://www.dropbox.com/1/oauth2/authorize?client_id=foo&redirect_uri=bar&response_type=code&scope=', - $service->getAuthorizationUri()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth2\Service\Dropbox::__construct - * @covers OAuth\OAuth2\Service\Dropbox::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Dropbox( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://www.dropbox.com/1/oauth2/authorize', $service->getAuthorizationEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\Dropbox::__construct - * @covers OAuth\OAuth2\Service\Dropbox::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Dropbox( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://api.dropbox.com/1/oauth2/token', $service->getAccessTokenEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\Dropbox::__construct - * @covers OAuth\OAuth2\Service\Dropbox::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\\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 Dropbox( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $uri = $service->request('https://pieterhordijk.com/my/awesome/path'); - $absoluteUri = parse_url($uri->getAbsoluteUri()); - - $this->assertSame('access_token=foo', $absoluteUri['query']); - } - - /** - * @covers OAuth\OAuth2\Service\Dropbox::__construct - * @covers OAuth\OAuth2\Service\Dropbox::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new Dropbox( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Dropbox::__construct - * @covers OAuth\OAuth2\Service\Dropbox::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=some_error')); - - $service = new Dropbox( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Dropbox::__construct - * @covers OAuth\OAuth2\Service\Dropbox::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithoutRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar"}')); - - $service = new Dropbox( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\Dropbox::__construct - * @covers OAuth\OAuth2\Service\Dropbox::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar","refresh_token":"baz"}')); - - $service = new Dropbox( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/FacebookTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/FacebookTest.php deleted file mode 100644 index f2fed463..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/FacebookTest.php +++ /dev/null @@ -1,242 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuth\OAuth2\Service\Facebook; -use OAuth\Common\Token\TokenInterface; - -class FacebookTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\Facebook::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Facebook( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Facebook::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Facebook( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Facebook::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Facebook( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Facebook::__construct - * @covers OAuth\OAuth2\Service\Facebook::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Facebook( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://www.facebook.com/dialog/oauth', $service->getAuthorizationEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\Facebook::__construct - * @covers OAuth\OAuth2\Service\Facebook::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Facebook( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://graph.facebook.com/oauth/access_token', $service->getAccessTokenEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\Facebook::__construct - */ - public function testGetAuthorizationMethod() - { - $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 Facebook( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $headers = $service->request('https://pieterhordijk.com/my/awesome/path'); - - $this->assertTrue(array_key_exists('Authorization', $headers)); - $this->assertTrue(in_array('OAuth foo', $headers, true)); - } - - /** - * @covers OAuth\OAuth2\Service\Facebook::__construct - * @covers OAuth\OAuth2\Service\Facebook::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=some_error')); - - $service = new Facebook( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Facebook::__construct - * @covers OAuth\OAuth2\Service\Facebook::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithoutRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('access_token=foo&expires=bar')); - - $service = new Facebook( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\Facebook::__construct - * @covers OAuth\OAuth2\Service\Facebook::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('access_token=foo&expires=bar&refresh_token=baz')); - - $service = new Facebook( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\Facebook::__construct - * @covers OAuth\OAuth2\Service\Facebook::getDialogUri - */ - public function testGetDialogUriRedirectUriMissing() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - - $service = new Facebook( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Exception\\Exception'); - - $service->getDialogUri('feed', array()); - } - - /** - * @covers OAuth\OAuth2\Service\Facebook::__construct - * @covers OAuth\OAuth2\Service\Facebook::getDialogUri - */ - public function testGetDialogUriInstanceofUri() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - - $service = new Facebook( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $dialogUri = $service->getDialogUri( - 'feed', - array( - 'redirect_uri' => 'http://www.facebook.com', - 'state' => 'Random state' - ) - ); - $this->assertInstanceOf('\\OAuth\\Common\\Http\\Uri\\Uri',$dialogUri); - } - - /** - * @covers OAuth\OAuth2\Service\Facebook::__construct - * @covers OAuth\OAuth2\Service\Facebook::getDialogUri - */ - public function testGetDialogUriContainsAppIdAndOtherParameters() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $credentials = $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'); - $credentials->expects($this->any())->method('getConsumerId')->will($this->returnValue('application_id')); - - - $service = new Facebook( - $credentials, - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $dialogUri = $service->getDialogUri( - 'feed', - array( - 'redirect_uri' => 'http://www.facebook.com', - 'state' => 'Random state' - ) - ); - - $queryString = $dialogUri->getQuery(); - parse_str($queryString, $queryArray); - - $this->assertArrayHasKey('app_id', $queryArray); - $this->assertArrayHasKey('redirect_uri', $queryArray); - $this->assertArrayHasKey('state', $queryArray); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/FoursquareTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/FoursquareTest.php deleted file mode 100644 index 96356ec5..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/FoursquareTest.php +++ /dev/null @@ -1,197 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuth\OAuth2\Service\Foursquare; -use OAuth\Common\Token\TokenInterface; - -class FoursquareTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\Foursquare::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Foursquare( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Foursquare::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Foursquare( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Foursquare::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Foursquare( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Foursquare::__construct - * @covers OAuth\OAuth2\Service\Foursquare::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Foursquare( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://foursquare.com/oauth2/authenticate', $service->getAuthorizationEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\Foursquare::__construct - * @covers OAuth\OAuth2\Service\Foursquare::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Foursquare( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://foursquare.com/oauth2/access_token', $service->getAccessTokenEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\Foursquare::__construct - * @covers OAuth\OAuth2\Service\Foursquare::getAuthorizationMethod - */ - public function testGetAuthorizationMethod() - { - $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 Foursquare( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $headers = $service->request('https://pieterhordijk.com/my/awesome/path'); - - $this->assertTrue(array_key_exists('Authorization', $headers)); - $this->assertTrue(in_array('OAuth foo', $headers, true)); - } - - /** - * @covers OAuth\OAuth2\Service\Foursquare::__construct - * @covers OAuth\OAuth2\Service\Foursquare::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new Foursquare( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Foursquare::__construct - * @covers OAuth\OAuth2\Service\Foursquare::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"error":"some_error"}')); - - $service = new Foursquare( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Foursquare::__construct - * @covers OAuth\OAuth2\Service\Foursquare::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithoutRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar"}')); - - $service = new Foursquare( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\Foursquare::__construct - * @covers OAuth\OAuth2\Service\Foursquare::request - */ - public function testRequest() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnArgument(0)); - - $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 Foursquare( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $this->assertSame( - 'https://api.foursquare.com/v2/https://pieterhordijk.com/my/awesome/path?v=20130829', - $service->request('https://pieterhordijk.com/my/awesome/path')->getAbsoluteUri() - ); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/GitHubTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/GitHubTest.php deleted file mode 100644 index edb0fee3..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/GitHubTest.php +++ /dev/null @@ -1,220 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuth\OAuth2\Service\GitHub; -use OAuth\Common\Token\TokenInterface; - -class GitHubTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\GitHub::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new GitHub( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\GitHub::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new GitHub( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\GitHub::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new GitHub( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\GitHub::__construct - * @covers OAuth\OAuth2\Service\GitHub::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new GitHub( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://github.com/login/oauth/authorize', $service->getAuthorizationEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\GitHub::__construct - * @covers OAuth\OAuth2\Service\GitHub::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new GitHub( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://github.com/login/oauth/access_token', $service->getAccessTokenEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\GitHub::__construct - * @covers OAuth\OAuth2\Service\GitHub::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\\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 GitHub( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $uri = $service->request('https://pieterhordijk.com/my/awesome/path'); - $absoluteUri = parse_url($uri->getAbsoluteUri()); - - $this->assertSame('access_token=foo', $absoluteUri['query']); - } - - /** - * @covers OAuth\OAuth2\Service\GitHub::__construct - * @covers OAuth\OAuth2\Service\GitHub::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new GitHub( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\GitHub::__construct - * @covers OAuth\OAuth2\Service\GitHub::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"error":"some_error"}')); - - $service = new GitHub( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\GitHub::__construct - * @covers OAuth\OAuth2\Service\GitHub::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithoutRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar"}')); - - $service = new GitHub( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\GitHub::__construct - * @covers OAuth\OAuth2\Service\GitHub::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 GitHub( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\GitHub::__construct - * @covers OAuth\OAuth2\Service\GitHub::getExtraApiHeaders - */ - public function testGetExtraApiHeaders() - { - $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 GitHub( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $headers = $service->request('https://pieterhordijk.com/my/awesome/path'); - - $this->assertTrue(array_key_exists('Accept', $headers)); - $this->assertSame('application/vnd.github.beta+json', $headers['Accept']); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/GoogleTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/GoogleTest.php deleted file mode 100644 index b55808d2..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/GoogleTest.php +++ /dev/null @@ -1,195 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuth\OAuth2\Service\Google; -use OAuth\Common\Token\TokenInterface; - -class GoogleTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\Google::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Google( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Google::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Google( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Google::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Google( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Google::__construct - * @covers OAuth\OAuth2\Service\Google::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Google( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame( - 'https://accounts.google.com/o/oauth2/auth?access_type=online', - $service->getAuthorizationEndpoint()->getAbsoluteUri() - ); - - // Verify that 'offine' works - $service->setAccessType('offline'); - $this->assertSame( - 'https://accounts.google.com/o/oauth2/auth?access_type=offline', - $service->getAuthorizationEndpoint()->getAbsoluteUri() - ); - - } - - /** - * @covers OAuth\OAuth2\Service\Google::__construct - * @covers OAuth\OAuth2\Service\Google::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpointException() - { - $service = new Google( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('OAuth\OAuth2\Service\Exception\InvalidAccessTypeException'); - - try { - $service->setAccessType('invalid'); - } catch (InvalidAccessTypeException $e) { - return; - } - $this->fail('Expected InvalidAccessTypeException not thrown'); - } - - /** - * @covers OAuth\OAuth2\Service\Google::__construct - * @covers OAuth\OAuth2\Service\Google::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Google( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame( - 'https://accounts.google.com/o/oauth2/token', - $service->getAccessTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth2\Service\Google::__construct - * @covers OAuth\OAuth2\Service\Google::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new Google( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Google::__construct - * @covers OAuth\OAuth2\Service\Google::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=some_error')); - - $service = new Google( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Google::__construct - * @covers OAuth\OAuth2\Service\Google::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithoutRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar"}')); - - $service = new Google( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\Google::__construct - * @covers OAuth\OAuth2\Service\Google::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar","refresh_token":"baz"}')); - - $service = new Google( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/HerokuTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/HerokuTest.php deleted file mode 100644 index cc2c0f69..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/HerokuTest.php +++ /dev/null @@ -1,261 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuth\OAuth2\Service\Heroku; -use OAuth\Common\Token\TokenInterface; - -class HerokuTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\Heroku::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Heroku( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Heroku::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Heroku( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Heroku::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Heroku( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Heroku::__construct - * @covers OAuth\OAuth2\Service\Heroku::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Heroku( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame( - 'https://id.heroku.com/oauth/authorize', - $service->getAuthorizationEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth2\Service\Heroku::__construct - * @covers OAuth\OAuth2\Service\Heroku::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Heroku( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://id.heroku.com/oauth/token', $service->getAccessTokenEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\Heroku::__construct - * @covers OAuth\OAuth2\Service\Heroku::getAuthorizationMethod - */ - public function testGetAuthorizationMethod() - { - $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 Heroku( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $headers = $service->request('https://pieterhordijk.com/my/awesome/path'); - - $this->assertTrue(array_key_exists('Authorization', $headers)); - $this->assertTrue(in_array('Bearer foo', $headers, true)); - } - - /** - * @covers OAuth\OAuth2\Service\Heroku::__construct - * @covers OAuth\OAuth2\Service\Heroku::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new Heroku( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Heroku::__construct - * @covers OAuth\OAuth2\Service\Heroku::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnErrorDescription() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error_description=some_error')); - - $service = new Heroku( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Heroku::__construct - * @covers OAuth\OAuth2\Service\Heroku::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=some_error')); - - $service = new Heroku( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Heroku::__construct - * @covers OAuth\OAuth2\Service\Heroku::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithoutRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar"}')); - - $service = new Heroku( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\Heroku::__construct - * @covers OAuth\OAuth2\Service\Heroku::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar","refresh_token":"baz"}')); - - $service = new Heroku( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\Heroku::__construct - * @covers OAuth\OAuth2\Service\Heroku::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/vnd.heroku+json; version=3', $extraHeaders, true)); - - return '{"access_token":"foo","expires_in":"bar"}'; - })); - - $service = new Heroku( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\Heroku::__construct - * @covers OAuth\OAuth2\Service\Heroku::getExtraApiHeaders - */ - public function testGetExtraApiHeaders() - { - $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 Heroku( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $headers = $service->request('https://pieterhordijk.com/my/awesome/path'); - - $this->assertTrue(array_key_exists('Accept', $headers)); - $this->assertSame('application/vnd.heroku+json; version=3', $headers['Accept']); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/InstagramTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/InstagramTest.php deleted file mode 100644 index bf9d764c..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/InstagramTest.php +++ /dev/null @@ -1,193 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuth\OAuth2\Service\Instagram; -use OAuth\Common\Token\TokenInterface; - -class InstagramTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\Instagram::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Instagram( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Instagram::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Instagram( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Instagram::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Instagram( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Instagram::__construct - * @covers OAuth\OAuth2\Service\Instagram::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Instagram( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame( - 'https://api.instagram.com/oauth/authorize/', - $service->getAuthorizationEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth2\Service\Instagram::__construct - * @covers OAuth\OAuth2\Service\Instagram::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Instagram( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame( - 'https://api.instagram.com/oauth/access_token', - $service->getAccessTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth2\Service\Instagram::__construct - * @covers OAuth\OAuth2\Service\Instagram::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\\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 Instagram( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $uri = $service->request('https://pieterhordijk.com/my/awesome/path'); - $absoluteUri = parse_url($uri->getAbsoluteUri()); - - $this->assertSame('access_token=foo', $absoluteUri['query']); - } - - /** - * @covers OAuth\OAuth2\Service\Instagram::__construct - * @covers OAuth\OAuth2\Service\Instagram::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new Instagram( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Instagram::__construct - * @covers OAuth\OAuth2\Service\Instagram::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=some_error')); - - $service = new Instagram( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Instagram::__construct - * @covers OAuth\OAuth2\Service\Instagram::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithoutRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar"}')); - - $service = new Instagram( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\Instagram::__construct - * @covers OAuth\OAuth2\Service\Instagram::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar","refresh_token":"baz"}')); - - $service = new Instagram( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/LinkedinTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/LinkedinTest.php deleted file mode 100644 index c7f5c76e..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/LinkedinTest.php +++ /dev/null @@ -1,213 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuth\OAuth2\Service\Linkedin; -use OAuth\Common\Token\TokenInterface; - -class LinkedinTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\Linkedin::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Linkedin( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Linkedin::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Linkedin( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Linkedin::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Linkedin( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Linkedin::__construct - * @covers OAuth\OAuth2\Service\Linkedin::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Linkedin( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame( - 'https://www.linkedin.com/uas/oauth2/authorization', - $service->getAuthorizationEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth2\Service\Linkedin::__construct - * @covers OAuth\OAuth2\Service\Linkedin::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Linkedin( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame( - 'https://www.linkedin.com/uas/oauth2/accessToken', - $service->getAccessTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth2\Service\Linkedin::__construct - * @covers OAuth\OAuth2\Service\Linkedin::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\\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 Linkedin( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $uri = $service->request('https://pieterhordijk.com/my/awesome/path'); - $absoluteUri = parse_url($uri->getAbsoluteUri()); - - $this->assertSame('oauth2_access_token=foo', $absoluteUri['query']); - } - - /** - * @covers OAuth\OAuth2\Service\Linkedin::__construct - * @covers OAuth\OAuth2\Service\Linkedin::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new Linkedin( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Linkedin::__construct - * @covers OAuth\OAuth2\Service\Linkedin::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnErrorDescription() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error_description=some_error')); - - $service = new Linkedin( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Linkedin::__construct - * @covers OAuth\OAuth2\Service\Linkedin::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=some_error')); - - $service = new Linkedin( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Linkedin::__construct - * @covers OAuth\OAuth2\Service\Linkedin::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithoutRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar"}')); - - $service = new Linkedin( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\Linkedin::__construct - * @covers OAuth\OAuth2\Service\Linkedin::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar","refresh_token":"baz"}')); - - $service = new Linkedin( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/MailchimpTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/MailchimpTest.php deleted file mode 100644 index e7f955e1..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/MailchimpTest.php +++ /dev/null @@ -1,179 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuth\OAuth2\Service\Mailchimp; -use OAuth\Common\Token\TokenInterface; -use OAuth\Common\Http\Uri\Uri; - -class MailchimpTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\Mailchimp::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Mailchimp( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Mailchimp::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Mailchimp( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Mailchimp::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Mailchimp( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Mailchimp::__construct - * @covers OAuth\OAuth2\Service\Mailchimp::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Mailchimp( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame( - 'https://login.mailchimp.com/oauth2/authorize', - $service->getAuthorizationEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth2\Service\Mailchimp::__construct - * @covers OAuth\OAuth2\Service\Mailchimp::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Mailchimp( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame( - 'https://login.mailchimp.com/oauth2/token', - $service->getAccessTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @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']); - } - - /** - * @covers OAuth\OAuth2\Service\Mailchimp::__construct - * @covers OAuth\OAuth2\Service\Mailchimp::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new Mailchimp( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Mailchimp::__construct - * @covers OAuth\OAuth2\Service\Mailchimp::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=some_error')); - - $service = new Mailchimp( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Mailchimp::__construct - * @covers OAuth\OAuth2\Service\Mailchimp::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValid() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->at(0))->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar"}')); - $client->expects($this->at(1))->method('retrieveResponse')->will($this->returnValue('{"dc": "us7"}')); - - $service = new Mailchimp( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/MicrosoftTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/MicrosoftTest.php deleted file mode 100644 index 4001e1e4..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/MicrosoftTest.php +++ /dev/null @@ -1,193 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuth\OAuth2\Service\Microsoft; -use OAuth\Common\Token\TokenInterface; - -class MicrosoftTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\Microsoft::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Microsoft( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Microsoft::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Microsoft( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Microsoft::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Microsoft( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Microsoft::__construct - * @covers OAuth\OAuth2\Service\Microsoft::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Microsoft( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame( - 'https://login.live.com/oauth20_authorize.srf', - $service->getAuthorizationEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth2\Service\Microsoft::__construct - * @covers OAuth\OAuth2\Service\Microsoft::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Microsoft( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame( - 'https://login.live.com/oauth20_token.srf', - $service->getAccessTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth2\Service\Microsoft::__construct - * @covers OAuth\OAuth2\Service\Microsoft::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\\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 Microsoft( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $uri = $service->request('https://pieterhordijk.com/my/awesome/path'); - $absoluteUri = parse_url($uri->getAbsoluteUri()); - - $this->assertSame('access_token=foo', $absoluteUri['query']); - } - - /** - * @covers OAuth\OAuth2\Service\Microsoft::__construct - * @covers OAuth\OAuth2\Service\Microsoft::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new Microsoft( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Microsoft::__construct - * @covers OAuth\OAuth2\Service\Microsoft::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=some_error')); - - $service = new Microsoft( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Microsoft::__construct - * @covers OAuth\OAuth2\Service\Microsoft::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithoutRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar"}')); - - $service = new Microsoft( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\Microsoft::__construct - * @covers OAuth\OAuth2\Service\Microsoft::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar","refresh_token":"baz"}')); - - $service = new Microsoft( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/PaypalTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/PaypalTest.php deleted file mode 100644 index 5396326f..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/PaypalTest.php +++ /dev/null @@ -1,213 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuth\OAuth2\Service\Paypal; -use OAuth\Common\Token\TokenInterface; - -class PaypalTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\Paypal::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Paypal( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Paypal::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Paypal( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Paypal::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Paypal( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Paypal::__construct - * @covers OAuth\OAuth2\Service\Paypal::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Paypal( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame( - 'https://www.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize', - $service->getAuthorizationEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth2\Service\Paypal::__construct - * @covers OAuth\OAuth2\Service\Paypal::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Paypal( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame( - 'https://api.paypal.com/v1/identity/openidconnect/tokenservice', - $service->getAccessTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth2\Service\Paypal::__construct - * @covers OAuth\OAuth2\Service\Paypal::getAuthorizationMethod - */ - public function testGetAuthorizationMethod() - { - $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 Paypal( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $headers = $service->request('https://pieterhordijk.com/my/awesome/path'); - - $this->assertTrue(array_key_exists('Authorization', $headers)); - $this->assertTrue(in_array('Bearer foo', $headers, true)); - } - - /** - * @covers OAuth\OAuth2\Service\Paypal::__construct - * @covers OAuth\OAuth2\Service\Paypal::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new Paypal( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Paypal::__construct - * @covers OAuth\OAuth2\Service\Paypal::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnMessage() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('message=some_error')); - - $service = new Paypal( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Paypal::__construct - * @covers OAuth\OAuth2\Service\Paypal::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnName() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('name=some_error')); - - $service = new Paypal( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Paypal::__construct - * @covers OAuth\OAuth2\Service\Paypal::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithoutRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar"}')); - - $service = new Paypal( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\Paypal::__construct - * @covers OAuth\OAuth2\Service\Paypal::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar","refresh_token":"baz"}')); - - $service = new Paypal( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/RedditTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/RedditTest.php deleted file mode 100644 index e8741e6f..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/RedditTest.php +++ /dev/null @@ -1,193 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuth\OAuth2\Service\Reddit; -use OAuth\Common\Token\TokenInterface; - -class RedditTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\Reddit::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Reddit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Reddit::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Reddit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Reddit::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Reddit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Reddit::__construct - * @covers OAuth\OAuth2\Service\Reddit::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Reddit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame( - 'https://ssl.reddit.com/api/v1/authorize', - $service->getAuthorizationEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth2\Service\Reddit::__construct - * @covers OAuth\OAuth2\Service\Reddit::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Reddit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame( - 'https://ssl.reddit.com/api/v1/access_token', - $service->getAccessTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth2\Service\Reddit::__construct - * @covers OAuth\OAuth2\Service\Reddit::getAuthorizationMethod - */ - public function testGetAuthorizationMethod() - { - $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 Reddit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $headers = $service->request('https://pieterhordijk.com/my/awesome/path'); - - $this->assertTrue(array_key_exists('Authorization', $headers)); - $this->assertTrue(in_array('Bearer foo', $headers, true)); - } - - /** - * @covers OAuth\OAuth2\Service\Reddit::__construct - * @covers OAuth\OAuth2\Service\Reddit::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new Reddit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Reddit::__construct - * @covers OAuth\OAuth2\Service\Reddit::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=some_error')); - - $service = new Reddit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Reddit::__construct - * @covers OAuth\OAuth2\Service\Reddit::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithoutRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar"}')); - - $service = new Reddit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\Reddit::__construct - * @covers OAuth\OAuth2\Service\Reddit::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar","refresh_token":"baz"}')); - - $service = new Reddit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/RunKeeperTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/RunKeeperTest.php deleted file mode 100644 index 671bd0cf..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/RunKeeperTest.php +++ /dev/null @@ -1,207 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuth\OAuth2\Service\RunKeeper; -use OAuth\Common\Token\TokenInterface; - -class RunKeeperTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\RunKeeper::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new RunKeeper( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\RunKeeper::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new RunKeeper( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\RunKeeper::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new RunKeeper( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\RunKeeper::__construct - * @covers OAuth\OAuth2\Service\RunKeeper::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new RunKeeper( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://runkeeper.com/apps/authorize', $service->getAuthorizationEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\RunKeeper::__construct - * @covers OAuth\OAuth2\Service\RunKeeper::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new RunKeeper( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://runkeeper.com/apps/token', $service->getAccessTokenEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\RunKeeper::__construct - * @covers OAuth\OAuth2\Service\RunKeeper::getAuthorizationMethod - */ - public function testGetAuthorizationMethod() - { - $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 RunKeeper( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $headers = $service->request('/user'); - - $this->assertTrue(array_key_exists('Authorization', $headers)); - $this->assertTrue(in_array('Bearer foo', $headers, true)); - } - - /** - * @covers OAuth\OAuth2\Service\RunKeeper::__construct - * @covers OAuth\OAuth2\Service\RunKeeper::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new RunKeeper( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\RunKeeper::__construct - * @covers OAuth\OAuth2\Service\RunKeeper::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnErrorDescription() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error_description=some_error')); - - $service = new RunKeeper( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\RunKeeper::__construct - * @covers OAuth\OAuth2\Service\RunKeeper::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=some_error')); - - $service = new RunKeeper( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\RunKeeper::__construct - * @covers OAuth\OAuth2\Service\RunKeeper::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithoutRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar"}')); - - $service = new RunKeeper( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\RunKeeper::__construct - * @covers OAuth\OAuth2\Service\RunKeeper::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar","refresh_token":"baz"}')); - - $service = new RunKeeper( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/SoundCloudTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/SoundCloudTest.php deleted file mode 100644 index ac988ba2..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/SoundCloudTest.php +++ /dev/null @@ -1,159 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuth\OAuth2\Service\SoundCloud; -use OAuth\Common\Token\TokenInterface; - -class SoundCloudTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\SoundCloud::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new SoundCloud( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\SoundCloud::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new SoundCloud( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\SoundCloud::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new SoundCloud( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\SoundCloud::__construct - * @covers OAuth\OAuth2\Service\SoundCloud::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new SoundCloud( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://soundcloud.com/connect', $service->getAuthorizationEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\SoundCloud::__construct - * @covers OAuth\OAuth2\Service\SoundCloud::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new SoundCloud( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://api.soundcloud.com/oauth2/token', $service->getAccessTokenEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\SoundCloud::__construct - * @covers OAuth\OAuth2\Service\SoundCloud::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new SoundCloud( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\SoundCloud::__construct - * @covers OAuth\OAuth2\Service\SoundCloud::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=some_error')); - - $service = new SoundCloud( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\SoundCloud::__construct - * @covers OAuth\OAuth2\Service\SoundCloud::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithoutRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar"}')); - - $service = new SoundCloud( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\SoundCloud::__construct - * @covers OAuth\OAuth2\Service\SoundCloud::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar","refresh_token":"baz"}')); - - $service = new SoundCloud( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/UstreamTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/UstreamTest.php deleted file mode 100644 index 48965ae0..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/UstreamTest.php +++ /dev/null @@ -1,193 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuth\OAuth2\Service\Ustream; -use OAuth\Common\Token\TokenInterface; - -class UstreamTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\Ustream::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Ustream( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Ustream::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Ustream( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Ustream::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Ustream( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Ustream::__construct - * @covers OAuth\OAuth2\Service\Ustream::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Ustream( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame( - 'https://www.ustream.tv/oauth2/authorize', - $service->getAuthorizationEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth2\Service\Ustream::__construct - * @covers OAuth\OAuth2\Service\Ustream::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Ustream( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame( - 'https://www.ustream.tv/oauth2/token', - $service->getAccessTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth2\Service\Ustream::__construct - * @covers OAuth\OAuth2\Service\Ustream::getAuthorizationMethod - */ - public function testGetAuthorizationMethod() - { - $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 Ustream( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $headers = $service->request('https://pieterhordijk.com/my/awesome/path'); - - $this->assertTrue(array_key_exists('Authorization', $headers)); - $this->assertTrue(in_array('Bearer foo', $headers, true)); - } - - /** - * @covers OAuth\OAuth2\Service\Ustream::__construct - * @covers OAuth\OAuth2\Service\Ustream::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new Ustream( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Ustream::__construct - * @covers OAuth\OAuth2\Service\Ustream::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=some_error')); - - $service = new Ustream( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Ustream::__construct - * @covers OAuth\OAuth2\Service\Ustream::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithoutRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar"}')); - - $service = new Ustream( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\Ustream::__construct - * @covers OAuth\OAuth2\Service\Ustream::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar","refresh_token":"baz"}')); - - $service = new Ustream( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/VkontakteTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/VkontakteTest.php deleted file mode 100644 index 7a8279b2..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/VkontakteTest.php +++ /dev/null @@ -1,159 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuth\OAuth2\Service\Vkontakte; -use OAuth\Common\Token\TokenInterface; - -class VkontakteTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\Vkontakte::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Vkontakte( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Vkontakte::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Vkontakte( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Vkontakte::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Vkontakte( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Vkontakte::__construct - * @covers OAuth\OAuth2\Service\Vkontakte::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Vkontakte( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://oauth.vk.com/authorize', $service->getAuthorizationEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\Vkontakte::__construct - * @covers OAuth\OAuth2\Service\Vkontakte::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Vkontakte( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://oauth.vk.com/access_token', $service->getAccessTokenEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\Vkontakte::__construct - * @covers OAuth\OAuth2\Service\Vkontakte::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new Vkontakte( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Vkontakte::__construct - * @covers OAuth\OAuth2\Service\Vkontakte::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=some_error')); - - $service = new Vkontakte( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Vkontakte::__construct - * @covers OAuth\OAuth2\Service\Vkontakte::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithoutRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar"}')); - - $service = new Vkontakte( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\Vkontakte::__construct - * @covers OAuth\OAuth2\Service\Vkontakte::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":"foo","expires_in":"bar","refresh_token":"baz"}')); - - $service = new Vkontakte( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/YammerTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/YammerTest.php deleted file mode 100644 index 86440395..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth2/Service/YammerTest.php +++ /dev/null @@ -1,187 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth2\Service; - -use OAuth\OAuth2\Service\Yammer; -use OAuth\Common\Token\TokenInterface; - -class YammerTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth2\Service\Yammer::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Yammer( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Yammer::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Yammer( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Yammer::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Yammer( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - array(), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth2\Service\Yammer::__construct - * @covers OAuth\OAuth2\Service\Yammer::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Yammer( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://www.yammer.com/dialog/oauth', $service->getAuthorizationEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\Yammer::__construct - * @covers OAuth\OAuth2\Service\Yammer::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Yammer( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('https://www.yammer.com/oauth2/access_token.json', $service->getAccessTokenEndpoint()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth2\Service\Yammer::__construct - * @covers OAuth\OAuth2\Service\Yammer::getAuthorizationMethod - */ - public function testGetAuthorizationMethod() - { - $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 Yammer( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage - ); - - $headers = $service->request('https://pieterhordijk.com/my/awesome/path'); - - $this->assertTrue(array_key_exists('Authorization', $headers)); - $this->assertTrue(in_array('Bearer foo', $headers, true)); - } - - /** - * @covers OAuth\OAuth2\Service\Yammer::__construct - * @covers OAuth\OAuth2\Service\Yammer::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new Yammer( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Yammer::__construct - * @covers OAuth\OAuth2\Service\Yammer::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=some_error')); - - $service = new Yammer( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo'); - } - - /** - * @covers OAuth\OAuth2\Service\Yammer::__construct - * @covers OAuth\OAuth2\Service\Yammer::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithoutRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":{"token":"foo", "expires_at":null}}')); - - $service = new Yammer( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } - - /** - * @covers OAuth\OAuth2\Service\Yammer::__construct - * @covers OAuth\OAuth2\Service\Yammer::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValidWithRefreshToken() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('{"access_token":{"token":"foo", "expires_at":null},"refresh_token":"baz"}')); - - $service = new Yammer( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth2\\Token\\StdOAuth2Token', $service->requestAccessToken('foo')); - } -} |