You are here

public function PrepareExecutionMetadataStateTest::testAddingVariable in Rules 8.3

Tests that a variable can be added by an action and is then available.

File

tests/src/Unit/Integration/Engine/PrepareExecutionMetadataStateTest.php, line 21

Class

PrepareExecutionMetadataStateTest
Tests that the setup of the execution metadata state for an expression works.

Namespace

Drupal\Tests\rules\Unit\Integration\Engine

Code

public function testAddingVariable() {
  $rule = $this->rulesExpressionManager
    ->createRule();
  $rule
    ->addAction('rules_variable_add', ContextConfig::create()
    ->setValue('type', 'string')
    ->setValue('value', '')
    ->provideAs('variable_added', 'result'));
  $state = ExecutionMetadataState::create();
  $found = $rule
    ->prepareExecutionMetadataState($state);
  $this
    ->assertTrue($state
    ->hasDataDefinition('result'));
  $this
    ->assertNull($found);
}