function RulesTriggerTestCase::testEventSettings
Same name in other branches
- 7.x-2.x tests/rules.test \RulesTriggerTestCase::testEventSettings()
Tests creating and triggering a reaction rule with event settings.
File
-
d7-tests/
rules_test_trigger_case.test, line 213
Class
- RulesTriggerTestCase
- Test triggering rules.
Code
function testEventSettings() {
$rule = rules_reaction_rule();
$rule->event('node_presave', array(
'bundle' => 'article',
))
->condition('data_is_empty', array(
'data:select' => 'node:field-tags',
))
->action('node_publish', array(
'node:select' => 'node',
));
$rule->integrityCheck()
->save();
$node = $this->drupalCreateNode(array(
'type' => 'page',
'status' => 0,
));
$this->assertEqual($node->status, 0, 'Rule has not been triggered.');
$node = $this->drupalCreateNode(array(
'type' => 'article',
'status' => 0,
));
$this->assertEqual($node->status, 1, 'Rule has been triggered.');
RulesLog::logger()->checkLog();
// Make sure an invalid bundle raises integrity problems.
$rule->event('node_presave', array(
'bundle' => 'invalid',
));
try {
$rule->integrityCheck();
$this->fail('Integrity check failed.');
} catch (RulesIntegrityException $e) {
$this->pass('Integrity check failed: ' . $e);
}
}