OAuthTestUnitCommonTokenAbstractTokenTest

The Gravity Forms Salesforce Add-On OAuthTest Unit Common Token AbstractTokenTest class.

Defined (1)

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

/lib/PHPoAuthLib/tests/Unit/Common/Token/AbstractTokenTest.php  
  1. class AbstractTokenTest extends \PHPUnit_Framework_TestCase 
  2. /** 
  3. * @covers OAuth\Common\Token\AbstractToken::__construct 
  4. */ 
  5. public function testConstructCorrectInterface() 
  6. $token = $this->getMockForAbstractClass('\\OAuth\\Common\\Token\\AbstractToken'); 
  7.  
  8. $this->assertInstanceOf('\\OAuth\\Common\\Token\\TokenInterface', $token); 
  9.  
  10. /** 
  11. * @covers OAuth\Common\Token\AbstractToken::__construct 
  12. * @covers OAuth\Common\Token\AbstractToken::getAccessToken 
  13. */ 
  14. public function testGetAccessTokenNotSet() 
  15. $token = $this->getMockForAbstractClass('\\OAuth\\Common\\Token\\AbstractToken'); 
  16.  
  17. $this->assertNull($token->getAccessToken()); 
  18.  
  19. /** 
  20. * @covers OAuth\Common\Token\AbstractToken::__construct 
  21. * @covers OAuth\Common\Token\AbstractToken::getAccessToken 
  22. */ 
  23. public function testGetAccessTokenSet() 
  24. $token = $this->getMockForAbstractClass('\\OAuth\\Common\\Token\\AbstractToken', array('foo')); 
  25.  
  26. $this->assertSame('foo', $token->getAccessToken()); 
  27.  
  28. /** 
  29. * @covers OAuth\Common\Token\AbstractToken::__construct 
  30. * @covers OAuth\Common\Token\AbstractToken::getAccessToken 
  31. * @covers OAuth\Common\Token\AbstractToken::setAccessToken 
  32. */ 
  33. public function testSetAccessToken() 
  34. $token = $this->getMockForAbstractClass('\\OAuth\\Common\\Token\\AbstractToken'); 
  35.  
  36. $token->setAccessToken('foo'); 
  37.  
  38. $this->assertSame('foo', $token->getAccessToken()); 
  39.  
  40. /** 
  41. * @covers OAuth\Common\Token\AbstractToken::__construct 
  42. * @covers OAuth\Common\Token\AbstractToken::getRefreshToken 
  43. */ 
  44. public function testGetRefreshToken() 
  45. $token = $this->getMockForAbstractClass('\\OAuth\\Common\\Token\\AbstractToken'); 
  46.  
  47. $this->assertNull($token->getRefreshToken()); 
  48.  
  49. /** 
  50. * @covers OAuth\Common\Token\AbstractToken::__construct 
  51. * @covers OAuth\Common\Token\AbstractToken::getRefreshToken 
  52. */ 
  53. public function testGetRefreshTokenSet() 
  54. $token = $this->getMockForAbstractClass('\\OAuth\\Common\\Token\\AbstractToken', array('foo', 'bar')); 
  55.  
  56. $this->assertSame('bar', $token->getRefreshToken()); 
  57.  
  58. /** 
  59. * @covers OAuth\Common\Token\AbstractToken::__construct 
  60. * @covers OAuth\Common\Token\AbstractToken::getRefreshToken 
  61. * @covers OAuth\Common\Token\AbstractToken::setRefreshToken 
  62. */ 
  63. public function testSetRefreshToken() 
  64. $token = $this->getMockForAbstractClass('\\OAuth\\Common\\Token\\AbstractToken'); 
  65.  
  66. $token->setRefreshToken('foo'); 
  67.  
  68. $this->assertSame('foo', $token->getRefreshToken()); 
  69.  
  70. /** 
  71. * @covers OAuth\Common\Token\AbstractToken::__construct 
  72. * @covers OAuth\Common\Token\AbstractToken::getExtraParams 
  73. */ 
  74. public function testGetExtraParamsNotSet() 
  75. $token = $this->getMockForAbstractClass('\\OAuth\\Common\\Token\\AbstractToken'); 
  76.  
  77. $this->assertSame(array(), $token->getExtraParams()); 
  78.  
  79. /** 
  80. * @covers OAuth\Common\Token\AbstractToken::__construct 
  81. * @covers OAuth\Common\Token\AbstractToken::getExtraParams 
  82. */ 
  83. public function testGetExtraParamsSet() 
  84. $token = $this->getMockForAbstractClass('\\OAuth\\Common\\Token\\AbstractToken', array('foo', 'bar', null, array('foo', 'bar'))); 
  85.  
  86. $this->assertEquals(array('foo', 'bar'), $token->getExtraParams()); 
  87.  
  88. /** 
  89. * @covers OAuth\Common\Token\AbstractToken::__construct 
  90. * @covers OAuth\Common\Token\AbstractToken::setExtraParams 
  91. * @covers OAuth\Common\Token\AbstractToken::getExtraParams 
  92. */ 
  93. public function testSetExtraParams() 
  94. $token = $this->getMockForAbstractClass('\\OAuth\\Common\\Token\\AbstractToken'); 
  95.  
  96. $token->setExtraParams(array('foo', 'bar')); 
  97.  
  98. $this->assertSame(array('foo', 'bar'), $token->getExtraParams()); 
  99.  
  100. /** 
  101. * @covers OAuth\Common\Token\AbstractToken::__construct 
  102. * @covers OAuth\Common\Token\AbstractToken::setLifetime 
  103. * @covers OAuth\Common\Token\AbstractToken::getEndOfLife 
  104. */ 
  105. public function testGetEndOfLifeNotSet() 
  106. $token = $this->getMockForAbstractClass('\\OAuth\\Common\\Token\\AbstractToken'); 
  107.  
  108. $this->assertSame(AbstractToken::EOL_UNKNOWN, $token->getEndOfLife()); 
  109.  
  110. /** 
  111. * @covers OAuth\Common\Token\AbstractToken::__construct 
  112. * @covers OAuth\Common\Token\AbstractToken::setLifetime 
  113. * @covers OAuth\Common\Token\AbstractToken::getEndOfLife 
  114. */ 
  115. public function testGetEndOfLifeZero() 
  116. $token = $this->getMockForAbstractClass('\\OAuth\\Common\\Token\\AbstractToken', array('foo', 'bar', 0)); 
  117.  
  118. $this->assertSame(AbstractToken::EOL_NEVER_EXPIRES, $token->getEndOfLife()); 
  119.  
  120. /** 
  121. * @covers OAuth\Common\Token\AbstractToken::__construct 
  122. * @covers OAuth\Common\Token\AbstractToken::setLifetime 
  123. * @covers OAuth\Common\Token\AbstractToken::getEndOfLife 
  124. */ 
  125. public function testGetEndOfLifeNeverExpires() 
  126. $token = $this->getMockForAbstractClass('\\OAuth\\Common\\Token\\AbstractToken', array('foo', 'bar', AbstractToken::EOL_NEVER_EXPIRES)); 
  127.  
  128. $this->assertSame(AbstractToken::EOL_NEVER_EXPIRES, $token->getEndOfLife()); 
  129.  
  130. /** 
  131. * @covers OAuth\Common\Token\AbstractToken::__construct 
  132. * @covers OAuth\Common\Token\AbstractToken::setLifetime 
  133. * @covers OAuth\Common\Token\AbstractToken::getEndOfLife 
  134. */ 
  135. public function testGetEndOfLifeNeverExpiresFiveMinutes() 
  136. $token = $this->getMockForAbstractClass('\\OAuth\\Common\\Token\\AbstractToken', array('foo', 'bar', 5 * 60)); 
  137.  
  138. $this->assertSame(time() + (5*60), $token->getEndOfLife()); 
  139.  
  140. /** 
  141. * @covers OAuth\Common\Token\AbstractToken::__construct 
  142. * @covers OAuth\Common\Token\AbstractToken::setLifetime 
  143. * @covers OAuth\Common\Token\AbstractToken::getEndOfLife 
  144. * @covers OAuth\Common\Token\AbstractToken::setEndOfLife 
  145. */ 
  146. public function testSetEndOfLife() 
  147. $token = $this->getMockForAbstractClass('\\OAuth\\Common\\Token\\AbstractToken'); 
  148.  
  149. $token->setEndOfLife(10); 
  150.  
  151. $this->assertSame(10, $token->getEndOfLife());