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:
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user