ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Monolog\Handler\RavenHandlerTest Class Reference
+ Inheritance diagram for Monolog\Handler\RavenHandlerTest:
+ Collaboration diagram for Monolog\Handler\RavenHandlerTest:

Public Member Functions

 setUp ()
 
 testConstruct ()
 @covers Monolog\Handler\RavenHandler::__construct More...
 
 testDebug ()
 
 testWarning ()
 
 testTag ()
 
 testExtraParameters ()
 
 testFingerprint ()
 
 testUserContext ()
 
 testException ()
 
 testHandleBatch ()
 
 testHandleBatchDoNothingIfRecordsAreBelowLevel ()
 
 testGetSetBatchFormatter ()
 
 testRelease ()
 

Protected Member Functions

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

Private Member Functions

 methodThatThrowsAnException ()
 

Detailed Description

Definition at line 18 of file RavenHandlerTest.php.

Member Function Documentation

◆ getHandler()

◆ getRavenClient()

◆ methodThatThrowsAnException()

Monolog\Handler\RavenHandlerTest::methodThatThrowsAnException ( )
private

Definition at line 223 of file RavenHandlerTest.php.

224 {
225 throw new \Exception('This is an exception');
226 }

Referenced by Monolog\Handler\RavenHandlerTest\testException().

+ Here is the caller graph for this function:

◆ setUp()

Monolog\Handler\RavenHandlerTest::setUp ( )

Definition at line 20 of file RavenHandlerTest.php.

21 {
22 if (!class_exists('Raven_Client')) {
23 $this->markTestSkipped('raven/raven not installed');
24 }
25
26 require_once __DIR__ . '/MockRavenClient.php';
27 }

◆ testConstruct()

Monolog\Handler\RavenHandlerTest::testConstruct ( )

@covers Monolog\Handler\RavenHandler::__construct

Definition at line 32 of file RavenHandlerTest.php.

33 {
34 $handler = new RavenHandler($this->getRavenClient());
35 $this->assertInstanceOf('Monolog\Handler\RavenHandler', $handler);
36 }

References $handler, and Monolog\Handler\RavenHandlerTest\getRavenClient().

+ Here is the call graph for this function:

◆ testDebug()

Monolog\Handler\RavenHandlerTest::testDebug ( )

Definition at line 52 of file RavenHandlerTest.php.

53 {
54 $ravenClient = $this->getRavenClient();
55 $handler = $this->getHandler($ravenClient);
56
57 $record = $this->getRecord(Logger::DEBUG, 'A test debug message');
58 $handler->handle($record);
59
60 $this->assertEquals($ravenClient::DEBUG, $ravenClient->lastData['level']);
61 $this->assertContains($record['message'], $ravenClient->lastData['message']);
62 }
const DEBUG
Detailed debug information.
Definition: Logger.php:32
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19
const DEBUG

References $handler, Monolog\Logger\DEBUG, DEBUG, Monolog\Handler\RavenHandlerTest\getHandler(), Monolog\Handler\RavenHandlerTest\getRavenClient(), and Monolog\TestCase\getRecord().

+ Here is the call graph for this function:

◆ testException()

Monolog\Handler\RavenHandlerTest::testException ( )

Definition at line 149 of file RavenHandlerTest.php.

150 {
151 $ravenClient = $this->getRavenClient();
152 $handler = $this->getHandler($ravenClient);
153
154 try {
156 } catch (\Exception $e) {
157 $record = $this->getRecord(Logger::ERROR, $e->getMessage(), array('exception' => $e));
158 $handler->handle($record);
159 }
160
161 $this->assertEquals($record['message'], $ravenClient->lastData['message']);
162 }
const ERROR
Runtime errors.
Definition: Logger.php:57

References $handler, Monolog\Logger\ERROR, Monolog\Handler\RavenHandlerTest\getHandler(), Monolog\Handler\RavenHandlerTest\getRavenClient(), Monolog\TestCase\getRecord(), and Monolog\Handler\RavenHandlerTest\methodThatThrowsAnException().

+ Here is the call graph for this function:

◆ testExtraParameters()

Monolog\Handler\RavenHandlerTest::testExtraParameters ( )

Definition at line 88 of file RavenHandlerTest.php.

89 {
90 $ravenClient = $this->getRavenClient();
91 $handler = $this->getHandler($ravenClient);
92
93 $checksum = '098f6bcd4621d373cade4e832627b4f6';
94 $release = '05a671c66aefea124cc08b76ea6d30bb';
95 $record = $this->getRecord(Logger::INFO, 'test', array('checksum' => $checksum, 'release' => $release));
96 $handler->handle($record);
97
98 $this->assertEquals($checksum, $ravenClient->lastData['checksum']);
99 $this->assertEquals($release, $ravenClient->lastData['release']);
100 }
const INFO
Interesting events.
Definition: Logger.php:39

References $handler, Monolog\Handler\RavenHandlerTest\getHandler(), Monolog\Handler\RavenHandlerTest\getRavenClient(), Monolog\TestCase\getRecord(), and Monolog\Logger\INFO.

+ Here is the call graph for this function:

◆ testFingerprint()

Monolog\Handler\RavenHandlerTest::testFingerprint ( )

Definition at line 102 of file RavenHandlerTest.php.

103 {
104 $ravenClient = $this->getRavenClient();
105 $handler = $this->getHandler($ravenClient);
106
107 $fingerprint = array('{{ default }}', 'other value');
108 $record = $this->getRecord(Logger::INFO, 'test', array('fingerprint' => $fingerprint));
109 $handler->handle($record);
110
111 $this->assertEquals($fingerprint, $ravenClient->lastData['fingerprint']);
112 }

References $handler, Monolog\Handler\RavenHandlerTest\getHandler(), Monolog\Handler\RavenHandlerTest\getRavenClient(), Monolog\TestCase\getRecord(), and Monolog\Logger\INFO.

+ Here is the call graph for this function:

◆ testGetSetBatchFormatter()

Monolog\Handler\RavenHandlerTest::testGetSetBatchFormatter ( )

Definition at line 198 of file RavenHandlerTest.php.

199 {
200 $ravenClient = $this->getRavenClient();
201 $handler = $this->getHandler($ravenClient);
202
203 $handler->setBatchFormatter($formatter = new LineFormatter());
204 $this->assertSame($formatter, $handler->getBatchFormatter());
205 }

References $handler, Monolog\Handler\RavenHandlerTest\getHandler(), and Monolog\Handler\RavenHandlerTest\getRavenClient().

+ Here is the call graph for this function:

◆ testHandleBatch()

Monolog\Handler\RavenHandlerTest::testHandleBatch ( )

Definition at line 164 of file RavenHandlerTest.php.

165 {
166 $records = $this->getMultipleRecords();
167 $records[] = $this->getRecord(Logger::WARNING, 'warning');
168 $records[] = $this->getRecord(Logger::WARNING, 'warning');
169
170 $logFormatter = $this->getMock('Monolog\\Formatter\\FormatterInterface');
171 $logFormatter->expects($this->once())->method('formatBatch');
172
173 $formatter = $this->getMock('Monolog\\Formatter\\FormatterInterface');
174 $formatter->expects($this->once())->method('format')->with($this->callback(function ($record) {
175 return $record['level'] == 400;
176 }));
177
178 $handler = $this->getHandler($this->getRavenClient());
179 $handler->setBatchFormatter($logFormatter);
180 $handler->setFormatter($formatter);
181 $handler->handleBatch($records);
182 }
const WARNING
Exceptional occurrences that are not errors.
Definition: Logger.php:52
$records
Definition: simple_test.php:22

References $handler, $records, Monolog\Handler\RavenHandlerTest\getHandler(), Monolog\TestCase\getMultipleRecords(), Monolog\Handler\RavenHandlerTest\getRavenClient(), Monolog\TestCase\getRecord(), and Monolog\Logger\WARNING.

+ Here is the call graph for this function:

◆ testHandleBatchDoNothingIfRecordsAreBelowLevel()

Monolog\Handler\RavenHandlerTest::testHandleBatchDoNothingIfRecordsAreBelowLevel ( )

Definition at line 184 of file RavenHandlerTest.php.

185 {
186 $records = array(
187 $this->getRecord(Logger::DEBUG, 'debug message 1'),
188 $this->getRecord(Logger::DEBUG, 'debug message 2'),
189 $this->getRecord(Logger::INFO, 'information'),
190 );
191
192 $handler = $this->getMock('Monolog\Handler\RavenHandler', null, array($this->getRavenClient()));
193 $handler->expects($this->never())->method('handle');
194 $handler->setLevel(Logger::ERROR);
195 $handler->handleBatch($records);
196 }

References $handler, $records, Monolog\Logger\DEBUG, Monolog\Logger\ERROR, Monolog\Handler\RavenHandlerTest\getRavenClient(), Monolog\TestCase\getRecord(), and Monolog\Logger\INFO.

+ Here is the call graph for this function:

◆ testRelease()

Monolog\Handler\RavenHandlerTest::testRelease ( )

Definition at line 207 of file RavenHandlerTest.php.

208 {
209 $ravenClient = $this->getRavenClient();
210 $handler = $this->getHandler($ravenClient);
211 $release = 'v42.42.42';
212 $handler->setRelease($release);
213 $record = $this->getRecord(Logger::INFO, 'test');
214 $handler->handle($record);
215 $this->assertEquals($release, $ravenClient->lastData['release']);
216
217 $localRelease = 'v41.41.41';
218 $record = $this->getRecord(Logger::INFO, 'test', array('release' => $localRelease));
219 $handler->handle($record);
220 $this->assertEquals($localRelease, $ravenClient->lastData['release']);
221 }

References $handler, Monolog\Handler\RavenHandlerTest\getHandler(), Monolog\Handler\RavenHandlerTest\getRavenClient(), Monolog\TestCase\getRecord(), and Monolog\Logger\INFO.

+ Here is the call graph for this function:

◆ testTag()

Monolog\Handler\RavenHandlerTest::testTag ( )

Definition at line 76 of file RavenHandlerTest.php.

77 {
78 $ravenClient = $this->getRavenClient();
79 $handler = $this->getHandler($ravenClient);
80
81 $tags = array(1, 2, 'foo');
82 $record = $this->getRecord(Logger::INFO, 'test', array('tags' => $tags));
83 $handler->handle($record);
84
85 $this->assertEquals($tags, $ravenClient->lastData['tags']);
86 }
$tags
Definition: croninfo.php:19

References $handler, $tags, Monolog\Handler\RavenHandlerTest\getHandler(), Monolog\Handler\RavenHandlerTest\getRavenClient(), Monolog\TestCase\getRecord(), and Monolog\Logger\INFO.

+ Here is the call graph for this function:

◆ testUserContext()

Monolog\Handler\RavenHandlerTest::testUserContext ( )

Definition at line 114 of file RavenHandlerTest.php.

115 {
116 $ravenClient = $this->getRavenClient();
117 $handler = $this->getHandler($ravenClient);
118
119 $recordWithNoContext = $this->getRecord(Logger::INFO, 'test with default user context');
120 // set user context 'externally'
121
122 $user = array(
123 'id' => '123',
124 'email' => 'test@test.com',
125 );
126
127 $recordWithContext = $this->getRecord(Logger::INFO, 'test', array('user' => $user));
128
129 $ravenClient->user_context(array('id' => 'test_user_id'));
130 // handle context
131 $handler->handle($recordWithContext);
132 $this->assertEquals($user, $ravenClient->lastData['user']);
133
134 // check to see if its reset
135 $handler->handle($recordWithNoContext);
136 $this->assertInternalType('array', $ravenClient->context->user);
137 $this->assertSame('test_user_id', $ravenClient->context->user['id']);
138
139 // handle with null context
140 $ravenClient->user_context(null);
141 $handler->handle($recordWithContext);
142 $this->assertEquals($user, $ravenClient->lastData['user']);
143
144 // check to see if its reset
145 $handler->handle($recordWithNoContext);
146 $this->assertNull($ravenClient->context->user);
147 }

References $handler, Monolog\Handler\RavenHandlerTest\getHandler(), Monolog\Handler\RavenHandlerTest\getRavenClient(), Monolog\TestCase\getRecord(), and Monolog\Logger\INFO.

+ Here is the call graph for this function:

◆ testWarning()

Monolog\Handler\RavenHandlerTest::testWarning ( )

Definition at line 64 of file RavenHandlerTest.php.

65 {
66 $ravenClient = $this->getRavenClient();
67 $handler = $this->getHandler($ravenClient);
68
69 $record = $this->getRecord(Logger::WARNING, 'A test warning message');
70 $handler->handle($record);
71
72 $this->assertEquals($ravenClient::WARNING, $ravenClient->lastData['level']);
73 $this->assertContains($record['message'], $ravenClient->lastData['message']);
74 }

References $handler, Monolog\Handler\RavenHandlerTest\getHandler(), Monolog\Handler\RavenHandlerTest\getRavenClient(), Monolog\TestCase\getRecord(), and Monolog\Logger\WARNING.

+ Here is the call graph for this function:

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