Security update for Core, with self-updated composer
[yaffs-website] / web / core / tests / Drupal / KernelTests / Core / Validation / ConstraintsTest.php
diff --git a/web/core/tests/Drupal/KernelTests/Core/Validation/ConstraintsTest.php b/web/core/tests/Drupal/KernelTests/Core/Validation/ConstraintsTest.php
new file mode 100644 (file)
index 0000000..8e17422
--- /dev/null
@@ -0,0 +1,45 @@
+<?php
+
+namespace Drupal\KernelTests\Core\Validation;
+
+use Drupal\KernelTests\KernelTestBase;
+
+/**
+ * Tests various low level constrains provided by core.
+ *
+ * @group Validation
+ */
+class ConstraintsTest extends KernelTestBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public static $modules = ['config_test'];
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+
+    $this->installConfig('config_test');
+  }
+
+  /**
+   * @see \Drupal\Core\Validation\Plugin\Validation\Constraint\UuidConstraint
+   */
+  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());
+  }
+
+}