function LoopTest::testInvalidListType
Tests that the data type used to loop over is a list.
File
-
tests/
src/ Unit/ Integration/ Engine/ LoopTest.php, line 256
Class
- LoopTest
- Test Rules execution with the loop plugin.
Namespace
Drupal\Tests\rules\Unit\Integration\EngineCode
public function testInvalidListType() {
$rule = $this->rulesExpressionManager
->createRule();
$loop = $this->rulesExpressionManager
->createInstance('rules_loop', [
'list' => 'string_variable',
]);
$rule->addExpressionObject($loop);
$violations = RulesComponent::create($rule)->addContextDefinition('string_variable', ContextDefinition::create('string'))
->checkIntegrity();
$this->assertCount(1, $violations);
$this->assertEquals('The data type of list variable <em class="placeholder">string_variable</em> is not a list.', (string) $violations[0]->getMessage());
}