Index: mollom.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/mollom.admin.inc,v
retrieving revision 1.30
diff -u -p -r1.30 mollom.admin.inc
--- mollom.admin.inc	4 Aug 2010 03:58:46 -0000	1.30
+++ mollom.admin.inc	5 Aug 2010 20:47:16 -0000
@@ -122,54 +122,66 @@ function mollom_admin_configure_form($fo
 
     case 'configure':
       $form['#after_build'][] = 'mollom_admin_configure_form_after_build';
+      drupal_set_title(t('Configure %form-title protection', array('%form-title' => $mollom_form['title'])), PASS_THROUGH);
 
       // Display a list of fields for textual analysis (last step).
       $form['mollom']['form_id'] = array(
         '#type' => 'value',
         '#value' => $mollom_form['form_id'],
       );
-      $form['mollom']['form_title'] = array(
-        '#type' => 'item',
-        '#title' => t('Form'),
-        '#markup' => $mollom_form['title'],
+
+      $modes = array();
+      // Textual analysis, if any elements are available.
+      if (!empty($mollom_form['elements'])) {
+        $modes[MOLLOM_MODE_ANALYSIS] = array(
+          '#title' => t('Text analysis and CAPTCHA backup'),
+          '#description' => t("A CAPTCHA will only be displayed if Mollom is unsure about the content."),
+        );
+      }
+      // CAPTCHA-only, always available.
+      $modes[MOLLOM_MODE_CAPTCHA] = array(
+        '#title' => t('CAPTCHA only'),
+        '#description' => t("Still applies Mollom's intelligent CAPTCHAs and user reputation rules."),
       );
+
+      $mode_options = array();
+      foreach ($modes as $mode => $radio) {
+        $mode_options[$mode] = $modes[$mode]['#title'];
+        // @see form_process_radios()
+        $modes[$mode]['#type'] = 'radio';
+        $modes[$mode]['#parents'] = array('mollom', 'mode');
+        $modes[$mode]['#return_value'] = check_plain($mode);
+        $modes[$mode]['#default_value'] = ($mollom_form['mode'] == $mode ? $mode : NULL);
+      }
       $form['mollom']['mode'] = array(
         '#type' => 'radios',
-        '#title' => t('Spam blocking'),
-        '#options' => array(
-          MOLLOM_MODE_CAPTCHA => t('CAPTCHA only'),
-        ),
+        '#title' => t('Protection mode'),
+        '#options' => $mode_options,
         '#default_value' => $mollom_form['mode'],
-      );
-
-      // Expose any individual form options from $mollom_form['data'].
-      $form['mollom']['data']['#tree'] = TRUE;
-      $form['mollom']['data']['profanity'] = array(
-        '#type' => 'radios',
-        '#title' => t('Profanity blocking (beta)'),
-        '#options' => array(t('Disabled'), t('Enabled')),
-        '#default_value' => isset($mollom_form['data']['profanity']) ? $mollom_form['data']['profanity'] : 0,
-        '#states' => array(
-          'visible' => array(
-            ':input[name="mollom[mode]"]' => array('value' => (string) MOLLOM_MODE_ANALYSIS),
-          ),
-        ),
-      );
+      ) + $modes;
 
       if (!empty($mollom_form['elements'])) {
-        // Add the text analysis protection mode as first, suggested option.
-        $form['mollom']['mode']['#options'] = array(
-          MOLLOM_MODE_ANALYSIS => t('Text analysis and CAPTCHA backup'),
-        ) + $form['mollom']['mode']['#options'];
         // If not re-configuring an existing protection, make it the default.
-        if (!isset($form['mollom']['mode']['#default_value'])) {
-          $form['mollom']['mode']['#default_value'] = MOLLOM_MODE_ANALYSIS;
+        if (!isset($mollom_form['mode'])) {
+          $form['mollom']['mode']['#default_value'] = array(MOLLOM_MODE_ANALYSIS => MOLLOM_MODE_ANALYSIS);
         }
 
-        // @todo Actually belongs to MOLLOM_MODE_ANALYSIS only.
-        $form['mollom']['mode']['#description'] = t('If %text-analysis-option is selected, a CAPTCHA will only be displayed if Mollom is unsure about the content.', array(
-          '%text-analysis-option' => $form['mollom']['mode']['#options'][MOLLOM_MODE_ANALYSIS],
-        ));
+        // Textual analysis filters.
+        $form['mollom']['checks'] = array(
+          '#type' => 'checkboxes',
+          '#title' => t('Text analysis checks'),
+          '#options' => array(
+            'spam' => t('Spam'),
+            'profanity' => t('Profanity'),
+          ),
+          '#default_value' => $mollom_form['checks'],
+          '#required' => $mollom_form['mode'] == MOLLOM_MODE_ANALYSIS,
+          '#states' => array(
+            'visible' => array(
+              ':input[name="mollom[mode]"]' => array('value' => (string) MOLLOM_MODE_ANALYSIS),
+            ),
+          ),
+        );
 
         // Form elements defined by hook_mollom_form_info() use the
         // 'parent][child' syntax, which Form API also uses internally for
@@ -182,7 +194,6 @@ function mollom_admin_configure_form($fo
         // This would lead to a form validation error, because it is a valid key.
         // By encoding them, we prevent this from happening:
         //   '#name' => 'mollom[enabled_fields][parent%5D%5Bchild]'
-        // @todo Use PHP5 functions in D7 (e.g. array_combine()).
         $elements = array();
         foreach ($mollom_form['elements'] as $key => $value) {
           $elements[rawurlencode($key)] = $value;
@@ -193,13 +204,13 @@ function mollom_admin_configure_form($fo
         }
         $form['mollom']['enabled_fields'] = array(
           '#type' => 'checkboxes',
-          '#title' => t('Fields to analyze for spam or profanity'),
+          '#title' => t('Checked form fields'),
           '#options' => $elements,
           '#default_value' => $enabled_fields,
           '#required' => $mollom_form['mode'] == MOLLOM_MODE_ANALYSIS,
           '#states' => array(
-            'invisible' => array(
-              'select[name="mollom[mode]"]' => array('value' => '1'),
+            'visible' => array(
+              ':input[name="mollom[mode]"]' => array('value' => (string) MOLLOM_MODE_ANALYSIS),
             ),
           ),
         );
@@ -227,8 +238,9 @@ function mollom_admin_configure_form($fo
 function mollom_admin_configure_form_after_build($form, &$form_state) {
   // Make field checkboxes required, if protection mode is textual analysis.
   // Accounts for different add and edit form builds and rebuilds.
-  $form['mollom']['enabled_fields']['#required'] = ($form_state['values']['mollom']['mode'] == MOLLOM_MODE_ANALYSIS);
-
+  $required = ($form_state['values']['mollom']['mode'] == MOLLOM_MODE_ANALYSIS);
+  $form['mollom']['checks']['#required'] = $required;
+  $form['mollom']['enabled_fields']['#required'] = $required;
   return $form;
 }
 
Index: mollom.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/mollom.install,v
retrieving revision 1.22
diff -u -p -r1.22 mollom.install
--- mollom.install	31 May 2010 21:27:06 -0000	1.22
+++ mollom.install	5 Aug 2010 19:32:11 -0000
@@ -83,6 +83,12 @@ function mollom_schema() {
         'not null' => TRUE,
         'default' => 0,
       ),
+      'checks' => array(
+        'description' => 'A list of checks to perform for textual analyis.',
+        'type' => 'text',
+        'not null' => FALSE,
+        'serialize' => TRUE,
+      ),
       'enabled_fields' => array(
         'description' => 'A list of form elements configured for textual analysis.',
         'type' => 'text',
@@ -96,12 +102,6 @@ function mollom_schema() {
         'not null' => TRUE,
         'default' => '',
       ),
-      'data' => array(
-        'description' => "Serialized data containing the form's Mollom options.",
-        'type' => 'text',
-        'not null' => TRUE,
-        'serialize' => TRUE,
-      ),
     ),
     'primary key' => array('form_id'),
   );
@@ -379,27 +379,41 @@ function mollom_update_7002() {
 }
 
 /**
- * Add {mollom}.data to store the individual form configuration.
+ * Add {mollom_form}.data to store the individual form configuration.
  */
 function mollom_update_7003() {
-  //@todo Migrate {mollom}.enabled_fields to this data.
-  if (!db_field_exists('mollom_form', 'data')) {
-    // First add the {mollom_form}.data as a nullable field.
-    db_add_field('mollom_form', 'data', array(
+}
+
+/**
+ * Add {mollom_form}.checks and migrate/remove {mollom_form}.data.
+ */
+function mollom_update_7004() {
+  // Add {mollom_form}.checks.
+  if (!db_field_exists('mollom_form', 'checks')) {
+    db_add_field('mollom_form', 'checks', array(
+      'description' => 'A list of checks to perform for textual analyis.',
       'type' => 'text',
-      'serialized' => TRUE,
+      'not null' => FALSE,
+      'serialize' => TRUE,
     ));
-    // Update {mollom_form}.data to equal an empty serialized array.
+    // Default all checks to 'spam', including CAPTCHA-only rows, so spam
+    // checking is enabled by default when switching the protection mode.
     db_update('mollom_form')
       ->fields(array(
-        'data' => serialize(array()),
+        'checks' => serialize(array('spam')),
       ))
       ->execute();
-    // Change the {mollom_form}.data field to not allow nullable values.
-    db_change_field('mollom_form', 'data', 'data', array(
-      'type' => 'text',
-      'not null' => TRUE,
-      'serialized' => TRUE,
-    ));
+  }
+  // Migrate {mollom_form}.data to {mollom_form}.checks.
+  if (db_field_exists('mollom_form', 'data')) {
+    // Add profanity checking flag where enabled.
+    db_update('mollom_form')
+      ->fields(array(
+        'checks' => serialize(array('spam', 'profanity'))
+      ))
+      ->condition('data', serialize(array('profanity' => '1')))
+      ->execute();
+    // Remove {mollom_form}.data.
+    db_drop_field('mollom_form', 'data');
   }
 }
Index: mollom.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/mollom.module,v
retrieving revision 1.64
diff -u -p -r1.64 mollom.module
--- mollom.module	4 Aug 2010 03:58:46 -0000	1.64
+++ mollom.module	5 Aug 2010 22:24:44 -0000
@@ -735,6 +735,7 @@ function mollom_form_info($form_id, $mod
     'title' => $form_id,
     'mode' => NULL,
     'bypass access' => array(),
+    'checks' => array(),
     'elements' => array(),
     'mapping' => array(),
     'mail ids' => array(),
@@ -752,8 +753,8 @@ function mollom_form_info($form_id, $mod
 function mollom_form_load($form_id) {
   $mollom_form = db_query_range('SELECT * FROM {mollom_form} WHERE form_id = :form_id', 0, 1, array(':form_id' => $form_id))->fetchAssoc();
   if ($mollom_form) {
+    $mollom_form['checks'] = unserialize($mollom_form['checks']);
     $mollom_form['enabled_fields'] = unserialize($mollom_form['enabled_fields']);
-    $mollom_form['data'] = unserialize($mollom_form['data']);
 
     // Attach form registry information.
     $mollom_form += mollom_form_info($form_id, $mollom_form['module']);
@@ -762,6 +763,7 @@ function mollom_form_load($form_id) {
     $mollom_form += array(
       'form_id' => $form_id,
       'title' => $form_id,
+      'checks' => array(),
       'elements' => array(),
     );
   }
@@ -772,6 +774,9 @@ function mollom_form_load($form_id) {
  * Saves a Mollom form configuration.
  */
 function mollom_form_save(&$mollom_form) {
+  // Ensure that only enabled textual analysis checks are stored.
+  $mollom_form['checks'] = array_keys(array_filter($mollom_form['checks']));
+
   $exists = db_query_range('SELECT 1 FROM {mollom_form} WHERE form_id = :form_id', 0, 1, array(':form_id' => $mollom_form['form_id']))->fetchField();
   if ($exists) {
     $status = drupal_write_record('mollom_form', $mollom_form, 'form_id');
@@ -1131,9 +1136,9 @@ function mollom_process_mollom($element,
       'require_captcha' => $element['#mollom_form']['mode'] == MOLLOM_MODE_CAPTCHA,
       'passed_captcha' => FALSE,
       'entity' => $element['#mollom_form']['entity'],
+      'checks' => $element['#mollom_form']['checks'],
       'enabled_fields' => $element['#mollom_form']['enabled_fields'],
       'mapping' => $element['#mollom_form']['mapping'],
-      'data' => $element['#mollom_form']['data'],
       'response' => array(
         'session_id' => '',
       ),
@@ -1217,9 +1222,8 @@ function mollom_validate_analysis(&$form
   if (isset($data['post_id'])) {
     unset($data['post_id']);
   }
-  if (!empty($form_state['mollom']['response']['session_id'])) {
-    $data['session_id'] = $form_state['mollom']['response']['session_id'];
-  }
+  $data['session_id'] = $form_state['mollom']['response']['session_id'];
+  $data['checks'] = implode(',', $form_state['mollom']['checks']);
   $result = mollom('mollom.checkContent', $data);
 
   // Trigger global fallback behavior if there is no result.
@@ -1234,44 +1238,51 @@ function mollom_validate_analysis(&$form
   $GLOBALS['mollom_form'] = $form['mollom']['#mollom_form'];
 
   // Check the profanity threshold of the content.
-  if (!empty($form_state['mollom']['data']['profanity']) && $result['profanity'] >= 0.5) {
+  if (isset($result['profanity']) && $result['profanity'] >= 0.5) {
     form_set_error('mollom', t('Your submission has triggered the profanity filter and will not be accepted until the inappropriate language is removed.'));
     watchdog('mollom', 'Profanity: <pre>@message</pre>Result: <pre>@result</pre>', array('@message' => print_r($data, TRUE), '@result' => print_r($result, TRUE)));
   }
 
-  switch ($result['spam']) {
-    case MOLLOM_ANALYSIS_HAM:
-      watchdog('mollom', 'Ham: <pre>@message</pre>Result: <pre>@result</pre>', array('@message' => print_r($data, TRUE), '@result' => print_r($result, TRUE)));
-      break;
-
-    case MOLLOM_ANALYSIS_SPAM:
-      form_set_error('mollom', t('Your submission has triggered the spam filter and will not be accepted.'));
-      watchdog('mollom', 'Spam: <pre>@message</pre>Result: <pre>@result</pre>', array('@message' => print_r($data, TRUE), '@result' => print_r($result, TRUE)));
-      break;
-
-    default:
-      // Fall back to a CAPTCHA.
-      form_set_error('mollom', t("To complete this form, please complete the word verification below."));
-      watchdog('mollom', 'Unsure: <pre>@message</pre>Result: <pre>@result</pre>', array('@message' => print_r($data, TRUE), '@result' => print_r($result, TRUE)));
-
-      $form_state['mollom']['require_captcha'] = TRUE;
-      $form['mollom']['captcha']['#access'] = TRUE;
-      $form['mollom']['captcha']['#required'] = TRUE;
-
-      $captcha_data = array(
-        'author_ip' => $data['author_ip'],
-        'session_id' => $result['session_id'],
-      );
-      $captcha = mollom_get_captcha('image', $captcha_data);
-
-      // If we get a response, add the image CAPTCHA to the form element.
-      if (isset($captcha['response']['session_id']) && !empty($captcha['markup'])) {
-        $form_state['mollom']['response']['session_id'] = $captcha['response']['session_id'];
-        $form['mollom']['session_id']['#value'] = $captcha['response']['session_id'];
-        $form['mollom']['captcha']['#field_prefix'] = $captcha['markup'];
-        $GLOBALS['mollom_response'] = $form_state['mollom']['response'];
-      }
-      break;
+  if (isset($result['spam'])) {
+    switch ($result['spam']) {
+      case MOLLOM_ANALYSIS_HAM:
+        watchdog('mollom', 'Ham: <pre>@message</pre>Result: <pre>@result</pre>', array('@message' => print_r($data, TRUE), '@result' => print_r($result, TRUE)));
+        break;
+  
+      case MOLLOM_ANALYSIS_SPAM:
+        form_set_error('mollom', t('Your submission has triggered the spam filter and will not be accepted.'));
+        watchdog('mollom', 'Spam: <pre>@message</pre>Result: <pre>@result</pre>', array('@message' => print_r($data, TRUE), '@result' => print_r($result, TRUE)));
+        break;
+  
+      case MOLLOM_ANALYSIS_UNSURE:
+        // Fall back to a CAPTCHA.
+        form_set_error('mollom', t("To complete this form, please complete the word verification below."));
+        watchdog('mollom', 'Unsure: <pre>@message</pre>Result: <pre>@result</pre>', array('@message' => print_r($data, TRUE), '@result' => print_r($result, TRUE)));
+  
+        $form_state['mollom']['require_captcha'] = TRUE;
+        $form['mollom']['captcha']['#access'] = TRUE;
+        $form['mollom']['captcha']['#required'] = TRUE;
+  
+        $captcha_data = array(
+          'author_ip' => $data['author_ip'],
+          'session_id' => $result['session_id'],
+        );
+        $captcha = mollom_get_captcha('image', $captcha_data);
+  
+        // If we get a response, add the image CAPTCHA to the form element.
+        if (isset($captcha['response']['session_id']) && !empty($captcha['markup'])) {
+          $form_state['mollom']['response']['session_id'] = $captcha['response']['session_id'];
+          $form['mollom']['session_id']['#value'] = $captcha['response']['session_id'];
+          $form['mollom']['captcha']['#field_prefix'] = $captcha['markup'];
+          $GLOBALS['mollom_response'] = $form_state['mollom']['response'];
+        }
+        break;
+  
+      default:
+        // If we end up here, something went totally wrong.
+        _mollom_fallback();
+        break;
+    }
   }
 }
 
Index: tests/mollom.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/tests/mollom.test,v
retrieving revision 1.49
diff -u -p -r1.49 mollom.test
--- tests/mollom.test	4 Aug 2010 03:58:46 -0000	1.49
+++ tests/mollom.test	5 Aug 2010 22:32:11 -0000
@@ -274,7 +274,9 @@ class MollomWebTestCase extends DrupalWe
    * @param $mode
    *   The Mollom protection mode for the form.
    * @param $fields
-   *   (optional) A list of form elements to enable for text analysis.
+   *   (optional) A list of form elements to enable for text analysis. If
+   *   omitted and the form registers individual elements, all fields are
+   *   enabled by default.
    * @param $edit
    *   (optional) An array of POST data to pass through to drupalPost() when
    *   configuring the form's protection.
@@ -305,6 +307,11 @@ class MollomWebTestCase extends DrupalWe
     // Process the enabled fields.
     $form_list = mollom_form_list();
     $form_info = mollom_form_info($form_id, $form_list[$form_id]['module']);
+    if (!empty($form_info['elements'])) {
+      $edit += array(
+        'mollom[checks][spam]' => TRUE,
+      );
+    }
     foreach (array_keys($form_info['elements']) as $field) {
       if (!isset($fields) || in_array($field, $fields)) {
         // If the user specified all fields by default or to include this
@@ -786,11 +793,14 @@ class MollomResponseTestCase extends Mol
     );
 
     // Ensure proper response for 'ham' submissions.
+    // By default (i.e., omitting 'checks') we expect spam and quality checking
+    // only.
     $data['post_body'] = 'ham';
     $result = mollom('mollom.checkContent', $data);
     $this->assertMollomWatchdogMessages();
     $this->assertSame('spam', $result['spam'], MOLLOM_ANALYSIS_HAM);
     $this->assertSame('quality', $result['quality'], 1);
+    $this->assertTrue(!isset($result['profanity']), 'profanity not returned.');
     $session_id = $this->assertSessionID($result['session_id']);
 
     // Ensure proper response for 'spam' submissions, re-using session_id.
@@ -800,6 +810,7 @@ class MollomResponseTestCase extends Mol
     $this->assertMollomWatchdogMessages();
     $this->assertSame('spam', $result['spam'], MOLLOM_ANALYSIS_SPAM);
     $this->assertSame('quality', $result['quality'], 0);
+    $this->assertTrue(!isset($result['profanity']), 'profanity not returned.');
     $session_id = $this->assertSessionID($result['session_id']);
 
     // Ensure proper response for 'unsure' submissions, re-using session_id.
@@ -809,6 +820,28 @@ class MollomResponseTestCase extends Mol
     $this->assertMollomWatchdogMessages();
     $this->assertSame('spam', $result['spam'], MOLLOM_ANALYSIS_UNSURE);
     $this->assertSame('quality', $result['quality'], 0.5);
+    $this->assertTrue(!isset($result['profanity']), 'profanity not returned.');
+    $session_id = $this->assertSessionID($result['session_id']);
+
+    // Additionally enable profanity checking.
+    $data['post_body'] = 'unsure profane';
+    $data['checks'] = 'spam,quality,profanity';
+    $data['session_id'] = $session_id;
+    $result = mollom('mollom.checkContent', $data);
+    $this->assertMollomWatchdogMessages();
+    $this->assertSame('spam', $result['spam'], MOLLOM_ANALYSIS_UNSURE);
+    $this->assertSame('quality', $result['quality'], 0.5);
+    $this->assertSame('profanity', $result['profanity'], 0.18);
+    $session_id = $this->assertSessionID($result['session_id']);
+
+    // Disable spam checking, only do profanity checking.
+    $data['checks'] = 'profanity';
+    $data['session_id'] = $session_id;
+    $result = mollom('mollom.checkContent', $data);
+    $this->assertMollomWatchdogMessages();
+    $this->assertTrue(!isset($result['spam']), 'spam not returned.');
+    $this->assertTrue(!isset($result['quality']), 'quality not returned.');
+    $this->assertSame('profanity', $result['profanity'], 0);
     $session_id = $this->assertSessionID($result['session_id']);
   }
 
@@ -1318,27 +1351,31 @@ class MollomProfanityTestCase extends Mo
    */
   function testProfanityFiltering() {
     // Protect Mollom test form but do not enable the profanity filter.
-    $config_edit = array('mollom[data][profanity]' => 0);
-    $this->setProtection('mollom_test_form', MOLLOM_MODE_ANALYSIS, array('title', 'body'), $config_edit);
+    $edit_config = array(
+      'mollom[checks][profanity]' => FALSE,
+    );
+    $this->setProtection('mollom_test_form', MOLLOM_MODE_ANALYSIS, NULL, $edit_config);
     $this->drupalLogout();
 
     // Assert that the profanity filter is disabled.
-    $post_edit = array(
+    $edit = array(
       'title' => 'Joomla lover unite!',
-      'body' => 'This is a post just for Joomla lovers. If you love Joomla, this is the content for you!',
+      'body' => 'This is a post just for unsure Joomla lovers. If you love Joomla, this is the content for you!',
     );
-    $this->drupalPost('mollom-test/form', $post_edit, 'Submit');
+    $this->drupalPost('mollom-test/form', $edit, 'Submit');
     $this->postCorrectCaptcha(NULL, array(), 'Submit', 'Successful form submission.');
     $this->assertNoText($this->profanity_message);
 
     // Enable the profanity filter setting for this form.
     $this->drupalLogin($this->admin_user);
-    $config_edit['mollom[data][profanity]'] = 1;
-    $this->setProtection('mollom_test_form', MOLLOM_MODE_ANALYSIS, array('title', 'body'), $config_edit);
+    $edit_config = array(
+      'mollom[checks][profanity]' => 1,
+    );
+    $this->setProtection('mollom_test_form', MOLLOM_MODE_ANALYSIS, NULL, $edit_config);
     $this->drupalLogout();
 
     // Assert that the profanity filter now blocks this content.
-    $this->drupalPost('mollom-test/form', $post_edit, 'Submit');
+    $this->drupalPost('mollom-test/form', $edit, 'Submit');
     $this->assertNoText('Successful form submission.');
     $this->assertText($this->profanity_message);
   }
@@ -1377,6 +1414,7 @@ class MollomFormConfigurationTestCase ex
     $this->assertText('Mollom test form');
     $edit = array(
       'mollom[mode]' => MOLLOM_MODE_ANALYSIS,
+      'mollom[checks][spam]' => TRUE,
       'mollom[enabled_fields][title]' => TRUE,
       'mollom[enabled_fields][body]' => TRUE,
       'mollom[enabled_fields][exclude]' => FALSE,
@@ -1521,7 +1559,7 @@ class MollomFormConfigurationTestCase ex
     );
     $this->drupalPost(NULL, $edit, t('Next'));
     $this->assertText($form_info['user_register_form']['title']);
-    $this->assertNoText(t('Fields to analyze'));
+    $this->assertNoText(t('Checked form fields'));
     $this->drupalPost(NULL, array(), t('Save'));
 
     // Verify that user registration form was protected.
@@ -1539,7 +1577,10 @@ class MollomFormConfigurationTestCase ex
         $this->assertText($info['title']);
         // Verify that forms specifying elements have all possible elements
         // preselected for textual analysis.
+        $edit = array();
         if (!empty($info['elements'])) {
+          $edit['mollom[checks][spam]'] = TRUE;
+
           foreach ($info['elements'] as $field => $label) {
             $field = rawurlencode($field);
             $this->assertFieldByName("mollom[enabled_fields][$field]", TRUE);
@@ -1547,9 +1588,9 @@ class MollomFormConfigurationTestCase ex
         }
         // Verify that CAPTCHA-only forms contain no configurable fields.
         else {
-          $this->assertNoText(t('Fields to analyze for spam or profanity'));
+          $this->assertNoText(t('Checked form fields'));
         }
-        $this->drupalPost(NULL, array(), t('Save'));
+        $this->drupalPost(NULL, $edit, t('Save'));
         $this->assertText(t('The form protection has been added.'));
       }
     }
Index: tests/mollom_test.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/tests/mollom_test.module,v
retrieving revision 1.12
diff -u -p -r1.12 mollom_test.module
--- tests/mollom_test.module	4 Aug 2010 03:58:46 -0000	1.12
+++ tests/mollom_test.module	5 Aug 2010 22:28:15 -0000
@@ -48,59 +48,84 @@ function mollom_test_check_content($data
   $storage[] = $data;
   variable_set(__FUNCTION__, $storage);
 
-  // Check post_title and post_body to determine whether to return ham, spam, or
-  // unsure as response.
-  $spam = FALSE;
-  $ham = FALSE;
-
-  foreach (array('post_title', 'post_body') as $key) {
-    if (!isset($data[$key])) {
-      continue;
-    }
-    // 'spam' always has precedence.
-    if (strpos($data[$key], 'spam') !== FALSE) {
-      $spam = TRUE;
-    }
-    // Otherwise, check for 'ham'.
-    elseif (strpos($data[$key], 'ham') !== FALSE) {
-      $ham = TRUE;
-    }
-    // Lastly, take a forced 'unsure' into account.
-    elseif (strpos($data[$key], 'unsure') !== FALSE) {
-      $spam = TRUE;
-      $ham = TRUE;
-    }
+  $response = array();
 
-    // If the message contains 'Joomla', give it a profanity score of 0.8.
-    $profanity = 0.0;
-    if (strpos($data[$key], 'Joomla') !== FALSE) {
-      $profanity = 0.8;
+  // Spam filter: Check post_title and post_body for ham, spam, or unsure.
+  if (!isset($data['checks']) || strpos($data['checks'], 'spam') !== FALSE) {
+    $spam = FALSE;
+    $ham = FALSE;
+    foreach (array('post_title', 'post_body') as $key) {
+      if (!isset($data[$key])) {
+        continue;
+      }
+      // 'spam' always has precedence.
+      if (strpos($data[$key], 'spam') !== FALSE) {
+        $spam = TRUE;
+      }
+      // Otherwise, check for 'ham'.
+      elseif (strpos($data[$key], 'ham') !== FALSE) {
+        $ham = TRUE;
+      }
+      // Lastly, take a forced 'unsure' into account.
+      elseif (strpos($data[$key], 'unsure') !== FALSE) {
+        $spam = TRUE;
+        $ham = TRUE;
+      }
+    }
+    if ($spam && $ham) {
+      $response['spam'] = MOLLOM_ANALYSIS_UNSURE;
+      $quality = 0.5;
+    }
+    elseif ($spam) {
+      $response['spam'] = MOLLOM_ANALYSIS_SPAM;
+      $quality = 0;
+    }
+    elseif ($ham) {
+      $response['spam'] = MOLLOM_ANALYSIS_HAM;
+      $quality = 1;
+    }
+    else {
+      $response['spam'] = MOLLOM_ANALYSIS_UNKNOWN;
+      $quality = NULL;
     }
   }
-  if ($spam && $ham) {
-    $response = MOLLOM_ANALYSIS_UNSURE;
-    $quality = 0.5;
+
+  // Quality filter.
+  if (!isset($data['checks']) || strpos($data['checks'], 'quality') !== FALSE) {
+    if (isset($quality)) {
+      $response['quality'] = $quality;
+    }
+    // @todo No idea how quality is calculated during testing without spam
+    //   results above.
+    else {
+      $response['quality'] = 0;
+    }
   }
-  elseif ($spam) {
-    $response = MOLLOM_ANALYSIS_SPAM;
-    $quality = 0;
+
+  // Profanity filter.
+  if (isset($data['checks']) && strpos($data['checks'], 'profanity') !== FALSE) {
+    $profanity = 0.0;
+    foreach (array('post_title', 'post_body') as $key) {
+      if (!isset($data[$key])) {
+        continue;
+      }
+      // @todo Client/server testing value mismatch.
+      if (strpos($data[$key], 'Joomla') !== FALSE) {
+        $profanity = 0.8;
+      }
+    }
+    $response['profanity'] = $profanity;
   }
-  elseif ($ham) {
-    $response = MOLLOM_ANALYSIS_HAM;
-    $quality = 1;
+
+  if (!empty($data['session_id'])) {
+    $response['session_id'] = $data['session_id'];
   }
   else {
-    $response = MOLLOM_ANALYSIS_UNKNOWN;
-    $quality = NULL;
+    drupal_session_start();
+    $response['session_id'] = session_id();
   }
 
-  drupal_session_start();
-  return array(
-    'session_id' => !empty($data['session_id']) ? $data['session_id'] : session_id(),
-    'spam' => $response,
-    'quality' => $quality,
-    'profanity' => $profanity,
-  );
+  return $response;
 }
 
 /**
