1
0
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:
Petter Blomberg
2018-05-31 15:08:33 +02:00
committed by Jordi Boggiano
parent e8db808dd3
commit b381a973bc
2 changed files with 59 additions and 5 deletions

View File

@@ -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(