Esempio n. 1
0
 function testReadWrite()
 {
     $key = 'storekey' . time();
     $store = HandsetDetection\HDStore::getInstance();
     $store->setConfig(array('filesdir' => '/tmp'), true);
     $store->write($key, $this->testData);
     $data = $store->read($key);
     $this->assertEquals($this->testData, $data);
     $cache = new HandsetDetection\HDCache();
     $data = $cache->read($key);
     if ($cache->getName() == 'none') {
         $this->assertFalse($data);
     } else {
         $this->assertEquals($this->testData, $data);
     }
     $exists = is_file($store->directory . DIRECTORY_SEPARATOR . "{$key}.json");
     $this->assertTrue($exists);
 }
Esempio n. 2
0
 function testGetName()
 {
     $config = array('cache' => array('memcached' => array('pool' => 'mypool', 'options' => '', 'servers' => array(array('localhost', '11211')))));
     $cache = new HandsetDetection\HDCache($config);
     $this->assertEquals('memcached', $cache->getName());
 }
Esempio n. 3
0
 function testGetName()
 {
     $config = array('cache' => array('apc' => true));
     $cache = new HandsetDetection\HDCache($config);
     $this->assertEquals('apc', $cache->getName());
 }
Esempio n. 4
0
 function testGetName()
 {
     $cache = new HandsetDetection\HDCache();
     $cacheNames = array('apc', 'apcu', 'memcache', 'memcached', 'file', 'none');
     $this->assertContains($cache->getName(), $cacheNames);
 }