function RulesTriggerTestCase::testReactiveRuleCreation
Same name in other branches
- 7.x-2.x tests/rules.test \RulesTriggerTestCase::testReactiveRuleCreation()
Tests CRUD for reaction rules - making sure the events are stored properly.
File
-
d7-tests/
rules_test_trigger_case.test, line 47
Class
- RulesTriggerTestCase
- Test triggering rules.
Code
function testReactiveRuleCreation() {
$rule = $this->createTestRule();
$rule->save();
$result = db_query("SELECT event FROM {rules_trigger} WHERE id = :id", array(
':id' => $rule->id,
));
$this->assertEqual($result->fetchField(), 'node_presave', 'Associated event has been saved.');
// Try updating.
$rule->removeEvent('node_presave');
$rule->event('node_insert');
$rule->event('node_update');
$rule->active = FALSE;
$rule->integrityCheck()
->save();
$result = db_query("SELECT event FROM {rules_trigger} WHERE id = :id", array(
':id' => $rule->id,
));
$this->assertEqual($result->fetchCol(), array_values($rule->events()), 'Updated associated events.');
// Try deleting.
$rule->delete();
$result = db_query("SELECT event FROM {rules_trigger} WHERE id = :id", array(
':id' => $rule->id,
));
$this->assertEqual($result->fetchField(), FALSE, 'Deleted associated events.');
}