ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Monolog\Handler\RedisHandlerTest Class Reference
+ Inheritance diagram for Monolog\Handler\RedisHandlerTest:
+ Collaboration diagram for Monolog\Handler\RedisHandlerTest:

Public Member Functions

 testConstructorShouldThrowExceptionForInvalidRedis ()
 InvalidArgumentException More...
 
 testConstructorShouldWorkWithPredis ()
 
 testConstructorShouldWorkWithRedis ()
 
 testPredisHandle ()
 
 testRedisHandle ()
 
 testRedisHandleCapped ()
 
 testPredisHandleCapped ()
 

Additional Inherited Members

- Protected Member Functions inherited from Monolog\TestCase
 getRecord ($level=Logger::WARNING, $message='test', $context=array())
 
 getMultipleRecords ()
 
 getIdentityFormatter ()
 

Detailed Description

Definition at line 18 of file RedisHandlerTest.php.

Member Function Documentation

◆ testConstructorShouldThrowExceptionForInvalidRedis()

Monolog\Handler\RedisHandlerTest::testConstructorShouldThrowExceptionForInvalidRedis ( )

InvalidArgumentException

Definition at line 23 of file RedisHandlerTest.php.

24  {
25  new RedisHandler(new \stdClass(), 'key');
26  }

◆ testConstructorShouldWorkWithPredis()

Monolog\Handler\RedisHandlerTest::testConstructorShouldWorkWithPredis ( )

Definition at line 28 of file RedisHandlerTest.php.

29  {
30  $redis = $this->getMock('Predis\Client');
31  $this->assertInstanceof('Monolog\Handler\RedisHandler', new RedisHandler($redis, 'key'));
32  }

◆ testConstructorShouldWorkWithRedis()

Monolog\Handler\RedisHandlerTest::testConstructorShouldWorkWithRedis ( )

Definition at line 34 of file RedisHandlerTest.php.

35  {
36  $redis = $this->getMock('Redis');
37  $this->assertInstanceof('Monolog\Handler\RedisHandler', new RedisHandler($redis, 'key'));
38  }

◆ testPredisHandle()

Monolog\Handler\RedisHandlerTest::testPredisHandle ( )

Definition at line 40 of file RedisHandlerTest.php.

References $handler, Monolog\TestCase\getRecord(), Sabre\Event\once(), and Monolog\Logger\WARNING.

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  }
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.
const WARNING
Exceptional occurrences that are not errors.
Definition: Logger.php:53
$handler
+ Here is the call graph for this function:

◆ testPredisHandleCapped()

Monolog\Handler\RedisHandlerTest::testPredisHandleCapped ( )

Definition at line 100 of file RedisHandlerTest.php.

References $handler, Monolog\Logger\DEBUG, Monolog\TestCase\getRecord(), Sabre\Event\once(), and Monolog\Logger\WARNING.

101  {
102  $redis = $this->getMock('Predis\Client', array('transaction'));
103 
104  $redisTransaction = $this->getMock('Predis\Client', array('rpush', 'ltrim'));
105 
106  $redisTransaction->expects($this->once())
107  ->method('rpush')
108  ->will($this->returnSelf());
109 
110  $redisTransaction->expects($this->once())
111  ->method('ltrim')
112  ->will($this->returnSelf());
113 
114  // Redis uses multi
115  $redis->expects($this->once())
116  ->method('transaction')
117  ->will($this->returnCallback(function ($cb) use ($redisTransaction) {
118  $cb($redisTransaction);
119  }));
120 
121  $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));
122 
123  $handler = new RedisHandler($redis, 'key', Logger::DEBUG, true, 10);
124  $handler->setFormatter(new LineFormatter("%message%"));
125  $handler->handle($record);
126  }
const DEBUG
Detailed debug information.
Definition: Logger.php:33
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.
const WARNING
Exceptional occurrences that are not errors.
Definition: Logger.php:53
$handler
+ Here is the call graph for this function:

◆ testRedisHandle()

Monolog\Handler\RedisHandlerTest::testRedisHandle ( )

Definition at line 56 of file RedisHandlerTest.php.

References $handler, Monolog\TestCase\getRecord(), Sabre\Event\once(), and Monolog\Logger\WARNING.

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  }
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.
const WARNING
Exceptional occurrences that are not errors.
Definition: Logger.php:53
$handler
+ Here is the call graph for this function:

◆ testRedisHandleCapped()

Monolog\Handler\RedisHandlerTest::testRedisHandleCapped ( )

Definition at line 72 of file RedisHandlerTest.php.

References $handler, Monolog\Logger\DEBUG, Monolog\TestCase\getRecord(), Sabre\Event\once(), and Monolog\Logger\WARNING.

73  {
74  $redis = $this->getMock('Redis', array('multi', 'rpush', 'ltrim', 'exec'));
75 
76  // Redis uses multi
77  $redis->expects($this->once())
78  ->method('multi')
79  ->will($this->returnSelf());
80 
81  $redis->expects($this->once())
82  ->method('rpush')
83  ->will($this->returnSelf());
84 
85  $redis->expects($this->once())
86  ->method('ltrim')
87  ->will($this->returnSelf());
88 
89  $redis->expects($this->once())
90  ->method('exec')
91  ->will($this->returnSelf());
92 
93  $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34));
94 
95  $handler = new RedisHandler($redis, 'key', Logger::DEBUG, true, 10);
96  $handler->setFormatter(new LineFormatter("%message%"));
97  $handler->handle($record);
98  }
const DEBUG
Detailed debug information.
Definition: Logger.php:33
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.
const WARNING
Exceptional occurrences that are not errors.
Definition: Logger.php:53
$handler
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: