You are here

public function LoggerChannelTest::test_sortLogger in Service Container 7.2

Same name and namespace in other branches
  1. 7 tests/src/Logger/LoggerChannelTest.php \Drupal\Tests\service_container\Logger\LoggerChannelTest::test_sortLogger()

@covers ::log() @covers ::sortLoggers() @covers ::addLogger()

@covers ::emergency() @covers ::alert() @covers ::critical() @covers ::error() @covers ::warning() @covers ::notice() @covers ::info() @covers ::debug()

@dataProvider providerLogLevels

File

tests/src/Logger/LoggerChannelTest.php, line 109
Contains \Drupal\Tests\service_container\Logger\LoggerChannelTest.

Class

LoggerChannelTest
@coversDefaultClass \Drupal\service_container\Logger\LoggerChannel

Namespace

Drupal\Tests\service_container\Logger

Code

public function test_sortLogger($log_method = NULL, $log_level = LogLevel::INFO) {
  $logger1 = \Mockery::mock('Psr\\Log\\LoggerInterface');
  $logger2 = \Mockery::mock('Psr\\Log\\LoggerInterface');

  // Note: We use globally()/ordered() in order to ensure that $logger2 is
  // called first.
  $logger2
    ->shouldReceive('log')
    ->globally()
    ->ordered()
    ->with($log_level, 'test-message', array(
    'key' => 'value',
    'channel' => 'test',
  ));
  $logger1
    ->shouldReceive('log')
    ->globally()
    ->ordered()
    ->with($log_level, 'test-message', array(
    'key' => 'value',
    'channel' => 'test',
  ));
  $this->loggerChannel
    ->addLogger($logger1, 0);
  $this->loggerChannel
    ->addLogger($logger2, 10);
  if (is_null($log_method)) {
    $this->loggerChannel
      ->log($log_level, 'test-message', array(
      'key' => 'value',
    ));
  }
  else {
    $this->loggerChannel
      ->{$log_method}('test-message', array(
      'key' => 'value',
    ));
  }
}