You are here

public function LoggerChannelTest::testLogRecursionProtection in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Logger/LoggerChannelTest.php \Drupal\Tests\Core\Logger\LoggerChannelTest::testLogRecursionProtection()

Tests LoggerChannel::log() recursion protection.

@covers ::log

File

core/tests/Drupal/Tests/Core/Logger/LoggerChannelTest.php, line 64
Contains \Drupal\Tests\Core\Logger\LoggerChannelTest.

Class

LoggerChannelTest
@coversDefaultClass \Drupal\Core\Logger\LoggerChannel @group Logger

Namespace

Drupal\Tests\Core\Logger

Code

public function testLogRecursionProtection() {
  $channel = new LoggerChannel('test');
  $logger = $this
    ->createMock('Psr\\Log\\LoggerInterface');
  $logger
    ->expects($this
    ->exactly(LoggerChannel::MAX_CALL_DEPTH))
    ->method('log');
  $channel
    ->addLogger($logger);
  $channel
    ->addLogger(new NaughtyRecursiveLogger($channel));
  $channel
    ->log(rand(0, 7), $this
    ->randomMachineName());
}