ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
RollbarHandlerTest.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 
14 use Exception;
16 use Monolog\Logger;
18 
26 {
31 
36 
37  protected function setUp()
38  {
39  parent::setUp();
40 
41  $this->setupRollbarNotifierMock();
42  }
43 
48  public function testExceptionLogLevel()
49  {
50  $handler = $this->createHandler();
51 
53 
54  $this->assertEquals('debug', $this->reportedExceptionArguments['payload']['level']);
55  }
56 
57  private function setupRollbarNotifierMock()
58  {
59  $this->rollbarNotifier = $this->getMockBuilder('RollbarNotifier')
60  ->setMethods(array('report_message', 'report_exception', 'flush'))
61  ->getMock();
62 
63  $that = $this;
64 
65  $this->rollbarNotifier
66  ->expects($this->any())
67  ->method('report_exception')
68  ->willReturnCallback(function ($exception, $context, $payload) use ($that) {
69  $that->reportedExceptionArguments = compact('exception', 'context', 'payload');
70  });
71  }
72 
73  private function createHandler()
74  {
75  return new RollbarHandler($this->rollbarNotifier, Logger::DEBUG);
76  }
77 
78  private function createExceptionRecord($level = Logger::DEBUG, $message = 'test', $exception = null)
79  {
80  return $this->getRecord($level, $message, array(
81  'exception' => $exception ?: new Exception()
82  ));
83  }
84 }
createExceptionRecord($level=Logger::DEBUG, $message='test', $exception=null)
const DEBUG
Detailed debug information.
Definition: Logger.php:33
$context
Definition: webdav.php:25
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19
catch(Exception $e) $message
testExceptionLogLevel()
When reporting exceptions to Rollbar the level has to be set in the payload data. ...
Sends errors to Rollbar.
$handler