diff options
author | Frédéric Guillot <fred@kanboard.net> | 2014-11-06 06:57:39 -0500 |
---|---|---|
committer | Frédéric Guillot <fred@kanboard.net> | 2014-11-06 06:57:39 -0500 |
commit | 420d0ca4dd6cf075204867de28c2e6d5b1b68184 (patch) | |
tree | e7723f4b0687d82300ca5b4d38e3ab0ff3fc13cf /vendor/lusitanian/oauth/tests/Unit/Common | |
parent | cfe1e13d4a2b964c950b5e3daa8cafab207f1158 (diff) |
Remove vendor again
Diffstat (limited to 'vendor/lusitanian/oauth/tests/Unit/Common')
15 files changed, 0 insertions, 3329 deletions
diff --git a/vendor/lusitanian/oauth/tests/Unit/Common/AutoloaderTest.php b/vendor/lusitanian/oauth/tests/Unit/Common/AutoloaderTest.php deleted file mode 100644 index eebc3408..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/Common/AutoloaderTest.php +++ /dev/null @@ -1,126 +0,0 @@ -<?php - -namespace OAuthTest\Unit\Commen\Core; - -use OAuth\Common\AutoLoader; - -class AutoLoaderTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\Common\AutoLoader::__construct - * @covers OAuth\Common\AutoLoader::register - */ - public function testRegister() - { - $autoloader = new AutoLoader('Test', '/'); - - $this->assertTrue($autoloader->register()); - } - - /** - * @covers OAuth\Common\AutoLoader::__construct - * @covers OAuth\Common\AutoLoader::register - * @covers OAuth\Common\AutoLoader::unregister - */ - public function testUnregister() - { - $autoloader = new AutoLoader('Test', '/'); - - $this->assertTrue($autoloader->register()); - $this->assertTrue($autoloader->unregister()); - } - - /** - * @covers OAuth\Common\AutoLoader::__construct - * @covers OAuth\Common\AutoLoader::register - * @covers OAuth\Common\AutoLoader::load - */ - public function testLoadSuccess() - { - $autoloader = new AutoLoader('FakeProject', dirname(__DIR__) . '/../Mocks/Common'); - - $this->assertTrue($autoloader->register()); - - $someClass = new \FakeProject\NS\SomeClass(); - - $this->assertTrue($someClass->isLoaded()); - } - - /** - * @covers OAuth\Common\AutoLoader::__construct - * @covers OAuth\Common\AutoLoader::register - * @covers OAuth\Common\AutoLoader::load - */ - public function testLoadSuccessExtraSlashedNamespace() - { - $autoloader = new AutoLoader('\\\\FakeProject', dirname(__DIR__) . '/../Mocks/Common'); - - $this->assertTrue($autoloader->register()); - - $someClass = new \FakeProject\NS\SomeClass(); - - $this->assertTrue($someClass->isLoaded()); - } - - /** - * @covers OAuth\Common\AutoLoader::__construct - * @covers OAuth\Common\AutoLoader::register - * @covers OAuth\Common\AutoLoader::load - */ - public function testLoadSuccessExtraForwardSlashedPath() - { - $autoloader = new AutoLoader('FakeProject', dirname(__DIR__) . '/../Mocks/Common//'); - - $this->assertTrue($autoloader->register()); - - $someClass = new \FakeProject\NS\SomeClass(); - - $this->assertTrue($someClass->isLoaded()); - } - - /** - * @covers OAuth\Common\AutoLoader::__construct - * @covers OAuth\Common\AutoLoader::register - * @covers OAuth\Common\AutoLoader::load - */ - public function testLoadSuccessExtraBackwardSlashedPath() - { - $autoloader = new AutoLoader('FakeProject', dirname(__DIR__) . '/../Mocks/Common\\'); - - $this->assertTrue($autoloader->register()); - - $someClass = new \FakeProject\NS\SomeClass(); - - $this->assertTrue($someClass->isLoaded()); - } - - /** - * @covers OAuth\Common\AutoLoader::__construct - * @covers OAuth\Common\AutoLoader::register - * @covers OAuth\Common\AutoLoader::load - */ - public function testLoadSuccessExtraMixedSlashedPath() - { - $autoloader = new AutoLoader('FakeProject', dirname(__DIR__) . '/../Mocks/Common\\\\/\\//'); - - $this->assertTrue($autoloader->register()); - - $someClass = new \FakeProject\NS\SomeClass(); - - $this->assertTrue($someClass->isLoaded()); - } - - /** - * @covers OAuth\Common\AutoLoader::__construct - * @covers OAuth\Common\AutoLoader::register - * @covers OAuth\Common\AutoLoader::load - */ - public function testLoadUnknownClass() - { - $autoloader = new AutoLoader('FakeProject', dirname(__DIR__) . '/../Mocks/Common\\\\/\\//'); - - $this->assertTrue($autoloader->register()); - - $this->assertFalse($autoloader->load('IDontExistClass')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/Common/Consumer/CredentialsTest.php b/vendor/lusitanian/oauth/tests/Unit/Common/Consumer/CredentialsTest.php deleted file mode 100644 index 1a895fbc..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/Common/Consumer/CredentialsTest.php +++ /dev/null @@ -1,51 +0,0 @@ -<?php - -namespace OAuth\Unit\Common\Consumer; - -use OAuth\Common\Consumer\Credentials; - -class CredentialsTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\Common\Consumer\Credentials::__construct - */ - public function testConstructCorrectInterface() - { - $credentials = new Credentials('foo', 'bar', 'baz'); - - $this->assertInstanceOf('\\OAuth\\Common\\Consumer\\CredentialsInterface', $credentials); - } - - /** - * @covers OAuth\Common\Consumer\Credentials::__construct - * @covers OAuth\Common\Consumer\Credentials::getConsumerId - */ - public function testGetConsumerId() - { - $credentials = new Credentials('foo', 'bar', 'baz'); - - $this->assertSame('foo', $credentials->getConsumerId()); - } - - /** - * @covers OAuth\Common\Consumer\Credentials::__construct - * @covers OAuth\Common\Consumer\Credentials::getConsumerSecret - */ - public function testGetConsumerSecret() - { - $credentials = new Credentials('foo', 'bar', 'baz'); - - $this->assertSame('bar', $credentials->getConsumerSecret()); - } - - /** - * @covers OAuth\Common\Consumer\Credentials::__construct - * @covers OAuth\Common\Consumer\Credentials::getCallbackUrl - */ - public function testGetCallbackUrl() - { - $credentials = new Credentials('foo', 'bar', 'baz'); - - $this->assertSame('baz', $credentials->getCallbackUrl()); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/Common/Http/Client/AbstractClientTest.php b/vendor/lusitanian/oauth/tests/Unit/Common/Http/Client/AbstractClientTest.php deleted file mode 100644 index b3531527..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/Common/Http/Client/AbstractClientTest.php +++ /dev/null @@ -1,67 +0,0 @@ -<?php - -namespace OAuthTest\Unit\Common\Http; - -class AbstractClientTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\Common\Http\Client\AbstractClient::__construct - */ - public function testConstructCorrectInterface() - { - $client = $this->getMockForAbstractClass('\\OAuth\\Common\\Http\\Client\\AbstractClient'); - - $this->assertInstanceOf('\\OAuth\\Common\\Http\\Client\\ClientInterface', $client); - } - - /** - * @covers OAuth\Common\Http\Client\AbstractClient::__construct - * @covers OAuth\Common\Http\Client\AbstractClient::setMaxRedirects - */ - public function testSetMaxRedirects() - { - $client = $this->getMockForAbstractClass('\\OAuth\\Common\\Http\\Client\\AbstractClient'); - - $this->assertInstanceOf('\\OAuth\\Common\\Http\\Client\\AbstractClient', $client->setMaxRedirects(10)); - $this->assertInstanceOf('\\OAuth\\Common\\Http\\Client\\ClientInterface', $client->setMaxRedirects(10)); - } - - /** - * @covers OAuth\Common\Http\Client\AbstractClient::__construct - * @covers OAuth\Common\Http\Client\AbstractClient::setTimeout - */ - public function testSetTimeout() - { - $client = $this->getMockForAbstractClass('\\OAuth\\Common\\Http\\Client\\AbstractClient'); - - $this->assertInstanceOf('\\OAuth\\Common\\Http\\Client\\AbstractClient', $client->setTimeout(25)); - $this->assertInstanceOf('\\OAuth\\Common\\Http\\Client\\ClientInterface', $client->setTimeout(25)); - } - - /** - * @covers OAuth\Common\Http\Client\AbstractClient::__construct - * @covers OAuth\Common\Http\Client\AbstractClient::normalizeHeaders - */ - public function testNormalizeHeaders() - { - $client = $this->getMockForAbstractClass('\\OAuth\\Common\\Http\\Client\\AbstractClient'); - - $original = array( - 'lowercasekey' => 'lowercasevalue', - 'UPPERCASEKEY' => 'UPPERCASEVALUE', - 'mIxEdCaSeKey' => 'MiXeDcAsEvAlUe', - '31i71casekey' => '31i71casevalue', - ); - - $goal = array( - 'lowercasekey' => 'Lowercasekey: lowercasevalue', - 'UPPERCASEKEY' => 'Uppercasekey: UPPERCASEVALUE', - 'mIxEdCaSeKey' => 'Mixedcasekey: MiXeDcAsEvAlUe', - '31i71casekey' => '31i71casekey: 31i71casevalue', - ); - - $client->normalizeHeaders($original); - - $this->assertSame($goal, $original); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/Common/Http/Client/CurlClientTest.php b/vendor/lusitanian/oauth/tests/Unit/Common/Http/Client/CurlClientTest.php deleted file mode 100644 index f635ce89..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/Common/Http/Client/CurlClientTest.php +++ /dev/null @@ -1,378 +0,0 @@ -<?php - -namespace OAuthTest\Unit\Common\Http\Client; - -use OAuth\Common\Http\Client\CurlClient; - -class CurlClientTest extends \PHPUnit_Framework_TestCase -{ - /** - * - */ - public function testConstructCorrectInstance() - { - $client = new CurlClient(); - - $this->assertInstanceOf('\\OAuth\\Common\\Http\\Client\\AbstractClient', $client); - } - - /** - * @covers OAuth\Common\Http\Client\CurlClient::setForceSSL3 - */ - public function testSetForceSSL3() - { - $client = new CurlClient(); - - $this->assertInstanceOf('\\OAuth\\Common\\Http\\Client\\CurlClient', $client->setForceSSL3(true)); - } - - /** - * @covers OAuth\Common\Http\Client\CurlClient::retrieveResponse - */ - public function testRetrieveResponseThrowsExceptionOnGetRequestWithBody() - { - $this->setExpectedException('\\InvalidArgumentException'); - - $client = new CurlClient(); - - $client->retrieveResponse( - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'), - 'foo', - array(), - 'GET' - ); - } - - /** - * @covers OAuth\Common\Http\Client\CurlClient::retrieveResponse - */ - public function testRetrieveResponseThrowsExceptionOnGetRequestWithBodyMethodConvertedToUpper() - { - $this->setExpectedException('\\InvalidArgumentException'); - - $client = new CurlClient(); - - $client->retrieveResponse( - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'), - 'foo', - array(), - 'get' - ); - } - - /** - * @covers OAuth\Common\Http\Client\StreamClient::retrieveResponse - * @covers OAuth\Common\Http\Client\StreamClient::generateStreamContext - */ - public function testRetrieveResponseDefaultUserAgent() - { - $endPoint = $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'); - $endPoint->expects($this->any()) - ->method('getHost') - ->will($this->returnValue('httpbin.org')); - $endPoint->expects($this->any()) - ->method('getAbsoluteUri') - ->will($this->returnValue('http://httpbin.org/get')); - - $client = new CurlClient(); - - $response = $client->retrieveResponse( - $endPoint, - '', - array(), - 'get' - ); - - $response = json_decode($response, true); - - $this->assertSame('PHPoAuthLib', $response['headers']['User-Agent']); - } - - /** - * @covers OAuth\Common\Http\Client\StreamClient::retrieveResponse - * @covers OAuth\Common\Http\Client\StreamClient::generateStreamContext - */ - public function testRetrieveResponseCustomUserAgent() - { - $endPoint = $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'); - $endPoint->expects($this->any()) - ->method('getHost') - ->will($this->returnValue('httpbin.org')); - $endPoint->expects($this->any()) - ->method('getAbsoluteUri') - ->will($this->returnValue('http://httpbin.org/get')); - - $client = new CurlClient('My Super Awesome Http Client'); - - $response = $client->retrieveResponse( - $endPoint, - '', - array(), - 'get' - ); - - $response = json_decode($response, true); - - $this->assertSame('My Super Awesome Http Client', $response['headers']['User-Agent']); - } - - /** - * @covers OAuth\Common\Http\Client\CurlClient::retrieveResponse - */ - public function testRetrieveResponseWithCustomContentType() - { - $endPoint = $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'); - $endPoint->expects($this->any()) - ->method('getHost') - ->will($this->returnValue('httpbin.org')); - $endPoint->expects($this->any()) - ->method('getAbsoluteUri') - ->will($this->returnValue('http://httpbin.org/get')); - - $client = new CurlClient(); - - $response = $client->retrieveResponse( - $endPoint, - '', - array('Content-Type' => 'foo/bar'), - 'get' - ); - - $response = json_decode($response, true); - - $this->assertSame('foo/bar', $response['headers']['Content-Type']); - } - - /** - * @covers OAuth\Common\Http\Client\CurlClient::retrieveResponse - */ - public function testRetrieveResponseWithFormUrlEncodedContentType() - { - $endPoint = $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'); - $endPoint->expects($this->any()) - ->method('getHost') - ->will($this->returnValue('httpbin.org')); - $endPoint->expects($this->any()) - ->method('getAbsoluteUri') - ->will($this->returnValue('http://httpbin.org/post')); - - $client = new CurlClient(); - - $response = $client->retrieveResponse( - $endPoint, - array('foo' => 'bar', 'baz' => 'fab'), - array(), - 'POST' - ); - - $response = json_decode($response, true); - - $this->assertSame('application/x-www-form-urlencoded', $response['headers']['Content-Type']); - $this->assertEquals(array('foo' => 'bar', 'baz' => 'fab'), $response['form']); - } - - /** - * @covers OAuth\Common\Http\Client\CurlClient::retrieveResponse - */ - public function testRetrieveResponseHost() - { - $endPoint = $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'); - $endPoint->expects($this->any()) - ->method('getHost') - ->will($this->returnValue('httpbin.org')); - $endPoint->expects($this->any()) - ->method('getAbsoluteUri') - ->will($this->returnValue('http://httpbin.org/post')); - - $client = new CurlClient(); - - $response = $client->retrieveResponse( - $endPoint, - array('foo' => 'bar', 'baz' => 'fab'), - array(), - 'POST' - ); - - $response = json_decode($response, true); - - $this->assertSame('httpbin.org', $response['headers']['Host']); - } - - /** - * @covers OAuth\Common\Http\Client\CurlClient::retrieveResponse - */ - public function testRetrieveResponsePostRequestWithRequestBodyAsString() - { - $endPoint = $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'); - $endPoint->expects($this->any()) - ->method('getHost') - ->will($this->returnValue('httpbin.org')); - $endPoint->expects($this->any()) - ->method('getAbsoluteUri') - ->will($this->returnValue('http://httpbin.org/post')); - - $formData = array('baz' => 'fab', 'foo' => 'bar'); - - $client = new CurlClient(); - - $response = $client->retrieveResponse( - $endPoint, - $formData, - array(), - 'POST' - ); - - $response = json_decode($response, true); - - $this->assertSame($formData, $response['form']); - } - - /** - * @covers OAuth\Common\Http\Client\CurlClient::retrieveResponse - */ - public function testRetrieveResponsePutRequestWithRequestBodyAsString() - { - $endPoint = $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'); - $endPoint->expects($this->any()) - ->method('getHost') - ->will($this->returnValue('httpbin.org')); - $endPoint->expects($this->any()) - ->method('getAbsoluteUri') - ->will($this->returnValue('http://httpbin.org/put')); - - $formData = array('baz' => 'fab', 'foo' => 'bar'); - - $client = new CurlClient(); - - $response = $client->retrieveResponse( - $endPoint, - $formData, - array(), - 'PUT' - ); - - $response = json_decode($response, true); - - $this->assertSame($formData, $response['form']); - } - - /** - * @covers OAuth\Common\Http\Client\CurlClient::retrieveResponse - */ - public function testRetrieveResponsePutRequestWithRequestBodyAsStringNoRedirects() - { - $endPoint = $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'); - $endPoint->expects($this->any()) - ->method('getHost') - ->will($this->returnValue('httpbin.org')); - $endPoint->expects($this->any()) - ->method('getAbsoluteUri') - ->will($this->returnValue('http://httpbin.org/put')); - - $formData = array('baz' => 'fab', 'foo' => 'bar'); - - $client = new CurlClient(); - - $client->setMaxRedirects(0); - - $response = $client->retrieveResponse( - $endPoint, - $formData, - array(), - 'PUT' - ); - - $response = json_decode($response, true); - - $this->assertSame($formData, $response['form']); - } - - /** - * @covers OAuth\Common\Http\Client\CurlClient::retrieveResponse - */ - public function testRetrieveResponseWithForcedSsl3() - { - $endPoint = $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'); - $endPoint->expects($this->any()) - ->method('getHost') - ->will($this->returnValue('httpbin.org')); - $endPoint->expects($this->any()) - ->method('getAbsoluteUri') - ->will($this->returnValue('https://httpbin.org/get')); - - $client = new CurlClient(); - - $client->setForceSSL3(true); - - $response = $client->retrieveResponse( - $endPoint, - '', - array('Content-Type' => 'foo/bar'), - 'get' - ); - - $response = json_decode($response, true); - - $this->assertSame('foo/bar', $response['headers']['Content-Type']); - } - - /** - * @covers OAuth\Common\Http\Client\CurlClient::retrieveResponse - */ - public function testRetrieveResponseThrowsExceptionOnInvalidUrl() - { - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $endPoint = $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'); - $endPoint->expects($this->any()) - ->method('getHost') - ->will($this->returnValue('jkehfkefcmekjhcnkerjh')); - $endPoint->expects($this->any()) - ->method('getAbsoluteUri') - ->will($this->returnValue('jkehfkefcmekjhcnkerjh')); - - $client = new CurlClient(); - - $client->setForceSSL3(true); - - $response = $client->retrieveResponse( - $endPoint, - '', - array('Content-Type' => 'foo/bar'), - 'get' - ); - - $response = json_decode($response, true); - - $this->assertSame('foo/bar', $response['headers']['Content-Type']); - } - - public function testAdditionalParameters() - { - $endPoint = $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'); - $endPoint->expects($this->any()) - ->method('getHost') - ->will($this->returnValue('httpbin.org')); - $endPoint->expects($this->any()) - ->method('getAbsoluteUri') - ->will($this->returnValue('http://httpbin.org/gzip')); - - $client = new CurlClient(); - $client->setCurlParameters(array( - CURLOPT_ENCODING => 'gzip', - )); - - $response = $client->retrieveResponse( - $endPoint, - '', - array(), - 'get' - ); - - $response = json_decode($response, true); - - $this->assertNotNull($response); - $this->assertSame('gzip', $response['headers']['Accept-Encoding']); - $this->assertTrue($response['gzipped']); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/Common/Http/Client/StreamClientTest.php b/vendor/lusitanian/oauth/tests/Unit/Common/Http/Client/StreamClientTest.php deleted file mode 100644 index f634f406..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/Common/Http/Client/StreamClientTest.php +++ /dev/null @@ -1,283 +0,0 @@ -<?php - -namespace OAuthTest\Unit\Common\Http\Client; - -use OAuth\Common\Http\Client\StreamClient; - -class StreamClientTest extends \PHPUnit_Framework_TestCase -{ - /** - * - */ - public function testConstructCorrectInstance() - { - $client = new StreamClient(); - - $this->assertInstanceOf('\\OAuth\\Common\\Http\\Client\\AbstractClient', $client); - } - - /** - * @covers OAuth\Common\Http\Client\StreamClient::retrieveResponse - */ - public function testRetrieveResponseThrowsExceptionOnGetRequestWithBody() - { - $this->setExpectedException('\\InvalidArgumentException'); - - $client = new StreamClient(); - - $client->retrieveResponse( - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'), - 'foo', - array(), - 'GET' - ); - } - - /** - * @covers OAuth\Common\Http\Client\StreamClient::retrieveResponse - */ - public function testRetrieveResponseThrowsExceptionOnGetRequestWithBodyMethodConvertedToUpper() - { - $this->setExpectedException('\\InvalidArgumentException'); - - $client = new StreamClient(); - - $client->retrieveResponse( - $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'), - 'foo', - array(), - 'get' - ); - } - - /** - * @covers OAuth\Common\Http\Client\StreamClient::retrieveResponse - * @covers OAuth\Common\Http\Client\StreamClient::generateStreamContext - */ - public function testRetrieveResponseDefaultUserAgent() - { - $endPoint = $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'); - $endPoint->expects($this->any()) - ->method('getHost') - ->will($this->returnValue('httpbin.org')); - $endPoint->expects($this->any()) - ->method('getAbsoluteUri') - ->will($this->returnValue('http://httpbin.org/get')); - - $client = new StreamClient(); - - $response = $client->retrieveResponse( - $endPoint, - '', - array(), - 'get' - ); - - $response = json_decode($response, true); - - $this->assertSame('PHPoAuthLib', $response['headers']['User-Agent']); - } - - /** - * @covers OAuth\Common\Http\Client\StreamClient::retrieveResponse - * @covers OAuth\Common\Http\Client\StreamClient::generateStreamContext - */ - public function testRetrieveResponseCustomUserAgent() - { - $endPoint = $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'); - $endPoint->expects($this->any()) - ->method('getHost') - ->will($this->returnValue('httpbin.org')); - $endPoint->expects($this->any()) - ->method('getAbsoluteUri') - ->will($this->returnValue('http://httpbin.org/get')); - - $client = new StreamClient('My Super Awesome Http Client'); - - $response = $client->retrieveResponse( - $endPoint, - '', - array(), - 'get' - ); - - $response = json_decode($response, true); - - $this->assertSame('My Super Awesome Http Client', $response['headers']['User-Agent']); - } - - /** - * @covers OAuth\Common\Http\Client\StreamClient::retrieveResponse - * @covers OAuth\Common\Http\Client\StreamClient::generateStreamContext - */ - public function testRetrieveResponseWithCustomContentType() - { - $endPoint = $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'); - $endPoint->expects($this->any()) - ->method('getHost') - ->will($this->returnValue('httpbin.org')); - $endPoint->expects($this->any()) - ->method('getAbsoluteUri') - ->will($this->returnValue('http://httpbin.org/get')); - - $client = new StreamClient(); - - $response = $client->retrieveResponse( - $endPoint, - '', - array('Content-Type' => 'foo/bar'), - 'get' - ); - - $response = json_decode($response, true); - - $this->assertSame('foo/bar', $response['headers']['Content-Type']); - } - - /** - * @covers OAuth\Common\Http\Client\StreamClient::retrieveResponse - * @covers OAuth\Common\Http\Client\StreamClient::generateStreamContext - */ - public function testRetrieveResponseWithFormUrlEncodedContentType() - { - $endPoint = $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'); - $endPoint->expects($this->any()) - ->method('getHost') - ->will($this->returnValue('httpbin.org')); - $endPoint->expects($this->any()) - ->method('getAbsoluteUri') - ->will($this->returnValue('http://httpbin.org/post')); - - $client = new StreamClient(); - - $response = $client->retrieveResponse( - $endPoint, - array('foo' => 'bar', 'baz' => 'fab'), - array(), - 'POST' - ); - - $response = json_decode($response, true); - - $this->assertSame('application/x-www-form-urlencoded', $response['headers']['Content-Type']); - $this->assertEquals(array('foo' => 'bar', 'baz' => 'fab'), $response['form']); - } - - /** - * @covers OAuth\Common\Http\Client\StreamClient::retrieveResponse - * @covers OAuth\Common\Http\Client\StreamClient::generateStreamContext - */ - public function testRetrieveResponseHost() - { - $endPoint = $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'); - $endPoint->expects($this->any()) - ->method('getHost') - ->will($this->returnValue('httpbin.org')); - $endPoint->expects($this->any()) - ->method('getAbsoluteUri') - ->will($this->returnValue('http://httpbin.org/post')); - - $client = new StreamClient(); - - $response = $client->retrieveResponse( - $endPoint, - array('foo' => 'bar', 'baz' => 'fab'), - array(), - 'POST' - ); - - $response = json_decode($response, true); - - $this->assertSame('httpbin.org', $response['headers']['Host']); - } - - /** - * @covers OAuth\Common\Http\Client\StreamClient::retrieveResponse - * @covers OAuth\Common\Http\Client\StreamClient::generateStreamContext - */ - public function testRetrieveResponsePostRequestWithRequestBodyAsString() - { - $endPoint = $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'); - $endPoint->expects($this->any()) - ->method('getHost') - ->will($this->returnValue('httpbin.org')); - $endPoint->expects($this->any()) - ->method('getAbsoluteUri') - ->will($this->returnValue('http://httpbin.org/post')); - - $formData = array('baz' => 'fab', 'foo' => 'bar'); - - $client = new StreamClient(); - - $response = $client->retrieveResponse( - $endPoint, - $formData, - array(), - 'POST' - ); - - $response = json_decode($response, true); - - $this->assertSame($formData, $response['form']); - } - - /** - * @covers OAuth\Common\Http\Client\StreamClient::retrieveResponse - * @covers OAuth\Common\Http\Client\StreamClient::generateStreamContext - */ - public function testRetrieveResponsePutRequestWithRequestBodyAsString() - { - $endPoint = $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'); - $endPoint->expects($this->any()) - ->method('getHost') - ->will($this->returnValue('httpbin.org')); - $endPoint->expects($this->any()) - ->method('getAbsoluteUri') - ->will($this->returnValue('http://httpbin.org/put')); - - $formData = array('baz' => 'fab', 'foo' => 'bar'); - - $client = new StreamClient(); - - $response = $client->retrieveResponse( - $endPoint, - $formData, - array(), - 'PUT' - ); - - $response = json_decode($response, true); - - $this->assertSame($formData, $response['form']); - } - - /** - * @covers OAuth\Common\Http\Client\StreamClient::retrieveResponse - * @covers OAuth\Common\Http\Client\StreamClient::generateStreamContext - */ - public function testRetrieveResponseThrowsExceptionOnInvalidRequest() - { - $this->setExpectedException('\\OAuth\\Common\\Http\\Exception\\TokenResponseException'); - - $endPoint = $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface'); - $endPoint->expects($this->any()) - ->method('getHost') - ->will($this->returnValue('dskjhfckjhekrsfhkehfkreljfrekljfkre')); - $endPoint->expects($this->any()) - ->method('getAbsoluteUri') - ->will($this->returnValue('dskjhfckjhekrsfhkehfkreljfrekljfkre')); - - $client = new StreamClient(); - - $response = $client->retrieveResponse( - $endPoint, - '', - array('Content-Type' => 'foo/bar'), - 'get' - ); - - $response = json_decode($response, true); - - $this->assertSame('foo/bar', $response['headers']['Content-Type']); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/Common/Http/HttpClientsTest.php b/vendor/lusitanian/oauth/tests/Unit/Common/Http/HttpClientsTest.php deleted file mode 100644 index 6fa9eace..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/Common/Http/HttpClientsTest.php +++ /dev/null @@ -1,171 +0,0 @@ -<?php - -/** - * @category OAuth - * @package Tests - * @author David Desberg <david@daviddesberg.com> - * @copyright Copyright (c) 2012 The authors - * @license http://www.opensource.org/licenses/mit-license.html MIT License - */ - -namespace OAuth\Unit\Common\Http; - -use OAuth\Common\Http\Uri\Uri; -use OAuth\Common\Http\Uri\UriInterface; -use OAuth\Common\Http\Client; - -class HttpClientsTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var object|\OAuth\Common\Http\Client\ClientInterface[] - */ - protected $clients; - - public function setUp() - { - $streamClient = new Client\StreamClient(); - $streamClient->setTimeout(3); - - $curlClient = new Client\CurlClient(); - $curlClient->setTimeout(3); - - $this->clients[] = $streamClient; - $this->clients[] = $curlClient; - } - - public function tearDown() - { - foreach ($this->clients as $client) { - unset($client); - } - } - - /** - * Test that extra headers are passed properly - */ - public function testHeaders() - { - $testUri = new Uri('http://httpbin.org/get'); - - $me = $this; - $headerCb = function ($response) use ($me) { - $data = json_decode($response, true); - $me->assertEquals('extraheadertest', $data['headers']['Testingheader']); - }; - - $this->__doTestRetrieveResponse($testUri, array(), array('Testingheader' => 'extraheadertest'), 'GET', $headerCb); - } - - /** - * Tests that we get an exception for a >= 400 status code - */ - public function testException() - { - // sending a post here should get us a 405 which should trigger an exception - $testUri = new Uri('http://httpbin.org/delete'); - foreach ($this->clients as $client) { - $this->setExpectedException('OAuth\Common\Http\Exception\TokenResponseException'); - $client->retrieveResponse($testUri, array('blah' => 'blih')); - } - } - - /** - * Tests the DELETE method - */ - public function testDelete() - { - $testUri = new Uri('http://httpbin.org/delete'); - - $me = $this; - $deleteTestCb = function ($response) use ($me) { - $data = json_decode($response, true); - $me->assertEquals('', $data['data']); - }; - - $this->__doTestRetrieveResponse($testUri, array(), array(), 'DELETE', $deleteTestCb); - } - - /** - * Tests the PUT method - */ - public function testPut() - { - $testUri = new Uri('http://httpbin.org/put'); - - $me = $this; - $putTestCb = function ($response) use ($me) { - // verify the put response - $data = json_decode($response, true); - $me->assertEquals(json_encode(array('testKey' => 'testValue')), $data['data']); - }; - - $this->__doTestRetrieveResponse($testUri, json_encode(array('testKey' => 'testValue')), array('Content-Type' => 'application/json'), 'PUT', $putTestCb); - } - - /** - * Tests the POST method - */ - public function testPost() - { - // http test server - $testUri = new Uri('http://httpbin.org/post'); - - $me = $this; - $postTestCb = function ($response) use ($me) { - // verify the post response - $data = json_decode($response, true); - // note that we check this because the retrieveResponse wrapper function automatically adds a content-type - // if there isn't one and it - $me->assertEquals('testValue', $data['form']['testKey']); - }; - - $this->__doTestRetrieveResponse($testUri, array('testKey' => 'testValue'), array(), 'POST', $postTestCb); - } - - /** - * Expect exception when we try to send a GET request with a body - */ - public function testInvalidGet() - { - $testUri = new Uri('http://site.net'); - - foreach ($this->clients as $client) { - $this->setExpectedException('InvalidArgumentException'); - $client->retrieveResponse($testUri, array('blah' => 'blih'), array(), 'GET'); - } - } - - /** - * Tests the GET method - */ - public function testGet() - { - // test uri - $testUri = new Uri('http://httpbin.org/get?testKey=testValue'); - - $me = $this; - $getTestCb = function ($response) use ($me) { - $data = json_decode($response, true); - $me->assertEquals('testValue', $data['args']['testKey']); - }; - - $this->__doTestRetrieveResponse($testUri, array(), array(), 'GET', $getTestCb); - } - - /** - * Test on all HTTP clients. - * - * @param UriInterface $uri - * @param array $param - * @param array $header - * @param string $method - * @param \Closure $responseCallback - */ - protected function __doTestRetrieveResponse(UriInterface $uri, $param, array $header, $method, $responseCallback) - { - foreach ($this->clients as $client) { - $response = $client->retrieveResponse($uri, $param, $header, $method); - $responseCallback($response, $client); - } - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/Common/Http/Uri/UriFactoryTest.php b/vendor/lusitanian/oauth/tests/Unit/Common/Http/Uri/UriFactoryTest.php deleted file mode 100644 index ea743509..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/Common/Http/Uri/UriFactoryTest.php +++ /dev/null @@ -1,331 +0,0 @@ -<?php - -namespace OAuthTest\Unit\Common\Http\Uri; - -use OAuth\Common\Http\Uri\UriFactory; -use OAuth\Common\Http\Uri\Uri; - -class UriFactoryTest extends \PHPUnit_Framework_TestCase -{ - /** - * - */ - public function testConstructCorrectInterface() - { - $factory = new UriFactory(); - - $this->assertInstanceOf('\\OAuth\\Common\\Http\\Uri\\UriFactoryInterface', $factory); - } - - /** - * @covers OAuth\Common\Http\Uri\UriFactory::createFromSuperGlobalArray - * @covers OAuth\Common\Http\Uri\UriFactory::attemptProxyStyleParse - */ - public function testCreateFromSuperGlobalArrayUsingProxyStyle() - { - $factory = new UriFactory(); - - $uri = $factory->createFromSuperGlobalArray(array('REQUEST_URI' => 'http://example.com')); - - $this->assertInstanceOf( - '\\OAuth\\Common\\Http\\Uri\\UriInterface', - $uri - ); - - $this->assertSame('http://example.com', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\UriFactory::createFromSuperGlobalArray - * @covers OAuth\Common\Http\Uri\UriFactory::attemptProxyStyleParse - * @covers OAuth\Common\Http\Uri\UriFactory::detectScheme - * @covers OAuth\Common\Http\Uri\UriFactory::detectHost - * @covers OAuth\Common\Http\Uri\UriFactory::detectPort - * @covers OAuth\Common\Http\Uri\UriFactory::detectPath - * @covers OAuth\Common\Http\Uri\UriFactory::detectQuery - * @covers OAuth\Common\Http\Uri\UriFactory::createFromParts - */ - public function testCreateFromSuperGlobalArrayHttp() - { - $factory = new UriFactory(); - - $uri = $factory->createFromSuperGlobalArray(array( - 'HTTPS' => 'off', - 'HTTP_HOST' => 'example.com', - 'REQUEST_URI' => '/foo', - 'QUERY_STRING' => 'param1=value1', - )); - - $this->assertInstanceOf( - '\\OAuth\\Common\\Http\\Uri\\UriInterface', - $uri - ); - - $this->assertSame('http://example.com/foo?param1=value1', $uri->getAbsoluteUri()); - } - - /** - * This looks wonky David. Should the port really fallback to 80 even when supplying https as scheme? - * - * @covers OAuth\Common\Http\Uri\UriFactory::createFromSuperGlobalArray - * @covers OAuth\Common\Http\Uri\UriFactory::attemptProxyStyleParse - * @covers OAuth\Common\Http\Uri\UriFactory::detectScheme - * @covers OAuth\Common\Http\Uri\UriFactory::detectHost - * @covers OAuth\Common\Http\Uri\UriFactory::detectPort - * @covers OAuth\Common\Http\Uri\UriFactory::detectPath - * @covers OAuth\Common\Http\Uri\UriFactory::detectQuery - * @covers OAuth\Common\Http\Uri\UriFactory::createFromParts - */ - public function testCreateFromSuperGlobalArrayHttps() - { - $factory = new UriFactory(); - - $uri = $factory->createFromSuperGlobalArray(array( - 'HTTPS' => 'on', - 'HTTP_HOST' => 'example.com', - 'REQUEST_URI' => '/foo', - 'QUERY_STRING' => 'param1=value1', - )); - - $this->assertInstanceOf( - '\\OAuth\\Common\\Http\\Uri\\UriInterface', - $uri - ); - - $this->assertSame('https://example.com:80/foo?param1=value1', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\UriFactory::createFromSuperGlobalArray - * @covers OAuth\Common\Http\Uri\UriFactory::attemptProxyStyleParse - * @covers OAuth\Common\Http\Uri\UriFactory::detectScheme - * @covers OAuth\Common\Http\Uri\UriFactory::detectHost - * @covers OAuth\Common\Http\Uri\UriFactory::detectPort - * @covers OAuth\Common\Http\Uri\UriFactory::detectPath - * @covers OAuth\Common\Http\Uri\UriFactory::detectQuery - * @covers OAuth\Common\Http\Uri\UriFactory::createFromParts - */ - public function testCreateFromSuperGlobalArrayPortSupplied() - { - $factory = new UriFactory(); - - $uri = $factory->createFromSuperGlobalArray(array( - 'HTTP_HOST' => 'example.com', - 'SERVER_PORT' => 21, - 'REQUEST_URI' => '/foo', - 'QUERY_STRING' => 'param1=value1', - )); - - $this->assertInstanceOf( - '\\OAuth\\Common\\Http\\Uri\\UriInterface', - $uri - ); - - $this->assertSame('http://example.com:21/foo?param1=value1', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\UriFactory::createFromSuperGlobalArray - * @covers OAuth\Common\Http\Uri\UriFactory::attemptProxyStyleParse - * @covers OAuth\Common\Http\Uri\UriFactory::detectScheme - * @covers OAuth\Common\Http\Uri\UriFactory::detectHost - * @covers OAuth\Common\Http\Uri\UriFactory::detectPort - * @covers OAuth\Common\Http\Uri\UriFactory::detectPath - * @covers OAuth\Common\Http\Uri\UriFactory::detectQuery - * @covers OAuth\Common\Http\Uri\UriFactory::createFromParts - */ - public function testCreateFromSuperGlobalArrayPortNotSet() - { - $factory = new UriFactory(); - - $uri = $factory->createFromSuperGlobalArray(array( - 'HTTP_HOST' => 'example.com', - 'REQUEST_URI' => '/foo', - 'QUERY_STRING' => 'param1=value1', - )); - - $this->assertInstanceOf( - '\\OAuth\\Common\\Http\\Uri\\UriInterface', - $uri - ); - - $this->assertSame('http://example.com/foo?param1=value1', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\UriFactory::createFromSuperGlobalArray - * @covers OAuth\Common\Http\Uri\UriFactory::attemptProxyStyleParse - * @covers OAuth\Common\Http\Uri\UriFactory::detectScheme - * @covers OAuth\Common\Http\Uri\UriFactory::detectHost - * @covers OAuth\Common\Http\Uri\UriFactory::detectPort - * @covers OAuth\Common\Http\Uri\UriFactory::detectPath - * @covers OAuth\Common\Http\Uri\UriFactory::detectQuery - * @covers OAuth\Common\Http\Uri\UriFactory::createFromParts - */ - public function testCreateFromSuperGlobalArrayRequestUriSet() - { - $factory = new UriFactory(); - - $uri = $factory->createFromSuperGlobalArray(array( - 'HTTP_HOST' => 'example.com', - 'REQUEST_URI' => '/foo', - 'QUERY_STRING' => 'param1=value1', - )); - - $this->assertInstanceOf( - '\\OAuth\\Common\\Http\\Uri\\UriInterface', - $uri - ); - - $this->assertSame('http://example.com/foo?param1=value1', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\UriFactory::createFromSuperGlobalArray - * @covers OAuth\Common\Http\Uri\UriFactory::attemptProxyStyleParse - * @covers OAuth\Common\Http\Uri\UriFactory::detectScheme - * @covers OAuth\Common\Http\Uri\UriFactory::detectHost - * @covers OAuth\Common\Http\Uri\UriFactory::detectPort - * @covers OAuth\Common\Http\Uri\UriFactory::detectPath - * @covers OAuth\Common\Http\Uri\UriFactory::detectQuery - * @covers OAuth\Common\Http\Uri\UriFactory::createFromParts - */ - public function testCreateFromSuperGlobalArrayRedirectUrlSet() - { - $factory = new UriFactory(); - - $uri = $factory->createFromSuperGlobalArray(array( - 'HTTP_HOST' => 'example.com', - 'REDIRECT_URL' => '/foo', - 'QUERY_STRING' => 'param1=value1', - )); - - $this->assertInstanceOf( - '\\OAuth\\Common\\Http\\Uri\\UriInterface', - $uri - ); - - $this->assertSame('http://example.com/foo?param1=value1', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\UriFactory::createFromSuperGlobalArray - * @covers OAuth\Common\Http\Uri\UriFactory::attemptProxyStyleParse - * @covers OAuth\Common\Http\Uri\UriFactory::detectScheme - * @covers OAuth\Common\Http\Uri\UriFactory::detectHost - * @covers OAuth\Common\Http\Uri\UriFactory::detectPort - * @covers OAuth\Common\Http\Uri\UriFactory::detectPath - * @covers OAuth\Common\Http\Uri\UriFactory::detectQuery - * @covers OAuth\Common\Http\Uri\UriFactory::createFromParts - */ - public function testCreateFromSuperGlobalArrayThrowsExceptionOnDetectingPathMissingIndices() - { - $factory = new UriFactory(); - - $this->setExpectedException('\\RuntimeException'); - - $uri = $factory->createFromSuperGlobalArray(array( - 'HTTP_HOST' => 'example.com', - 'QUERY_STRING' => 'param1=value1', - )); - } - - /** - * @covers OAuth\Common\Http\Uri\UriFactory::createFromSuperGlobalArray - * @covers OAuth\Common\Http\Uri\UriFactory::attemptProxyStyleParse - * @covers OAuth\Common\Http\Uri\UriFactory::detectScheme - * @covers OAuth\Common\Http\Uri\UriFactory::detectHost - * @covers OAuth\Common\Http\Uri\UriFactory::detectPort - * @covers OAuth\Common\Http\Uri\UriFactory::detectPath - * @covers OAuth\Common\Http\Uri\UriFactory::detectQuery - * @covers OAuth\Common\Http\Uri\UriFactory::createFromParts - */ - public function testCreateFromSuperGlobalArrayWithQueryString() - { - $factory = new UriFactory(); - - $uri = $factory->createFromSuperGlobalArray(array( - 'HTTP_HOST' => 'example.com', - 'REQUEST_URI' => '/foo?param1=value1', - 'QUERY_STRING' => 'param1=value1', - )); - - $this->assertInstanceOf( - '\\OAuth\\Common\\Http\\Uri\\UriInterface', - $uri - ); - - $this->assertSame('http://example.com/foo?param1=value1', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\UriFactory::createFromSuperGlobalArray - * @covers OAuth\Common\Http\Uri\UriFactory::attemptProxyStyleParse - * @covers OAuth\Common\Http\Uri\UriFactory::detectScheme - * @covers OAuth\Common\Http\Uri\UriFactory::detectHost - * @covers OAuth\Common\Http\Uri\UriFactory::detectPort - * @covers OAuth\Common\Http\Uri\UriFactory::detectPath - * @covers OAuth\Common\Http\Uri\UriFactory::detectQuery - * @covers OAuth\Common\Http\Uri\UriFactory::createFromParts - */ - public function testCreateFromSuperGlobalArrayWithoutQueryString() - { - $factory = new UriFactory(); - - $uri = $factory->createFromSuperGlobalArray(array( - 'HTTP_HOST' => 'example.com', - 'REQUEST_URI' => '/foo', - )); - - $this->assertInstanceOf( - '\\OAuth\\Common\\Http\\Uri\\UriInterface', - $uri - ); - - $this->assertSame('http://example.com/foo', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\UriFactory::createFromSuperGlobalArray - * @covers OAuth\Common\Http\Uri\UriFactory::attemptProxyStyleParse - * @covers OAuth\Common\Http\Uri\UriFactory::detectScheme - * @covers OAuth\Common\Http\Uri\UriFactory::detectHost - * @covers OAuth\Common\Http\Uri\UriFactory::detectPort - * @covers OAuth\Common\Http\Uri\UriFactory::detectPath - * @covers OAuth\Common\Http\Uri\UriFactory::detectQuery - * @covers OAuth\Common\Http\Uri\UriFactory::createFromParts - */ - public function testCreateFromSuperGlobalArrayHostWithColon() - { - $factory = new UriFactory(); - - $uri = $factory->createFromSuperGlobalArray(array( - 'HTTP_HOST' => 'example.com:80', - 'REQUEST_URI' => '/foo', - )); - - $this->assertInstanceOf( - '\\OAuth\\Common\\Http\\Uri\\UriInterface', - $uri - ); - - $this->assertSame('http://example.com/foo', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\UriFactory::createFromAbsolute - */ - public function testCreateFromAbsolute() - { - $factory = new UriFactory(); - - $uri = $factory->createFromAbsolute('http://example.com'); - - $this->assertInstanceOf( - '\\OAuth\\Common\\Http\\Uri\\UriInterface', - $uri - ); - - $this->assertSame('http://example.com', $uri->getAbsoluteUri()); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/Common/Http/Uri/UriTest.php b/vendor/lusitanian/oauth/tests/Unit/Common/Http/Uri/UriTest.php deleted file mode 100644 index bc158ffa..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/Common/Http/Uri/UriTest.php +++ /dev/null @@ -1,898 +0,0 @@ -<?php - -namespace OAuthTest\Unit\Common\Http\Uri; - -use OAuth\Common\Http\Uri\Uri; - -class UriTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - */ - public function testConstructCorrectInterfaceWithoutUri() - { - $uri = new Uri(); - - $this->assertInstanceOf('\\OAuth\\Common\\Http\\Uri\\UriInterface', $uri); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - */ - public function testConstructThrowsExceptionOnInvalidUri() - { - $this->setExpectedException('\\InvalidArgumentException'); - - // http://lxr.php.net/xref/PHP_5_4/ext/standard/tests/url/urls.inc#92 - $uri = new Uri('http://@:/'); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - */ - public function testConstructThrowsExceptionOnUriWithoutScheme() - { - $this->setExpectedException('\\InvalidArgumentException'); - - $uri = new Uri('www.pieterhordijk.com'); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getScheme - */ - public function testGetScheme() - { - $uri = new Uri('http://example.com'); - - $this->assertSame('http', $uri->getScheme()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setUserInfo - * @covers OAuth\Common\Http\Uri\Uri::protectUserInfo - * @covers OAuth\Common\Http\Uri\Uri::getUserInfo - */ - public function testGetUserInfo() - { - $uri = new Uri('http://peehaa@example.com'); - - $this->assertSame('peehaa', $uri->getUserInfo()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setUserInfo - * @covers OAuth\Common\Http\Uri\Uri::protectUserInfo - * @covers OAuth\Common\Http\Uri\Uri::getUserInfo - */ - public function testGetUserInfoWithPass() - { - $uri = new Uri('http://peehaa:pass@example.com'); - - $this->assertSame('peehaa:********', $uri->getUserInfo()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setUserInfo - * @covers OAuth\Common\Http\Uri\Uri::protectUserInfo - * @covers OAuth\Common\Http\Uri\Uri::getRawUserInfo - */ - public function testGetRawUserInfo() - { - $uri = new Uri('http://peehaa@example.com'); - - $this->assertSame('peehaa', $uri->getRawUserInfo()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setUserInfo - * @covers OAuth\Common\Http\Uri\Uri::protectUserInfo - * @covers OAuth\Common\Http\Uri\Uri::getRawUserInfo - */ - public function testGetRawUserInfoWithPass() - { - $uri = new Uri('http://peehaa:pass@example.com'); - - $this->assertSame('peehaa:pass', $uri->getRawUserInfo()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getHost - */ - public function testGetHost() - { - $uri = new Uri('http://example.com'); - - $this->assertSame('example.com', $uri->getHost()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getPort - */ - public function testGetPortImplicitHttp() - { - $uri = new Uri('http://example.com'); - - $this->assertSame(80, $uri->getPort()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getPort - */ - public function testGetPortImplicitHttps() - { - $uri = new Uri('https://example.com'); - - $this->assertSame(443, $uri->getPort()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getPort - */ - public function testGetPortExplicit() - { - $uri = new Uri('http://example.com:21'); - - $this->assertSame(21, $uri->getPort()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getPath - */ - public function testGetPathNotSupplied() - { - $uri = new Uri('http://example.com'); - - $this->assertSame('/', $uri->getPath()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getPath - */ - public function testGetPathSlash() - { - $uri = new Uri('http://example.com/'); - - $this->assertSame('/', $uri->getPath()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getPath - */ - public function testGetPath() - { - $uri = new Uri('http://example.com/foo'); - - $this->assertSame('/foo', $uri->getPath()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getQuery - */ - public function testGetQueryWithParams() - { - $uri = new Uri('http://example.com?param1=first¶m2=second'); - - $this->assertSame('param1=first¶m2=second', $uri->getQuery()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getQuery - */ - public function testGetQueryWithoutParams() - { - $uri = new Uri('http://example.com'); - - $this->assertSame('', $uri->getQuery()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getFragment - */ - public function testGetFragmentExists() - { - $uri = new Uri('http://example.com#foo'); - - $this->assertSame('foo', $uri->getFragment()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getFragment - */ - public function testGetFragmentNotExists() - { - $uri = new Uri('http://example.com'); - - $this->assertSame('', $uri->getFragment()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getAuthority - */ - public function testGetAuthorityWithoutUserInfo() - { - $uri = new Uri('http://example.com'); - - $this->assertSame('example.com', $uri->getAuthority()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getAuthority - */ - public function testGetAuthorityWithoutUserInfoWithExplicitPort() - { - $uri = new Uri('http://example.com:21'); - - $this->assertSame('example.com:21', $uri->getAuthority()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setUserInfo - * @covers OAuth\Common\Http\Uri\Uri::protectUserInfo - * @covers OAuth\Common\Http\Uri\Uri::getAuthority - */ - public function testGetAuthorityWithUsernameWithExplicitPort() - { - $uri = new Uri('http://peehaa@example.com:21'); - - $this->assertSame('peehaa@example.com:21', $uri->getAuthority()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setUserInfo - * @covers OAuth\Common\Http\Uri\Uri::protectUserInfo - * @covers OAuth\Common\Http\Uri\Uri::getAuthority - */ - public function testGetAuthorityWithUsernameAndPassWithExplicitPort() - { - $uri = new Uri('http://peehaa:pass@example.com:21'); - - $this->assertSame('peehaa:********@example.com:21', $uri->getAuthority()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setUserInfo - * @covers OAuth\Common\Http\Uri\Uri::protectUserInfo - * @covers OAuth\Common\Http\Uri\Uri::getAuthority - */ - public function testGetAuthorityWithUsernameAndPassWithoutExplicitPort() - { - $uri = new Uri('http://peehaa:pass@example.com'); - - $this->assertSame('peehaa:********@example.com', $uri->getAuthority()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getRawAuthority - */ - public function testGetRawAuthorityWithoutUserInfo() - { - $uri = new Uri('http://example.com'); - - $this->assertSame('example.com', $uri->getRawAuthority()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getRawAuthority - */ - public function testGetRawAuthorityWithoutUserInfoWithExplicitPort() - { - $uri = new Uri('http://example.com:21'); - - $this->assertSame('example.com:21', $uri->getRawAuthority()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setUserInfo - * @covers OAuth\Common\Http\Uri\Uri::protectUserInfo - * @covers OAuth\Common\Http\Uri\Uri::getRawAuthority - */ - public function testGetRawAuthorityWithUsernameWithExplicitPort() - { - $uri = new Uri('http://peehaa@example.com:21'); - - $this->assertSame('peehaa@example.com:21', $uri->getRawAuthority()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setUserInfo - * @covers OAuth\Common\Http\Uri\Uri::protectUserInfo - * @covers OAuth\Common\Http\Uri\Uri::getRawAuthority - */ - public function testGetRawAuthorityWithUsernameAndPassWithExplicitPort() - { - $uri = new Uri('http://peehaa:pass@example.com:21'); - - $this->assertSame('peehaa:pass@example.com:21', $uri->getRawAuthority()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setUserInfo - * @covers OAuth\Common\Http\Uri\Uri::protectUserInfo - * @covers OAuth\Common\Http\Uri\Uri::getRawAuthority - */ - public function testGetRawAuthorityWithUsernameAndPassWithoutExplicitPort() - { - $uri = new Uri('http://peehaa:pass@example.com'); - - $this->assertSame('peehaa:pass@example.com', $uri->getRawAuthority()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testGetAbsoluteUriBare() - { - $uri = new Uri('http://example.com'); - - $this->assertSame('http://example.com', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setUserInfo - * @covers OAuth\Common\Http\Uri\Uri::protectUserInfo - * @covers OAuth\Common\Http\Uri\Uri::getRawAuthority - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testGetAbsoluteUriWithAuthority() - { - $uri = new Uri('http://peehaa:pass@example.com'); - - $this->assertSame('http://peehaa:pass@example.com', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testGetAbsoluteUriWithPath() - { - $uri = new Uri('http://example.com/foo'); - - $this->assertSame('http://example.com/foo', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testGetAbsoluteUriWithoutPath() - { - $uri = new Uri('http://example.com'); - - $this->assertSame('http://example.com', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testGetAbsoluteUriWithoutPathExplicitTrailingSlash() - { - $uri = new Uri('http://example.com/'); - - $this->assertSame('http://example.com/', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testGetAbsoluteUriWithQuery() - { - $uri = new Uri('http://example.com?param1=value1'); - - $this->assertSame('http://example.com?param1=value1', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testGetAbsoluteUriWithFragment() - { - $uri = new Uri('http://example.com#foo'); - - $this->assertSame('http://example.com#foo', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getRelativeUri - */ - public function testGetRelativeUriWithoutPath() - { - $uri = new Uri('http://example.com'); - - $this->assertSame('', $uri->getRelativeUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getRelativeUri - */ - public function testGetRelativeUriWithPath() - { - $uri = new Uri('http://example.com/foo'); - - $this->assertSame('/foo', $uri->getRelativeUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::getRelativeUri - */ - public function testGetRelativeUriWithExplicitTrailingSlash() - { - $uri = new Uri('http://example.com/'); - - $this->assertSame('/', $uri->getRelativeUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::__toString - */ - public function testToStringBare() - { - $uri = new Uri('http://example.com'); - - $this->assertSame('http://example.com', (string) $uri); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setUserInfo - * @covers OAuth\Common\Http\Uri\Uri::protectUserInfo - * @covers OAuth\Common\Http\Uri\Uri::getRawAuthority - * @covers OAuth\Common\Http\Uri\Uri::__toString - */ - public function testToStringWithAuthority() - { - $uri = new Uri('http://peehaa:pass@example.com'); - - $this->assertSame('http://peehaa:********@example.com', (string) $uri); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::__toString - */ - public function testToStringWithPath() - { - $uri = new Uri('http://example.com/foo'); - - $this->assertSame('http://example.com/foo', (string) $uri); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::__toString - */ - public function testToStringWithoutPath() - { - $uri = new Uri('http://example.com'); - - $this->assertSame('http://example.com', (string) $uri); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::__toString - */ - public function testToStringWithoutPathExplicitTrailingSlash() - { - $uri = new Uri('http://example.com/'); - - $this->assertSame('http://example.com/', (string) $uri); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::__toString - */ - public function testToStringWithQuery() - { - $uri = new Uri('http://example.com?param1=value1'); - - $this->assertSame('http://example.com?param1=value1', (string) $uri); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::__toString - */ - public function testToStringWithFragment() - { - $uri = new Uri('http://example.com#foo'); - - $this->assertSame('http://example.com#foo', (string) $uri); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setPath - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testSetPathEmpty() - { - $uri = new Uri('http://example.com'); - $uri->setPath(''); - - $this->assertSame('http://example.com', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setPath - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testSetPathWithPath() - { - $uri = new Uri('http://example.com'); - $uri->setPath('/foo'); - - $this->assertSame('http://example.com/foo', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setPath - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testSetPathWithOnlySlash() - { - $uri = new Uri('http://example.com'); - $uri->setPath('/'); - - $this->assertSame('http://example.com/', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setQuery - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testSetQueryEmpty() - { - $uri = new Uri('http://example.com'); - $uri->setQuery(''); - - $this->assertSame('http://example.com', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setQuery - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testSetQueryFilled() - { - $uri = new Uri('http://example.com'); - $uri->setQuery('param1=value1¶m2=value2'); - - $this->assertSame('http://example.com?param1=value1¶m2=value2', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::addToQuery - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testAddToQueryAppend() - { - $uri = new Uri('http://example.com?param1=value1'); - $uri->addToQuery('param2', 'value2'); - - $this->assertSame('http://example.com?param1=value1¶m2=value2', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::addToQuery - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testAddToQueryCreate() - { - $uri = new Uri('http://example.com'); - $uri->addToQuery('param1', 'value1'); - - $this->assertSame('http://example.com?param1=value1', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setFragment - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testSetFragmentEmpty() - { - $uri = new Uri('http://example.com'); - $uri->setFragment(''); - - $this->assertSame('http://example.com', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setFragment - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testSetFragmentWithData() - { - $uri = new Uri('http://example.com'); - $uri->setFragment('foo'); - - $this->assertSame('http://example.com#foo', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setScheme - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testSetSchemeWithEmpty() - { - $uri = new Uri('http://example.com'); - $uri->setScheme(''); - - $this->assertSame('://example.com', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setScheme - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testSetSchemeWithData() - { - $uri = new Uri('http://example.com'); - $uri->setScheme('foo'); - - $this->assertSame('foo://example.com', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setUserInfo - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testSetUserInfoEmpty() - { - $uri = new Uri('http://example.com'); - $uri->setUserInfo(''); - - $this->assertSame('http://example.com', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setUserInfo - * @covers OAuth\Common\Http\Uri\Uri::protectUserInfo - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testSetUserInfoWithData() - { - $uri = new Uri('http://example.com'); - $uri->setUserInfo('foo:bar'); - - $this->assertSame('http://foo:bar@example.com', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setPort - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testSetPortCustom() - { - $uri = new Uri('http://example.com'); - $uri->setPort('21'); - - $this->assertSame('http://example.com:21', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setPort - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testSetPortHttpImplicit() - { - $uri = new Uri('http://example.com'); - $uri->setPort(80); - - $this->assertSame('http://example.com', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setPort - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testSetPortHttpsImplicit() - { - $uri = new Uri('https://example.com'); - $uri->setPort(443); - - $this->assertSame('https://example.com', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setPort - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testSetPortHttpExplicit() - { - $uri = new Uri('http://example.com'); - $uri->setPort(443); - - $this->assertSame('http://example.com:443', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setPort - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testSetPortHttpsExplicit() - { - $uri = new Uri('https://example.com'); - $uri->setPort(80); - - $this->assertSame('https://example.com:80', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::setHost - * @covers OAuth\Common\Http\Uri\Uri::getAbsoluteUri - */ - public function testSetHost() - { - $uri = new Uri('http://example.com'); - $uri->setHost('pieterhordijk.com'); - - $this->assertSame('http://pieterhordijk.com', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::hasExplicitTrailingHostSlash - */ - public function testHasExplicitTrailingHostSlashTrue() - { - $uri = new Uri('http://example.com/'); - - $this->assertTrue($uri->hasExplicitTrailingHostSlash()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::hasExplicitTrailingHostSlash - */ - public function testHasExplicitTrailingHostSlashFalse() - { - $uri = new Uri('http://example.com/foo'); - - $this->assertFalse($uri->hasExplicitTrailingHostSlash()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::hasExplicitPortSpecified - */ - public function testHasExplicitPortSpecifiedTrue() - { - $uri = new Uri('http://example.com:8080'); - - $this->assertTrue($uri->hasExplicitPortSpecified()); - } - - /** - * @covers OAuth\Common\Http\Uri\Uri::__construct - * @covers OAuth\Common\Http\Uri\Uri::parseUri - * @covers OAuth\Common\Http\Uri\Uri::hasExplicitPortSpecified - */ - public function testHasExplicitPortSpecifiedFalse() - { - $uri = new Uri('http://example.com'); - - $this->assertFalse($uri->hasExplicitPortSpecified()); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/Common/Service/AbstractServiceTest.php b/vendor/lusitanian/oauth/tests/Unit/Common/Service/AbstractServiceTest.php deleted file mode 100644 index 2d8bff46..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/Common/Service/AbstractServiceTest.php +++ /dev/null @@ -1,171 +0,0 @@ -<?php - -namespace OAuthTest\Unit\Common\Service; - -use OAuthTest\Mocks\Common\Service\Mock; - -class AbstractServiceTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\Common\Service\AbstractService::__construct - */ - public function testConstructCorrectInterface() - { - $service = $this->getMockForAbstractClass( - '\\OAuth\\Common\\Service\\AbstractService', - array( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ) - ); - - $this->assertInstanceOf('\\OAuth\\Common\\Service\\ServiceInterface', $service); - } - - /** - * @covers OAuth\Common\Service\AbstractService::__construct - * @covers OAuth\Common\Service\AbstractService::getStorage - */ - public function testGetStorage() - { - $service = $this->getMockForAbstractClass( - '\\OAuth\\Common\\Service\\AbstractService', - array( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ) - ); - - $this->assertInstanceOf('\\OAuth\\Common\\Storage\\TokenStorageInterface', $service->getStorage()); - } - - /** - * @covers OAuth\Common\Service\AbstractService::__construct - * @covers OAuth\Common\Service\AbstractService::service - */ - public function testService() - { - $service = new Mock( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertSame('Mock', $service->service()); - } - - /** - * @covers OAuth\Common\Service\AbstractService::__construct - * @covers OAuth\Common\Service\AbstractService::determineRequestUriFromPath - */ - public function testDetermineRequestUriFromPathUsingUriObject() - { - $service = new Mock( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $this->assertInstanceOf( - '\\OAuth\\Common\\Http\\Uri\\UriInterface', - $service->testDetermineRequestUriFromPath($this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface')) - ); - } - - /** - * @covers OAuth\Common\Service\AbstractService::__construct - * @covers OAuth\Common\Service\AbstractService::determineRequestUriFromPath - */ - public function testDetermineRequestUriFromPathUsingHttpPath() - { - $service = new Mock( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $uri = $service->testDetermineRequestUriFromPath('http://example.com'); - - $this->assertInstanceOf('\\OAuth\\Common\\Http\\Uri\\UriInterface', $uri); - $this->assertSame('http://example.com', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Service\AbstractService::__construct - * @covers OAuth\Common\Service\AbstractService::determineRequestUriFromPath - */ - public function testDetermineRequestUriFromPathUsingHttpsPath() - { - $service = new Mock( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $uri = $service->testDetermineRequestUriFromPath('https://example.com'); - - $this->assertInstanceOf('\\OAuth\\Common\\Http\\Uri\\UriInterface', $uri); - $this->assertSame('https://example.com', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Service\AbstractService::__construct - * @covers OAuth\Common\Service\AbstractService::determineRequestUriFromPath - */ - public function testDetermineRequestUriFromPathThrowsExceptionOnInvalidUri() - { - $this->setExpectedException('\\OAuth\\Common\\Exception\\Exception'); - - $service = new Mock( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $uri = $service->testDetermineRequestUriFromPath('example.com'); - } - - /** - * @covers OAuth\Common\Service\AbstractService::__construct - * @covers OAuth\Common\Service\AbstractService::determineRequestUriFromPath - */ - public function testDetermineRequestUriFromPathWithQueryString() - { - $service = new Mock( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $uri = $service->testDetermineRequestUriFromPath( - 'path?param1=value1', - new \OAuth\Common\Http\Uri\Uri('https://example.com') - ); - - $this->assertInstanceOf('\\OAuth\\Common\\Http\\Uri\\UriInterface', $uri); - $this->assertSame('https://example.com/path?param1=value1', $uri->getAbsoluteUri()); - } - - /** - * @covers OAuth\Common\Service\AbstractService::__construct - * @covers OAuth\Common\Service\AbstractService::determineRequestUriFromPath - */ - public function testDetermineRequestUriFromPathWithLeadingSlashInPath() - { - $service = new Mock( - $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'), - $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'), - $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') - ); - - $uri = $service->testDetermineRequestUriFromPath( - '/path', - new \OAuth\Common\Http\Uri\Uri('https://example.com') - ); - - $this->assertInstanceOf('\\OAuth\\Common\\Http\\Uri\\UriInterface', $uri); - $this->assertSame('https://example.com/path', $uri->getAbsoluteUri()); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/Common/Storage/MemoryTest.php b/vendor/lusitanian/oauth/tests/Unit/Common/Storage/MemoryTest.php deleted file mode 100644 index 93a01a79..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/Common/Storage/MemoryTest.php +++ /dev/null @@ -1,132 +0,0 @@ -<?php - -namespace OAuthTest\Unit\Common\Storage; - -use OAuth\Common\Storage\Memory; - -class MemoryTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\Common\Storage\Memory::__construct - */ - public function testConstructCorrectInterface() - { - $storage = new Memory(); - - $this->assertInstanceOf('\\OAuth\\Common\\Storage\\TokenStorageInterface', $storage); - } - - /** - * @covers OAuth\Common\Storage\Memory::__construct - * @covers OAuth\Common\Storage\Memory::storeAccessToken - */ - public function testStoreAccessToken() - { - $storage = new Memory(); - - $this->assertInstanceOf( - '\\OAuth\\Common\\Storage\\Memory', - $storage->storeAccessToken('foo', $this->getMock('\\OAuth\\Common\\Token\\TokenInterface')) - ); - } - - /** - * @covers OAuth\Common\Storage\Memory::__construct - * @covers OAuth\Common\Storage\Memory::storeAccessToken - * @covers OAuth\Common\Storage\Memory::retrieveAccessToken - * @covers OAuth\Common\Storage\Memory::hasAccessToken - */ - public function testRetrieveAccessTokenValid() - { - $storage = new Memory(); - - $storage->storeAccessToken('foo', $this->getMock('\\OAuth\\Common\\Token\\TokenInterface')); - - $this->assertInstanceOf('\\OAuth\\Common\\Token\\TokenInterface', $storage->retrieveAccessToken('foo')); - } - - /** - * @covers OAuth\Common\Storage\Memory::__construct - * @covers OAuth\Common\Storage\Memory::retrieveAccessToken - * @covers OAuth\Common\Storage\Memory::hasAccessToken - */ - public function testRetrieveAccessTokenThrowsExceptionWhenTokenIsNotFound() - { - $this->setExpectedException('\\OAuth\\Common\\Storage\\Exception\\TokenNotFoundException'); - - $storage = new Memory(); - - $storage->retrieveAccessToken('foo'); - } - - /** - * @covers OAuth\Common\Storage\Memory::__construct - * @covers OAuth\Common\Storage\Memory::storeAccessToken - * @covers OAuth\Common\Storage\Memory::hasAccessToken - */ - public function testHasAccessTokenTrue() - { - $storage = new Memory(); - - $storage->storeAccessToken('foo', $this->getMock('\\OAuth\\Common\\Token\\TokenInterface')); - - $this->assertTrue($storage->hasAccessToken('foo')); - } - - /** - * @covers OAuth\Common\Storage\Memory::__construct - * @covers OAuth\Common\Storage\Memory::hasAccessToken - */ - public function testHasAccessTokenFalse() - { - $storage = new Memory(); - - $this->assertFalse($storage->hasAccessToken('foo')); - } - - /** - * @covers OAuth\Common\Storage\Memory::__construct - * @covers OAuth\Common\Storage\Memory::clearToken - */ - public function testClearTokenIsNotSet() - { - $storage = new Memory(); - - $this->assertInstanceOf('\\OAuth\\Common\\Storage\\Memory', $storage->clearToken('foo')); - } - - /** - * @covers OAuth\Common\Storage\Memory::__construct - * @covers OAuth\Common\Storage\Memory::storeAccessToken - * @covers OAuth\Common\Storage\Memory::clearToken - */ - public function testClearTokenSet() - { - $storage = new Memory(); - - $storage->storeAccessToken('foo', $this->getMock('\\OAuth\\Common\\Token\\TokenInterface')); - - $this->assertTrue($storage->hasAccessToken('foo')); - $this->assertInstanceOf('\\OAuth\\Common\\Storage\\Memory', $storage->clearToken('foo')); - $this->assertFalse($storage->hasAccessToken('foo')); - } - - /** - * @covers OAuth\Common\Storage\Memory::__construct - * @covers OAuth\Common\Storage\Memory::storeAccessToken - * @covers OAuth\Common\Storage\Memory::clearAllTokens - */ - public function testClearAllTokens() - { - $storage = new Memory(); - - $storage->storeAccessToken('foo', $this->getMock('\\OAuth\\Common\\Token\\TokenInterface')); - $storage->storeAccessToken('bar', $this->getMock('\\OAuth\\Common\\Token\\TokenInterface')); - - $this->assertTrue($storage->hasAccessToken('foo')); - $this->assertTrue($storage->hasAccessToken('bar')); - $this->assertInstanceOf('\\OAuth\\Common\\Storage\\Memory', $storage->clearAllTokens()); - $this->assertFalse($storage->hasAccessToken('foo')); - $this->assertFalse($storage->hasAccessToken('bar')); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/Common/Storage/RedisTest.php b/vendor/lusitanian/oauth/tests/Unit/Common/Storage/RedisTest.php deleted file mode 100644 index 83e7a284..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/Common/Storage/RedisTest.php +++ /dev/null @@ -1,102 +0,0 @@ -<?php - -/** - * @category OAuth - * @package Tests - * @author David Desberg <david@daviddesberg.com> - * @copyright Copyright (c) 2012 The authors - * @license http://www.opensource.org/licenses/mit-license.html MIT License - */ - -namespace OAuth\Unit\Common\Storage; - -use OAuth\Common\Storage\Redis; -use Predis\Client as Predis; -use OAuth\OAuth2\Token\StdOAuth2Token; - -class RedisTest extends \PHPUnit_Framework_TestCase -{ - protected $storage; - - public function setUp() - { - // connect to a redis daemon - $predis = new Predis(array( - 'host' => $_ENV['redis_host'], - 'port' => $_ENV['redis_port'], - )); - - // set it - $this->storage = new Redis($predis, 'test_user_token', 'test_user_state'); - - try { - $predis->connect(); - } catch (\Predis\Connection\ConnectionException $e) { - $this->markTestSkipped('No redis instance available: ' . $e->getMessage()); - } - } - - public function tearDown() - { - // delete - $this->storage->clearAllTokens(); - - // close connection - $this->storage->getRedis()->quit(); - } - - /** - * Check that the token gets properly stored. - */ - public function testStorage() - { - // arrange - $service_1 = 'Facebook'; - $service_2 = 'Foursquare'; - - $token_1 = new StdOAuth2Token('access_1', 'refresh_1', StdOAuth2Token::EOL_NEVER_EXPIRES, array('extra' => 'param')); - $token_2 = new StdOAuth2Token('access_2', 'refresh_2', StdOAuth2Token::EOL_NEVER_EXPIRES, array('extra' => 'param')); - - // act - $this->storage->storeAccessToken($service_1, $token_1); - $this->storage->storeAccessToken($service_2, $token_2); - - // assert - $extraParams = $this->storage->retrieveAccessToken($service_1)->getExtraParams(); - $this->assertEquals('param', $extraParams['extra']); - $this->assertEquals($token_1, $this->storage->retrieveAccessToken($service_1)); - $this->assertEquals($token_2, $this->storage->retrieveAccessToken($service_2)); - } - - /** - * Test hasAccessToken. - */ - public function testHasAccessToken() - { - // arrange - $service = 'Facebook'; - $this->storage->clearToken($service); - - // act - // assert - $this->assertFalse($this->storage->hasAccessToken($service)); - } - - /** - * Check that the token gets properly deleted. - */ - public function testStorageClears() - { - // arrange - $service = 'Facebook'; - $token = new StdOAuth2Token('access', 'refresh', StdOAuth2Token::EOL_NEVER_EXPIRES, array('extra' => 'param')); - - // act - $this->storage->storeAccessToken($service, $token); - $this->storage->clearToken($service); - - // assert - $this->setExpectedException('OAuth\Common\Storage\Exception\TokenNotFoundException'); - $this->storage->retrieveAccessToken($service); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/Common/Storage/SessionTest.php b/vendor/lusitanian/oauth/tests/Unit/Common/Storage/SessionTest.php deleted file mode 100644 index 72f38b1a..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/Common/Storage/SessionTest.php +++ /dev/null @@ -1,245 +0,0 @@ -<?php - -namespace OAuthTest\Unit\Common\Storage; - -use OAuth\Common\Storage\Session; - -class SessionTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\Common\Storage\Session::__construct - * - * @runInSeparateProcess - */ - public function testConstructCorrectInterface() - { - $storage = new Session(); - - $this->assertInstanceOf('\\OAuth\\Common\\Storage\\TokenStorageInterface', $storage); - } - - /** - * @covers OAuth\Common\Storage\Session::__construct - * - * @runInSeparateProcess - */ - public function testConstructWithoutStartingSession() - { - session_start(); - - $storage = new Session(false); - - $this->assertInstanceOf('\\OAuth\\Common\\Storage\\TokenStorageInterface', $storage); - } - - /** - * @covers OAuth\Common\Storage\Session::__construct - * - * @runInSeparateProcess - */ - public function testConstructTryingToStartWhileSessionAlreadyExists() - { - session_start(); - - $storage = new Session(); - - $this->assertInstanceOf('\\OAuth\\Common\\Storage\\TokenStorageInterface', $storage); - } - - /** - * @covers OAuth\Common\Storage\Session::__construct - * - * @runInSeparateProcess - */ - public function testConstructWithExistingSessionKey() - { - session_start(); - - $_SESSION['lusitanian_oauth_token'] = array(); - - $storage = new Session(); - - $this->assertInstanceOf('\\OAuth\\Common\\Storage\\TokenStorageInterface', $storage); - } - - /** - * @covers OAuth\Common\Storage\Session::__construct - * @covers OAuth\Common\Storage\Session::storeAccessToken - * - * @runInSeparateProcess - */ - public function testStoreAccessTokenIsAlreadyArray() - { - $storage = new Session(); - - $this->assertInstanceOf( - '\\OAuth\\Common\\Storage\\Session', - $storage->storeAccessToken('foo', $this->getMock('\\OAuth\\Common\\Token\\TokenInterface')) - ); - } - - /** - * @covers OAuth\Common\Storage\Session::__construct - * @covers OAuth\Common\Storage\Session::storeAccessToken - * - * @runInSeparateProcess - */ - public function testStoreAccessTokenIsNotArray() - { - $storage = new Session(); - - $_SESSION['lusitanian_oauth_token'] = 'foo'; - - $this->assertInstanceOf( - '\\OAuth\\Common\\Storage\\Session', - $storage->storeAccessToken('foo', $this->getMock('\\OAuth\\Common\\Token\\TokenInterface')) - ); - } - - /** - * @covers OAuth\Common\Storage\Session::__construct - * @covers OAuth\Common\Storage\Session::storeAccessToken - * @covers OAuth\Common\Storage\Session::retrieveAccessToken - * @covers OAuth\Common\Storage\Session::hasAccessToken - * - * @runInSeparateProcess - */ - public function testRetrieveAccessTokenValid() - { - $storage = new Session(); - - $storage->storeAccessToken('foo', $this->getMock('\\OAuth\\Common\\Token\\TokenInterface')); - - $this->assertInstanceOf('\\OAuth\\Common\\Token\\TokenInterface', $storage->retrieveAccessToken('foo')); - } - - /** - * @covers OAuth\Common\Storage\Session::__construct - * @covers OAuth\Common\Storage\Session::retrieveAccessToken - * @covers OAuth\Common\Storage\Session::hasAccessToken - * - * @runInSeparateProcess - */ - public function testRetrieveAccessTokenThrowsExceptionWhenTokenIsNotFound() - { - $this->setExpectedException('\\OAuth\\Common\\Storage\\Exception\\TokenNotFoundException'); - - $storage = new Session(); - - $storage->retrieveAccessToken('foo'); - } - - /** - * @covers OAuth\Common\Storage\Session::__construct - * @covers OAuth\Common\Storage\Session::storeAccessToken - * @covers OAuth\Common\Storage\Session::hasAccessToken - * - * @runInSeparateProcess - */ - public function testHasAccessTokenTrue() - { - $storage = new Session(); - - $storage->storeAccessToken('foo', $this->getMock('\\OAuth\\Common\\Token\\TokenInterface')); - - $this->assertTrue($storage->hasAccessToken('foo')); - } - - /** - * @covers OAuth\Common\Storage\Session::__construct - * @covers OAuth\Common\Storage\Session::hasAccessToken - * - * @runInSeparateProcess - */ - public function testHasAccessTokenFalse() - { - $storage = new Session(); - - $this->assertFalse($storage->hasAccessToken('foo')); - } - - /** - * @covers OAuth\Common\Storage\Session::__construct - * @covers OAuth\Common\Storage\Session::clearToken - * - * @runInSeparateProcess - */ - public function testClearTokenIsNotSet() - { - $storage = new Session(); - - $this->assertInstanceOf('\\OAuth\\Common\\Storage\\Session', $storage->clearToken('foo')); - } - - /** - * @covers OAuth\Common\Storage\Session::__construct - * @covers OAuth\Common\Storage\Session::storeAccessToken - * @covers OAuth\Common\Storage\Session::clearToken - * - * @runInSeparateProcess - */ - public function testClearTokenSet() - { - $storage = new Session(); - - $storage->storeAccessToken('foo', $this->getMock('\\OAuth\\Common\\Token\\TokenInterface')); - - $this->assertTrue($storage->hasAccessToken('foo')); - $this->assertInstanceOf('\\OAuth\\Common\\Storage\\Session', $storage->clearToken('foo')); - $this->assertFalse($storage->hasAccessToken('foo')); - } - - /** - * @covers OAuth\Common\Storage\Session::__construct - * @covers OAuth\Common\Storage\Session::storeAccessToken - * @covers OAuth\Common\Storage\Session::clearAllTokens - * - * @runInSeparateProcess - */ - public function testClearAllTokens() - { - $storage = new Session(); - - $storage->storeAccessToken('foo', $this->getMock('\\OAuth\\Common\\Token\\TokenInterface')); - $storage->storeAccessToken('bar', $this->getMock('\\OAuth\\Common\\Token\\TokenInterface')); - - $this->assertTrue($storage->hasAccessToken('foo')); - $this->assertTrue($storage->hasAccessToken('bar')); - $this->assertInstanceOf('\\OAuth\\Common\\Storage\\Session', $storage->clearAllTokens()); - $this->assertFalse($storage->hasAccessToken('foo')); - $this->assertFalse($storage->hasAccessToken('bar')); - } - - /** - * @covers OAuth\Common\Storage\Session::__construct - * @covers OAuth\Common\Storage\Session::__destruct - * - * @runInSeparateProcess - */ - public function testDestruct() - { - $storage = new Session(); - - unset($storage); - } - - /** - * @covers OAuth\Common\Storage\Session::storeAccessToken - * @covers OAuth\Common\Storage\Session::retrieveAccessToken - * - * @runInSeparateProcess - */ - public function testSerializeUnserialize() - { - $mock = $this->getMock('\\OAuth\\Common\\Token\\AbstractToken', array('__sleep')); - $mock->expects($this->once()) - ->method('__sleep') - ->will($this->returnValue(array('accessToken'))); - - $storage = new Session(); - $storage->storeAccessToken('foo', $mock); - $retrievedToken = $storage->retrieveAccessToken('foo'); - - $this->assertInstanceOf('\\OAuth\\Common\\Token\\AbstractToken', $retrievedToken); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/Common/Storage/StorageTest.php b/vendor/lusitanian/oauth/tests/Unit/Common/Storage/StorageTest.php deleted file mode 100644 index 3fe19906..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/Common/Storage/StorageTest.php +++ /dev/null @@ -1,74 +0,0 @@ -<?php - -/** - * @category OAuth - * @package Tests - * @author David Desberg <david@daviddesberg.com> - * @author Hannes Van De Vreken <vandevreken.hannes@gmail.com> - * @copyright Copyright (c) 2012 The authors - * @license http://www.opensource.org/licenses/mit-license.html MIT License - */ - -namespace OAuth\Unit\Common\Storage; - -use \OAuth\OAuth2\Token\StdOAuth2Token; - -abstract class StorageTest extends \PHPUnit_Framework_TestCase -{ - protected $storage; - - /** - * Check that the token gets properly stored. - */ - public function testStorage() - { - // arrange - $service_1 = 'Facebook'; - $service_2 = 'Foursquare'; - - $token_1 = new StdOAuth2Token('access_1', 'refresh_1', StdOAuth2Token::EOL_NEVER_EXPIRES, array('extra' => 'param')); - $token_2 = new StdOAuth2Token('access_2', 'refresh_2', StdOAuth2Token::EOL_NEVER_EXPIRES, array('extra' => 'param')); - - // act - $this->storage->storeAccessToken($service_1, $token_1); - $this->storage->storeAccessToken($service_2, $token_2); - - // assert - $extraParams = $this->storage->retrieveAccessToken($service_1)->getExtraParams(); - $this->assertEquals('param', $extraParams['extra']); - $this->assertEquals($token_1, $this->storage->retrieveAccessToken($service_1)); - $this->assertEquals($token_2, $this->storage->retrieveAccessToken($service_2)); - } - - /** - * Test hasAccessToken. - */ - public function testHasAccessToken() - { - // arrange - $service = 'Facebook'; - $this->storage->clearToken($service); - - // act - // assert - $this->assertFalse($this->storage->hasAccessToken($service)); - } - - /** - * Check that the token gets properly deleted. - */ - public function testStorageClears() - { - // arrange - $service = 'Facebook'; - $token = new StdOAuth2Token('access', 'refresh', StdOAuth2Token::EOL_NEVER_EXPIRES, array('extra' => 'param')); - - // act - $this->storage->storeAccessToken($service, $token); - $this->storage->clearToken($service); - - // assert - $this->setExpectedException('OAuth\Common\Storage\Exception\TokenNotFoundException'); - $this->storage->retrieveAccessToken($service); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/Common/Storage/SymfonySessionTest.php b/vendor/lusitanian/oauth/tests/Unit/Common/Storage/SymfonySessionTest.php deleted file mode 100644 index c6434612..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/Common/Storage/SymfonySessionTest.php +++ /dev/null @@ -1,111 +0,0 @@ -<?php - -/** - * @category OAuth - * @package Tests - * @author David Desberg <david@daviddesberg.com> - * @copyright Copyright (c) 2012 The authors - * @license http://www.opensource.org/licenses/mit-license.html MIT License - */ - -namespace OAuth\Unit\Common\Storage; - -use OAuth\Common\Storage\SymfonySession; -use OAuth\OAuth2\Token\StdOAuth2Token; -use Symfony\Component\HttpFoundation\Session\Session; -use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; - -class SymfonySessionTest extends \PHPUnit_Framework_TestCase -{ - protected $session; - - protected $storage; - - public function setUp() - { - // set it - $this->session = new Session(new MockArraySessionStorage()); - $this->storage = new SymfonySession($this->session); - } - - public function tearDown() - { - // delete - $this->storage->getSession()->clear(); - unset($this->storage); - } - - /** - * Check that the token survives the constructor - */ - public function testStorageSurvivesConstructor() - { - $service = 'Facebook'; - $token = new StdOAuth2Token('access', 'refresh', StdOAuth2Token::EOL_NEVER_EXPIRES, array('extra' => 'param')); - - // act - $this->storage->storeAccessToken($service, $token); - $this->storage = null; - $this->storage = new SymfonySession($this->session); - - // assert - $extraParams = $this->storage->retrieveAccessToken($service)->getExtraParams(); - $this->assertEquals('param', $extraParams['extra']); - $this->assertEquals($token, $this->storage->retrieveAccessToken($service)); - } - - /** - * Check that the token gets properly stored. - */ - public function testStorage() - { - // arrange - $service_1 = 'Facebook'; - $service_2 = 'Foursquare'; - - $token_1 = new StdOAuth2Token('access_1', 'refresh_1', StdOAuth2Token::EOL_NEVER_EXPIRES, array('extra' => 'param')); - $token_2 = new StdOAuth2Token('access_2', 'refresh_2', StdOAuth2Token::EOL_NEVER_EXPIRES, array('extra' => 'param')); - - // act - $this->storage->storeAccessToken($service_1, $token_1); - $this->storage->storeAccessToken($service_2, $token_2); - - // assert - $extraParams = $this->storage->retrieveAccessToken($service_1)->getExtraParams(); - $this->assertEquals('param', $extraParams['extra']); - $this->assertEquals($token_1, $this->storage->retrieveAccessToken($service_1)); - $this->assertEquals($token_2, $this->storage->retrieveAccessToken($service_2)); - } - - /** - * Test hasAccessToken. - */ - public function testHasAccessToken() - { - // arrange - $service = 'Facebook'; - $this->storage->clearToken($service); - - // act - // assert - $this->assertFalse($this->storage->hasAccessToken($service)); - } - - /** - * Check that the token gets properly deleted. - */ - public function testStorageClears() - { - // arrange - $service = 'Facebook'; - $token = new StdOAuth2Token('access', 'refresh', StdOAuth2Token::EOL_NEVER_EXPIRES, array('extra' => 'param')); - - // act - $this->storage->storeAccessToken($service, $token); - $this->storage->clearToken($service); - - // assert - $this->setExpectedException('OAuth\Common\Storage\Exception\TokenNotFoundException'); - $this->storage->retrieveAccessToken($service); - } -} diff --git a/vendor/lusitanian/oauth/tests/Unit/Common/Token/AbstractTokenTest.php b/vendor/lusitanian/oauth/tests/Unit/Common/Token/AbstractTokenTest.php deleted file mode 100644 index 54b3bb63..00000000 --- a/vendor/lusitanian/oauth/tests/Unit/Common/Token/AbstractTokenTest.php +++ /dev/null @@ -1,189 +0,0 @@ -<?php - -namespace OAuthTest\Unit\Common\Token; - -use \OAuth\Common\Token\AbstractToken; - -class AbstractTokenTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers OAuth\Common\Token\AbstractToken::__construct - */ - public function testConstructCorrectInterface() - { - $token = $this->getMockForAbstractClass('\\OAuth\\Common\\Token\\AbstractToken'); - - $this->assertInstanceOf('\\OAuth\\Common\\Token\\TokenInterface', $token); - } - - /** - * @covers OAuth\Common\Token\AbstractToken::__construct - * @covers OAuth\Common\Token\AbstractToken::getAccessToken - */ - public function testGetAccessTokenNotSet() - { - $token = $this->getMockForAbstractClass('\\OAuth\\Common\\Token\\AbstractToken'); - - $this->assertNull($token->getAccessToken()); - } - - /** - * @covers OAuth\Common\Token\AbstractToken::__construct - * @covers OAuth\Common\Token\AbstractToken::getAccessToken - */ - public function testGetAccessTokenSet() - { - $token = $this->getMockForAbstractClass('\\OAuth\\Common\\Token\\AbstractToken', array('foo')); - - $this->assertSame('foo', $token->getAccessToken()); - } - - /** - * @covers OAuth\Common\Token\AbstractToken::__construct - * @covers OAuth\Common\Token\AbstractToken::getAccessToken - * @covers OAuth\Common\Token\AbstractToken::setAccessToken - */ - public function testSetAccessToken() - { - $token = $this->getMockForAbstractClass('\\OAuth\\Common\\Token\\AbstractToken'); - - $token->setAccessToken('foo'); - - $this->assertSame('foo', $token->getAccessToken()); - } - - /** - * @covers OAuth\Common\Token\AbstractToken::__construct - * @covers OAuth\Common\Token\AbstractToken::getRefreshToken - */ - public function testGetRefreshToken() - { - $token = $this->getMockForAbstractClass('\\OAuth\\Common\\Token\\AbstractToken'); - - $this->assertNull($token->getRefreshToken()); - } - - /** - * @covers OAuth\Common\Token\AbstractToken::__construct - * @covers OAuth\Common\Token\AbstractToken::getRefreshToken - */ - public function testGetRefreshTokenSet() - { - $token = $this->getMockForAbstractClass('\\OAuth\\Common\\Token\\AbstractToken', array('foo', 'bar')); - - $this->assertSame('bar', $token->getRefreshToken()); - } - - /** - * @covers OAuth\Common\Token\AbstractToken::__construct - * @covers OAuth\Common\Token\AbstractToken::getRefreshToken - * @covers OAuth\Common\Token\AbstractToken::setRefreshToken - */ - public function testSetRefreshToken() - { - $token = $this->getMockForAbstractClass('\\OAuth\\Common\\Token\\AbstractToken'); - - $token->setRefreshToken('foo'); - - $this->assertSame('foo', $token->getRefreshToken()); - } - - /** - * @covers OAuth\Common\Token\AbstractToken::__construct - * @covers OAuth\Common\Token\AbstractToken::getExtraParams - */ - public function testGetExtraParamsNotSet() - { - $token = $this->getMockForAbstractClass('\\OAuth\\Common\\Token\\AbstractToken'); - - $this->assertSame(array(), $token->getExtraParams()); - } - - /** - * @covers OAuth\Common\Token\AbstractToken::__construct - * @covers OAuth\Common\Token\AbstractToken::getExtraParams - */ - public function testGetExtraParamsSet() - { - $token = $this->getMockForAbstractClass('\\OAuth\\Common\\Token\\AbstractToken', array('foo', 'bar', null, array('foo', 'bar'))); - - $this->assertEquals(array('foo', 'bar'), $token->getExtraParams()); - } - - /** - * @covers OAuth\Common\Token\AbstractToken::__construct - * @covers OAuth\Common\Token\AbstractToken::setExtraParams - * @covers OAuth\Common\Token\AbstractToken::getExtraParams - */ - public function testSetExtraParams() - { - $token = $this->getMockForAbstractClass('\\OAuth\\Common\\Token\\AbstractToken'); - - $token->setExtraParams(array('foo', 'bar')); - - $this->assertSame(array('foo', 'bar'), $token->getExtraParams()); - } - - /** - * @covers OAuth\Common\Token\AbstractToken::__construct - * @covers OAuth\Common\Token\AbstractToken::setLifetime - * @covers OAuth\Common\Token\AbstractToken::getEndOfLife - */ - public function testGetEndOfLifeNotSet() - { - $token = $this->getMockForAbstractClass('\\OAuth\\Common\\Token\\AbstractToken'); - - $this->assertSame(AbstractToken::EOL_UNKNOWN, $token->getEndOfLife()); - } - - /** - * @covers OAuth\Common\Token\AbstractToken::__construct - * @covers OAuth\Common\Token\AbstractToken::setLifetime - * @covers OAuth\Common\Token\AbstractToken::getEndOfLife - */ - public function testGetEndOfLifeZero() - { - $token = $this->getMockForAbstractClass('\\OAuth\\Common\\Token\\AbstractToken', array('foo', 'bar', 0)); - - $this->assertSame(AbstractToken::EOL_NEVER_EXPIRES, $token->getEndOfLife()); - } - - /** - * @covers OAuth\Common\Token\AbstractToken::__construct - * @covers OAuth\Common\Token\AbstractToken::setLifetime - * @covers OAuth\Common\Token\AbstractToken::getEndOfLife - */ - public function testGetEndOfLifeNeverExpires() - { - $token = $this->getMockForAbstractClass('\\OAuth\\Common\\Token\\AbstractToken', array('foo', 'bar', AbstractToken::EOL_NEVER_EXPIRES)); - - $this->assertSame(AbstractToken::EOL_NEVER_EXPIRES, $token->getEndOfLife()); - } - - /** - * @covers OAuth\Common\Token\AbstractToken::__construct - * @covers OAuth\Common\Token\AbstractToken::setLifetime - * @covers OAuth\Common\Token\AbstractToken::getEndOfLife - */ - public function testGetEndOfLifeNeverExpiresFiveMinutes() - { - $token = $this->getMockForAbstractClass('\\OAuth\\Common\\Token\\AbstractToken', array('foo', 'bar', 5 * 60)); - - $this->assertSame(time() + (5*60), $token->getEndOfLife()); - } - - /** - * @covers OAuth\Common\Token\AbstractToken::__construct - * @covers OAuth\Common\Token\AbstractToken::setLifetime - * @covers OAuth\Common\Token\AbstractToken::getEndOfLife - * @covers OAuth\Common\Token\AbstractToken::setEndOfLife - */ - public function testSetEndOfLife() - { - $token = $this->getMockForAbstractClass('\\OAuth\\Common\\Token\\AbstractToken'); - - $token->setEndOfLife(10); - - $this->assertSame(10, $token->getEndOfLife()); - } -} |