public function LoggerChannelTest::testSortLoggers in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/Tests/Core/Logger/LoggerChannelTest.php \Drupal\Tests\Core\Logger\LoggerChannelTest::testSortLoggers()
Tests LoggerChannel::addLoggers().
@covers ::addLogger @covers ::sortLoggers
File
- core/
tests/ Drupal/ Tests/ Core/ Logger/ LoggerChannelTest.php, line 80 - Contains \Drupal\Tests\Core\Logger\LoggerChannelTest.
Class
- LoggerChannelTest
- @coversDefaultClass \Drupal\Core\Logger\LoggerChannel @group Logger
Namespace
Drupal\Tests\Core\LoggerCode
public function testSortLoggers() {
$channel = new LoggerChannel($this
->randomMachineName());
$index_order = '';
for ($i = 0; $i < 4; $i++) {
$logger = $this
->createMock('Psr\\Log\\LoggerInterface');
$logger
->expects($this
->once())
->method('log')
->will($this
->returnCallback(function () use ($i, &$index_order) {
// Append the $i to the index order, so that we know the order that
// loggers got called with.
$index_order .= $i;
}));
$channel
->addLogger($logger, $i);
}
$channel
->log(rand(0, 7), $this
->randomMachineName());
// Ensure that the logger added in the end fired first.
$this
->assertEquals($index_order, '3210');
}