You are here

function RulesTriggerTestCase::testDefaultRule in Rules 8.3

Same name and namespace in other branches
  1. 7.2 tests/rules.test \RulesTriggerTestCase::testDefaultRule()

Tests the provided default rule 'rules_test_default_1'.

File

d7-tests/rules_test_trigger_case.test, line 192
Rules 7.x tests.

Class

RulesTriggerTestCase
Test triggering rules.

Code

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.');

  // 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.');
}