1 dblog.test private DBLogTestCase::testDBLogCorrupted()

Tests corrupted log entries can still display available data.

File

core/modules/dblog/tests/dblog.test, line 65
Tests for dblog.module.

Class

DBLogTestCase
Tests logging messages to the database.

Code

private function testDBLogCorrupted() {
  global $base_root;

  // Prepare the fields to be logged.
  $log = array(
    'type' => 'custom',
    'message' => 'Log entry added to test the unserialize failure.',
    'variables' => 'BAD SERIALIZED DATA',
    'severity' => WATCHDOG_NOTICE,
    'link' => '',
    'user' => $this->big_user,
    'uid' => isset($this->big_user->uid) ? $this->big_user->uid : 0,
    'request_uri' => $base_root . request_uri(),
    'referer' => $_SERVER['HTTP_REFERER'],
    'ip' => ip_address(),
    'timestamp' => REQUEST_TIME,
  );
  dblog_watchdog($log);

  // View the database log report page.
  $this->backdropGet('admin/reports/dblog');
  $this->assertResponse(200);
  $expected_output = truncate_utf8(filter_xss(t('Log data is corrupted and cannot be unserialized: Log entry added to test unserialize failure.'), array()), 56, TRUE, TRUE);
  $this->assertText($expected_output, 'Log data is corrupted and cannot be unserialized.');
}