ZendDataCacheTest.php 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace Doctrine\Tests\Common\Cache;
  3. use Doctrine\Common\Cache\ZendDataCache;
  4. require_once __DIR__ . '/../../TestInit.php';
  5. class ZendDataCacheTest extends \Doctrine\Tests\DoctrineTestCase
  6. {
  7. public function setUp()
  8. {
  9. if (!function_exists('zend_shm_cache_fetch') || (php_sapi_name() != 'apache2handler')) {
  10. $this->markTestSkipped('The ' . __CLASS__ .' requires the use of Zend Data Cache which only works in apache2handler SAPI');
  11. }
  12. }
  13. protected function _getCacheDriver()
  14. {
  15. return new ZendDataCache();
  16. }
  17. public function testBasics()
  18. {
  19. $cache = $this->_getCacheDriver();
  20. // Test save
  21. $cache->save('test_key', 'testing this out');
  22. // Test contains to test that save() worked
  23. $this->assertTrue($cache->contains('test_key'));
  24. // Test fetch
  25. $this->assertEquals('testing this out', $cache->fetch('test_key'));
  26. // Test delete
  27. $cache->save('test_key2', 'test2');
  28. $cache->delete('test_key2');
  29. $this->assertFalse($cache->contains('test_key2'));
  30. }
  31. }