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); }
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()); }
function testGetName() { $config = array('cache' => array('apc' => true)); $cache = new HandsetDetection\HDCache($config); $this->assertEquals('apc', $cache->getName()); }
function testGetName() { $cache = new HandsetDetection\HDCache(); $cacheNames = array('apc', 'apcu', 'memcache', 'memcached', 'file', 'none'); $this->assertContains($cache->getName(), $cacheNames); }