public function IntegrityCheckTest::testRefiningContextBasedonMappedContext in Rules 8.3
Tests context can be refined based upon mapped context.
File
- tests/
src/ Unit/ Integration/ Engine/ IntegrityCheckTest.php, line 370
Class
- IntegrityCheckTest
- Test the integrity check functionality during configuration time.
Namespace
Drupal\Tests\rules\Unit\Integration\EngineCode
public function testRefiningContextBasedonMappedContext() {
// DataComparision 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
->assertEquals(0, iterator_count($violation_list));
$violation_list = RulesComponent::create($rule)
->addContextDefinition('text', ContextDefinition::create('string'))
->addContextDefinition('text2', ContextDefinition::create('integer'))
->checkIntegrity();
$this
->assertEquals(1, iterator_count($violation_list));
}