function IntegrityCheckTest::testUsingRefinedProvidedVariables

Tests using provided variables with refined context.

File

tests/src/Unit/Integration/Engine/IntegrityCheckTest.php, line 398

Class

IntegrityCheckTest
Test the integrity check functionality during configuration time.

Namespace

Drupal\Tests\rules\Unit\Integration\Engine

Code

public function testUsingRefinedProvidedVariables() {
    $rule = $this->rulesExpressionManager
        ->createRule();
    $rule->addAction('rules_variable_add', ContextConfig::create()->setValue('type', 'string')
        ->setValue('value', 'foo'));
    $rule->addAction('rules_system_message', ContextConfig::create()->map('message', 'variable_added')
        ->setValue('type', MessengerInterface::TYPE_STATUS));
    // The message action requires a string, thus if the context is not refined
    // it will end up as "any" and integrity check would fail.
    $violation_list = RulesComponent::create($rule)->checkIntegrity();
    $this->assertCount(0, $violation_list);
}