function UuidValidatorTest::testUuid
Same name in other branches
- 11.x core/tests/Drupal/KernelTests/Core/Validation/UuidValidatorTest.php \Drupal\KernelTests\Core\Validation\UuidValidatorTest::testUuid()
See also
\Drupal\Core\Validation\Plugin\Validation\Constraint\UuidConstraint
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Validation/ UuidValidatorTest.php, line 33
Class
- UuidValidatorTest
- Tests the UUID validator.
Namespace
Drupal\KernelTests\Core\ValidationCode
public function testUuid() : void {
$typed_config_manager = \Drupal::service('config.typed');
/** @var \Drupal\Core\Config\Schema\TypedConfigInterface $typed_config */
$typed_config = $typed_config_manager->get('config_test.validation');
$typed_config->get('uuid')
->setValue(\Drupal::service('uuid')->generate());
$this->assertCount(0, $typed_config->validate());
$typed_config->get('uuid')
->setValue(\Drupal::service('uuid')->generate() . '-invalid');
$this->assertCount(1, $typed_config->validate());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.