public function IntegrityCheckTest::testCheckUuid in Rules 8.3
Tests that the integrity check with UUID works.
File
- tests/
src/ Unit/ Integration/ Engine/ IntegrityCheckTest.php, line 58
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
->assertEquals(2, iterator_count($all_violations));
$uuid_violations = $all_violations
->getFor($second_action
->getUuid());
$this
->assertEquals(1, count($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());
}