1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-04 12:17:35 +02:00

Refactored writeZendMonitorCustomEvent signature to provide better testability

This commit is contained in:
ChristianB
2013-01-30 21:42:59 +01:00
parent 4eb6011dc1
commit b4b2d91c67
2 changed files with 15 additions and 8 deletions

View File

@@ -62,18 +62,20 @@ class ZendMonitorHandler extends AbstractProcessingHandler
{ {
if ($this->isZendServer()) { if ($this->isZendServer()) {
$formatter = new NormalizerFormatter(); $formatter = new NormalizerFormatter();
$this->writeZendMonitorCustomEvent($formatter->format($record)); $record = $formatter->format($record);
$this->writeZendMonitorCustomEvent($record['level'], $record['message']);
} }
} }
/** /**
* Write a record to Zend Monitor * Write a record to Zend Monitor
* *
* @param array $record * @param int $level
* @param string $message
*/ */
protected function writeZendMonitorCustomEvent(array $record) protected function writeZendMonitorCustomEvent($level, $message)
{ {
zend_monitor_custom_event($this->levelMap[$record['level']], $record['message'], $record['formatted']); zend_monitor_custom_event($level, $message);
} }
/** /**

View File

@@ -39,12 +39,17 @@ class ZendMonitorHandlerTest extends TestCase
*/ */
public function testWrite() public function testWrite()
{ {
$record = $this->getRecord();
$zendMonitor = $this->getMockBuilder('Monolog\Handler\ZendMonitorHandler') $zendMonitor = $this->getMockBuilder('Monolog\Handler\ZendMonitorHandler')
->setMethods(array('writeZendMonitorCustomEvent')) ->setMethods(array('writeZendMonitorCustomEvent'))
->getMock(); ->getMock();
$zendMonitor->expects($this->once()) $zendMonitor->expects($this->once())
->method('writeZendMonitorCustomEvent'); ->method('writeZendMonitorCustomEvent')
$zendMonitor->handle($this->getRecord()); ->with($record['level'], $record['message']);
$zendMonitor->handle($record);
} }
} }