1 bootstrap.test BootstrapWatchdogTestCase::testWatchdogLogging()

File

core/modules/simpletest/tests/bootstrap.test, line 840

Class

BootstrapWatchdogTestCase

Code

function testWatchdogLogging() {
  // Check the basic watchdog calls work.
  watchdog('testing', 'test @severity message', array('@severity' => 'notice'), WATCHDOG_NOTICE, 'http://example.org');
  $this->assertLogMessage('testing', 'test @severity message', array('@severity' => 'notice'), WATCHDOG_NOTICE, 'http://example.org');

  // By default, no WATCHDOG_DEPRECATED log messages should be entered.
  watchdog('testing', 'test @severity message', array('@severity' => 'deprecated'), WATCHDOG_DEPRECATED);
  $this->assertNoLogMessage('testing', 'test @severity message', array('@severity' => 'deprecated'), WATCHDOG_DEPRECATED);

  // Enable WATCHDOG_DEPRECATED logging
  $enabled_severity_levels = config('system.core')->get('watchdog_enabled_severity_levels');
  $enabled_severity_levels[] = WATCHDOG_DEPRECATED;
  config('system.core')->set('watchdog_enabled_severity_levels', $enabled_severity_levels);

  watchdog('testing', 'test @severity message', array('@severity' => 'deprecated'), WATCHDOG_DEPRECATED);
  $this->assertLogMessage('testing', 'test @severity message', array('@severity' => 'deprecated'), WATCHDOG_DEPRECATED);
}