Commit dd590b30 authored by webchick's avatar webchick

#246096 by andypost, mr.baileys, and Sutharsan: Fix typo so that cron triggers...

#246096 by andypost, mr.baileys, and Sutharsan: Fix typo so that cron triggers may be executed (with tests).
parent 9669352f
; $Id$
name = "Trigger Test"
description = "Support module for Trigger tests."
package = Testing
core = 7.x
files[] = trigger_test.module
hidden = TRUE
<?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);
}
......@@ -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;
......
......@@ -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.'));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment