OAuthUnitCommonStorageStorageTest

The Gravity Forms Salesforce Add-On OAuth Unit Common Storage StorageTest class.

Defined (1)

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

/lib/PHPoAuthLib/tests/Unit/Common/Storage/StorageTest.php  
  1. abstract class StorageTest extends \PHPUnit_Framework_TestCase 
  2. protected $storage; 
  3.  
  4. /** 
  5. * Check that the token gets properly stored. 
  6. */ 
  7. public function testStorage() 
  8. // arrange 
  9. $service_1 = 'Facebook'; 
  10. $service_2 = 'Foursquare'; 
  11.  
  12. $token_1 = new StdOAuth2Token('access_1', 'refresh_1', StdOAuth2Token::EOL_NEVER_EXPIRES, array('extra' => 'param')); 
  13. $token_2 = new StdOAuth2Token('access_2', 'refresh_2', StdOAuth2Token::EOL_NEVER_EXPIRES, array('extra' => 'param')); 
  14.  
  15. // act 
  16. $this->storage->storeAccessToken($service_1, $token_1); 
  17. $this->storage->storeAccessToken($service_2, $token_2); 
  18.  
  19. // assert 
  20. $extraParams = $this->storage->retrieveAccessToken($service_1)->getExtraParams(); 
  21. $this->assertEquals('param', $extraParams['extra']); 
  22. $this->assertEquals($token_1, $this->storage->retrieveAccessToken($service_1)); 
  23. $this->assertEquals($token_2, $this->storage->retrieveAccessToken($service_2)); 
  24.  
  25. /** 
  26. * Test hasAccessToken. 
  27. */ 
  28. public function testHasAccessToken() 
  29. // arrange 
  30. $service = 'Facebook'; 
  31. $this->storage->clearToken($service); 
  32.  
  33. // act 
  34. // assert 
  35. $this->assertFalse($this->storage->hasAccessToken($service)); 
  36.  
  37. /** 
  38. * Check that the token gets properly deleted. 
  39. */ 
  40. public function testStorageClears() 
  41. // arrange 
  42. $service = 'Facebook'; 
  43. $token = new StdOAuth2Token('access', 'refresh', StdOAuth2Token::EOL_NEVER_EXPIRES, array('extra' => 'param')); 
  44.  
  45. // act 
  46. $this->storage->storeAccessToken($service, $token); 
  47. $this->storage->clearToken($service); 
  48.  
  49. // assert 
  50. $this->setExpectedException('OAuth\Common\Storage\Exception\TokenNotFoundException'); 
  51. $this->storage->retrieveAccessToken($service);