function IntegrityCheckTest::testRefiningContextBasedOnMappedContext
Tests context can be refined based upon mapped context.
File
-
tests/
src/ Unit/ Integration/ Engine/ IntegrityCheckTest.php, line 372
Class
- IntegrityCheckTest
- Test the integrity check functionality during configuration time.
Namespace
Drupal\Tests\rules\Unit\Integration\EngineCode
public function testRefiningContextBasedOnMappedContext() {
// DataComparison condition refines context based on selected data. Thus
// it for the test and ensure checking integrity passes when the comparison
// value is of a compatible type and fails else.
$rule = $this->rulesExpressionManager
->createRule();
$rule->addCondition('rules_data_comparison', ContextConfig::create()->map('data', 'text')
->map('value', 'text2'));
$violation_list = RulesComponent::create($rule)->addContextDefinition('text', ContextDefinition::create('string'))
->addContextDefinition('text2', ContextDefinition::create('string'))
->checkIntegrity();
$this->assertCount(0, $violation_list);
$violation_list = RulesComponent::create($rule)->addContextDefinition('text', ContextDefinition::create('string'))
->addContextDefinition('text2', ContextDefinition::create('integer'))
->checkIntegrity();
$this->assertCount(1, $violation_list);
}