function RulesTestCase::testActionSetup

Same name and namespace in other branches
  1. 7.x-2.x tests/rules.test \RulesTestCase::testActionSetup()

Test setting up an action with some action_info and serializing and executing it.

File

d7-tests/rules_test_case.test, line 132

Class

RulesTestCase
@file Rules 7.x tests.

Code

function testActionSetup() {
  $action = rules_action('rules_node_publish_action');
  $s = serialize($action);
  $action2 = unserialize($s);
  $node = (object) array(
    'status' => 0,
    'type' => 'page',
  );
  $node->title = 'test';
  $action2->execute($node);
  $this->assertEqual($node->status, 1, 'Action executed correctly');
  $this->assertTrue(in_array('node', array_keys($action2->parameterInfo())), 'Parameter info returned.');
  $node->status = 0;
  $action2->integrityCheck();
  $action2->executeByArgs(array(
    'node' => $node,
  ));
  $this->assertEqual($node->status, 1, 'Action executed correctly');
  // Test calling an extended + overridden method.
  $this->assertEqual($action2->help(), 'custom', 'Using custom help callback.');
  // Inspect the cache
  //$this->pass(serialize(rules_get_cache()));
  RulesLog::logger()->checkLog();
}