19 public $data = array();
24 protected function setUp()
29 $this->callables = array(
30 'contains' =>
function($id, $options = array()) use ($that) {
31 return array_key_exists($id, $that->data);
33 'delete' =>
function($id, $options = array()) use ($that) {
34 unset($that->data[$id]);
37 'fetch' =>
function($id, $options = array()) use ($that) {
38 return array_key_exists($id, $that->data) ? $that->data[$id] :
null;
40 'save' =>
function($id,
$data, $lifeTime, $options = array()) use ($that) {
41 $that->data[$id] =
$data;
46 $this->adapter =
new ClosureCacheAdapter($this->callables);
55 $this->callables =
null;
64 $callables = $this->callables;
65 unset($callables[
'delete']);
76 $this->assertTrue($this->adapter->save(
'test',
'data', 1000));
77 $this->assertEquals(
'data', $this->adapter->fetch(
'test'));
82 $this->adapter->save(
'test',
'data', 1000);
83 $this->assertTrue($this->adapter->contains(
'test'));
84 $this->assertFalse($this->adapter->contains(
'foo'));
89 $this->adapter->save(
'test',
'data', 1000);
90 $this->assertTrue($this->adapter->contains(
'test'));
91 $this->adapter->delete(
'test');
92 $this->assertFalse($this->adapter->contains(
'test'));