Index: tests/mollom.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/tests/mollom.test,v
retrieving revision 1.61
diff -u -p -r1.61 mollom.test
--- tests/mollom.test	20 Sep 2010 03:39:10 -0000	1.61
+++ tests/mollom.test	22 Sep 2010 09:24:04 -0000
@@ -136,16 +136,20 @@ class MollomWebTestCase extends DrupalWe
    *
    * This function can be (repeatedly) invoked to assert new watchdog messages.
    * All watchdog messages with a higher severity than WATCHDOG_NOTICE are
-   * considered as fails.
+   * considered as "severe".
    *
-   * @param $no_fail_expected
-   *   (optional) Boolean whether a failing watchdog message is expected.
-   *   Defaults to TRUE (no fail expected). If FALSE is passed, the logic for
-   *   assertion messages is flipped.
+   * @param $max_severity
+   *   (optional) A maximum watchdog severity level message constant that log
+   *   messages must have to pass the assertion. All messages with a higher
+   *   severity will fail. Defaults to WATCHDOG_NOTICE. If the actual severity
+   *   does not matter, you may also pass TRUE instead of WATCHDOG_NOTICE, or
+   *   FALSE for WATCHDOG_EMERGENCY. If FALSE or a severity level higher than
+   *   WATCHDOG_NOTICE is passed, then there must have been at least one severe
+   *   message.
    *
-   * @todo Add this to D7 core.
+   * @todo Add this to Drupal core.
    */
-  protected function assertMollomWatchdogMessages($no_fail_expected = TRUE) {
+  protected function assertMollomWatchdogMessages($max_severity = WATCHDOG_NOTICE) {
     module_load_include('inc', 'dblog', 'dblog.admin');
 
     $this->messages = array();
@@ -153,23 +157,39 @@ class MollomWebTestCase extends DrupalWe
       ->fields('w')
       ->condition('w.type', 'mollom')
       ->orderBy('w.timestamp', 'ASC');
+
+    // The comparison logic applied in this function is a bit confusing, since
+    // the values of the watchdog severity level constants in Drupal core are
+    // negated to their actual "severity level" meaning:
+    // WATCHDOG_EMERGENCY is 0, WATCHDOG_NOTICE is 5, WATCHDOG_DEBUG is 7.
+
+    // Convert a Boolean into WATCHDOG_NOTICE (if TRUE) or respectively
+    // WATCHDOG_EMERGENCY (if FALSE).
+    if (is_bool($max_severity)) {
+      $max_severity = ($max_severity ? WATCHDOG_NOTICE : WATCHDOG_EMERGENCY);
+    }
+    $fail_expected = ($max_severity < WATCHDOG_NOTICE);
+    $had_severe_message = FALSE;
     foreach ($query->execute() as $row) {
-      // In case no fail is expected, only log messages with a severity of
-      // WATCHDOG_NOTICE or less severe messages must pass. More severe messages
-      // need to fail. The comparison logic applied here is a bit confusing,
-      // since the values of watchdog severity level constants are negated to
-      // their actual "severity level" meaning:
-      // WATCHDOG_EMERGENCY is 0, WATCHDOG_NOTICE is 5, WATCHDOG_DEBUG is 7.
-      // In case a fail is expected, all messages always pass, since we would
-      // otherwise trigger a false positive test failure if there are additional
-      // non-severe log messages.
-      if (!$no_fail_expected || $row->severity >= WATCHDOG_NOTICE) {
+      $this->messages[$row->wid] = $row;
+      // Only messages with a maximum severity of $max_severity or less severe
+      // messages must pass. More severe messages need to fail. See note about
+      // severity level constant values above.
+      if ($row->severity >= $max_severity) {
         $this->pass(theme_dblog_message(array('event' => $row, 'link' => FALSE)), t('Watchdog'));
       }
       else {
         $this->fail(theme_dblog_message(array('event' => $row, 'link' => FALSE)), t('Watchdog'));
       }
-      $this->messages[$row->wid] = $row;
+      // In case a severe message is expected, non-severe messages always pass,
+      // since we would trigger a false positive test failure otherwise.
+      // However, in order to actually assert the expectation, there must have
+      // been at least one severe log message.
+      $had_severe_message = ($had_severe_message || $row->severity < WATCHDOG_NOTICE);
+    }
+    // Assert that there was a severe message, in case we expected one.
+    if ($fail_expected && !$had_severe_message) {
+      $this->fail(t('Severe log message not found.'), t('Watchdog'));
     }
     // Delete processed watchdog messages.
     if (!empty($this->messages)) {
@@ -790,7 +810,8 @@ class MollomInstallationTestCase extends
       'mollom_public_key' => 'foo',
       'mollom_private_key' => 'bar',
     );
-    $this->drupalPost('admin/config/content/mollom/settings', $edit, t('Save configuration'), array('watchdog' => FALSE));
+    $this->drupalGet('admin/config/content/mollom/settings');
+    $this->drupalPost(NULL, $edit, t('Save configuration'), array('watchdog' => FALSE));
     $this->assertText(t('The configuration options have been saved.'));
     $this->assertNoText($this->fallback_message, t('Fallback message not found.'));
 
