function IntegrityCheckTest::testInputRestriction

Tests the input restriction on contexts.

File

tests/src/Unit/Integration/Engine/IntegrityCheckTest.php, line 168

Class

IntegrityCheckTest
Test the integrity check functionality during configuration time.

Namespace

Drupal\Tests\rules\Unit\Integration\Engine

Code

public function testInputRestriction() {
    $rule = $this->rulesExpressionManager
        ->createRule();
    $action = $this->rulesExpressionManager
        ->createAction('rules_entity_fetch_by_id', ContextConfig::create()->map('type', 'variable_1')
        ->setValue('entity_id', 1));
    $rule->addExpressionObject($action);
    $violation_list = RulesComponent::create($rule)->addContextDefinition('variable_1', ContextDefinition::create('string'))
        ->checkIntegrity();
    $this->assertCount(1, $violation_list);
    $this->assertEquals('The context <em class="placeholder">Entity type</em> may not be configured using a selector.', (string) $violation_list[0]->getMessage());
    $this->assertEquals($action->getUuid(), $violation_list[0]->getUuid());
}