diff options
author | Frédéric Guillot <fred@kanboard.net> | 2014-11-06 06:41:47 -0500 |
---|---|---|
committer | Frédéric Guillot <fred@kanboard.net> | 2014-11-06 06:41:47 -0500 |
commit | c80c15dcc33a70acc2b177691d33f088f8c2541e (patch) | |
tree | bc3e44e35b97b751c145cc5797a0faf356922244 /vendor/lusitanian/oauth/tests/Unit/Common/Service/AbstractServiceTest.php | |
parent | c91ff61cdfa8b5eb76783927e5b8710f2a9f2601 (diff) |
Include all vendor files in the repo to be easier for people
Diffstat (limited to 'vendor/lusitanian/oauth/tests/Unit/Common/Service/AbstractServiceTest.php')
-rw-r--r-- | vendor/lusitanian/oauth/tests/Unit/Common/Service/AbstractServiceTest.php | 171 |
1 files changed, 171 insertions, 0 deletions
diff --git a/vendor/lusitanian/oauth/tests/Unit/Common/Service/AbstractServiceTest.php b/vendor/lusitanian/oauth/tests/Unit/Common/Service/AbstractServiceTest.php new file mode 100644 index 00000000..2d8bff46 --- /dev/null +++ b/vendor/lusitanian/oauth/tests/Unit/Common/Service/AbstractServiceTest.php @@ -0,0 +1,171 @@ +<?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()); + } +} |