mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-06 21:26:43 +02:00
Make TestHandler::hasRecord assert context, not only message
This commit is contained in:
committed by
Jordi Boggiano
parent
e8db808dd3
commit
b381a973bc
@@ -54,6 +54,52 @@ class TestHandlerTest extends TestCase
|
||||
$this->assertEquals(array($record), $records);
|
||||
}
|
||||
|
||||
public function testHandlerAssertEmptyContext() {
|
||||
$handler = new TestHandler;
|
||||
$record = $this->getRecord(Logger::WARNING, 'test', []);
|
||||
$this->assertFalse($handler->hasWarning([
|
||||
'message' => 'test',
|
||||
'context' => [],
|
||||
]));
|
||||
|
||||
$handler->handle($record);
|
||||
|
||||
$this->assertTrue($handler->hasWarning([
|
||||
'message' => 'test',
|
||||
'context' => [],
|
||||
]));
|
||||
$this->assertFalse($handler->hasWarning([
|
||||
'message' => 'test',
|
||||
'context' => [
|
||||
'foo' => 'bar'
|
||||
],
|
||||
]));
|
||||
}
|
||||
|
||||
public function testHandlerAssertNonEmptyContext() {
|
||||
$handler = new TestHandler;
|
||||
$record = $this->getRecord(Logger::WARNING, 'test', ['foo' => 'bar']);
|
||||
$this->assertFalse($handler->hasWarning([
|
||||
'message' => 'test',
|
||||
'context' => [
|
||||
'foo' => 'bar'
|
||||
],
|
||||
]));
|
||||
|
||||
$handler->handle($record);
|
||||
|
||||
$this->assertTrue($handler->hasWarning([
|
||||
'message' => 'test',
|
||||
'context' => [
|
||||
'foo' => 'bar'
|
||||
],
|
||||
]));
|
||||
$this->assertFalse($handler->hasWarning([
|
||||
'message' => 'test',
|
||||
'context' => [],
|
||||
]));
|
||||
}
|
||||
|
||||
public function methodProvider()
|
||||
{
|
||||
return array(
|
||||
|
Reference in New Issue
Block a user