function PrepareExecutionMetadataStateTest::testPrepareAfterLoop
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\EngineCode
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);
}