public function ConstraintsTest::testUuid in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/Core/Validation/ConstraintsTest.php \Drupal\KernelTests\Core\Validation\ConstraintsTest::testUuid()
- 9 core/tests/Drupal/KernelTests/Core/Validation/ConstraintsTest.php \Drupal\KernelTests\Core\Validation\ConstraintsTest::testUuid()
See also
\Drupal\Core\Validation\Plugin\Validation\Constraint\UuidConstraint
File
- core/
tests/ Drupal/ KernelTests/ Core/ Validation/ ConstraintsTest.php, line 31
Class
- ConstraintsTest
- Tests various low level constrains provided by core.
Namespace
Drupal\KernelTests\Core\ValidationCode
public function testUuid() {
$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());
}