scratch – Blame information for rev

Subversion Repositories:
Rev:
Rev Author Line No. Line
115 office 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  
13 use Monolog\TestCase;
14  
15 class ZendMonitorHandlerTest extends TestCase
16 {
17 protected $zendMonitorHandler;
18  
19 public function setUp()
20 {
21 if (!function_exists('zend_monitor_custom_event')) {
22 $this->markTestSkipped('ZendServer is not installed');
23 }
24 }
25  
26 /**
27 * @covers Monolog\Handler\ZendMonitorHandler::write
28 */
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  
61 /**
62 * @covers Monolog\Handler\ZendMonitorHandler::getDefaultFormatter
63 */
64 public function testGetDefaultFormatterReturnsNormalizerFormatter()
65 {
66 $zendMonitor = new ZendMonitorHandler();
67 $this->assertInstanceOf('Monolog\Formatter\NormalizerFormatter', $zendMonitor->getDefaultFormatter());
68 }
69 }