Index: mollom.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/mollom.install,v
retrieving revision 1.5
diff -u -p -r1.5 mollom.install
--- mollom.install	22 Dec 2009 08:10:34 -0000	1.5
+++ mollom.install	6 Jan 2010 16:32:23 -0000
@@ -101,35 +101,6 @@ function mollom_schema() {
 }
 
 /**
- * Implements hook_install().
- */
-function mollom_install() {
-  // Install default form configuration for enabled, supported modules.
-  foreach (module_list(FALSE, FALSE) as $module) {
-    drupal_load('module', $module);
-  }
-  drupal_load('module', 'mollom');
-
-  $form_info = mollom_get_form_info();
-  $query = db_insert('mollom_form')
-    ->fields(array('form_id', 'mode', 'fields', 'module'));
-  foreach ($form_info as $form_id => $info) {
-    if (!empty($info['mode'])) {
-      $info['fields'] = array_keys($info['elements']);
-      // Upon installation, our own schema is not available yet, so we cannot
-      // use mollom_form_save(), resp. drupal_write_record().
-      $query->values(array(
-        $info['form_id'],
-        $info['mode'],
-        serialize($info['fields']),
-        $info['module'],
-      ));
-    }
-  }
-  $query->execute();
-}
-
-/**
  * Implements hook_uninstall().
  */
 function mollom_uninstall() {
Index: mollom.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/mollom.module,v
retrieving revision 1.11
diff -u -p -r1.11 mollom.module
--- mollom.module	6 Jan 2010 07:36:59 -0000	1.11
+++ mollom.module	6 Jan 2010 17:28:19 -0000
@@ -276,6 +276,23 @@ function mollom_permission() {
 }
 
 /**
+ * Implements hook_modules_installed().
+ *
+ * Automatically protects registered forms of installed modules.
+ */
+function mollom_modules_installed($modules) {
+  $form_info = mollom_get_form_info();
+  foreach ($form_info as $form_id => $info) {
+    // Only forms belonging to installed modules are taken into consideration,
+    // and the registered form needs to define a default protection mode.
+    if (in_array($info['module'], $modules) && !empty($info['mode'])) {
+      $info['fields'] = array_keys($info['elements']);
+      mollom_form_save($info);
+    }
+  }
+}
+
+/**
  * Implements hook_modules_uninstalled().
  */
 function mollom_modules_uninstalled($modules) {
Index: tests/mollom.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/tests/mollom.test,v
retrieving revision 1.7
diff -u -p -r1.7 mollom.test
--- tests/mollom.test	6 Jan 2010 07:36:59 -0000	1.7
+++ tests/mollom.test	6 Jan 2010 17:43:05 -0000
@@ -79,10 +79,17 @@ class MollomWebTestCase extends DrupalWe
    * Set up an administrative user account and testing keys.
    */
   function setUp() {
-    // Call parent::setUp() allowing Mollom test cases to pass further modules.
+    // SimpleTest does not invoke hook_modules_installed() for any undocumented
+    // reason, but we need our own hook implementation invoked to auto-protect
+    // registered forms.
+    parent::setUp('mollom');
+
     $modules = func_get_args();
-    $modules[] = 'mollom';
-    call_user_func_array(array($this, 'parent::setUp'), $modules);
+    if ($modules) {
+      drupal_install_modules($modules);
+    }
+    $this->refreshVariables();
+    $this->checkPermissions(array(), TRUE);
 
     $this->admin_user = $this->drupalCreateUser(array(
       'administer mollom',
@@ -459,8 +466,8 @@ class MollomWebTestCase extends DrupalWe
 class MollomAccessTestCase extends MollomWebTestCase {
   public static function getInfo() {
     return array(
-      'name' => 'Mollom access checking',
-      'description' => 'Confirm that there is a working key pair and that this status is correctly indicated on the module settings page for appropriate users.',
+      'name' => 'API keys and administrative access',
+      'description' => 'Confirm that there is a working key pair and that this status is correctly indicated on the module settings page.',
       'group' => 'Mollom',
     );
   }
@@ -502,7 +509,7 @@ class MollomAccessTestCase extends Mollo
     // Check access for a user that has everything except the 'administer
     // mollom' permission. This user should not have access to the Mollom
     // settings page.
-    $this->web_user = $this->drupalCreateUser(array_diff(module_invoke_all('perm'), array('administer mollom')));
+    $this->web_user = $this->drupalCreateUser(array_diff(module_invoke_all('permission'), array('administer mollom')));
     $this->drupalLogin($this->web_user);
     $this->drupalGet('admin/config/content/mollom');
     $this->assertResponse(403);
@@ -512,10 +519,14 @@ class MollomAccessTestCase extends Mollo
    * Tests 'bypass access' property of registered forms.
    */
   function testBypassAccess() {
+    $this->drupalLogin($this->admin_user);
+    $this->setProtection('comment_form');
+    $this->drupalLogout();
+
     $node = $this->drupalCreateNode(array('body' => array(LANGUAGE_NONE => array(array('value' => 'node body'))), 'type' => 'article'));
 
     // Create a regular user and post a comment.
-    $this->web_user = $this->drupalCreateUser(array('post comments', 'post comments without approval'));
+    $this->web_user = $this->drupalCreateUser(array('post comments', 'post comments without approval', 'edit own comments'));
     $this->drupalLogin($this->web_user);
     $edit = array(
       'comment' => 'ham',
