function StringEqualsConcatenatedValuesConstraintValidatorTest::testReservedCharacters

Tests that validation fails if reserved characters are not replaced.

See also

\Drupal\Core\Validation\Plugin\Validation\Constraint\StringEqualsConcatenatedValuesConstraint

File

core/tests/Drupal/KernelTests/Core/Validation/StringEqualsConcatenatedValuesConstraintValidatorTest.php, line 81

Class

StringEqualsConcatenatedValuesConstraintValidatorTest
Tests the StringEqualsConcatenatedValues validator.

Namespace

Drupal\KernelTests\Core\Validation

Code

public function testReservedCharacters() : void {
  /** @var \Drupal\Core\Config\Config $editable_config */
  $editable_config = \Drupal::configFactory()->getEditable('config_test.validation');
  $editable_config->set('string_concat_value_1', 'test|||value');
  $editable_config->set('string_concat_values', 'test>>>value.llama');
  $editable_config->save();
  $this->expectExceptionMessage('Schema errors for config_test.validation with the following errors: 0 [string_concat_values] Expected 'test>>>value.llama', not 'test|||value.llama'. Format: '<%parent.string_concat_value_1>.<%parent.string_concat_value_2>'.');
  $editable_config->set('string_concat_values', 'test|||value.llama');
  $editable_config->save();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.