/**
  * @expectedException \Exception
  */
 public function testRemoveAllUnWorkingAdapters()
 {
     $data = new \Itkg\Core\Cache\CacheableData('my_key', null, array('values'));
     $adapters = array(new \Itkg\Core\Cache\Adapter\Redis(array('host' => 'localhost', 'port' => 80)));
     $chain = new \Itkg\Core\Cache\Adapter\Chain($adapters);
     $chain->remove($data);
 }
Beispiel #2
0
 public function testGetSetRemoveAndRemoveAll()
 {
     $data = new \Itkg\Core\Cache\CacheableData('my_key', null, array('values'));
     $adapters = array($this->getMock('Itkg\\Core\\Cache\\Adapter\\Redis', array(), array(array())));
     $strategy = $this->getMock('Itkg\\Core\\Cache\\Adapter\\Chain\\UseFirstWorkingStrategy');
     $strategy->expects($this->once())->method('get')->with($adapters, $data);
     $strategy->expects($this->once())->method('set')->with($adapters, $data);
     $strategy->expects($this->once())->method('remove')->with($adapters, $data);
     $strategy->expects($this->once())->method('get')->with($adapters);
     $chain = new \Itkg\Core\Cache\Adapter\Chain($adapters, $strategy);
     $chain->set($data);
     $chain->get($data);
     $chain->remove($data);
     $chain->removeAll();
 }
Beispiel #3
0
 public function testGetSetRemoveAndRemoveAll()
 {
     $data = new \Itkg\Core\Cache\CacheableData('my_key', null, array('values'));
     $stub = $this->getMock('Itkg\\Core\\Cache\\Adapter\\Redis', array(), array(array()));
     $stub->expects($this->once())->method('get')->with($data)->will($this->returnValue('yeah!'));
     $stub->expects($this->once())->method('set')->with($data);
     $stub->expects($this->once())->method('remove')->with($data);
     $stub->expects($this->once())->method('removeAll');
     $secondStub = $this->getMock('Itkg\\Core\\Cache\\Adapter\\Redis', array(), array(array()));
     $secondStub->expects($this->never())->method('get');
     $secondStub->expects($this->once())->method('set');
     $secondStub->expects($this->once())->method('remove')->with($data);
     $secondStub->expects($this->once())->method('removeAll');
     $adapters = array($stub, $secondStub);
     $chain = new \Itkg\Core\Cache\Adapter\Chain($adapters, new \Itkg\Core\Cache\Adapter\Chain\UseAllStrategy());
     $chain->get($data);
     $chain->set($data);
     $chain->remove($data);
     $chain->removeAll();
 }