public function LoopTest::testInvalidListType in Rules 8.3
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
->assertEquals(1, iterator_count($violations));
$this
->assertEquals('The data type of list variable <em class="placeholder">string_variable</em> is not a list.', (string) $violations[0]
->getMessage());
}