CacheTest

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.

Defined (1)

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

/vendor/google/apiclient/tests/general/CacheTest.php  
  1. class CacheTest extends BaseTest 
  2. public function testFile() 
  3. $dir = sys_get_temp_dir() . '/google-api-php-client/tests'; 
  4. $client = $this->getClient(); 
  5. $client->setClassConfig( 
  6. 'Google_Cache_File',  
  7. 'directory',  
  8. $dir 
  9. ); 
  10. $cache = new Google_Cache_File($client); 
  11. $cache->set('foo', 'bar'); 
  12. $this->assertEquals($cache->get('foo'), 'bar'); 
  13.  
  14. $this->getSetDelete($cache); 
  15.  
  16. /** 
  17. * @requires extension Memcache 
  18. */ 
  19. public function testNull() 
  20. $client = $this->getClient(); 
  21. $cache = new Google_Cache_Null($client); 
  22. $client->setCache($cache); 
  23.  
  24. $cache->set('foo', 'bar'); 
  25. $cache->delete('foo'); 
  26. $this->assertEquals(false, $cache->get('foo')); 
  27.  
  28. $cache->set('foo.1', 'bar.1'); 
  29. $this->assertEquals($cache->get('foo.1'), false); 
  30.  
  31. $cache->set('foo', 'baz'); 
  32. $this->assertEquals($cache->get('foo'), false); 
  33.  
  34. $cache->set('foo', null); 
  35. $cache->delete('foo'); 
  36. $this->assertEquals($cache->get('foo'), false); 
  37.  
  38. /** 
  39. * @requires extension Memcache 
  40. */ 
  41. public function testMemcache() 
  42. $client = $this->getClient(); 
  43. if (!$client->getClassConfig('Google_Cache_Memcache', 'host')) { 
  44. $this->markTestSkipped('Test requires memcache host specified'); 
  45.  
  46. $cache = new Google_Cache_Memcache($client); 
  47.  
  48. $this->getSetDelete($cache); 
  49.  
  50. /** 
  51. * @requires extension APC 
  52. */ 
  53. public function testAPC() 
  54. if (!ini_get('apc.enable_cli')) { 
  55. $this->markTestSkipped('Test requires APC enabled for CLI'); 
  56. $client = $this->getClient(); 
  57. $cache = new Google_Cache_Apc($client); 
  58.  
  59. $this->getSetDelete($cache); 
  60.  
  61. public function getSetDelete($cache) 
  62. $cache->set('foo', 'bar'); 
  63. $cache->delete('foo'); 
  64. $this->assertEquals(false, $cache->get('foo')); 
  65.  
  66. $cache->set('foo.1', 'bar.1'); 
  67. $cache->delete('foo.1'); 
  68. $this->assertEquals($cache->get('foo.1'), false); 
  69.  
  70. $cache->set('foo', 'baz'); 
  71. $cache->delete('foo'); 
  72. $this->assertEquals($cache->get('foo'), false); 
  73.  
  74. $cache->set('foo', null); 
  75. $cache->delete('foo'); 
  76. $this->assertEquals($cache->get('foo'), false); 
  77.  
  78. $obj = new stdClass(); 
  79. $obj->foo = 'bar'; 
  80. $cache->set('foo', $obj); 
  81. $cache->delete('foo'); 
  82. $this->assertEquals($cache->get('foo'), false); 
  83.  
  84. $cache->set('foo.1', 'bar.1'); 
  85. $this->assertEquals($cache->get('foo.1'), 'bar.1'); 
  86.  
  87. $cache->set('foo', 'baz'); 
  88. $this->assertEquals($cache->get('foo'), 'baz'); 
  89.  
  90. $cache->set('foo', null); 
  91. $this->assertEquals($cache->get('foo'), null); 
  92.  
  93. $cache->set('1/2/3', 'bar'); 
  94. $this->assertEquals($cache->get('1/2/3'), 'bar'); 
  95.  
  96. $obj = new stdClass(); 
  97. $obj->foo = 'bar'; 
  98. $cache->set('foo', $obj); 
  99. $this->assertEquals($cache->get('foo'), $obj);