function LegacyBootstrapTest::testWatchdogException

Same name in other branches
  1. 11.x core/tests/Drupal/KernelTests/Core/Bootstrap/LegacyBootstrapTest.php \Drupal\KernelTests\Core\Bootstrap\LegacyBootstrapTest::testWatchdogException()

Tests watchdog_exception() deprecation.

File

core/tests/Drupal/KernelTests/Core/Bootstrap/LegacyBootstrapTest.php, line 28

Class

LegacyBootstrapTest
Tests legacy bootstrap functions.

Namespace

Drupal\KernelTests\Core\Bootstrap

Code

public function testWatchdogException() : void {
    $logger = new TestLogger();
    
    /** @var \Drupal\Core\Logger\LoggerChannelFactoryInterface $loggerFactory */
    $loggerFactory = \Drupal::service('logger.factory');
    $loggerFactory->addLogger($logger);
    $this->expectDeprecation('watchdog_exception() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use \\Drupal\\Core\\Utility\\Error::logException() instead. See https://www.drupal.org/node/2932520');
    $e = new \RuntimeException("foo");
    watchdog_exception('test', $e);
    $this->assertTrue($logger->hasRecordThatContains(Error::DEFAULT_ERROR_MESSAGE, RfcLogLevel::ERROR));
}

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