You are here

public function CasHelperTest::testLogWhenDebugTurnedOff in CAS 8

Same name and namespace in other branches
  1. 2.x tests/src/Unit/Service/CasHelperTest.php \Drupal\Tests\cas\Unit\Service\CasHelperTest::testLogWhenDebugTurnedOff()

Test our log wrapper when debug logging is off.

@covers ::log @covers ::__construct

File

tests/src/Unit/Service/CasHelperTest.php, line 122

Class

CasHelperTest
CasHelper unit tests.

Namespace

Drupal\Tests\cas\Unit\Service

Code

public function testLogWhenDebugTurnedOff() {

  /** @var \Drupal\Core\Config\ConfigFactory $config_factory */
  $config_factory = $this
    ->getConfigFactoryStub([
    'cas.settings' => [
      'advanced.debug_log' => FALSE,
    ],
  ]);
  $cas_helper = new CasHelper($config_factory, $this->loggerFactory, $this->token
    ->reveal());

  // The actual logger should only called once, when we log an error.
  $this->loggerChannel
    ->expects($this
    ->once())
    ->method('log');
  $cas_helper
    ->log(LogLevel::DEBUG, 'This is a debug log');
  $cas_helper
    ->log(LogLevel::ERROR, 'This is an error log');
}