ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ZendMonitorHandlerTest.php
Go to the documentation of this file.
1 <?php
2 /*
3  * This file is part of the Monolog package.
4  *
5  * (c) Jordi Boggiano <j.boggiano@seld.be>
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10 
11 namespace Monolog\Handler;
12 
14 
16 {
18 
19  public function setUp()
20  {
21  if (!function_exists('zend_monitor_custom_event')) {
22  $this->markTestSkipped('ZendServer is not installed');
23  }
24  }
25 
29  public function testWrite()
30  {
31  $record = $this->getRecord();
32  $formatterResult = array(
33  'message' => $record['message'],
34  );
35 
36  $zendMonitor = $this->getMockBuilder('Monolog\Handler\ZendMonitorHandler')
37  ->setMethods(array('writeZendMonitorCustomEvent', 'getDefaultFormatter'))
38  ->getMock();
39 
40  $formatterMock = $this->getMockBuilder('Monolog\Formatter\NormalizerFormatter')
41  ->disableOriginalConstructor()
42  ->getMock();
43 
44  $formatterMock->expects($this->once())
45  ->method('format')
46  ->will($this->returnValue($formatterResult));
47 
48  $zendMonitor->expects($this->once())
49  ->method('getDefaultFormatter')
50  ->will($this->returnValue($formatterMock));
51 
52  $levelMap = $zendMonitor->getLevelMap();
53 
54  $zendMonitor->expects($this->once())
55  ->method('writeZendMonitorCustomEvent')
56  ->with($levelMap[$record['level']], $record['message'], $formatterResult);
57 
58  $zendMonitor->handle($record);
59  }
60 
65  {
66  $zendMonitor = new ZendMonitorHandler();
67  $this->assertInstanceOf('Monolog\Formatter\NormalizerFormatter', $zendMonitor->getDefaultFormatter());
68  }
69 }
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19
Create styles array
The data for the language used.
Handler sending logs to Zend Monitor.
testGetDefaultFormatterReturnsNormalizerFormatter()
Monolog::getDefaultFormatter