You are here

public function IntegrityCheckTest::testInvalidProvidedName in Rules 8.3

Tests invalid characters in provided variables.

File

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

Class

IntegrityCheckTest
Test the integrity check functionality during configuration time.

Namespace

Drupal\Tests\rules\Unit\Integration\Engine

Code

public function testInvalidProvidedName() {
  $rule = $this->rulesExpressionManager
    ->createRule();

  // The condition provides a "provided_text" variable.
  $condition = $this->rulesExpressionManager
    ->createCondition('rules_test_provider', ContextConfig::create()
    ->provideAs('provided_text', 'invalid_näme'));
  $rule
    ->addExpressionObject($condition);
  $violation_list = RulesComponent::create($rule)
    ->checkIntegrity();
  $this
    ->assertEquals(1, iterator_count($violation_list));
  $this
    ->assertEquals('Provided variable name <em class="placeholder">invalid_näme</em> contains not allowed characters.', (string) $violation_list[0]
    ->getMessage());
  $this
    ->assertEquals($condition
    ->getUuid(), $violation_list[0]
    ->getUuid());
}