Example #1
0
 public function testShouldRemoveTheExpiredItem()
 {
     $params = array("dir" => self::storageDir(), WURFL_Configuration_Config::EXPIRATION => 1);
     $storage = new WURFL_Storage_File($params);
     $storage->save("item2", "item2");
     $this->assertEquals("item2", $storage->load("item2"));
     sleep(2);
     $this->assertEquals(null, $storage->load("item2"));
 }
 private function assertCacheAllowed(WURFL_Storage_Base $cache)
 {
     $config = array("dir" => self::storageDir(), WURFL_Configuration_Config::EXPIRATION => 0);
     $storage = new WURFL_Storage_File($config);
     $uncached_storage = new WURFL_Storage_File($config);
     $this->assertTrue($storage->supportsSecondaryCaching());
     $this->assertTrue($storage->validSecondaryCache($cache));
     $storage->setCacheStorage($cache);
     $storage->save("foo", "foo");
     sleep(1);
     // Make sure it's there
     $this->assertEquals("foo", $storage->load("foo"));
     $cache->clear();
     // Check after cache is empty (fall through to file)
     $this->assertEquals("foo", $storage->load("foo"));
     // Remove underlying files
     $uncached_storage->clear();
     // Check cache without file-backing
     $this->assertEquals("foo", $storage->load("foo"));
     // Clear cache
     $cache->clear();
     $this->assertNull($storage->load("foo"));
 }