Index: modules/trigger/trigger.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/trigger/trigger.module,v
retrieving revision 1.46
diff -u -u -p -r1.46 trigger.module
--- modules/trigger/trigger.module	24 Aug 2009 00:14:22 -0000	1.46
+++ modules/trigger/trigger.module	26 Aug 2009 21:36:50 -0000
@@ -380,7 +380,7 @@ function _trigger_normalize_user_context
 }
 
 /**
- * trigger_user_login
+ * Implements trigger_user_login().
  */
 function trigger_user_login(&$edit, $account, $category) {
   _trigger_user('login', $edit, $account, $category);
@@ -455,12 +455,32 @@ function _trigger_user($op, &$edit, $acc
 }
 
 /**
- * Implement hook_taxonomy().
+ * Implements hook_taxonomy_term_insert().
  */
-function trigger_taxonomy($op, $type, $array) {
-  if ($type != 'term') {
-    return;
-  }
+function trigger_taxonomy_term_insert($term) {
+  _trigger_taxonomy('insert', (array)$term);
+}
+
+/**
+ * Implements hook_taxonomy_term_update().
+ */
+function trigger_taxonomy_term_update($term) {
+  _trigger_taxonomy('update', (array)$term);
+}
+
+/**
+ * Implements hook_taxonomy_term_delete().
+ */
+function trigger_taxonomy_term_delete($term) {
+  _trigger_taxonomy('delete', (array)$term);
+}
+
+/**
+ * Simple wrapper function to make taxonomy hooks work with new entry points.
+ *
+ * @TODO: Take advantage of the new API and reorganise/remove this function.
+ */
+function _trigger_taxonomy($op, $array) {
   $aids = _trigger_get_hook_aids('taxonomy', $op);
   $context = array(
     'hook' => 'taxonomy',
Index: modules/trigger/trigger.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/trigger/trigger.test,v
retrieving revision 1.16
diff -u -u -p -r1.16 trigger.test
--- modules/trigger/trigger.test	22 Aug 2009 00:58:55 -0000	1.16
+++ modules/trigger/trigger.test	26 Aug 2009 21:36:50 -0000
@@ -138,11 +138,11 @@ class TriggerCronTestCase extends Drupal
     // Create an administrative user.
     $test_user = $this->drupalCreateUser(array('administer actions'));
     $this->drupalLogin($test_user);
- 
+
     // Assign a non-configurable action to the cron run trigger.
     $edit = array('aid' => md5('trigger_test_system_cron_action'));
     $this->drupalPost('admin/structure/trigger/cron', $edit, t('Assign'));
- 
+
     // Assign a configurable action to the cron trigger.
     $hash = md5('trigger_test_system_cron_conf_action');
     $action_description = $this->randomName();
@@ -153,7 +153,7 @@ class TriggerCronTestCase extends Drupal
     $this->drupalPost('admin/settings/actions/configure/' . $hash, $edit, t('Save'));
     $edit = array('aid' => md5('1'));
     $this->drupalPost('admin/structure/trigger/cron', $edit, t('Assign'));
- 
+
     // Add a second configurable action to the cron trigger.
     $action_description = $this->randomName();
     $edit = array(
@@ -163,16 +163,139 @@ class TriggerCronTestCase extends Drupal
     $this->drupalPost('admin/settings/actions/configure/' . $hash, $edit, t('Save'));
     $edit = array('aid' => md5('2'));
     $this->drupalPost('admin/structure/trigger/cron', $edit, t('Assign'));
- 
+
     // Force a cron run.
     drupal_cron_run();
- 
+
     // Make sure the non-configurable action has fired.
     $action_run = variable_get('trigger_test_system_cron_action', FALSE);
     $this->assertTrue($action_run, t('Check that the cron run triggered the test action.'));
- 
+
     // Make sure that both configurable actions have fired.
     $action_run = variable_get('trigger_test_system_cron_conf_action', 0) == 2;
     $this->assertTrue($action_run, t('Check that the cron run triggered both complex actions.'));
   }
 }
+
+
+/**
+ * Test other triggers.
+ */
+class TriggerOtherTestCase extends DrupalWebTestCase {
+  var $_cleanup_roles = array();
+  var $_cleanup_users = array();
+
+  public static function getInfo() {
+    return array(
+      'name' => 'Trigger other actions',
+      'description' => 'Test triggering of user, comment, taxonomy actions.' ,
+      'group' => 'Trigger',
+    );
+  }
+
+  function setUp() {
+    parent::setUp('trigger', 'trigger_test');
+  }
+
+  /**
+   * Test triggering on user create.
+   */
+  function testActionsUser() {
+    // Assign an action to the create user trigger.
+    $test_user = $this->drupalCreateUser(array('administer actions'));
+    $this->drupalLogin($test_user);
+    $action_id = 'trigger_test_generic_action';
+    $hash = md5($action_id);
+    $edit = array('aid' => $hash);
+    $this->drupalPost('admin/structure/trigger/user', $edit, t('Assign'));
+
+    // Set action variable to FALSE.
+    variable_set( $action_id, FALSE );
+
+    // Create an unblocked user
+    $web_user = $this->drupalCreateUser(array('administer users'));
+    $this->drupalLogin($web_user);
+    $name = $this->randomName();
+    $pass = user_password();
+    $edit = array();
+    $edit['name'] = $name;
+    $edit['mail'] = $name . '@example.com';
+    $edit['pass[pass1]'] = $pass;
+    $edit['pass[pass2]'] = $pass;
+    $edit['status'] = 1;
+    $this->drupalPost('admin/people/create', $edit, t('Create new account'));
+
+    // Verify that the action variable has been set.
+    $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 );
+  }
+
+  /**
+   * Test triggering on comment save.
+   */
+  function testActionsComment() {
+    // Assign an action to the comment save trigger.
+    $test_user = $this->drupalCreateUser(array('administer actions'));
+    $this->drupalLogin($test_user);
+    $action_id = 'trigger_test_generic_action';
+    $hash = md5($action_id);
+    $edit = array('aid' => $hash);
+    $this->drupalPost('admin/structure/trigger/comment', $edit, t('Assign'));
+
+    // Set action variable to 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'));
+    $this->drupalLogin($web_user);
+    $node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1));
+    $edit = array();
+    $edit['subject'] = $this->randomName(10);
+    $edit['comment'] = $this->randomName(10) . ' ' . $this->randomName(10);
+    $this->drupalGet('comment/reply/' . $node->nid);
+    $this->drupalPost(NULL, $edit, t('Save'));
+    $this->drupalGet('node/' . $node->nid);
+    $this->outputScreenContents('After assigning action', 'trigger_screen');
+
+    // Verify that the action variable has been set.
+    $this->assertTrue(variable_get($action_id, FALSE), t('Check that creating a comment triggered the action.'));
+  }
+
+  /**
+   * Test triggering on taxonomy new term
+   */
+  function testActionsTaxonomy() {
+    // Assign an action to the taxonomy term save trigger
+    $test_user = $this->drupalCreateUser(array('administer actions'));
+    $this->drupalLogin($test_user);
+    $action_id = 'trigger_test_generic_action';
+    $hash = md5($action_id);
+    $edit = array('aid' => $hash);
+    $this->drupalPost('admin/structure/trigger/taxonomy', $edit, t('Assign'));
+
+    // Set action variable to FALSE.
+    variable_set( $action_id, FALSE );
+
+    // Create a taxonomy vocabulary and add a term to it.
+
+    // Create a vocabulary.
+    $vocabulary = new stdClass();
+    $vocabulary->name = $this->randomName();
+    $vocabulary->description = $this->randomName();
+    $vocabulary->machine_name = drupal_strtolower($this->randomName());
+    $vocabulary->help = '';
+    $vocabulary->nodes = array('article' => 'article');
+    $vocabulary->weight = mt_rand(0, 10);
+    taxonomy_vocabulary_save($vocabulary);
+
+    $term = new stdClass();
+    $term->name = $this->randomName();
+    $term->vid = $vocabulary->vid;
+    taxonomy_term_save($term);
+
+    // 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.2
diff -u -u -p -r1.2 trigger_test.module
--- modules/trigger/tests/trigger_test.module	31 May 2009 03:12:19 -0000	1.2
+++ modules/trigger/tests/trigger_test.module	26 Aug 2009 21:36:50 -0000
@@ -28,6 +28,17 @@ function trigger_test_action_info() {
         'cron' => array('run'),
       ),
     ),
+    'trigger_test_generic_action' => array(
+      'type' => 'system',
+      'description' => t('Generic test action'),
+      'configurable' => FALSE,
+      'hooks' => array(
+        'taxonomy' => array('insert', 'update', 'delete'),
+        'comment' => array('insert', 'update', 'delete', 'view'),
+        'taxonomy' => array('insert', 'update', 'delete'),
+        'user' => array('insert', 'update', 'delete', 'login', 'logout', 'view'),
+      ),
+    ),
   );
 }
 
@@ -74,3 +85,11 @@ function trigger_test_system_cron_conf_a
   );
   return $params;
 }
+
+/**
+ * Action fired during the "taxonomy", "comment", and "user" trigger tests.
+ */
+function trigger_test_generic_action($context) {
+  // Indicate successful execution by setting a persistent variable.
+  variable_set('trigger_test_generic_action', TRUE);
+}
