function IntegrityCheckTest::testCheckUuid
Tests that the integrity check with UUID works.
File
-
tests/
src/ Unit/ Integration/ Engine/ IntegrityCheckTest.php, line 60
Class
- IntegrityCheckTest
- Test the integrity check functionality during configuration time.
Namespace
Drupal\Tests\rules\Unit\Integration\EngineCode
public function testCheckUuid() {
$rule = $this->rulesExpressionManager
->createRule();
// Just use a rule with 2 dummy actions.
$rule->addAction('rules_entity_save', ContextConfig::create()->map('entity', 'unknown_variable_1'));
$second_action = $this->rulesExpressionManager
->createAction('rules_entity_save', ContextConfig::create()->map('entity', 'unknown_variable_2'));
$rule->addExpressionObject($second_action);
$all_violations = RulesComponent::create($rule)->addContextDefinition('entity', ContextDefinition::create('entity'))
->checkIntegrity();
$this->assertCount(2, $all_violations);
$uuid_violations = $all_violations->getFor($second_action->getUuid());
$this->assertCount(1, $uuid_violations);
$violation = $uuid_violations[0];
// The Exception message part of the output should be HTML-escaped.
$this->assertEquals("Data selector <em class=\"placeholder\">unknown_variable_2</em> for context <em class=\"placeholder\">Entity</em> is invalid. Unable to get variable 'unknown_variable_2'; it is not defined.", (string) $violation->getMessage());
$this->assertEquals($second_action->getUuid(), $violation->getUuid());
}