function RulesEngineTest::testContextPassing

Tests passing a string context to a condition.

File

tests/src/Kernel/RulesEngineTest.php, line 78

Class

RulesEngineTest
Test using the Rules API to create and evaluate rules.

Namespace

Drupal\Tests\rules\Kernel

Code

public function testContextPassing() {
    $rule = $this->expressionManager
        ->createRule();
    $rule->addCondition('rules_test_string_condition', ContextConfig::create()->map('text', 'test'));
    $rule->addAction('rules_test_debug_log');
    RulesComponent::create($rule)->addContextDefinition('test', ContextDefinition::create('string'))
        ->setContextValue('test', 'test value')
        ->execute();
    // Test that the action logged something.
    $this->assertRulesDebugLogEntryExists('action called');
}