public function testRedisHandle() { $redis = $this->getMock('Redis', array('rpush')); // Redis uses rPush $redis->expects($this->once())->method('rPush')->with('key', 'test'); $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass(), 'foo' => 34)); $handler = new RedisHandler($redis, 'key'); $handler->setFormatter(new LineFormatter("%message%")); $handler->handle($record); }
public function testPredisHandleCapped() { $redis = $this->getMock('Predis\\Client', array('transaction')); $redisTransaction = $this->getMock('Predis\\Client', array('rpush', 'ltrim')); $redisTransaction->expects($this->once())->method('rpush')->will($this->returnSelf()); $redisTransaction->expects($this->once())->method('ltrim')->will($this->returnSelf()); // Redis uses multi $redis->expects($this->once())->method('transaction')->will($this->returnCallback(function ($cb) use($redisTransaction) { $cb($redisTransaction); })); $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass(), 'foo' => 34)); $handler = new RedisHandler($redis, 'key', Logger::DEBUG, true, 10); $handler->setFormatter(new LineFormatter("%message%")); $handler->handle($record); }