function IntegrityCheckTest::testMissingRequiredContext
Tests that an absent required context triggers a violation.
File
-
tests/
src/ Unit/ Integration/ Engine/ IntegrityCheckTest.php, line 291
Class
- IntegrityCheckTest
- Test the integrity check functionality during configuration time.
Namespace
Drupal\Tests\rules\Unit\Integration\EngineCode
public function testMissingRequiredContext() {
$rule = $this->rulesExpressionManager
->createRule();
// The condition is completely un-configured, missing 2 required contexts.
$condition = $this->rulesExpressionManager
->createCondition('rules_node_is_of_type');
$rule->addExpressionObject($condition);
$violation_list = RulesComponent::create($rule)->checkIntegrity();
$this->assertCount(2, $violation_list);
$this->assertEquals('The required context <em class="placeholder">Node</em> is missing.', (string) $violation_list[0]->getMessage());
$this->assertEquals('The required context <em class="placeholder">Content types</em> is missing.', (string) $violation_list[1]->getMessage());
$this->assertEquals($condition->getUuid(), $violation_list[0]->getUuid());
$this->assertEquals($condition->getUuid(), $violation_list[1]->getUuid());
}