public function RulesTriggerTestCase::testDefaultRule in Rules 7.2
Same name and namespace in other branches
- 8.3 d7-tests/rules_test_trigger_case.test \RulesTriggerTestCase::testDefaultRule()
Tests the provided default rule 'rules_test_default_1'.
File
- tests/
rules.test, line 1318 - Rules tests.
Class
- RulesTriggerTestCase
- Test triggering rules.
Code
public function testDefaultRule() {
$rule = rules_config_load('rules_test_default_1');
$this
->assertTrue($rule->status & ENTITY_IN_CODE && !($rule->status & ENTITY_IN_DB), 'Default rule can be loaded and has the right status.');
$this
->assertTrue($rule->tags == array(
'Admin',
'Tag2',
), 'Default rule has correct tags.');
// Enable.
$rule->active = TRUE;
$rule
->save();
// Create a node that triggers the rule.
$node = $this
->drupalCreateNode(array(
'type' => 'page',
'sticky' => 0,
'status' => 0,
));
// Clear messages.
drupal_get_messages();
// Let event node_update occur.
node_save($node);
$msg = drupal_get_messages();
$this
->assertEqual($msg['status'][0], 'A node has been updated.', 'Default rule has been triggered.');
}