OAuthTestUnitCommonStorageMemoryTest

The Gravity Forms Salesforce Add-On OAuthTest Unit Common Storage MemoryTest class.

Defined (1)

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

/lib/PHPoAuthLib/tests/Unit/Common/Storage/MemoryTest.php  
  1. class MemoryTest extends \PHPUnit_Framework_TestCase 
  2. /** 
  3. * @covers OAuth\Common\Storage\Memory::__construct 
  4. */ 
  5. public function testConstructCorrectInterface() 
  6. $storage = new Memory(); 
  7.  
  8. $this->assertInstanceOf('\\OAuth\\Common\\Storage\\TokenStorageInterface', $storage); 
  9.  
  10. /** 
  11. * @covers OAuth\Common\Storage\Memory::__construct 
  12. * @covers OAuth\Common\Storage\Memory::storeAccessToken 
  13. */ 
  14. public function testStoreAccessToken() 
  15. $storage = new Memory(); 
  16.  
  17. $this->assertInstanceOf( 
  18. '\\OAuth\\Common\\Storage\\Memory',  
  19. $storage->storeAccessToken('foo', $this->getMock('\\OAuth\\Common\\Token\\TokenInterface')) 
  20. ); 
  21.  
  22. /** 
  23. * @covers OAuth\Common\Storage\Memory::__construct 
  24. * @covers OAuth\Common\Storage\Memory::storeAccessToken 
  25. * @covers OAuth\Common\Storage\Memory::retrieveAccessToken 
  26. * @covers OAuth\Common\Storage\Memory::hasAccessToken 
  27. */ 
  28. public function testRetrieveAccessTokenValid() 
  29. $storage = new Memory(); 
  30.  
  31. $storage->storeAccessToken('foo', $this->getMock('\\OAuth\\Common\\Token\\TokenInterface')); 
  32.  
  33. $this->assertInstanceOf('\\OAuth\\Common\\Token\\TokenInterface', $storage->retrieveAccessToken('foo')); 
  34.  
  35. /** 
  36. * @covers OAuth\Common\Storage\Memory::__construct 
  37. * @covers OAuth\Common\Storage\Memory::retrieveAccessToken 
  38. * @covers OAuth\Common\Storage\Memory::hasAccessToken 
  39. */ 
  40. public function testRetrieveAccessTokenThrowsExceptionWhenTokenIsNotFound() 
  41. $this->setExpectedException('\\OAuth\\Common\\Storage\\Exception\\TokenNotFoundException'); 
  42.  
  43. $storage = new Memory(); 
  44.  
  45. $storage->retrieveAccessToken('foo'); 
  46.  
  47. /** 
  48. * @covers OAuth\Common\Storage\Memory::__construct 
  49. * @covers OAuth\Common\Storage\Memory::storeAccessToken 
  50. * @covers OAuth\Common\Storage\Memory::hasAccessToken 
  51. */ 
  52. public function testHasAccessTokenTrue() 
  53. $storage = new Memory(); 
  54.  
  55. $storage->storeAccessToken('foo', $this->getMock('\\OAuth\\Common\\Token\\TokenInterface')); 
  56.  
  57. $this->assertTrue($storage->hasAccessToken('foo')); 
  58.  
  59. /** 
  60. * @covers OAuth\Common\Storage\Memory::__construct 
  61. * @covers OAuth\Common\Storage\Memory::hasAccessToken 
  62. */ 
  63. public function testHasAccessTokenFalse() 
  64. $storage = new Memory(); 
  65.  
  66. $this->assertFalse($storage->hasAccessToken('foo')); 
  67.  
  68. /** 
  69. * @covers OAuth\Common\Storage\Memory::__construct 
  70. * @covers OAuth\Common\Storage\Memory::clearToken 
  71. */ 
  72. public function testClearTokenIsNotSet() 
  73. $storage = new Memory(); 
  74.  
  75. $this->assertInstanceOf('\\OAuth\\Common\\Storage\\Memory', $storage->clearToken('foo')); 
  76.  
  77. /** 
  78. * @covers OAuth\Common\Storage\Memory::__construct 
  79. * @covers OAuth\Common\Storage\Memory::storeAccessToken 
  80. * @covers OAuth\Common\Storage\Memory::clearToken 
  81. */ 
  82. public function testClearTokenSet() 
  83. $storage = new Memory(); 
  84.  
  85. $storage->storeAccessToken('foo', $this->getMock('\\OAuth\\Common\\Token\\TokenInterface')); 
  86.  
  87. $this->assertTrue($storage->hasAccessToken('foo')); 
  88. $this->assertInstanceOf('\\OAuth\\Common\\Storage\\Memory', $storage->clearToken('foo')); 
  89. $this->assertFalse($storage->hasAccessToken('foo')); 
  90.  
  91. /** 
  92. * @covers OAuth\Common\Storage\Memory::__construct 
  93. * @covers OAuth\Common\Storage\Memory::storeAccessToken 
  94. * @covers OAuth\Common\Storage\Memory::clearAllTokens 
  95. */ 
  96. public function testClearAllTokens() 
  97. $storage = new Memory(); 
  98.  
  99. $storage->storeAccessToken('foo', $this->getMock('\\OAuth\\Common\\Token\\TokenInterface')); 
  100. $storage->storeAccessToken('bar', $this->getMock('\\OAuth\\Common\\Token\\TokenInterface')); 
  101.  
  102. $this->assertTrue($storage->hasAccessToken('foo')); 
  103. $this->assertTrue($storage->hasAccessToken('bar')); 
  104. $this->assertInstanceOf('\\OAuth\\Common\\Storage\\Memory', $storage->clearAllTokens()); 
  105. $this->assertFalse($storage->hasAccessToken('foo')); 
  106. $this->assertFalse($storage->hasAccessToken('bar'));