public function testKeysGeneratorFailsWhenNotIterable() { $backend = $this->getMockBuilder('Cachet\\Backend')->getMockForAbstractClass(); $cache = new \Cachet\Cache('cache', $backend); $this->setExpectedException('RuntimeException', "This backend does not support iteration"); $keys = iterator_to_array($cache->keys()); }
<?php require __DIR__ . '/../src/Cachet.php'; Cachet::register(); $pdo = new Cachet\Backend\PDO(function () { return new PDO('sqlite:/tmp/db.sqlite'); }); $cachet = new Cachet\Cache('cache', $pdo); echo $cachet->increment('foo');