public function RulesTestCase::testSorting in Rules 7.2
Same name and namespace in other branches
- 8.3 d7-tests/rules_test_case.test \RulesTestCase::testSorting()
Tests sorting rule elements.
File
- tests/
rules.test, line 421 - Rules tests.
Class
- RulesTestCase
- Rules test cases.
Code
public function testSorting() {
$rule = $this
->createTestRule();
$conditions = $rule
->conditions();
$conditions[0]->weight = 10;
$conditions[2]->weight = 10;
$id[0] = $conditions[0]
->elementId();
$id[1] = $conditions[1]
->elementId();
$id[2] = $conditions[2]
->elementId();
// For testing use a deep sort, even if not necessary here.
$rule
->sortChildren(TRUE);
$conditions = $rule
->conditions();
$this
->assertEqual($conditions[0]
->elementId(), $id[1], 'Condition sorted correctly.');
$this
->assertEqual($conditions[1]
->elementId(), $id[0], 'Condition sorted correctly.');
$this
->assertEqual($conditions[2]
->elementId(), $id[2], 'Condition sorted correctly.');
}