summaryrefslogtreecommitdiff
path: root/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2014-11-06 06:41:47 -0500
committerFrédéric Guillot <fred@kanboard.net>2014-11-06 06:41:47 -0500
commitc80c15dcc33a70acc2b177691d33f088f8c2541e (patch)
treebc3e44e35b97b751c145cc5797a0faf356922244 /vendor/lusitanian/oauth/tests/Unit/OAuth1/Service
parentc91ff61cdfa8b5eb76783927e5b8710f2a9f2601 (diff)
Include all vendor files in the repo to be easier for people
Diffstat (limited to 'vendor/lusitanian/oauth/tests/Unit/OAuth1/Service')
-rw-r--r--vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/AbstractServiceTest.php215
-rw-r--r--vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/BitBucketTest.php278
-rw-r--r--vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/EtsyTest.php286
-rw-r--r--vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/FitBitTest.php278
-rw-r--r--vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/FlickrTest.php302
-rw-r--r--vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/ScoopItTest.php302
-rw-r--r--vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/TumblrTest.php278
-rw-r--r--vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/TwitterTest.php307
-rw-r--r--vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/XingTest.php239
-rw-r--r--vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/YahooTest.php302
10 files changed, 2787 insertions, 0 deletions
diff --git a/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/AbstractServiceTest.php b/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/AbstractServiceTest.php
new file mode 100644
index 00000000..ab5417b2
--- /dev/null
+++ b/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/AbstractServiceTest.php
@@ -0,0 +1,215 @@
+<?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
new file mode 100644
index 00000000..87be98b1
--- /dev/null
+++ b/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/BitBucketTest.php
@@ -0,0 +1,278 @@
+<?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
new file mode 100644
index 00000000..97ad3cdd
--- /dev/null
+++ b/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/EtsyTest.php
@@ -0,0 +1,286 @@
+<?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
new file mode 100644
index 00000000..a8b7ae2d
--- /dev/null
+++ b/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/FitBitTest.php
@@ -0,0 +1,278 @@
+<?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
new file mode 100644
index 00000000..ee88f714
--- /dev/null
+++ b/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/FlickrTest.php
@@ -0,0 +1,302 @@
+<?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
new file mode 100644
index 00000000..4ba83fa6
--- /dev/null
+++ b/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/ScoopItTest.php
@@ -0,0 +1,302 @@
+<?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
new file mode 100644
index 00000000..f1467ad6
--- /dev/null
+++ b/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/TumblrTest.php
@@ -0,0 +1,278 @@
+<?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
new file mode 100644
index 00000000..bb31fa29
--- /dev/null
+++ b/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/TwitterTest.php
@@ -0,0 +1,307 @@
+<?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
new file mode 100644
index 00000000..d3a5f4ae
--- /dev/null
+++ b/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/XingTest.php
@@ -0,0 +1,239 @@
+<?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
new file mode 100644
index 00000000..e8feb5dc
--- /dev/null
+++ b/vendor/lusitanian/oauth/tests/Unit/OAuth1/Service/YahooTest.php
@@ -0,0 +1,302 @@
+<?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'));
+ }
+}