Security update for Core, with self-updated composer
[yaffs-website] / web / core / tests / Drupal / KernelTests / Core / Validation / ConstraintsTest.php
1 <?php
2
3 namespace Drupal\KernelTests\Core\Validation;
4
5 use Drupal\KernelTests\KernelTestBase;
6
7 /**
8  * Tests various low level constrains provided by core.
9  *
10  * @group Validation
11  */
12 class ConstraintsTest extends KernelTestBase {
13
14   /**
15    * {@inheritdoc}
16    */
17   public static $modules = ['config_test'];
18
19   /**
20    * {@inheritdoc}
21    */
22   protected function setUp() {
23     parent::setUp();
24
25     $this->installConfig('config_test');
26   }
27
28   /**
29    * @see \Drupal\Core\Validation\Plugin\Validation\Constraint\UuidConstraint
30    */
31   public function testUuid() {
32     $typed_config_manager = \Drupal::service('config.typed');
33     /** @var \Drupal\Core\Config\Schema\TypedConfigInterface $typed_config */
34     $typed_config = $typed_config_manager->get('config_test.validation');
35     $typed_config->get('uuid')
36       ->setValue(\Drupal::service('uuid')->generate());
37
38     $this->assertCount(0, $typed_config->validate());
39
40     $typed_config->get('uuid')
41       ->setValue(\Drupal::service('uuid')->generate() . '-invalid');
42     $this->assertCount(1, $typed_config->validate());
43   }
44
45 }