You are here

public function PrepareExecutionMetadataStateTest::testPrepareAfterLoop in Rules 8.3

Tests that the loop list item is removed after the loop.

File

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

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 testPrepareAfterLoop() {
  $rule = $this->rulesExpressionManager
    ->createRule();
  $loop = $this->rulesExpressionManager
    ->createInstance('rules_loop', [
    'list' => 'string_list',
  ]);
  $action = $this->rulesExpressionManager
    ->createAction('rules_test_string')
    ->setConfiguration(ContextConfig::create()
    ->setValue('text', 'x')
    ->toArray());
  $loop
    ->addExpressionObject($action);
  $rule
    ->addExpressionObject($loop);
  $state = RulesComponent::create($rule)
    ->addContextDefinition('string_list', ContextDefinition::create('string')
    ->setMultiple())
    ->getMetadataState();
  $found = $rule
    ->prepareExecutionMetadataState($state);
  $this
    ->assertFalse($state
    ->hasDataDefinition('list_item'));
  $this
    ->assertNull($found);
}