public function RulesConditionalFrameworkTestCase::testProvidesVariables in Conditional Rules 7
Same name and namespace in other branches
- 8 tests/rules_conditional.test \RulesConditionalFrameworkTestCase::testProvidesVariables()
Tests container provided variables.
File
- tests/
rules_conditional.test, line 230 - SimpleTest testing suites.
Class
- RulesConditionalFrameworkTestCase
- Framework tests.
Code
public function testProvidesVariables() {
rules_action_set(array())
->action($container = new RulesConditionalTestStubContainer());
$textVariable = array(
'variable_added:var' => 'text',
'type' => 'text',
);
$mixedVariable1 = array(
'variable_added:var' => 'mixed',
'type' => 'text',
);
$mixedVariable2 = array(
'variable_added:var' => 'mixed',
'type' => 'token',
);
$branch1 = new RulesConditionalTestStubElement();
$branch1
->action('variable_add', $textVariable)
->setParent($container);
$this
->assertIdentical(array(), $container
->providesVariables(), 'Container does not provide variables without a default branch.');
$defaultBranch = new RulesConditionalTestStubDefaultElement();
$defaultBranch
->action('variable_add', $textVariable)
->setParent($container);
$this
->assertIdentical(array(
'text',
), array_keys($container
->providesVariables()), 'Container provides common variables in complete branches.');
$branch1
->action('variable_add', $mixedVariable1);
$defaultBranch
->action('variable_add', $mixedVariable2);
$this
->assertIdentical(array(
'text',
), array_keys($container
->providesVariables()), 'Container does not provide variables with mixed types.');
$branch2 = new RulesConditionalTestStubElement();
$branch2
->setParent($container);
$this
->assertIdentical(array(), $container
->providesVariables(), 'Container provides no variables if one branch provides none.');
}