You are here

public function IntegrityCheckTest::testUsingRefinedProvidedVariables in Rules 8.3

Tests using provided variables with refined context.

File

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

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
    ->assertEquals(0, iterator_count($violation_list));
}