Index: mollom.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/mollom.module,v
retrieving revision 1.90
diff -u -p -r1.90 mollom.module
--- mollom.module	18 Oct 2010 00:34:51 -0000	1.90
+++ mollom.module	18 Oct 2010 11:50:04 -0000
@@ -2269,7 +2269,6 @@ function user_mollom_form_info($form_id)
   switch ($form_id) {
     case 'user_register_form':
       $form_info = array(
-        'mode' => MOLLOM_MODE_CAPTCHA,
         'bypass access' => array('administer users'),
         'moderation callback' => 'user_mollom_form_moderation',
         'mapping' => array(
@@ -2390,3 +2389,30 @@ function contact_mollom_form_info($form_
 /**
  * @} End of "name mollom_contact".
  */
+
+/**
+ * @name mollom_profile Profile module integration for Mollom.
+ * @{
+ */
+
+/**
+ * Implements hook_mollom_form_info_alter().
+ *
+ * Adds profile fields exposed on the user registration form.
+ */
+function profile_mollom_form_info_alter(&$form_info, $form_id) {
+  if ($form_id != 'user_register_form') {
+    return;
+  }
+  // @see profile_form_profile()
+  $result = db_query("SELECT name, title FROM {profile_field} WHERE register = 1 AND type IN (:types)", array(
+    ':types' => array('textfield', 'textarea', 'url', 'list'),
+  ));
+  foreach ($result as $field) {
+    $form_info['elements'][$field->name] = check_plain($field->title);
+  }
+}
+
+/**
+ * @} End of "name mollom_profile".
+ */
Index: tests/mollom.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/tests/mollom.test,v
retrieving revision 1.69
diff -u -p -r1.69 mollom.test
--- tests/mollom.test	16 Oct 2010 18:00:29 -0000	1.69
+++ tests/mollom.test	18 Oct 2010 12:02:58 -0000
@@ -98,19 +98,21 @@ class MollomWebTestCase extends DrupalWe
     // If not explicitly disabled by a test, setup with Mollom and default admin
     // user.
     if (empty($this->disableDefaultSetup)) {
-      // Call parent::setUp() allowing Mollom test cases to pass further modules.
       $modules[] = 'mollom';
       $modules[] = 'dblog';
       parent::setUp($modules);
 
-      $this->admin_user = $this->drupalCreateUser(array(
-        'administer mollom',
+      $permissions = array(
         'access administration pages',
+        'administer mollom',
         'administer content types',
-        'administer comments',
         'administer permissions',
         'administer users',
-      ));
+      );
+      if (module_exists('comment')) {
+        $permissions[] = 'administer comments';
+      }
+      $this->admin_user = $this->drupalCreateUser($permissions);
     }
     else {
       $modules[] = 'dblog';
@@ -1979,6 +1981,72 @@ class MollomUserFormsTestCase extends Mo
   }
 }
 
+/**
+ * Tests Profile module integration.
+ */
+class MollomProfileFormsTestCase extends MollomWebTestCase {
+  protected $profile = 'testing';
+
+  public static function getInfo() {
+    return array(
+      'name' => 'Profile integration',
+      'description' => 'Tests Profile module integration.',
+      'group' => 'Mollom',
+    );
+  }
+
+  function setUp() {
+    parent::setUp(array('profile'));
+  }
+
+  /**
+   * Tests Profile module integration with user registration form.
+   */
+  function testProfileRegistration() {
+    $this->drupalLogin($this->admin_user);
+
+    // Allow registration by site visitors without administrator approval.
+    variable_set('user_register', USER_REGISTER_VISITORS);
+
+    // Add the three supported profile field types.
+    $fields = array();
+    foreach (array('textfield', 'textarea', 'url', 'list') as $type) {
+      $name = 'profile_' . drupal_strtolower($this->randomName());
+      $title = $this->randomString();
+      $edit = array(
+        'category' => 'Registration',
+        'title' => $title,
+        'name' => $name,
+        'register' => 1,
+      );
+      $fields[$name] = $edit + array(
+        'type' => $type,
+      );
+      $this->drupalPost('admin/config/people/profile/add/' . $type, $edit, t('Save field'));
+    }
+
+    // Enable text analysis protection for user registration form.
+    $this->setProtection('user_register_form', MOLLOM_MODE_ANALYSIS);
+    $this->drupalLogout();
+
+    $this->drupalGet('user/register');
+    $this->assertNoCaptchaField();
+
+    $name = $this->randomName();
+    $edit = array(
+      'name' => $name,
+      'mail' => $name . '@example.com',
+    );
+    foreach ($fields as $key => $field) {
+      $edit[$key] = ($field['type'] != 'url' ? 'unsure' : 'http://example.com/unsure');
+    }
+    $this->drupalPost(NULL, $edit, t('Create new account'));
+    $this->postCorrectCaptcha(NULL, array(), t('Create new account'));
+    $this->assertText(t('A welcome message with further instructions has been sent to your e-mail address.'));
+    $this->assertTrue(user_load_by_name($name), t('New user was found in database.'));
+  }
+}
+
 class MollomCommentFormTestCase extends MollomWebTestCase {
   private $node;
 
