You are here

function ModuleTestCase::assertLogMessage in Drupal 7

Verify a log entry was entered for a module's status change. Called in the same way of the expected original watchdog() execution.

Parameters

$type: The category to which this message belongs.

$message: The message to store in the log. Keep $message translatable by not concatenating dynamic values into it! Variables in the message should be added by using placeholder strings alongside the variables argument to declare the value of the placeholders. See t() for documentation on how $message and $variables interact.

$variables: Array of variables to replace in the message on display or NULL if message is already translated or not possible to translate.

$severity: The severity of the message, as per RFC 3164.

$link: A link to associate with the message.

2 calls to ModuleTestCase::assertLogMessage()
EnableDisableTestCase::assertSuccessfulDisableAndUninstall in modules/system/system.test
Disables and uninstalls a module and asserts that it was done correctly.
EnableDisableTestCase::testEnableDisable in modules/system/system.test
Test that all core modules can be enabled, disabled and uninstalled.

File

modules/system/system.test, line 115
Tests for system.module.

Class

ModuleTestCase
Helper class for module test cases.

Code

function assertLogMessage($type, $message, $variables = array(), $severity = WATCHDOG_NOTICE, $link = '') {
  $count = db_select('watchdog', 'w')
    ->condition('type', $type)
    ->condition('message', $message)
    ->condition('variables', serialize($variables))
    ->condition('severity', $severity)
    ->condition('link', $link)
    ->countQuery()
    ->execute()
    ->fetchField();
  $this
    ->assertTrue($count > 0, format_string('watchdog table contains @count rows for @message', array(
    '@count' => $count,
    '@message' => $message,
  )));
}