OAuthTestUnitCommonServiceAbstractServiceTest

The Gravity Forms Salesforce Add-On OAuthTest Unit Common Service AbstractServiceTest class.

Defined (1)

The class is defined in the following location(s).

/lib/PHPoAuthLib/tests/Unit/Common/Service/AbstractServiceTest.php  
  1. class AbstractServiceTest extends \PHPUnit_Framework_TestCase 
  2. /** 
  3. * @covers OAuth\Common\Service\AbstractService::__construct 
  4. */ 
  5. public function testConstructCorrectInterface() 
  6. $service = $this->getMockForAbstractClass( 
  7. '\\OAuth\\Common\\Service\\AbstractService',  
  8. array( 
  9. $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),  
  10. $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'),  
  11. $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') 
  12. ); 
  13.  
  14. $this->assertInstanceOf('\\OAuth\\Common\\Service\\ServiceInterface', $service); 
  15.  
  16. /** 
  17. * @covers OAuth\Common\Service\AbstractService::__construct 
  18. * @covers OAuth\Common\Service\AbstractService::getStorage 
  19. */ 
  20. public function testGetStorage() 
  21. $service = $this->getMockForAbstractClass( 
  22. '\\OAuth\\Common\\Service\\AbstractService',  
  23. array( 
  24. $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),  
  25. $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'),  
  26. $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') 
  27. ); 
  28.  
  29. $this->assertInstanceOf('\\OAuth\\Common\\Storage\\TokenStorageInterface', $service->getStorage()); 
  30.  
  31. /** 
  32. * @covers OAuth\Common\Service\AbstractService::__construct 
  33. * @covers OAuth\Common\Service\AbstractService::service 
  34. */ 
  35. public function testService() 
  36. $service = new Mock( 
  37. $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),  
  38. $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'),  
  39. $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') 
  40. ); 
  41.  
  42. $this->assertSame('Mock', $service->service()); 
  43.  
  44. /** 
  45. * @covers OAuth\Common\Service\AbstractService::__construct 
  46. * @covers OAuth\Common\Service\AbstractService::determineRequestUriFromPath 
  47. */ 
  48. public function testDetermineRequestUriFromPathUsingUriObject() 
  49. $service = new Mock( 
  50. $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),  
  51. $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'),  
  52. $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') 
  53. ); 
  54.  
  55. $this->assertInstanceOf( 
  56. '\\OAuth\\Common\\Http\\Uri\\UriInterface',  
  57. $service->testDetermineRequestUriFromPath($this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface')) 
  58. ); 
  59.  
  60. /** 
  61. * @covers OAuth\Common\Service\AbstractService::__construct 
  62. * @covers OAuth\Common\Service\AbstractService::determineRequestUriFromPath 
  63. */ 
  64. public function testDetermineRequestUriFromPathUsingHttpPath() 
  65. $service = new Mock( 
  66. $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),  
  67. $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'),  
  68. $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') 
  69. ); 
  70.  
  71. $uri = $service->testDetermineRequestUriFromPath('http://example.com'); 
  72.  
  73. $this->assertInstanceOf('\\OAuth\\Common\\Http\\Uri\\UriInterface', $uri); 
  74. $this->assertSame('http://example.com', $uri->getAbsoluteUri()); 
  75.  
  76. /** 
  77. * @covers OAuth\Common\Service\AbstractService::__construct 
  78. * @covers OAuth\Common\Service\AbstractService::determineRequestUriFromPath 
  79. */ 
  80. public function testDetermineRequestUriFromPathUsingHttpsPath() 
  81. $service = new Mock( 
  82. $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),  
  83. $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'),  
  84. $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') 
  85. ); 
  86.  
  87. $uri = $service->testDetermineRequestUriFromPath('https://example.com'); 
  88.  
  89. $this->assertInstanceOf('\\OAuth\\Common\\Http\\Uri\\UriInterface', $uri); 
  90. $this->assertSame('https://example.com', $uri->getAbsoluteUri()); 
  91.  
  92. /** 
  93. * @covers OAuth\Common\Service\AbstractService::__construct 
  94. * @covers OAuth\Common\Service\AbstractService::determineRequestUriFromPath 
  95. */ 
  96. public function testDetermineRequestUriFromPathThrowsExceptionOnInvalidUri() 
  97. $this->setExpectedException('\\OAuth\\Common\\Exception\\Exception'); 
  98.  
  99. $service = new Mock( 
  100. $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),  
  101. $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'),  
  102. $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') 
  103. ); 
  104.  
  105. $uri = $service->testDetermineRequestUriFromPath('example.com'); 
  106.  
  107. /** 
  108. * @covers OAuth\Common\Service\AbstractService::__construct 
  109. * @covers OAuth\Common\Service\AbstractService::determineRequestUriFromPath 
  110. */ 
  111. public function testDetermineRequestUriFromPathWithQueryString() 
  112. $service = new Mock( 
  113. $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),  
  114. $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'),  
  115. $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') 
  116. ); 
  117.  
  118. $uri = $service->testDetermineRequestUriFromPath( 
  119. 'path?param1=value1',  
  120. new \OAuth\Common\Http\Uri\Uri('https://example.com') 
  121. ); 
  122.  
  123. $this->assertInstanceOf('\\OAuth\\Common\\Http\\Uri\\UriInterface', $uri); 
  124. $this->assertSame('https://example.com/path?param1=value1', $uri->getAbsoluteUri()); 
  125.  
  126. /** 
  127. * @covers OAuth\Common\Service\AbstractService::__construct 
  128. * @covers OAuth\Common\Service\AbstractService::determineRequestUriFromPath 
  129. */ 
  130. public function testDetermineRequestUriFromPathWithLeadingSlashInPath() 
  131. $service = new Mock( 
  132. $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),  
  133. $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'),  
  134. $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface') 
  135. ); 
  136.  
  137. $uri = $service->testDetermineRequestUriFromPath( 
  138. '/path',  
  139. new \OAuth\Common\Http\Uri\Uri('https://example.com') 
  140. ); 
  141.  
  142. $this->assertInstanceOf('\\OAuth\\Common\\Http\\Uri\\UriInterface', $uri); 
  143. $this->assertSame('https://example.com/path', $uri->getAbsoluteUri());