mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-11 07:34:12 +02:00
Fixed passing Closure as parameter to minMaxHandler.
This commit is contained in:
@@ -93,4 +93,35 @@ class MinMaxHandlerTest extends TestCase
|
||||
$this->assertFalse($handler->handle($this->getRecord(Logger::INFO)));
|
||||
$this->assertFalse($handler->handle($this->getRecord(Logger::WARNING)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Monolog\Handler\MinMaxHandler::handle
|
||||
*/
|
||||
public function testHandleWithCallback()
|
||||
{
|
||||
$test = new TestHandler();
|
||||
$handler = new MinMaxHandler(
|
||||
function ($record, $handler) use ($test) {
|
||||
return $test;
|
||||
}, Logger::INFO, Logger::NOTICE, false
|
||||
);
|
||||
$handler->handle($this->getRecord(Logger::DEBUG));
|
||||
$handler->handle($this->getRecord(Logger::INFO));
|
||||
$this->assertFalse($test->hasDebugRecords());
|
||||
$this->assertTrue($test->hasInfoRecords());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Monolog\Handler\MinMaxHandler::handle
|
||||
* @expectedException \RuntimeException
|
||||
*/
|
||||
public function testHandleWithBadCallbackThrowsException()
|
||||
{
|
||||
$handler = new MinMaxHandler(
|
||||
function ($record, $handler) {
|
||||
return 'foo';
|
||||
}
|
||||
);
|
||||
$handler->handle($this->getRecord(Logger::WARNING));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user