ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
11namespace 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}
testGetDefaultFormatterReturnsNormalizerFormatter()
@covers Monolog\Handler\ZendMonitorHandler::getDefaultFormatter
testWrite()
@covers Monolog\Handler\ZendMonitorHandler::write
Handler sending logs to Zend Monitor.
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19