public function RulesTestCase::testRuleCreation in Rules 7.2
Tests creating a rule and iterating over the rule elements.
File
- tests/
rules.test, line 68 - Rules tests.
Class
- RulesTestCase
- Rules test cases.
Code
public function testRuleCreation() {
$rule = $this
->createTestRule();
$rule
->integrityCheck();
$rule
->execute();
$log = RulesLog::logger()
->get();
$last = array_pop($log);
$last = array_pop($log);
$last = array_pop($log);
$this
->assertEqual($last[0], 'action called', 'Action called');
RulesLog::logger()
->checkLog();
// Make sure condition and action iterators are working.
$it = new RecursiveIteratorIterator($rule
->conditions(), RecursiveIteratorIterator::SELF_FIRST);
$this
->assertEqual(iterator_count($it), 8, 'Iterated over all conditions and condition containers');
$it = new RecursiveIteratorIterator($rule
->conditions());
$this
->assertEqual(iterator_count($it), 6, 'Iterated over all conditions');
$this
->assertEqual(iterator_count($rule
->actions()), 1, 'Iterated over all actions');
$this
->assertEqual(iterator_count($rule
->elements()), 10, 'Iterated over all rule elements.');
// Test getting dependencies and the integrity check.
$rule
->integrityCheck();
$this
->assertTrue($rule
->dependencies() === array(
'rules_test',
), 'Dependencies correctly returned.');
}