You are here

protected function XMLSitemapTestHelper::assertNoWatchdogErrors in XML sitemap 7.2

Same name and namespace in other branches
  1. 6.2 xmlsitemap.test \XMLSitemapTestHelper::assertNoWatchdogErrors()

Check that there were no watchdog errors or worse.

1 call to XMLSitemapTestHelper::assertNoWatchdogErrors()
XMLSitemapTestHelper::tearDown in ./xmlsitemap.test
Tear Down.

File

./xmlsitemap.test, line 357
Unit tests for the xmlsitemap.

Class

XMLSitemapTestHelper
Helper test class with some added functions for testing.

Code

protected function assertNoWatchdogErrors() {
  $messages = $this
    ->getWatchdogMessages();
  $verbose = array();
  foreach ($messages as $message) {
    $message->text = $this
      ->formatWatchdogMessage($message);
    if (in_array($message->severity, array(
      WATCHDOG_EMERGENCY,
      WATCHDOG_ALERT,
      WATCHDOG_CRITICAL,
      WATCHDOG_ERROR,
      WATCHDOG_WARNING,
    ))) {
      $this
        ->fail($message->text);
    }
    $verbose[] = $message->text;
  }
  if ($verbose) {
    array_unshift($verbose, '<h2>Watchdog messages</h2>');
    $this
      ->verbose(implode("<br />", $verbose), 'Watchdog messages from test run');
  }

  // Clear the seen watchdog messages since we've failed on any errors.
  $this
    ->getWatchdogMessages(array(), TRUE);
}