public function setMicrotime($microtime)
{
try {
$data = DoublePacker::pack($microtime);
if (!$this->redis->set($this->key, $data)) {
throw new StorageException("Failed to store microtime");
}
} catch (RedisException $e) {
throw new StorageException("Failed to store microtime", 0, $e);
}
}
/** * Tests setMicrotime() fails. * * @test * @expectedException bandwidthThrottle\tokenBucket\storage\StorageException */ public function testSetMicrotimeFails() { $redis = $this->getMock(Redis::class); $redis->expects($this->once())->method("set")->willReturn(false); $storage = new PHPRedisStorage("test", $redis); $storage->setMicrotime(1); }