Index: modules/simpletest/drupal_web_test_case.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v
retrieving revision 1.196
diff -u -p -r1.196 drupal_web_test_case.php
--- modules/simpletest/drupal_web_test_case.php	9 Feb 2010 12:28:39 -0000	1.196
+++ modules/simpletest/drupal_web_test_case.php	22 Feb 2010 20:12:56 -0000
@@ -1533,8 +1533,12 @@ class DrupalWebTestCase extends DrupalTe
    * @param $headers
    *   An array containing additional HTTP request headers, each formatted as
    *   "name: value".
+   * @param $form_id
+   *   The optional string identifying the form to be submitted. On some pages
+   *   there are many identical forms, so just using the value of the submit
+   *   button is not enough.
    */
-  protected function drupalPost($path, $edit, $submit, array $options = array(), array $headers = array()) {
+  protected function drupalPost($path, $edit, $submit, array $options = array(), array $headers = array(), $form_id = NULL) {
     $submit_matches = FALSE;
     $ajax = is_array($submit);
     if (isset($path)) {
@@ -1543,7 +1547,11 @@ class DrupalWebTestCase extends DrupalTe
     if ($this->parse()) {
       $edit_save = $edit;
       // Let's iterate over all the forms.
-      $forms = $this->xpath('//form');
+      $xpath = "//form";
+      if (!empty($form_id)) {
+        $xpath .= "[@id='" . drupal_html_id($form_id) . "']";
+      }
+      $forms = $this->xpath($xpath);
       foreach ($forms as $form) {
         // We try to set the fields of this form as specified in $edit.
         $edit = $edit_save;
@@ -2711,6 +2719,32 @@ class DrupalWebTestCase extends DrupalTe
   }
 
   /**
+   * Look for a regex in the body of the email.
+   *
+   * @param $name
+   *   Name of the portion of the body to search. Most common: 'body'
+   * @param $regex
+   *   Text to search for.
+   * @param $message
+   *   Message for simpletest.
+   */
+  protected function assertMailPattern($name, $regex, $message) {
+    $mails = $this->drupalGetMails();
+    $mail = end($mails);
+    $regex_found = preg_match("/$regex/", $mail[$name]);
+    $this->assertTrue($regex_found, $message);
+  }
+
+  /**
+   * Output to verbose the most recent email sent.
+   */
+  protected function verboseEmail() {
+    $mails = $this->drupalGetMails();
+    $mail = end($mails);
+    $this->verbose(t('Email was:') . '<pre>' . print_r($mail, TRUE) . '</pre>');
+  }
+
+  /**
    * Log verbose message in a text file.
    *
    * The a link to the vebose message will be placed in the test results via
Index: modules/trigger/trigger.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/trigger/trigger.test,v
retrieving revision 1.26
diff -u -p -r1.26 trigger.test
--- modules/trigger/trigger.test	9 Feb 2010 12:29:39 -0000	1.26
+++ modules/trigger/trigger.test	22 Feb 2010 20:12:58 -0000
@@ -1,7 +1,35 @@
 <?php
 // $Id: trigger.test,v 1.26 2010/02/09 12:29:39 dries Exp $
 
-class TriggerContentTestCase extends DrupalWebTestCase {
+/**
+ * Class with common helper methods.
+ */
+class TriggerWebTestCase extends DrupalWebTestCase {
+
+  /**
+   * Configure an advanced action.
+   *
+   * @param $action
+   *   The name of the action callback. For example: 'user_block_user_action'
+   * @param $edit
+   *   The $edit array for the form to be used to configure.
+   *   Example members would be 'actions_label' (always), 'message', etc.
+   * @return
+   *   the aid (action id) of the configured action, or FALSE if none.
+   */
+  protected function configureAdvancedAction($action, $edit) {
+    // Create an advanced action.
+    $hash = md5($action);
+    $this->drupalPost("admin/config/system/actions/configure/$hash", $edit, t('Save'));
+    $this->assertText(t('The action has been successfully saved.'));
+
+    // Now we have to find out the action ID of what we created.
+    return db_query('SELECT aid FROM {actions} WHERE callback = :callback AND label = :label', array(':callback' => $action, ':label' => $edit['actions_label']))->fetchField();
+  }
+
+}
+
+class TriggerContentTestCase extends TriggerWebTestCase {
   var $_cleanup_roles = array();
   var $_cleanup_users = array();
 
@@ -114,7 +142,7 @@ class TriggerContentTestCase extends Dru
 /**
  * Test cron trigger.
  */
-class TriggerCronTestCase extends DrupalWebTestCase {
+class TriggerCronTestCase extends TriggerWebTestCase {
   public static function getInfo() {
     return array(
       'name' => 'Trigger cron (system) actions',
@@ -144,14 +172,12 @@ class TriggerCronTestCase extends Drupal
     $this->drupalPost('admin/structure/trigger/system', $edit, t('Assign'));
 
     // Assign a configurable action to the cron trigger.
-    $hash = md5('trigger_test_system_cron_conf_action');
     $action_label = $this->randomName();
     $edit = array(
       'actions_label' => $action_label,
       'subject' => $action_label,
     );
-    $this->drupalPost('admin/config/system/actions/configure/' . $hash, $edit, t('Save'));
-    $aid = db_query('SELECT aid FROM {actions} WHERE callback = :callback', array(':callback' => 'trigger_test_system_cron_conf_action'))->fetchField();
+    $aid = $this->configureAdvancedAction('trigger_test_system_cron_conf_action', $edit);
     // $aid is likely 3 but if we add more uses for the sequences table in
     // core it might break, so it is easier to get the value from the database.
     $edit = array('aid' => md5($aid));
@@ -163,8 +189,8 @@ class TriggerCronTestCase extends Drupal
       'actions_label' => $action_label,
       'subject' => $action_label,
     );
-    $this->drupalPost('admin/config/system/actions/configure/' . $hash, $edit, t('Save'));
-    $edit = array('aid' => md5($aid + 1));
+    $aid = $this->configureAdvancedAction('trigger_test_system_cron_conf_action', $edit);
+    $edit = array('aid' => md5($aid));
     $this->drupalPost('admin/structure/trigger/system', $edit, t('Assign'));
 
     // Force a cron run.
@@ -183,7 +209,7 @@ class TriggerCronTestCase extends Drupal
 /**
  * Test other triggers.
  */
-class TriggerOtherTestCase extends DrupalWebTestCase {
+class TriggerOtherTestCase extends TriggerWebTestCase {
   var $_cleanup_roles = array();
   var $_cleanup_users = array();
 
@@ -196,11 +222,11 @@ class TriggerOtherTestCase extends Drupa
   }
 
   function setUp() {
-    parent::setUp('trigger', 'trigger_test');
+    parent::setUp('trigger', 'trigger_test', 'contact');
   }
 
   /**
-   * Test triggering on user create.
+   * Test triggering on user create and user login.
    */
   function testActionsUser() {
     // Assign an action to the create user trigger.
@@ -231,7 +257,29 @@ class TriggerOtherTestCase extends Drupa
     $this->assertTrue(variable_get($action_id, FALSE), t('Check that creating a user triggered the test action.'));
 
     // Reset the action variable.
-    variable_set( $action_id, FALSE );
+    variable_set($action_id, FALSE);
+
+    $this->drupalLogin($test_user);
+    // Assign a configurable action 'System message' to the user_login trigger.
+    $action_edit = array(
+      'actions_label' => $this->randomName(16),
+      'message' => t("You have logged in:") . $this->randomName(16),
+    );
+
+    // Configure an advanced action that we can assign.
+    $aid = $this->configureAdvancedAction('system_message_action', $action_edit);
+    $edit = array('aid' => md5($aid));
+    $this->drupalPost('admin/structure/trigger/user', $edit, t('Assign'), array(), array(), 'trigger_user_login_assign_form');
+
+    // Verify that the action has been assigned to the correct hook.
+    $actions = trigger_get_assigned_actions('user_login');
+    $this->assertEqual(1, count($actions), t('One Action assigned to the hook'));
+    $this->assertEqual($actions[$aid]['label'], $action_edit['actions_label'], t('Correct action label found.'));
+
+    // User should get the configured message at login.
+    $contact_user = $this->drupalCreateUser(array('access site-wide contact form'));;
+    $this->drupalLogin($contact_user);
+    $this->assertText($action_edit['message']);
   }
 
   /**
@@ -247,7 +295,7 @@ class TriggerOtherTestCase extends Drupa
     $this->drupalPost('admin/structure/trigger/comment', $edit, t('Assign'));
 
     // Set action variable to FALSE.
-    variable_set( $action_id, FALSE );
+    variable_set($action_id, FALSE);
 
     // Create a node and add a comment to it.
     $web_user = $this->drupalCreateUser(array('create article content', 'access content', 'post comments without approval', 'post comments'));
@@ -276,7 +324,7 @@ class TriggerOtherTestCase extends Drupa
     $this->drupalPost('admin/structure/trigger/taxonomy', $edit, t('Assign'));
 
     // Set action variable to FALSE.
-    variable_set( $action_id, FALSE );
+    variable_set($action_id, FALSE);
 
     // Create a taxonomy vocabulary and add a term to it.
 
@@ -298,4 +346,5 @@ class TriggerOtherTestCase extends Drupa
     // Verify that the action variable has been set.
     $this->assertTrue(variable_get($action_id, FALSE), t('Check that creating a taxonomy term triggered the action.'));
   }
+
 }
Index: modules/trigger/tests/trigger_test.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/trigger/tests/trigger_test.module,v
retrieving revision 1.5
diff -u -p -r1.5 trigger_test.module
--- modules/trigger/tests/trigger_test.module	4 Dec 2009 16:49:47 -0000	1.5
+++ modules/trigger/tests/trigger_test.module	22 Feb 2010 20:12:58 -0000
@@ -63,12 +63,12 @@ function trigger_test_trigger_info() {
   return array(
     'node' => array(
       'node_triggertest' => array(
-        'runs when' => t('A test trigger is fired'),
+        'label' => t('When a test trigger is fired'),
       ),
     ),
     'trigger_test' => array(
       'trigger_test_triggertest' => array(
-        'runs when' => t('Another test trigger is fired'),
+        'label' => t('When another test trigger is fired'),
       ),
     ),
   );
