function LoopTest::testListExists

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\Engine

Code

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->assertCount(1, $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 &#039;unknown_list&#039;; it is not defined.", (string) $violations[0]->getMessage());
}