BaseTest

Copyright 2011 Google Inc.

Defined (1)

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

/vendor/google/apiclient/tests/BaseTest.php  
  1. class BaseTest extends PHPUnit_Framework_TestCase 
  2. const KEY = ""; 
  3. private $token; 
  4. private $memcacheHost; 
  5. private $memcachePort; 
  6.  
  7. public function __construct() 
  8. parent::__construct(); 
  9.  
  10. $this->token = $this->loadToken(); 
  11. $this->memcacheHost = getenv('MEMCACHE_HOST') ? getenv('MEMCACHE_HOST') : null; 
  12. $this->memcachePort = getenv('MEMCACHE_PORT') ? getenv('MEMCACHE_PORT') : null; 
  13.  
  14. public function getClient() 
  15. $client = new Google_Client(); 
  16. $client->setDeveloperKey(self::KEY); 
  17. if (strlen($this->token)) { 
  18. $client->setAccessToken($this->token); 
  19. if (strlen($this->memcacheHost)) { 
  20. $client->setClassConfig('Google_Cache_Memcache', 'host', $this->memcacheHost); 
  21. $client->setClassConfig('Google_Cache_Memcache', 'port', $this->memcachePort); 
  22. return $client; 
  23.  
  24. public function checkToken() 
  25. if (!strlen($this->token)) { 
  26. $this->markTestSkipped("Test requires access token\nrun \"php tests/OAuthHelper.php\""); 
  27. return false; 
  28. return true; 
  29.  
  30. public function loadToken() 
  31. if (file_exists($f = dirname(__FILE__) . DIRECTORY_SEPARATOR . '.accessToken')) { 
  32. $t = file_get_contents($f); 
  33. if ($token = json_decode($t, true)) { 
  34. if ($token['expires_in'] + $token['created'] > time()) { 
  35. return $t;