You are here

public function LoggerTest::testAddRecord in Monolog 8

Same name and namespace in other branches
  1. 2.x tests/src/Unit/Logger/LoggerTest.php \Drupal\Tests\monolog\Unit\Logger\LoggerTest::testAddRecord()

Make sure that the level gets translated before sent to processors. @covers ::addRecord @dataProvider providerTestAddRecord

File

tests/src/Unit/Logger/LoggerTest.php, line 21

Class

LoggerTest
@coversDefaultClass \Drupal\monolog\Logger\Logger @group monolog

Namespace

Drupal\Tests\monolog\Unit\Logger

Code

public function testAddRecord($log_level, $handler_log_level, $log_message) {
  $mock = $this
    ->getMock('Monolog\\Handler\\NullHandler');
  $mock
    ->expects($this
    ->once())
    ->method('isHandling')
    ->will($this
    ->returnValue(TRUE));
  $mock
    ->expects($this
    ->once())
    ->method('handle')
    ->with($this
    ->callback(function (array $record) use ($handler_log_level, $log_message) {
    return $record['level'] === $handler_log_level && $record['message'] === $log_message;
  }));
  $logger = new Logger('Foo channel', [
    $mock,
  ]);
  $logger
    ->addRecord($log_level, $log_message);
}