1.20.x dblog.test protected DBLogTestCase::testDBLogException()

Verifies that exceptions are caught in dblog_watchdog().

File

modules/dblog/tests/dblog.test, line 538
Tests for dblog.module.

Class

DBLogTestCase
Tests logging messages to the database.

Code

protected function testDBLogException() {
  $log = array(
    'type' => 'custom',
    'message' => 'Log entry added to test watchdog handling of Exceptions.',
    'variables' => array(),
    'severity' => WATCHDOG_NOTICE,
    'link' => NULL,
    'user' => $this->big_user,
    'uid' => isset($this->big_user->uid) ? $this->big_user->uid : 0,
    'request_uri' => request_uri(),
    'referer' => $_SERVER['HTTP_REFERER'],
    'ip' => ip_address(),
    'timestamp' => REQUEST_TIME,
  );

  // Remove watchdog table temporarily to simulate it missing during
  // installation.
  db_query("DROP TABLE {watchdog}");

  // Add a watchdog entry.
  // This should not throw an Exception, but fail silently.
  dblog_watchdog($log);
}