ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
RedisHandlerTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the Monolog package.
5  *
6  * (c) Jordi Boggiano <j.boggiano@seld.be>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11 
12 namespace Monolog\Handler;
13 
15 use Monolog\Logger;
17 
19 {
24  {
25  new RedisHandler(new \stdClass(), 'key');
26  }
27 
29  {
30  $redis = $this->getMock('Predis\Client');
31  $this->assertInstanceof('Monolog\Handler\RedisHandler', new RedisHandler($redis, 'key'));
32  }
33 
35  {
36  $redis = $this->getMock('Redis');
37  $this->assertInstanceof('Monolog\Handler\RedisHandler', new RedisHandler($redis, 'key'));
38  }
39 
40  public function testPredisHandle()
41  {
42  $redis = $this->getMock('Predis\Client', array('rpush'));
43 
44  // Predis\Client uses rpush
45  $redis->expects($this->once())
46  ->method('rpush')
47  ->with('key', 'test');
48 
49  $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));
50 
51  $handler = new RedisHandler($redis, 'key');
52  $handler->setFormatter(new LineFormatter("%message%"));
53  $handler->handle($record);
54  }
55 
56  public function testRedisHandle()
57  {
58  $redis = $this->getMock('Redis', array('rpush'));
59 
60  // Redis uses rPush
61  $redis->expects($this->once())
62  ->method('rPush')
63  ->with('key', 'test');
64 
65  $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));
66 
67  $handler = new RedisHandler($redis, 'key');
68  $handler->setFormatter(new LineFormatter("%message%"));
69  $handler->handle($record);
70  }
71 }
testConstructorShouldThrowExceptionForInvalidRedis()
InvalidArgumentException
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19
Logs to a Redis key using rpush.
const WARNING
Exceptional occurrences that are not errors.
Definition: Logger.php:52
Formats incoming records into a one-line string.