summaryrefslogtreecommitdiff
path: root/modules/trigger
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2009-05-31 03:12:19 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2009-05-31 03:12:19 +0000
commita26efbeb5a0ad8b90c8eb2b20f06d34e69d2958f (patch)
treef552be0bea60b63a791cc66cf362c3b684ff0610 /modules/trigger
parent5b8d80b95d409a899821bf6b3b0825e1c24cd9dc (diff)
downloadbrdo-a26efbeb5a0ad8b90c8eb2b20f06d34e69d2958f.tar.gz
brdo-a26efbeb5a0ad8b90c8eb2b20f06d34e69d2958f.tar.bz2
#408434 by mr.baileys and andypost: Fix fatal error in actions.inc after DBTNG conversion.
Diffstat (limited to 'modules/trigger')
-rw-r--r--modules/trigger/tests/trigger_test.module44
-rw-r--r--modules/trigger/trigger.test48
2 files changed, 81 insertions, 11 deletions
diff --git a/modules/trigger/tests/trigger_test.module b/modules/trigger/tests/trigger_test.module
index c44360d52..bb973ba11 100644
--- a/modules/trigger/tests/trigger_test.module
+++ b/modules/trigger/tests/trigger_test.module
@@ -20,6 +20,14 @@ function trigger_test_action_info() {
'cron' => array('run'),
),
),
+ 'trigger_test_system_cron_conf_action' => array(
+ 'type' => 'system',
+ 'description' => t('Cron test configurable action'),
+ 'configurable' => TRUE,
+ 'hooks' => array(
+ 'cron' => array('run'),
+ ),
+ ),
);
}
@@ -30,3 +38,39 @@ function trigger_test_system_cron_action() {
// Indicate successful execution by setting a persistent variable.
variable_set('trigger_test_system_cron_action', TRUE);
}
+
+/**
+ * Implement a configurable Drupal action.
+ */
+function trigger_test_system_cron_conf_action($object, $context) {
+ // Indicate successful execution by incrementing a persistent variable.
+ $value = variable_get('trigger_test_system_cron_conf_action', 0) + 1;
+ variable_set('trigger_test_system_cron_conf_action', $value);
+}
+
+/**
+ * Form for configurable test action.
+ */
+function trigger_test_system_cron_conf_action_form($context) {
+ if (!isset($context['subject'])) {
+ $context['subject'] = '';
+ }
+ $form['subject'] = array(
+ '#type' => 'textfield',
+ '#default_value' => $context['subject'],
+ );
+ return $form;
+}
+
+/**
+ * Form submission handler for configurable test action.
+ */
+function trigger_test_system_cron_conf_action_submit($form, $form_state) {
+ $form_values = $form_state['values'];
+ // Process the HTML form to store configuration. The keyed array that
+ // we return will be serialized to the database.
+ $params = array(
+ 'subject' => $form_values['subject'],
+ );
+ return $params;
+}
diff --git a/modules/trigger/trigger.test b/modules/trigger/trigger.test
index 1acac13b2..32f056cff 100644
--- a/modules/trigger/trigger.test
+++ b/modules/trigger/trigger.test
@@ -127,25 +127,51 @@ class TriggerCronTestCase extends DrupalWebTestCase {
}
/**
- * Assign an action to a trigger, then pull the trigger, and make sure the actions fire.
+ * Test assigning multiple actions to the cron trigger.
+ *
+ * This test ensures that both simple and multiple complex actions
+ * succeed properly. This is done in the cron trigger test because
+ * cron allows passing multiple actions in at once.
*/
function testActionsCron() {
- $action = 'trigger_test_system_cron_action';
- $hash = md5($action);
-
- // Create administrative user.
+ // Create an 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);
+
+ // Assign a non-configurable action to the cron run trigger.
+ $edit = array('aid' => md5('trigger_test_system_cron_action'));
$this->drupalPost('admin/build/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();
+ $edit = array(
+ 'actions_description' => $action_description,
+ 'subject' => $action_description,
+ );
+ $this->drupalPost('admin/settings/actions/configure/' . $hash, $edit, t('Save'));
+ $edit = array('aid' => md5('1'));
+ $this->drupalPost('admin/build/trigger/cron', $edit, t('Assign'));
+
+ // Add a second configurable action to the cron trigger.
+ $action_description = $this->randomName();
+ $edit = array(
+ 'actions_description' => $action_description,
+ 'subject' => $action_description,
+ );
+ $this->drupalPost('admin/settings/actions/configure/' . $hash, $edit, t('Save'));
+ $edit = array('aid' => md5('2'));
+ $this->drupalPost('admin/build/trigger/cron', $edit, t('Assign'));
+
// Force a cron run.
drupal_cron_run();
-
- // Make sure the actions fire.
+
+ // 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.'));
}
}