Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / doctrine / common / tests / Doctrine / Tests / Common / Cache / MemcacheCacheTest.php
1 <?php
2
3 namespace Doctrine\Tests\Common\Cache;
4
5 use Doctrine\Common\Cache\MemcacheCache;
6
7 class MemcacheCacheTest extends CacheTest
8 {
9     private $_memcache;
10
11     public function setUp()
12     {
13         if (extension_loaded('memcache')) {
14             $this->_memcache = new \Memcache;
15             $ok = @$this->_memcache->connect('localhost', 11211);
16             if (!$ok) {
17                 $this->markTestSkipped('The ' . __CLASS__ .' requires the use of memcache');
18             }
19         } else {
20             $this->markTestSkipped('The ' . __CLASS__ .' requires the use of memcache');
21         }
22     }
23
24     public function testNoExpire() {
25         $cache = $this->_getCacheDriver();
26         $cache->save('noexpire', 'value', 0);
27         sleep(1);
28         $this->assertTrue($cache->contains('noexpire'), 'Memcache provider should support no-expire');
29     }
30
31     public function testLongLifetime()
32     {
33         $cache = $this->_getCacheDriver();
34         $cache->save('key', 'value', 30 * 24 * 3600 + 1);
35         $this->assertTrue($cache->contains('key'), 'Memcache provider should support TTL > 30 days');
36     }
37
38     protected function _getCacheDriver()
39     {
40         $driver = new MemcacheCache();
41         $driver->setMemcache($this->_memcache);
42         return $driver;
43     }
44
45 }