public function RulesComponentTest::testRuleExecutionWithContext in Rules 8.3
Tests executing a rule providing context based upon given context.
File
- tests/
src/ Unit/ Integration/ Engine/ RulesComponentTest.php, line 22
Class
- RulesComponentTest
- Tests the Rules component class.
Namespace
Drupal\Tests\rules\Unit\Integration\EngineCode
public function testRuleExecutionWithContext() {
$rule = $this->rulesExpressionManager
->createRule();
$rule
->addAction('rules_test_string', ContextConfig::create()
->map('text', 'text'));
$result = RulesComponent::create($rule)
->addContextDefinition('text', ContextDefinition::create('string'))
->provideContext('concatenated')
->setContextValue('text', 'foo')
->execute();
// Ensure the provided context is returned.
$this
->assertTrue(isset($result['concatenated']) && $result['concatenated'] == 'foofoo');
}