22 if (!class_exists(
'Raven_Client')) {
23 $this->markTestSkipped(
'raven/raven not installed');
26 require_once __DIR__ .
'/MockRavenClient.php';
35 $this->assertInstanceOf(
'Monolog\Handler\RavenHandler',
$handler);
47 $dsn =
'http://43f6017361224d098402974103bfc53d:a6a0538fc2934ba2bed32e08741b2cd3@marca.python.live.cheggnet.com:9000/1';
61 $this->assertContains($record[
'message'], $ravenClient->lastData[
'message']);
72 $this->assertEquals($ravenClient::WARNING, $ravenClient->lastData[
'level']);
73 $this->assertContains($record[
'message'], $ravenClient->lastData[
'message']);
81 $tags = array(1, 2,
'foo');
85 $this->assertEquals(
$tags, $ravenClient->lastData[
'tags']);
93 $checksum =
'098f6bcd4621d373cade4e832627b4f6';
94 $release =
'05a671c66aefea124cc08b76ea6d30bb';
96 $record = $this->
getRecord(
Logger::INFO,
'test', array(
'checksum' => $checksum,
'release' => $release,
'event_id' => $eventId));
99 $this->assertEquals($checksum, $ravenClient->lastData[
'checksum']);
100 $this->assertEquals($release, $ravenClient->lastData[
'release']);
101 $this->assertEquals($eventId, $ravenClient->lastData[
'event_id']);
109 $fingerprint = array(
'{{ default }}',
'other value');
113 $this->assertEquals($fingerprint, $ravenClient->lastData[
'fingerprint']);
126 'email' =>
'test@test.com',
131 $ravenClient->user_context(array(
'id' =>
'test_user_id'));
133 $handler->handle($recordWithContext);
134 $this->assertEquals(
$user, $ravenClient->lastData[
'user']);
137 $handler->handle($recordWithNoContext);
138 $this->assertInternalType(
'array', $ravenClient->context->user);
139 $this->assertSame(
'test_user_id', $ravenClient->context->user[
'id']);
142 $ravenClient->user_context(null);
143 $handler->handle($recordWithContext);
144 $this->assertEquals(
$user, $ravenClient->lastData[
'user']);
147 $handler->handle($recordWithNoContext);
148 $this->assertNull($ravenClient->context->user);
163 $this->assertEquals($record[
'message'], $ravenClient->lastData[
'message']);
172 $logFormatter = $this->getMock(
'Monolog\\Formatter\\FormatterInterface');
173 $logFormatter->expects($this->
once())->method(
'formatBatch');
175 $formatter = $this->getMock(
'Monolog\\Formatter\\FormatterInterface');
176 $formatter->expects($this->
once())->method(
'format')->with($this->callback(
function ($record) {
177 return $record[
'level'] == 400;
181 $handler->setBatchFormatter($logFormatter);
195 $handler->expects($this->never())->method(
'handle');
212 $logFormatter = $this->getMock(
'Monolog\\Formatter\\FormatterInterface');
213 $logFormatter->expects($this->
once())->method(
'formatBatch');
215 $formatter = $this->getMock(
'Monolog\\Formatter\\FormatterInterface');
216 $formatter->expects($this->
once())->method(
'format')->with($this->callback(
function ($record) use (
$records) {
217 return $record[
'message'] ==
'error 1';
221 $handler->setBatchFormatter($logFormatter);
232 $this->assertSame($formatter,
$handler->getBatchFormatter());
239 $release =
'v42.42.42';
243 $this->assertEquals($release, $ravenClient->lastData[
'release']);
245 $localRelease =
'v41.41.41';
248 $this->assertEquals($localRelease, $ravenClient->lastData[
'release']);
253 throw new \Exception(
'This is an exception');
testHandleBatchPicksProperMessage()
const DEBUG
Detailed debug information.
const ERROR
Runtime errors.
testConstruct()
Monolog::__construct
methodThatThrowsAnException()
foreach($paths as $path) $dsn
getRecord($level=Logger::WARNING, $message='test', $context=array())
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.
const WARNING
Exceptional occurrences that are not errors.
testHandleBatchDoNothingIfRecordsAreBelowLevel()
testGetSetBatchFormatter()
Handler to send messages to a Sentry (https://github.com/getsentry/sentry) server using sentry-php (h...
const INFO
Interesting events.