function IntegrityCheckTest::testSelectorRestriction

Tests the data selector restriction on contexts.

File

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

Class

IntegrityCheckTest
Test the integrity check functionality during configuration time.

Namespace

Drupal\Tests\rules\Unit\Integration\Engine

Code

public function testSelectorRestriction() {
    $rule = $this->rulesExpressionManager
        ->createRule();
    $action = $this->rulesExpressionManager
        ->createAction('rules_data_set', ContextConfig::create()->setValue('data', 'some value')
        ->setValue('value', 'some new value'));
    $rule->addExpressionObject($action);
    $violation_list = RulesComponent::create($rule)->checkIntegrity();
    $this->assertCount(1, $violation_list);
    $this->assertEquals('The context <em class="placeholder">Data</em> may only be configured using a selector.', (string) $violation_list[0]->getMessage());
    $this->assertEquals($action->getUuid(), $violation_list[0]->getUuid());
}