3 * This file is part of the Monolog package.
5 * (c) Jordi Boggiano <j.boggiano@seld.be>
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
11 namespace Monolog\Handler;
15 class ZendMonitorHandlerTest extends TestCase
17 protected $zendMonitorHandler;
19 public function setUp()
21 if (!function_exists('zend_monitor_custom_event')) {
22 $this->markTestSkipped('ZendServer is not installed');
27 * @covers Monolog\Handler\ZendMonitorHandler::write
29 public function testWrite()
31 $record = $this->getRecord();
32 $formatterResult = array(
33 'message' => $record['message'],
36 $zendMonitor = $this->getMockBuilder('Monolog\Handler\ZendMonitorHandler')
37 ->setMethods(array('writeZendMonitorCustomEvent', 'getDefaultFormatter'))
40 $formatterMock = $this->getMockBuilder('Monolog\Formatter\NormalizerFormatter')
41 ->disableOriginalConstructor()
44 $formatterMock->expects($this->once())
46 ->will($this->returnValue($formatterResult));
48 $zendMonitor->expects($this->once())
49 ->method('getDefaultFormatter')
50 ->will($this->returnValue($formatterMock));
52 $levelMap = $zendMonitor->getLevelMap();
54 $zendMonitor->expects($this->once())
55 ->method('writeZendMonitorCustomEvent')
56 ->with($levelMap[$record['level']], $record['message'], $formatterResult);
58 $zendMonitor->handle($record);
62 * @covers Monolog\Handler\ZendMonitorHandler::getDefaultFormatter
64 public function testGetDefaultFormatterReturnsNormalizerFormatter()
66 $zendMonitor = new ZendMonitorHandler();
67 $this->assertInstanceOf('Monolog\Formatter\NormalizerFormatter', $zendMonitor->getDefaultFormatter());