ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 ()
 
 testUserContext ()
 
 testException ()
 
 testHandleBatch ()
 
 testHandleBatchDoNothingIfRecordsAreBelowLevel ()
 
 testGetSetBatchFormatter ()
 

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()

Monolog\Handler\RavenHandlerTest::getHandler (   $ravenClient)
protected

◆ getRavenClient()

Monolog\Handler\RavenHandlerTest::getRavenClient ( )
protected

◆ methodThatThrowsAnException()

Monolog\Handler\RavenHandlerTest::methodThatThrowsAnException ( )
private

Definition at line 181 of file RavenHandlerTest.php.

182 {
183 throw new \Exception('This is an exception');
184 }

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 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 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 123 of file RavenHandlerTest.php.

124 {
125 $ravenClient = $this->getRavenClient();
126 $handler = $this->getHandler($ravenClient);
127
128 try {
130 } catch (\Exception $e) {
131 $record = $this->getRecord(Logger::ERROR, $e->getMessage(), array('exception' => $e));
132 $handler->handle($record);
133 }
134
135 $this->assertEquals($record['message'], $ravenClient->lastData['message']);
136 }
const ERROR
Runtime errors.
Definition: Logger.php:57

References 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:

◆ testGetSetBatchFormatter()

Monolog\Handler\RavenHandlerTest::testGetSetBatchFormatter ( )

Definition at line 172 of file RavenHandlerTest.php.

173 {
174 $ravenClient = $this->getRavenClient();
175 $handler = $this->getHandler($ravenClient);
176
177 $handler->setBatchFormatter($formatter = new LineFormatter());
178 $this->assertSame($formatter, $handler->getBatchFormatter());
179 }

References 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 138 of file RavenHandlerTest.php.

139 {
140 $records = $this->getMultipleRecords();
141 $records[] = $this->getRecord(Logger::WARNING, 'warning');
142 $records[] = $this->getRecord(Logger::WARNING, 'warning');
143
144 $logFormatter = $this->getMock('Monolog\\Formatter\\FormatterInterface');
145 $logFormatter->expects($this->once())->method('formatBatch');
146
147 $formatter = $this->getMock('Monolog\\Formatter\\FormatterInterface');
148 $formatter->expects($this->once())->method('format')->with($this->callback(function ($record) {
149 return $record['level'] == 400;
150 }));
151
152 $handler = $this->getHandler($this->getRavenClient());
153 $handler->setBatchFormatter($logFormatter);
154 $handler->setFormatter($formatter);
155 $handler->handleBatch($records);
156 }
const WARNING
Exceptional occurrences that are not errors.
Definition: Logger.php:52
$records
Definition: simple_test.php:17

References $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 158 of file RavenHandlerTest.php.

159 {
160 $records = array(
161 $this->getRecord(Logger::DEBUG, 'debug message 1'),
162 $this->getRecord(Logger::DEBUG, 'debug message 2'),
163 $this->getRecord(Logger::INFO, 'information'),
164 );
165
166 $handler = $this->getMock('Monolog\Handler\RavenHandler', null, array($this->getRavenClient()));
167 $handler->expects($this->never())->method('handle');
168 $handler->setLevel(Logger::ERROR);
169 $handler->handleBatch($records);
170 }
const INFO
Interesting events.
Definition: Logger.php:39

References $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:

◆ 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 }

References 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 88 of file RavenHandlerTest.php.

89 {
90 $ravenClient = $this->getRavenClient();
91 $handler = $this->getHandler($ravenClient);
92
93 $recordWithNoContext = $this->getRecord(Logger::INFO, 'test with default user context');
94 // set user context 'externally'
95
96 $user = array(
97 'id' => '123',
98 'email' => 'test@test.com'
99 );
100
101 $recordWithContext = $this->getRecord(Logger::INFO, 'test', array('user' => $user));
102
103 $ravenClient->user_context(array('id' => 'test_user_id'));
104 // handle context
105 $handler->handle($recordWithContext);
106 $this->assertEquals($user, $ravenClient->lastData['sentry.interfaces.User']);
107
108 // check to see if its reset
109 $handler->handle($recordWithNoContext);
110 $this->assertInternalType('array', $ravenClient->context->user);
111 $this->assertSame('test_user_id', $ravenClient->context->user['id']);
112
113 // handle with null context
114 $ravenClient->user_context(null);
115 $handler->handle($recordWithContext);
116 $this->assertEquals($user, $ravenClient->lastData['sentry.interfaces.User']);
117
118 // check to see if its reset
119 $handler->handle($recordWithNoContext);
120 $this->assertNull($ravenClient->context->user);
121 }

References 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 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: