1 bootstrap.test BootstrapWatchdogTestCase::testWatchdogLogging()

File

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

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
  $wesl = config('system.core')->get('watchdog_enabled_severity_levels');
  $wesl[] = WATCHDOG_DEPRECATED;
  config('system.core')->set('watchdog_enabled_severity_levels', $wesl);

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