function LoggerChannelTest::testLogRecursionProtection

Same name and namespace in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Logger/LoggerChannelTest.php \Drupal\Tests\Core\Logger\LoggerChannelTest::testLogRecursionProtection()
  2. 10 core/tests/Drupal/Tests/Core/Logger/LoggerChannelTest.php \Drupal\Tests\Core\Logger\LoggerChannelTest::testLogRecursionProtection()
  3. 11.x 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

Class

LoggerChannelTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Logger%21LoggerChannel.php/class/LoggerChannel/9" title="Defines a logger channel that most implementations will use." class="local">\Drupal\Core\Logger\LoggerChannel</a> @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());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.