/**
  * @expectedException \Itkg\Core\Cache\Adapter\Chain\Exception\UnhandledCacheException
  */
 public function testSetUnWorkingAdapters()
 {
     $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->get($data);
 }
Beispiel #2
0
 public function testFirstAdapterNoContainsCache()
 {
     $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(false));
     $secondStub = $this->getMock('Itkg\\Core\\Cache\\Adapter\\Redis', array(), array(array()));
     $secondStub->expects($this->once())->method('get');
     $adapters = array($stub, $secondStub);
     $chain = new \Itkg\Core\Cache\Adapter\Chain($adapters, new \Itkg\Core\Cache\Adapter\Chain\UseAllStrategy());
     $chain->get($data);
 }
Beispiel #3
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();
 }