summaryrefslogtreecommitdiff
path: root/modules/trigger
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2009-05-27 16:29:05 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2009-05-27 16:29:05 +0000
commitdd590b30800fdbb7652673cc9b48e005048df557 (patch)
treeca3c66780407133be4b5a686eaf122c94500f4e8 /modules/trigger
parent9669352fda5d5eef6c8114d71a30afeb1f60976b (diff)
downloadbrdo-dd590b30800fdbb7652673cc9b48e005048df557.tar.gz
brdo-dd590b30800fdbb7652673cc9b48e005048df557.tar.bz2
#246096 by andypost, mr.baileys, and Sutharsan: Fix typo so that cron triggers may be executed (with tests).
Diffstat (limited to 'modules/trigger')
-rw-r--r--modules/trigger/tests/trigger_test.info7
-rw-r--r--modules/trigger/tests/trigger_test.module32
-rw-r--r--modules/trigger/trigger.module4
-rw-r--r--modules/trigger/trigger.test40
4 files changed, 81 insertions, 2 deletions
diff --git a/modules/trigger/tests/trigger_test.info b/modules/trigger/tests/trigger_test.info
new file mode 100644
index 000000000..878f9f98b
--- /dev/null
+++ b/modules/trigger/tests/trigger_test.info
@@ -0,0 +1,7 @@
+; $Id$
+name = "Trigger Test"
+description = "Support module for Trigger tests."
+package = Testing
+core = 7.x
+files[] = trigger_test.module
+hidden = TRUE
diff --git a/modules/trigger/tests/trigger_test.module b/modules/trigger/tests/trigger_test.module
new file mode 100644
index 000000000..c44360d52
--- /dev/null
+++ b/modules/trigger/tests/trigger_test.module
@@ -0,0 +1,32 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Mock module to aid in testing trigger.module.
+ */
+
+/**
+ * Implementation of hook_action_info().
+ */
+function trigger_test_action_info() {
+ // Register an action that can be assigned to the trigger "cron run".
+ return array(
+ 'trigger_test_system_cron_action' => array(
+ 'type' => 'system',
+ 'description' => t('Cron test action'),
+ 'configurable' => FALSE,
+ 'hooks' => array(
+ 'cron' => array('run'),
+ ),
+ ),
+ );
+}
+
+/**
+ * Action fired during the "cron run" trigger test.
+ */
+function trigger_test_system_cron_action() {
+ // Indicate successful execution by setting a persistent variable.
+ variable_set('trigger_test_system_cron_action', TRUE);
+}
diff --git a/modules/trigger/trigger.module b/modules/trigger/trigger.module
index f7c931ca3..9cf0a4f84 100644
--- a/modules/trigger/trigger.module
+++ b/modules/trigger/trigger.module
@@ -371,10 +371,10 @@ function _trigger_comment($a1, $op) {
* Implementation of hook_cron().
*/
function trigger_cron() {
- $aids = _trigger_get_hook_aids('cron');
+ $aids = _trigger_get_hook_aids('cron', 'run');
$context = array(
'hook' => 'cron',
- 'op' => '',
+ 'op' => 'run',
);
// Cron does not act on any specific object.
$object = NULL;
diff --git a/modules/trigger/trigger.test b/modules/trigger/trigger.test
index a662e33e7..72a496909 100644
--- a/modules/trigger/trigger.test
+++ b/modules/trigger/trigger.test
@@ -109,3 +109,43 @@ class TriggerContentTestCase extends DrupalWebTestCase {
return $info[$action];
}
}
+
+/**
+ * Test cron trigger.
+ */
+class TriggerCronTestCase extends DrupalWebTestCase {
+ function getInfo() {
+ return array(
+ 'name' => t('Trigger cron (system) actions'),
+ 'description' => t('Perform various tests with cron trigger.') ,
+ 'group' => t('Trigger'),
+ );
+ }
+
+ function setUp() {
+ parent::setUp('trigger', 'trigger_test');
+ }
+
+ /**
+ * Assign an action to a trigger, then pull the trigger, and make sure the actions fire.
+ */
+ function testActionsCron() {
+ $action = 'trigger_test_system_cron_action';
+ $hash = md5($action);
+
+ // Create administrative user.
+ $test_user = $this->drupalCreateUser(array('administer actions'));
+ $this->drupalLogin($test_user);
+
+ // Select our test action and assign it to a cron run trigger.
+ $edit = array('aid' => $hash);
+ $this->drupalPost('admin/build/trigger/cron', $edit, t('Assign'));
+
+ // Force a cron run.
+ drupal_cron_run();
+
+ // Make sure the actions fire.
+ $action_run = variable_get('trigger_test_system_cron_action', FALSE);
+ $this->assertTrue($action_run, t('Check that the cron run triggered the test action.'));
+ }
+}