Index: mollom.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/mollom.module,v
retrieving revision 1.70
diff -u -p -r1.70 mollom.module
--- mollom.module	9 Sep 2010 15:05:03 -0000	1.70
+++ mollom.module	9 Sep 2010 17:27:27 -0000
@@ -1299,10 +1299,10 @@ function mollom_validate_analysis(&$form
           $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;
 
+      case MOLLOM_ANALYSIS_UNKNOWN:
       default:
         // If we end up here, something went totally wrong.
         _mollom_fallback();
Index: tests/mollom.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/tests/mollom.test,v
retrieving revision 1.54
diff -u -p -r1.54 mollom.test
--- tests/mollom.test	3 Sep 2010 17:34:07 -0000	1.54
+++ tests/mollom.test	9 Sep 2010 21:13:04 -0000
@@ -811,6 +811,8 @@ class MollomInstallationTestCase extends
  * Tests low-level XML-RPC communication with Mollom servers.
  */
 class MollomResponseTestCase extends MollomWebTestCase {
+  protected $profile = 'testing';
+
   public static function getInfo() {
     return array(
       'name' => 'Server responses',
@@ -819,14 +821,22 @@ class MollomResponseTestCase extends Mol
     );
   }
 
+  function setUp() {
+    $this->disableDefaultSetup = TRUE;
+    parent::setUp();
+    $this->setKeys();
+    $this->assertValidKeys();
+  }
+
   /**
    * Tests mollom.checkContent().
    */
   function testCheckContent() {
+    $this->web_user = $this->drupalCreateUser(array());
     $data = array(
-      'author_name' => $this->admin_user->name,
-      'author_mail' => $this->admin_user->mail,
-      'author_id' => $this->admin_user->uid,
+      'author_name' => $this->web_user->name,
+      'author_mail' => $this->web_user->mail,
+      'author_id' => $this->web_user->uid,
       'author_ip' => ip_address(),
     );
 
@@ -872,7 +882,19 @@ class MollomResponseTestCase extends Mol
     $this->assertSame('profanity', $result['profanity'], 1);
     $session_id = $this->assertSessionID($result['session_id']);
 
+    // Change the string to contain profanity only.
+    $data['post_body'] = 'profanity';
+    $data['checks'] = 'spam,quality,profanity';
+    $data['session_id'] = $session_id;
+    $result = mollom('mollom.checkContent', $data);
+    $this->assertMollomWatchdogMessages();
+    $this->assertSame('spam', $result['spam'], MOLLOM_ANALYSIS_HAM);
+    $this->assertSame('quality', $result['quality'], 0);
+    $this->assertSame('profanity', $result['profanity'], 1);
+    $session_id = $this->assertSessionID($result['session_id']);
+
     // Disable spam checking, only do profanity checking.
+    $data['post_body'] = 'spam profanity';
     $data['checks'] = 'profanity';
     $data['session_id'] = $session_id;
     $result = mollom('mollom.checkContent', $data);
@@ -1380,25 +1402,23 @@ class MollomProfanityTestCase extends Mo
   public static function getInfo() {
     return array(
       'name' => 'Profanity filtering',
-      'description' => 'Verify that forms can be properly protected and unprotected.',
+      'description' => 'Verify that form submissions can be checked for profanity.',
       'group' => 'Mollom',
     );
   }
 
   function setUp() {
-    parent::setUp('mollom_test');
-    // Re-route Mollom communication to this testing site.
-    variable_set('mollom_servers', array($GLOBALS['base_url'] . '/xmlrpc.php?version='));
+    parent::setUp();
 
-    $this->drupalLogin($this->admin_user);
+    user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access comments', 'post comments', 'post comments without approval'));
   }
 
   /**
-   * Test the different levels of profanity filtering. With our test Mollom
-   * server, the profanity keyword is 'Joomla'.
+   * Tests text analysis profanity checking.
    */
   function testProfanityFiltering() {
     // Protect Mollom test form but do not enable the profanity filter.
+    $this->drupalLogin($this->admin_user);
     $edit_config = array(
       'mollom[checks][profanity]' => FALSE,
     );
@@ -1437,6 +1457,43 @@ class MollomProfanityTestCase extends Mo
     $this->assertText('Successful form submission.');
     $this->assertNoText($this->profanity_message);
   }
+
+  function testExaminerAnonymous() {
+    variable_set('comment_preview_article', DRUPAL_OPTIONAL);
+    $node = $this->drupalCreateNode(array('type' => 'article'));
+    $langcode = LANGUAGE_NONE;
+
+    // Enable profanity checking for the comment form.
+    $this->drupalLogin($this->admin_user);
+    $edit_config = array(
+      'mollom[checks][profanity]' => TRUE,
+      'mollom[checks][spam]' => TRUE,
+    );
+    $this->setProtection('comment_form', MOLLOM_MODE_ANALYSIS, NULL, $edit_config);
+    $this->drupalLogout();
+
+    $this->drupalGet("node/{$node->nid}");
+    $this->assertNoCaptchaField();
+    $this->assertPrivacyLink();
+    $edit = array(
+      "comment_body[$langcode][0][value]" => 'profanity',
+    );
+    $this->drupalPost(NULL, $edit, t('Save'));
+    $this->assertText($this->profanity_message);
+    $this->assertNoText(t('Your comment has been posted.'));
+    $session_id = $this->assertSessionIDInForm();
+
+    $edit = array(
+      'subject' => $this->randomName(),
+      "comment_body[$langcode][0][value]" => 'not profane',
+    );
+    $this->drupalPost(NULL, $edit, t('Save'));
+    $this->assertNoText($this->profanity_message);
+    $this->assertText(t('Your comment has been posted.'));
+    $this->assertRaw('<p>' . $edit["comment_body[$langcode][0][value]"] . '</p>', t('Comment previously containing profanity was found.'));
+    $cid = db_query('SELECT cid FROM {comment} WHERE subject = :subject ORDER BY created DESC', array(':subject' => $edit['subject']))->fetchField();
+    $this->assertMollomData('comment', $cid, $session_id);
+  }
 }
 
 /**
Index: tests/mollom_test.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/tests/mollom_test.module,v
retrieving revision 1.13
diff -u -p -r1.13 mollom_test.module
--- tests/mollom_test.module	10 Aug 2010 19:33:51 -0000	1.13
+++ tests/mollom_test.module	9 Sep 2010 21:14:07 -0000
@@ -13,6 +13,7 @@ function mollom_test_xmlrpc() {
   return array(
     // $data contains a variable amount of properties, so we cannot specify a
     // signature.
+    'mollom.getServerList' => 'mollom_test_get_server_list',
     'mollom.verifyKey' => 'mollom_test_verify_key',
     'mollom.checkContent' => 'mollom_test_check_content',
     'mollom.getImageCaptcha' => 'mollom_test_get_captcha',
@@ -21,6 +22,17 @@ function mollom_test_xmlrpc() {
 }
 
 /**
+ * XML-RPC callback for mollom.getServerList to retrieve new server list.
+ */
+function mollom_test_get_server_list($data) {
+  $storage = variable_get(__FUNCTION__, array());
+  $storage[] = $data;
+  variable_set(__FUNCTION__, $storage);
+
+  return array($GLOBALS['base_url'] . '/xmlrpc.php?version=');
+}
+
+/**
  * XML-RPC callback for mollom.verifyKey to validate API keys.
  */
 function mollom_test_verify_key($data) {
@@ -85,7 +97,7 @@ function mollom_test_check_content($data
       $quality = 1;
     }
     else {
-      $response['spam'] = MOLLOM_ANALYSIS_UNKNOWN;
+      $response['spam'] = MOLLOM_ANALYSIS_HAM;
       $quality = NULL;
     }
   }
@@ -106,12 +118,8 @@ function mollom_test_check_content($data
   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], 'profanity') !== FALSE) {
-        $profanity = 0.8;
+      if (isset($data[$key]) && strpos($data[$key], 'profanity') !== FALSE) {
+        $profanity = 1.0;
       }
     }
     $response['profanity'] = $profanity;
