public function LoopTest::testListExists in Rules 8.3
Tests that the specified list variable exists in the execution state.
File
- tests/
src/ Unit/ Integration/ Engine/ LoopTest.php, line 188
Class
- LoopTest
- Test Rules execution with the loop plugin.
Namespace
Drupal\Tests\rules\Unit\Integration\EngineCode
public function testListExists() {
$rule = $this->rulesExpressionManager
->createRule();
$loop = $this->rulesExpressionManager
->createInstance('rules_loop', [
'list' => 'unknown_list',
]);
$rule
->addExpressionObject($loop);
$violations = RulesComponent::create($rule)
->checkIntegrity();
$this
->assertEquals(1, iterator_count($violations));
// The Exception message part of the output should be HTML-escaped.
$this
->assertEquals("List variable <em class=\"placeholder\">unknown_list</em> does not exist. Unable to get variable 'unknown_list'; it is not defined.", (string) $violations[0]
->getMessage());
}