diff options
Diffstat (limited to 'vendor/lusitanian/oauth/tests/Unit/OAuth1')
12 files changed, 0 insertions, 3197 deletions
diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/AbstractServiceTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/AbstractServiceTest.php deleted file mode 100644 index ab5417b2..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/AbstractServiceTest.php +++ /dev/null @@ -1,215 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth1\Service; - -use OAuthTest\Mocks\OAuth1\Service\Mock; - -class AbstractServiceTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth1\Service\AbstractService::__construct - */ - public function testConstructCorrectInterface() - { - $service = $this->getMockForAbstractClass( - '\\OAuth\\OAuth1\\Service\\AbstractService', - array( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'), - ) - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth1\Service\AbstractService::__construct - */ - public function testConstructCorrectParent() - { - $service = $this->getMockForAbstractClass( - '\\OAuth\\OAuth1\\Service\\AbstractService', - array( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'), - ) - ); - - $this->assertInstanceOf('\\OAuth\\Common\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth1\Service\AbstractService::requestRequestToken - * @covers OAuth\OAuth1\Service\AbstractService::buildAuthorizationHeaderForTokenRequest - * @covers OAuth\OAuth1\Service\AbstractService::getBasicAuthorizationHeaderInfo - * @covers OAuth\OAuth1\Service\AbstractService::generateNonce - * @covers OAuth\OAuth1\Service\AbstractService::getSignatureMethod - * @covers OAuth\OAuth1\Service\AbstractService::getVersion - * @covers OAuth\OAuth1\Service\AbstractService::getExtraOAuthHeaders - * @covers OAuth\OAuth1\Service\AbstractService::parseRequestTokenResponse - */ - public function testRequestRequestTokenBuildAuthHeaderTokenRequestWithoutParams() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnCallback(function($endpoint, $array, $headers) { - \PHPUnit_Framework_Assert::assertSame('http://pieterhordijk.com/token', $endpoint->getAbsoluteUri()); - })); - - $service = new Mock( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Token\\StdOAuth1Token', $service->requestRequestToken()); - } - - /** - * @covers OAuth\OAuth1\Service\AbstractService::getAuthorizationUri - * @covers OAuth\OAuth1\Service\AbstractService::getAuthorizationEndpoint - */ - public function testGetAuthorizationUriWithoutParameters() - { - $service = new Mock( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertSame('http://pieterhordijk.com/auth', $service->getAuthorizationUri()->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth1\Service\AbstractService::getAuthorizationUri - * @covers OAuth\OAuth1\Service\AbstractService::getAuthorizationEndpoint - */ - public function testGetAuthorizationUriWithParameters() - { - $service = new Mock( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertSame('http://pieterhordijk.com/auth?foo=bar&baz=beer', $service->getAuthorizationUri(array( - 'foo' => 'bar', - 'baz' => 'beer', - ))->getAbsoluteUri()); - } - - /** - * @covers OAuth\OAuth1\Service\AbstractService::requestAccessToken - * @covers OAuth\OAuth1\Service\AbstractService::service - * @covers OAuth\OAuth1\Service\AbstractService::buildAuthorizationHeaderForAPIRequest - * @covers OAuth\OAuth1\Service\AbstractService::getBasicAuthorizationHeaderInfo - * @covers OAuth\OAuth1\Service\AbstractService::generateNonce - * @covers OAuth\OAuth1\Service\AbstractService::getSignatureMethod - * @covers OAuth\OAuth1\Service\AbstractService::getVersion - * @covers OAuth\OAuth1\Service\AbstractService::getAccessTokenEndpoint - * @covers OAuth\OAuth1\Service\AbstractService::getExtraOAuthHeaders - * @covers OAuth\OAuth1\Service\AbstractService::parseAccessTokenResponse - */ - public function testRequestAccessTokenWithoutSecret() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnCallback(function($endpoint, $array, $headers) { - \PHPUnit_Framework_Assert::assertSame('http://pieterhordijk.com/access', $endpoint->getAbsoluteUri()); - })); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - $token->expects($this->once())->method('getRequestTokenSecret')->will($this->returnValue('baz')); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Mock( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Token\\StdOAuth1Token', $service->requestAccessToken('foo', 'bar')); - } - - /** - * @covers OAuth\OAuth1\Service\AbstractService::requestAccessToken - * @covers OAuth\OAuth1\Service\AbstractService::service - * @covers OAuth\OAuth1\Service\AbstractService::buildAuthorizationHeaderForAPIRequest - * @covers OAuth\OAuth1\Service\AbstractService::getBasicAuthorizationHeaderInfo - * @covers OAuth\OAuth1\Service\AbstractService::generateNonce - * @covers OAuth\OAuth1\Service\AbstractService::getSignatureMethod - * @covers OAuth\OAuth1\Service\AbstractService::getVersion - * @covers OAuth\OAuth1\Service\AbstractService::getAccessTokenEndpoint - * @covers OAuth\OAuth1\Service\AbstractService::getExtraOAuthHeaders - * @covers OAuth\OAuth1\Service\AbstractService::parseAccessTokenResponse - */ - public function testRequestAccessTokenWithSecret() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnCallback(function($endpoint, $array, $headers) { - \PHPUnit_Framework_Assert::assertSame('http://pieterhordijk.com/access', $endpoint->getAbsoluteUri()); - })); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Mock( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Token\\StdOAuth1Token', $service->requestAccessToken('foo', 'bar', $token)); - } - - /** - * @covers OAuth\OAuth1\Service\AbstractService::request - * @covers OAuth\OAuth1\Service\AbstractService::determineRequestUriFromPath - * @covers OAuth\OAuth1\Service\AbstractService::service - * @covers OAuth\OAuth1\Service\AbstractService::getExtraApiHeaders - * @covers OAuth\OAuth1\Service\AbstractService::buildAuthorizationHeaderForAPIRequest - * @covers OAuth\OAuth1\Service\AbstractService::getBasicAuthorizationHeaderInfo - * @covers OAuth\OAuth1\Service\AbstractService::generateNonce - * @covers OAuth\OAuth1\Service\AbstractService::getSignatureMethod - * @covers OAuth\OAuth1\Service\AbstractService::getVersion - */ - public function testRequest() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('response!')); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - //$token->expects($this->once())->method('getRequestTokenSecret')->will($this->returnValue('baz')); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Mock( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertSame('response!', $service->request('/my/awesome/path')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/BitBucketTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/BitBucketTest.php deleted file mode 100644 index 87be98b1..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/BitBucketTest.php +++ /dev/null @@ -1,278 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth1\Service; - -use OAuth\OAuth1\Service\BitBucket; - -class BitBucketTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth1\Service\BitBucket::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new BitBucket( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth1\Service\BitBucket::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new BitBucket( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth1\Service\BitBucket::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new BitBucket( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth1\Service\BitBucket::__construct - * @covers OAuth\OAuth1\Service\BitBucket::getRequestTokenEndpoint - */ - public function testGetRequestTokenEndpoint() - { - $service = new BitBucket( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://bitbucket.org/!api/1.0/oauth/request_token', - $service->getRequestTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\BitBucket::__construct - * @covers OAuth\OAuth1\Service\BitBucket::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new BitBucket( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://bitbucket.org/!api/1.0/oauth/authenticate', - $service->getAuthorizationEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\BitBucket::__construct - * @covers OAuth\OAuth1\Service\BitBucket::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new BitBucket( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://bitbucket.org/!api/1.0/oauth/access_token', - $service->getAccessTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\BitBucket::__construct - * @covers OAuth\OAuth1\Service\BitBucket::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\BitBucket::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new BitBucket( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\BitBucket::__construct - * @covers OAuth\OAuth1\Service\BitBucket::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\BitBucket::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseNotAnArray() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('notanarray')); - - $service = new BitBucket( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\BitBucket::__construct - * @covers OAuth\OAuth1\Service\BitBucket::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\BitBucket::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseCallbackNotSet() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('foo=bar')); - - $service = new BitBucket( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\BitBucket::__construct - * @covers OAuth\OAuth1\Service\BitBucket::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\BitBucket::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseCallbackNotTrue() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_callback_confirmed=false' - )); - - $service = new BitBucket( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\BitBucket::__construct - * @covers OAuth\OAuth1\Service\BitBucket::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\BitBucket::parseRequestTokenResponse - * @covers OAuth\OAuth1\Service\BitBucket::parseAccessTokenResponse - */ - public function testParseRequestTokenResponseValid() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_callback_confirmed=true&oauth_token=foo&oauth_token_secret=bar' - )); - - $service = new BitBucket( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Token\\StdOAuth1Token', $service->requestRequestToken()); - } - - /** - * @covers OAuth\OAuth1\Service\BitBucket::__construct - * @covers OAuth\OAuth1\Service\BitBucket::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\BitBucket::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=bar')); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new BitBucket( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo', 'bar', $token); - } - - /** - * @covers OAuth\OAuth1\Service\BitBucket::__construct - * @covers OAuth\OAuth1\Service\BitBucket::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\BitBucket::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValid() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_token=foo&oauth_token_secret=bar' - )); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new BitBucket( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Token\\StdOAuth1Token', $service->requestAccessToken('foo', 'bar', $token)); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/EtsyTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/EtsyTest.php deleted file mode 100644 index 97ad3cdd..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/EtsyTest.php +++ /dev/null @@ -1,286 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth1\Service; - -use OAuth\OAuth1\Service\Etsy; - -class EtsyTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth1\Service\Etsy::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Etsy( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth1\Service\Etsy::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Etsy( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth1\Service\Etsy::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Etsy( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth1\Service\Etsy::__construct - * @covers OAuth\OAuth1\Service\Etsy::getRequestTokenEndpoint - */ - public function testGetRequestTokenEndpoint() - { - $service = new Etsy( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://openapi.etsy.com/v2/oauth/request_token', - $service->getRequestTokenEndpoint()->getAbsoluteUri() - ); - - $service->setScopes(array('email_r', 'cart_rw')); - - $this->assertSame( - 'https://openapi.etsy.com/v2/oauth/request_token?scope=email_r%20cart_rw', - $service->getRequestTokenEndpoint()->getAbsoluteUri() - ); - - } - - /** - * @covers OAuth\OAuth1\Service\Etsy::__construct - * @covers OAuth\OAuth1\Service\Etsy::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Etsy( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://openapi.etsy.com/v2/', - $service->getAuthorizationEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\Etsy::__construct - * @covers OAuth\OAuth1\Service\Etsy::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Etsy( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://openapi.etsy.com/v2/oauth/access_token', - $service->getAccessTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\Etsy::__construct - * @covers OAuth\OAuth1\Service\Etsy::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Etsy::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new Etsy( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Etsy::__construct - * @covers OAuth\OAuth1\Service\Etsy::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Etsy::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseNotAnArray() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('notanarray')); - - $service = new Etsy( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Etsy::__construct - * @covers OAuth\OAuth1\Service\Etsy::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Etsy::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseCallbackNotSet() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('foo=bar')); - - $service = new Etsy( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Etsy::__construct - * @covers OAuth\OAuth1\Service\Etsy::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Etsy::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseCallbackNotTrue() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_callback_confirmed=false' - )); - - $service = new Etsy( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Etsy::__construct - * @covers OAuth\OAuth1\Service\Etsy::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Etsy::parseRequestTokenResponse - * @covers OAuth\OAuth1\Service\Etsy::parseAccessTokenResponse - */ - public function testParseRequestTokenResponseValid() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_callback_confirmed=true&oauth_token=foo&oauth_token_secret=bar' - )); - - $service = new Etsy( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Token\\StdOAuth1Token', $service->requestRequestToken()); - } - - /** - * @covers OAuth\OAuth1\Service\Etsy::__construct - * @covers OAuth\OAuth1\Service\Etsy::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Etsy::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=bar')); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Etsy( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo', 'bar', $token); - } - - /** - * @covers OAuth\OAuth1\Service\Etsy::__construct - * @covers OAuth\OAuth1\Service\Etsy::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Etsy::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValid() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_token=foo&oauth_token_secret=bar' - )); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Etsy( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Token\\StdOAuth1Token', $service->requestAccessToken('foo', 'bar', $token)); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/FitBitTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/FitBitTest.php deleted file mode 100644 index a8b7ae2d..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/FitBitTest.php +++ /dev/null @@ -1,278 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth1\Service; - -use OAuth\OAuth1\Service\FitBit; - -class FitBitTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth1\Service\FitBit::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new FitBit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth1\Service\FitBit::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new FitBit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth1\Service\FitBit::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new FitBit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth1\Service\FitBit::__construct - * @covers OAuth\OAuth1\Service\FitBit::getRequestTokenEndpoint - */ - public function testGetRequestTokenEndpoint() - { - $service = new FitBit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://api.fitbit.com/oauth/request_token', - $service->getRequestTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\FitBit::__construct - * @covers OAuth\OAuth1\Service\FitBit::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new FitBit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://www.fitbit.com/oauth/authorize', - $service->getAuthorizationEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\FitBit::__construct - * @covers OAuth\OAuth1\Service\FitBit::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new FitBit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://api.fitbit.com/oauth/access_token', - $service->getAccessTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\FitBit::__construct - * @covers OAuth\OAuth1\Service\FitBit::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\FitBit::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new FitBit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\FitBit::__construct - * @covers OAuth\OAuth1\Service\FitBit::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\FitBit::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseNotAnArray() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('notanarray')); - - $service = new FitBit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\FitBit::__construct - * @covers OAuth\OAuth1\Service\FitBit::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\FitBit::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseCallbackNotSet() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('foo=bar')); - - $service = new FitBit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\FitBit::__construct - * @covers OAuth\OAuth1\Service\FitBit::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\FitBit::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseCallbackNotTrue() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_callback_confirmed=false' - )); - - $service = new FitBit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\FitBit::__construct - * @covers OAuth\OAuth1\Service\FitBit::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\FitBit::parseRequestTokenResponse - * @covers OAuth\OAuth1\Service\FitBit::parseAccessTokenResponse - */ - public function testParseRequestTokenResponseValid() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_callback_confirmed=true&oauth_token=foo&oauth_token_secret=bar' - )); - - $service = new FitBit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Token\\StdOAuth1Token', $service->requestRequestToken()); - } - - /** - * @covers OAuth\OAuth1\Service\FitBit::__construct - * @covers OAuth\OAuth1\Service\FitBit::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\FitBit::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=bar')); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new FitBit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo', 'bar', $token); - } - - /** - * @covers OAuth\OAuth1\Service\FitBit::__construct - * @covers OAuth\OAuth1\Service\FitBit::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\FitBit::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValid() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_token=foo&oauth_token_secret=bar' - )); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new FitBit( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Token\\StdOAuth1Token', $service->requestAccessToken('foo', 'bar', $token)); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/FlickrTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/FlickrTest.php deleted file mode 100644 index ee88f714..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/FlickrTest.php +++ /dev/null @@ -1,302 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth1\Service; - -use OAuth\OAuth1\Service\Flickr; - -class FlickrTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth1\Service\Flickr::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Flickr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth1\Service\Flickr::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Flickr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth1\Service\Flickr::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Flickr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth1\Service\Flickr::__construct - * @covers OAuth\OAuth1\Service\Flickr::getRequestTokenEndpoint - */ - public function testGetRequestTokenEndpoint() - { - $service = new Flickr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://www.flickr.com/services/oauth/request_token', - $service->getRequestTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\Flickr::__construct - * @covers OAuth\OAuth1\Service\Flickr::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Flickr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://www.flickr.com/services/oauth/authorize', - $service->getAuthorizationEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\Flickr::__construct - * @covers OAuth\OAuth1\Service\Flickr::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Flickr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://www.flickr.com/services/oauth/access_token', - $service->getAccessTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\Flickr::__construct - * @covers OAuth\OAuth1\Service\Flickr::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Flickr::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new Flickr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Flickr::__construct - * @covers OAuth\OAuth1\Service\Flickr::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Flickr::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseNotAnArray() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('notanarray')); - - $service = new Flickr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Flickr::__construct - * @covers OAuth\OAuth1\Service\Flickr::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Flickr::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseCallbackNotSet() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('foo=bar')); - - $service = new Flickr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Flickr::__construct - * @covers OAuth\OAuth1\Service\Flickr::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Flickr::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseCallbackNotTrue() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_callback_confirmed=false' - )); - - $service = new Flickr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Flickr::__construct - * @covers OAuth\OAuth1\Service\Flickr::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Flickr::parseRequestTokenResponse - * @covers OAuth\OAuth1\Service\Flickr::parseAccessTokenResponse - */ - public function testParseRequestTokenResponseValid() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_callback_confirmed=true&oauth_token=foo&oauth_token_secret=bar' - )); - - $service = new Flickr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Token\\StdOAuth1Token', $service->requestRequestToken()); - } - - /** - * @covers OAuth\OAuth1\Service\Flickr::__construct - * @covers OAuth\OAuth1\Service\Flickr::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Flickr::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=bar')); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Flickr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo', 'bar', $token); - } - - /** - * @covers OAuth\OAuth1\Service\Flickr::__construct - * @covers OAuth\OAuth1\Service\Flickr::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Flickr::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValid() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_token=foo&oauth_token_secret=bar' - )); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Flickr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Token\\StdOAuth1Token', $service->requestAccessToken('foo', 'bar', $token)); - } - - /** - * @covers OAuth\OAuth1\Service\Flickr::request - */ - public function testRequest() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('response!')); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Flickr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertSame('response!', $service->request('/my/awesome/path')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/ScoopItTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/ScoopItTest.php deleted file mode 100644 index 4ba83fa6..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/ScoopItTest.php +++ /dev/null @@ -1,302 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth1\Service; - -use OAuth\OAuth1\Service\ScoopIt; - -class ScoopItTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth1\Service\ScoopIt::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new ScoopIt( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth1\Service\ScoopIt::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new ScoopIt( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth1\Service\ScoopIt::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new ScoopIt( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth1\Service\ScoopIt::__construct - * @covers OAuth\OAuth1\Service\ScoopIt::getRequestTokenEndpoint - */ - public function testGetRequestTokenEndpoint() - { - $service = new ScoopIt( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://www.scoop.it/oauth/request', - $service->getRequestTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\ScoopIt::__construct - * @covers OAuth\OAuth1\Service\ScoopIt::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new ScoopIt( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://www.scoop.it/oauth/authorize', - $service->getAuthorizationEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\ScoopIt::__construct - * @covers OAuth\OAuth1\Service\ScoopIt::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new ScoopIt( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://www.scoop.it/oauth/access', - $service->getAccessTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\ScoopIt::__construct - * @covers OAuth\OAuth1\Service\ScoopIt::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\ScoopIt::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new ScoopIt( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\ScoopIt::__construct - * @covers OAuth\OAuth1\Service\ScoopIt::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\ScoopIt::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseNotAnArray() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('notanarray')); - - $service = new ScoopIt( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\ScoopIt::__construct - * @covers OAuth\OAuth1\Service\ScoopIt::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\ScoopIt::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseCallbackNotSet() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('foo=bar')); - - $service = new ScoopIt( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\ScoopIt::__construct - * @covers OAuth\OAuth1\Service\ScoopIt::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\ScoopIt::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseCallbackNotTrue() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_callback_confirmed=false' - )); - - $service = new ScoopIt( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\ScoopIt::__construct - * @covers OAuth\OAuth1\Service\ScoopIt::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\ScoopIt::parseRequestTokenResponse - * @covers OAuth\OAuth1\Service\ScoopIt::parseAccessTokenResponse - */ - public function testParseRequestTokenResponseValid() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_callback_confirmed=true&oauth_token=foo&oauth_token_secret=bar' - )); - - $service = new ScoopIt( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Token\\StdOAuth1Token', $service->requestRequestToken()); - } - - /** - * @covers OAuth\OAuth1\Service\ScoopIt::__construct - * @covers OAuth\OAuth1\Service\ScoopIt::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\ScoopIt::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=bar')); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new ScoopIt( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo', 'bar', $token); - } - - /** - * @covers OAuth\OAuth1\Service\ScoopIt::__construct - * @covers OAuth\OAuth1\Service\ScoopIt::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\ScoopIt::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValid() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_token=foo&oauth_token_secret=bar' - )); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new ScoopIt( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Token\\StdOAuth1Token', $service->requestAccessToken('foo', 'bar', $token)); - } - - /** - * @covers OAuth\OAuth1\Service\ScoopIt::request - */ - public function testRequest() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('response!')); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new ScoopIt( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertSame('response!', $service->request('/my/awesome/path')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/TumblrTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/TumblrTest.php deleted file mode 100644 index f1467ad6..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/TumblrTest.php +++ /dev/null @@ -1,278 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth1\Service; - -use OAuth\OAuth1\Service\Tumblr; - -class TumblrTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth1\Service\Tumblr::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Tumblr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth1\Service\Tumblr::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Tumblr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth1\Service\Tumblr::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Tumblr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth1\Service\Tumblr::__construct - * @covers OAuth\OAuth1\Service\Tumblr::getRequestTokenEndpoint - */ - public function testGetRequestTokenEndpoint() - { - $service = new Tumblr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://www.tumblr.com/oauth/request_token', - $service->getRequestTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\Tumblr::__construct - * @covers OAuth\OAuth1\Service\Tumblr::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Tumblr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://www.tumblr.com/oauth/authorize', - $service->getAuthorizationEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\Tumblr::__construct - * @covers OAuth\OAuth1\Service\Tumblr::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Tumblr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://www.tumblr.com/oauth/access_token', - $service->getAccessTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\Tumblr::__construct - * @covers OAuth\OAuth1\Service\Tumblr::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Tumblr::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new Tumblr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Tumblr::__construct - * @covers OAuth\OAuth1\Service\Tumblr::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Tumblr::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseNotAnArray() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('notanarray')); - - $service = new Tumblr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Tumblr::__construct - * @covers OAuth\OAuth1\Service\Tumblr::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Tumblr::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseCallbackNotSet() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('foo=bar')); - - $service = new Tumblr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Tumblr::__construct - * @covers OAuth\OAuth1\Service\Tumblr::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Tumblr::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseCallbackNotTrue() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_callback_confirmed=false' - )); - - $service = new Tumblr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Tumblr::__construct - * @covers OAuth\OAuth1\Service\Tumblr::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Tumblr::parseRequestTokenResponse - * @covers OAuth\OAuth1\Service\Tumblr::parseAccessTokenResponse - */ - public function testParseRequestTokenResponseValid() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_callback_confirmed=true&oauth_token=foo&oauth_token_secret=bar' - )); - - $service = new Tumblr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Token\\StdOAuth1Token', $service->requestRequestToken()); - } - - /** - * @covers OAuth\OAuth1\Service\Tumblr::__construct - * @covers OAuth\OAuth1\Service\Tumblr::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Tumblr::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=bar')); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Tumblr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo', 'bar', $token); - } - - /** - * @covers OAuth\OAuth1\Service\Tumblr::__construct - * @covers OAuth\OAuth1\Service\Tumblr::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Tumblr::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValid() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_token=foo&oauth_token_secret=bar' - )); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Tumblr( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Token\\StdOAuth1Token', $service->requestAccessToken('foo', 'bar', $token)); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/TwitterTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/TwitterTest.php deleted file mode 100644 index bb31fa29..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/TwitterTest.php +++ /dev/null @@ -1,307 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth1\Service; - -use OAuth\OAuth1\Service\Twitter; - -class TwitterTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth1\Service\Twitter::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Twitter( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth1\Service\Twitter::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Twitter( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth1\Service\Twitter::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Twitter( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth1\Service\Twitter::__construct - * @covers OAuth\OAuth1\Service\Twitter::getRequestTokenEndpoint - */ - public function testGetRequestTokenEndpoint() - { - $service = new Twitter( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://api.twitter.com/oauth/request_token', - $service->getRequestTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\Twitter::__construct - * @covers OAuth\OAuth1\Service\Twitter::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Twitter( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertTrue( - in_array( - strtolower($service->getAuthorizationEndpoint()->getAbsoluteUri()), - array(\OAuth\OAuth1\Service\Twitter::ENDPOINT_AUTHENTICATE, \OAuth\OAuth1\Service\Twitter::ENDPOINT_AUTHORIZE) - ) - ); - - $service->setAuthorizationEndpoint( \OAuth\OAuth1\Service\Twitter::ENDPOINT_AUTHORIZE ); - - $this->assertTrue( - in_array( - strtolower($service->getAuthorizationEndpoint()->getAbsoluteUri()), - array(\OAuth\OAuth1\Service\Twitter::ENDPOINT_AUTHENTICATE, \OAuth\OAuth1\Service\Twitter::ENDPOINT_AUTHORIZE) - ) - ); - } - - /** - * @covers OAuth\OAuth1\Service\Twitter::__construct - * @covers OAuth\OAuth1\Service\Twitter::setAuthorizationEndpoint - */ - public function testSetAuthorizationEndpoint() - { - $service = new Twitter( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Exception\\Exception'); - - $service->setAuthorizationEndpoint('foo'); - } - - /** - * @covers OAuth\OAuth1\Service\Twitter::__construct - * @covers OAuth\OAuth1\Service\Twitter::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Twitter( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://api.twitter.com/oauth/access_token', - $service->getAccessTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\Twitter::__construct - * @covers OAuth\OAuth1\Service\Twitter::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Twitter::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new Twitter( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Twitter::__construct - * @covers OAuth\OAuth1\Service\Twitter::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Twitter::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseNotAnArray() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('notanarray')); - - $service = new Twitter( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Twitter::__construct - * @covers OAuth\OAuth1\Service\Twitter::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Twitter::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseCallbackNotSet() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('foo=bar')); - - $service = new Twitter( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Twitter::__construct - * @covers OAuth\OAuth1\Service\Twitter::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Twitter::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseCallbackNotTrue() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_callback_confirmed=false' - )); - - $service = new Twitter( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Twitter::__construct - * @covers OAuth\OAuth1\Service\Twitter::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Twitter::parseRequestTokenResponse - * @covers OAuth\OAuth1\Service\Twitter::parseAccessTokenResponse - */ - public function testParseRequestTokenResponseValid() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_callback_confirmed=true&oauth_token=foo&oauth_token_secret=bar' - )); - - $service = new Twitter( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Token\\StdOAuth1Token', $service->requestRequestToken()); - } - - /** - * @covers OAuth\OAuth1\Service\Twitter::__construct - * @covers OAuth\OAuth1\Service\Twitter::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Twitter::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=bar')); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Twitter( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo', 'bar', $token); - } - - /** - * @covers OAuth\OAuth1\Service\Twitter::__construct - * @covers OAuth\OAuth1\Service\Twitter::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Twitter::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValid() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_token=foo&oauth_token_secret=bar' - )); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Twitter( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Token\\StdOAuth1Token', $service->requestAccessToken('foo', 'bar', $token)); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/XingTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/XingTest.php deleted file mode 100644 index d3a5f4ae..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/XingTest.php +++ /dev/null @@ -1,239 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth1\Service; - -use OAuth\OAuth1\Service\Xing; - -class XingTest extends \PHPUnit_Framework_TestCase -{ - private $client; - private $storage; - private $xing; - - - protected function setUp() - { - parent::setUp(); - - $this->client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $this->storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - - $this->xing = new Xing( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->client, - $this->storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - } - - /** - * @covers OAuth\OAuth1\Service\Xing::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $this->assertInstanceOf( - '\\OAuth\\OAuth1\\Service\\ServiceInterface', $this->xing - ); - } - - /** - * @covers OAuth\OAuth1\Service\Xing::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $this->assertInstanceOf( - '\\OAuth\\OAuth1\\Service\\AbstractService', $this->xing - ); - } - - /** - * @covers OAuth\OAuth1\Service\Xing::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Xing( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->client, - $this->storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth1\Service\Xing::__construct - * @covers OAuth\OAuth1\Service\Xing::getRequestTokenEndpoint - */ - public function testGetRequestTokenEndpoint() - { - $this->assertSame( - 'https://api.xing.com/v1/request_token', - $this->xing->getRequestTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\Xing::__construct - * @covers OAuth\OAuth1\Service\Xing::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $this->assertSame( - 'https://api.xing.com/v1/authorize', - $this->xing->getAuthorizationEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\Xing::__construct - * @covers OAuth\OAuth1\Service\Xing::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $this->assertSame( - 'https://api.xing.com/v1/access_token', - $this->xing->getAccessTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\Xing::__construct - * @covers OAuth\OAuth1\Service\Xing::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Xing::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnNulledResponse() - { - $this->client - ->expects($this->once()) - ->method('retrieveResponse') - ->will($this->returnValue(null)); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $this->xing->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Xing::__construct - * @covers OAuth\OAuth1\Service\Xing::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Xing::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseNotAnArray() - { - $this->client - ->expects($this->once()) - ->method('retrieveResponse') - ->will($this->returnValue('notanarray')); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $this->xing->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Xing::__construct - * @covers OAuth\OAuth1\Service\Xing::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Xing::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseCallbackNotSet() - { - $this->client - ->expects($this->once()) - ->method('retrieveResponse') - ->will($this->returnValue('foo=bar')); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $this->xing->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Xing::__construct - * @covers OAuth\OAuth1\Service\Xing::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Xing::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseCallbackNotTrue() - { - $this->client - ->expects($this->once()) - ->method('retrieveResponse') - ->will($this->returnValue('oauth_callback_confirmed=false')); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $this->xing->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Xing::__construct - * @covers OAuth\OAuth1\Service\Xing::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Xing::parseRequestTokenResponse - * @covers OAuth\OAuth1\Service\Xing::parseAccessTokenResponse - */ - public function testParseRequestTokenResponseValid() - { - $this->client - ->expects($this->once()) - ->method('retrieveResponse') - ->will($this->returnValue( - 'oauth_callback_confirmed=true&oauth_token=foo&oauth_token_secret=bar' - )); - - $this->assertInstanceOf( - '\\OAuth\\OAuth1\\Token\\StdOAuth1Token', - $this->xing->requestRequestToken() - ); - } - - /** - * @covers OAuth\OAuth1\Service\Xing::__construct - * @covers OAuth\OAuth1\Service\Xing::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Xing::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $this->client - ->expects($this->once()) - ->method('retrieveResponse') - ->will($this->returnValue('error=bar')); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - - $this->storage - ->expects($this->any()) - ->method('retrieveAccessToken') - ->will($this->returnValue($token)); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $this->xing->requestAccessToken('foo', 'bar', $token); - } - - /** - * @covers OAuth\OAuth1\Service\Xing::__construct - * @covers OAuth\OAuth1\Service\Xing::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Xing::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValid() - { - $this->client - ->expects($this->once()) - ->method('retrieveResponse') - ->will($this->returnValue('oauth_token=foo&oauth_token_secret=bar')); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - - $this->storage - ->expects($this->any()) - ->method('retrieveAccessToken') - ->will($this->returnValue($token)); - - - $this->assertInstanceOf( - '\\OAuth\\OAuth1\\Token\\StdOAuth1Token', - $this->xing->requestAccessToken('foo', 'bar', $token) - ); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/YahooTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/YahooTest.php deleted file mode 100644 index e8feb5dc..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/YahooTest.php +++ /dev/null @@ -1,302 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth1\Service; - -use OAuth\OAuth1\Service\Yahoo; - -class YahooTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth1\Service\Yahoo::__construct - */ - public function testConstructCorrectInterfaceWithoutCustomUri() - { - $service = new Yahoo( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\OAuth1\Service\Yahoo::__construct - */ - public function testConstructCorrectInstanceWithoutCustomUri() - { - $service = new Yahoo( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth1\Service\Yahoo::__construct - */ - public function testConstructCorrectInstanceWithCustomUri() - { - $service = new Yahoo( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\AbstractService', $service); - } - - /** - * @covers OAuth\OAuth1\Service\Yahoo::__construct - * @covers OAuth\OAuth1\Service\Yahoo::getRequestTokenEndpoint - */ - public function testGetRequestTokenEndpoint() - { - $service = new Yahoo( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://api.login.yahoo.com/oauth/v2/get_request_token', - $service->getRequestTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\Yahoo::__construct - * @covers OAuth\OAuth1\Service\Yahoo::getAuthorizationEndpoint - */ - public function testGetAuthorizationEndpoint() - { - $service = new Yahoo( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://api.login.yahoo.com/oauth/v2/request_auth', - $service->getAuthorizationEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\Yahoo::__construct - * @covers OAuth\OAuth1\Service\Yahoo::getAccessTokenEndpoint - */ - public function testGetAccessTokenEndpoint() - { - $service = new Yahoo( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertSame( - 'https://api.login.yahoo.com/oauth/v2/get_token', - $service->getAccessTokenEndpoint()->getAbsoluteUri() - ); - } - - /** - * @covers OAuth\OAuth1\Service\Yahoo::__construct - * @covers OAuth\OAuth1\Service\Yahoo::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Yahoo::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnNulledResponse() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue(null)); - - $service = new Yahoo( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Yahoo::__construct - * @covers OAuth\OAuth1\Service\Yahoo::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Yahoo::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseNotAnArray() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('notanarray')); - - $service = new Yahoo( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Yahoo::__construct - * @covers OAuth\OAuth1\Service\Yahoo::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Yahoo::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseCallbackNotSet() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('foo=bar')); - - $service = new Yahoo( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Yahoo::__construct - * @covers OAuth\OAuth1\Service\Yahoo::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Yahoo::parseRequestTokenResponse - */ - public function testParseRequestTokenResponseThrowsExceptionOnResponseCallbackNotTrue() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_callback_confirmed=false' - )); - - $service = new Yahoo( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestRequestToken(); - } - - /** - * @covers OAuth\OAuth1\Service\Yahoo::__construct - * @covers OAuth\OAuth1\Service\Yahoo::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Yahoo::parseRequestTokenResponse - * @covers OAuth\OAuth1\Service\Yahoo::parseAccessTokenResponse - */ - public function testParseRequestTokenResponseValid() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_callback_confirmed=true&oauth_token=foo&oauth_token_secret=bar' - )); - - $service = new Yahoo( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'), - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Token\\StdOAuth1Token', $service->requestRequestToken()); - } - - /** - * @covers OAuth\OAuth1\Service\Yahoo::__construct - * @covers OAuth\OAuth1\Service\Yahoo::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Yahoo::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseThrowsExceptionOnError() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('error=bar')); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Yahoo( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $service->requestAccessToken('foo', 'bar', $token); - } - - /** - * @covers OAuth\OAuth1\Service\Yahoo::__construct - * @covers OAuth\OAuth1\Service\Yahoo::getRequestTokenEndpoint - * @covers OAuth\OAuth1\Service\Yahoo::parseAccessTokenResponse - */ - public function testParseAccessTokenResponseValid() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue( - 'oauth_token=foo&oauth_token_secret=bar' - )); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Yahoo( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface') - ); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Token\\StdOAuth1Token', $service->requestAccessToken('foo', 'bar', $token)); - } - - /** - * @covers OAuth\OAuth1\Service\Yahoo::request - */ - public function testRequest() - { - $client = $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'); - $client->expects($this->once())->method('retrieveResponse')->will($this->returnValue('response!')); - - $token = $this->getMock('\\OAuth\\OAuth1\\Token\\TokenInterface'); - - $storage = $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'); - $storage->expects($this->any())->method('retrieveAccessToken')->will($this->returnValue($token)); - - $service = new Yahoo( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $client, - $storage, - $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface') - ); - - $this->assertSame('response!', $service->request('/my/awesome/path')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Signature/SignatureTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth1/Signature/SignatureTest.php deleted file mode 100644 index 44c731f5..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Signature/SignatureTest.php +++ /dev/null @@ -1,325 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth1\Signature; - -use OAuth\OAuth1\Signature\Signature; - -class SignatureTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\OAuth1\Signature\Signature::__construct - */ - public function testConstructCorrectInterface() - { - $signature = new Signature($this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface')); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Signature\\SignatureInterface', $signature); - } - - /** - * @covers OAuth\OAuth1\Signature\Signature::__construct - * @covers OAuth\OAuth1\Signature\Signature::setHashingAlgorithm - */ - public function testSetHashingAlgorithm() - { - $signature = new Signature($this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface')); - - $this->assertNull($signature->setHashingAlgorithm('foo')); - } - - /** - * @covers OAuth\OAuth1\Signature\Signature::__construct - * @covers OAuth\OAuth1\Signature\Signature::setTokenSecret - */ - public function testSetTokenSecret() - { - $signature = new Signature($this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface')); - - $this->assertNull($signature->setTokenSecret('foo')); - } - - /** - * @covers OAuth\OAuth1\Signature\Signature::__construct - * @covers OAuth\OAuth1\Signature\Signature::setHashingAlgorithm - * @covers OAuth\OAuth1\Signature\Signature::setTokenSecret - * @covers OAuth\OAuth1\Signature\Signature::getSignature - * @covers OAuth\OAuth1\Signature\Signature::buildSignatureDataString - * @covers OAuth\OAuth1\Signature\Signature::hash - * @covers OAuth\OAuth1\Signature\Signature::getSigningKey - */ - public function testGetSignatureBareUri() - { - $credentials = $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'); - $credentials->expects($this->any()) - ->method('getConsumerSecret') - ->will($this->returnValue('foo')); - - - $signature = new Signature($credentials); - - $signature->setHashingAlgorithm('HMAC-SHA1'); - $signature->setTokenSecret('foo'); - - $uri = $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'); - $uri->expects($this->any()) - ->method('getQuery') - ->will($this->returnValue('')); - $uri->expects($this->any()) - ->method('getScheme') - ->will($this->returnValue('http')); - $uri->expects($this->any()) - ->method('getRawAuthority') - ->will($this->returnValue('')); - $uri->expects($this->any()) - ->method('getPath') - ->will($this->returnValue('/foo')); - - $this->assertSame('uoCpiII/Lg/cPiF0XrU2pj4eGFQ=', $signature->getSignature($uri, array('pee' => 'haa'))); - } - - /** - * @covers OAuth\OAuth1\Signature\Signature::__construct - * @covers OAuth\OAuth1\Signature\Signature::setHashingAlgorithm - * @covers OAuth\OAuth1\Signature\Signature::setTokenSecret - * @covers OAuth\OAuth1\Signature\Signature::getSignature - * @covers OAuth\OAuth1\Signature\Signature::buildSignatureDataString - * @covers OAuth\OAuth1\Signature\Signature::hash - * @covers OAuth\OAuth1\Signature\Signature::getSigningKey - */ - public function testGetSignatureWithQueryString() - { - $credentials = $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'); - $credentials->expects($this->any()) - ->method('getConsumerSecret') - ->will($this->returnValue('foo')); - - - $signature = new Signature($credentials); - - $signature->setHashingAlgorithm('HMAC-SHA1'); - $signature->setTokenSecret('foo'); - - $uri = $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'); - $uri->expects($this->any()) - ->method('getQuery') - ->will($this->returnValue('param1=value1')); - $uri->expects($this->any()) - ->method('getScheme') - ->will($this->returnValue('http')); - $uri->expects($this->any()) - ->method('getRawAuthority') - ->will($this->returnValue('')); - $uri->expects($this->any()) - ->method('getPath') - ->will($this->returnValue('/foo')); - - $this->assertSame('LxtD+WjJBRppIUvEI79iQ7I0hSo=', $signature->getSignature($uri, array('pee' => 'haa'))); - } - - /** - * @covers OAuth\OAuth1\Signature\Signature::__construct - * @covers OAuth\OAuth1\Signature\Signature::setHashingAlgorithm - * @covers OAuth\OAuth1\Signature\Signature::setTokenSecret - * @covers OAuth\OAuth1\Signature\Signature::getSignature - * @covers OAuth\OAuth1\Signature\Signature::buildSignatureDataString - * @covers OAuth\OAuth1\Signature\Signature::hash - * @covers OAuth\OAuth1\Signature\Signature::getSigningKey - */ - public function testGetSignatureWithAuthority() - { - $credentials = $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'); - $credentials->expects($this->any()) - ->method('getConsumerSecret') - ->will($this->returnValue('foo')); - - - $signature = new Signature($credentials); - - $signature->setHashingAlgorithm('HMAC-SHA1'); - $signature->setTokenSecret('foo'); - - $uri = $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'); - $uri->expects($this->any()) - ->method('getQuery') - ->will($this->returnValue('param1=value1')); - $uri->expects($this->any()) - ->method('getScheme') - ->will($this->returnValue('http')); - $uri->expects($this->any()) - ->method('getRawAuthority') - ->will($this->returnValue('peehaa:pass')); - $uri->expects($this->any()) - ->method('getPath') - ->will($this->returnValue('/foo')); - - $this->assertSame('MHvkRndIntLrxiPkjkiCNsMEqv4=', $signature->getSignature($uri, array('pee' => 'haa'))); - } - - /** - * @covers OAuth\OAuth1\Signature\Signature::__construct - * @covers OAuth\OAuth1\Signature\Signature::setHashingAlgorithm - * @covers OAuth\OAuth1\Signature\Signature::setTokenSecret - * @covers OAuth\OAuth1\Signature\Signature::getSignature - * @covers OAuth\OAuth1\Signature\Signature::buildSignatureDataString - * @covers OAuth\OAuth1\Signature\Signature::hash - * @covers OAuth\OAuth1\Signature\Signature::getSigningKey - */ - public function testGetSignatureWithBarePathNonExplicitTrailingHostSlash() - { - $credentials = $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'); - $credentials->expects($this->any()) - ->method('getConsumerSecret') - ->will($this->returnValue('foo')); - - - $signature = new Signature($credentials); - - $signature->setHashingAlgorithm('HMAC-SHA1'); - $signature->setTokenSecret('foo'); - - $uri = $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'); - $uri->expects($this->any()) - ->method('getQuery') - ->will($this->returnValue('param1=value1')); - $uri->expects($this->any()) - ->method('getScheme') - ->will($this->returnValue('http')); - $uri->expects($this->any()) - ->method('getRawAuthority') - ->will($this->returnValue('peehaa:pass')); - $uri->expects($this->any()) - ->method('getPath') - ->will($this->returnValue('/')); - $uri->expects($this->any()) - ->method('hasExplicitTrailingHostSlash') - ->will($this->returnValue(false)); - - $this->assertSame('iFELDoiI5Oj9ixB3kHzoPvBpq0w=', $signature->getSignature($uri, array('pee' => 'haa'))); - } - - /** - * @covers OAuth\OAuth1\Signature\Signature::__construct - * @covers OAuth\OAuth1\Signature\Signature::setHashingAlgorithm - * @covers OAuth\OAuth1\Signature\Signature::setTokenSecret - * @covers OAuth\OAuth1\Signature\Signature::getSignature - * @covers OAuth\OAuth1\Signature\Signature::buildSignatureDataString - * @covers OAuth\OAuth1\Signature\Signature::hash - * @covers OAuth\OAuth1\Signature\Signature::getSigningKey - */ - public function testGetSignatureWithBarePathWithExplicitTrailingHostSlash() - { - $credentials = $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'); - $credentials->expects($this->any()) - ->method('getConsumerSecret') - ->will($this->returnValue('foo')); - - - $signature = new Signature($credentials); - - $signature->setHashingAlgorithm('HMAC-SHA1'); - $signature->setTokenSecret('foo'); - - $uri = $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'); - $uri->expects($this->any()) - ->method('getQuery') - ->will($this->returnValue('param1=value1')); - $uri->expects($this->any()) - ->method('getScheme') - ->will($this->returnValue('http')); - $uri->expects($this->any()) - ->method('getRawAuthority') - ->will($this->returnValue('peehaa:pass')); - $uri->expects($this->any()) - ->method('getPath') - ->will($this->returnValue('/')); - $uri->expects($this->any()) - ->method('hasExplicitTrailingHostSlash') - ->will($this->returnValue(true)); - - $this->assertSame('IEhUsArSTLvbQ3QYr0zzn+Rxpjg=', $signature->getSignature($uri, array('pee' => 'haa'))); - } - - /** - * @covers OAuth\OAuth1\Signature\Signature::__construct - * @covers OAuth\OAuth1\Signature\Signature::setHashingAlgorithm - * @covers OAuth\OAuth1\Signature\Signature::setTokenSecret - * @covers OAuth\OAuth1\Signature\Signature::getSignature - * @covers OAuth\OAuth1\Signature\Signature::buildSignatureDataString - * @covers OAuth\OAuth1\Signature\Signature::hash - * @covers OAuth\OAuth1\Signature\Signature::getSigningKey - */ - public function testGetSignatureNoTokenSecretSet() - { - $credentials = $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'); - $credentials->expects($this->any()) - ->method('getConsumerSecret') - ->will($this->returnValue('foo')); - - - $signature = new Signature($credentials); - - $signature->setHashingAlgorithm('HMAC-SHA1'); - - $uri = $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'); - $uri->expects($this->any()) - ->method('getQuery') - ->will($this->returnValue('param1=value1')); - $uri->expects($this->any()) - ->method('getScheme') - ->will($this->returnValue('http')); - $uri->expects($this->any()) - ->method('getRawAuthority') - ->will($this->returnValue('peehaa:pass')); - $uri->expects($this->any()) - ->method('getPath') - ->will($this->returnValue('/')); - $uri->expects($this->any()) - ->method('hasExplicitTrailingHostSlash') - ->will($this->returnValue(true)); - - $this->assertSame('YMHF7FYmLq7wzGnnHWYtd1VoBBE=', $signature->getSignature($uri, array('pee' => 'haa'))); - } - - /** - * @covers OAuth\OAuth1\Signature\Signature::__construct - * @covers OAuth\OAuth1\Signature\Signature::setHashingAlgorithm - * @covers OAuth\OAuth1\Signature\Signature::setTokenSecret - * @covers OAuth\OAuth1\Signature\Signature::getSignature - * @covers OAuth\OAuth1\Signature\Signature::buildSignatureDataString - * @covers OAuth\OAuth1\Signature\Signature::hash - * @covers OAuth\OAuth1\Signature\Signature::getSigningKey - */ - public function testGetSignatureThrowsExceptionOnUnsupportedAlgo() - { - $this->setExpectedException('\\OAuth\\OAuth1\\Signature\\Exception\\UnsupportedHashAlgorithmException'); - - $credentials = $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'); - $credentials->expects($this->any()) - ->method('getConsumerSecret') - ->will($this->returnValue('foo')); - - - $signature = new Signature($credentials); - - $signature->setHashingAlgorithm('UnsupportedAlgo'); - - $uri = $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'); - $uri->expects($this->any()) - ->method('getQuery') - ->will($this->returnValue('param1=value1')); - $uri->expects($this->any()) - ->method('getScheme') - ->will($this->returnValue('http')); - $uri->expects($this->any()) - ->method('getRawAuthority') - ->will($this->returnValue('peehaa:pass')); - $uri->expects($this->any()) - ->method('getPath') - ->will($this->returnValue('/')); - $uri->expects($this->any()) - ->method('hasExplicitTrailingHostSlash') - ->will($this->returnValue(true)); - - $signature->getSignature($uri, array('pee' => 'haa')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Token/StdOAuth1TokenTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth1/Token/StdOAuth1TokenTest.php deleted file mode 100644 index 9b065b1e..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Token/StdOAuth1TokenTest.php +++ /dev/null @@ -1,85 +0,0 @@ -<?php - -namespace OAuthTest\Unit\OAuth1\Token; - -use OAuth\OAuth1\Token\StdOAuth1Token; - -class StdOAuth1TokenTest extends \PHPUnit_Framework_TestCase -{ - /** - * - */ - public function testConstructCorrectInterfaces() - { - $token = new StdOAuth1Token(); - - $this->assertInstanceOf('\\OAuth\\OAuth1\\Token\\TokenInterface', $token); - $this->assertInstanceOf('\\OAuth\\Common\\Token\\AbstractToken', $token); - } - - /** - * @covers OAuth\OAuth1\Token\StdOAuth1Token::setRequestToken - */ - public function testSetRequestToken() - { - $token = new StdOAuth1Token(); - - $this->assertNull($token->setRequestToken('foo')); - } - - /** - * @covers OAuth\OAuth1\Token\StdOAuth1Token::setRequestToken - * @covers OAuth\OAuth1\Token\StdOAuth1Token::getRequestToken - */ - public function testGetRequestToken() - { - $token = new StdOAuth1Token(); - - $this->assertNull($token->setRequestToken('foo')); - $this->assertSame('foo', $token->getRequestToken()); - } - - /** - * @covers OAuth\OAuth1\Token\StdOAuth1Token::setRequestTokenSecret - */ - public function testSetRequestTokenSecret() - { - $token = new StdOAuth1Token(); - - $this->assertNull($token->setRequestTokenSecret('foo')); - } - - /** - * @covers OAuth\OAuth1\Token\StdOAuth1Token::setRequestTokenSecret - * @covers OAuth\OAuth1\Token\StdOAuth1Token::getRequestTokenSecret - */ - public function testGetRequestTokenSecret() - { - $token = new StdOAuth1Token(); - - $this->assertNull($token->setRequestTokenSecret('foo')); - $this->assertSame('foo', $token->getRequestTokenSecret()); - } - - /** - * @covers OAuth\OAuth1\Token\StdOAuth1Token::setAccessTokenSecret - */ - public function testSetAccessTokenSecret() - { - $token = new StdOAuth1Token(); - - $this->assertNull($token->setAccessTokenSecret('foo')); - } - - /** - * @covers OAuth\OAuth1\Token\StdOAuth1Token::setAccessTokenSecret - * @covers OAuth\OAuth1\Token\StdOAuth1Token::getAccessTokenSecret - */ - public function testGetAccessTokenSecret() - { - $token = new StdOAuth1Token(); - - $this->assertNull($token->setAccessTokenSecret('foo')); - $this->assertSame('foo', $token->getAccessTokenSecret()); - } -} |