UuidItemTest.php

Same filename and directory in other branches
  1. 9 core/modules/field/tests/src/Kernel/String/UuidItemTest.php
  2. 8.9.x core/modules/field/tests/src/Kernel/String/UuidItemTest.php
  3. 10 core/modules/field/tests/src/Kernel/KernelString/UuidItemTest.php

Namespace

Drupal\Tests\field\Kernel\KernelString

File

core/modules/field/tests/src/Kernel/KernelString/UuidItemTest.php

View source
<?php

declare (strict_types=1);
namespace Drupal\Tests\field\Kernel\KernelString;

use Drupal\entity_test\Entity\EntityTest;
use Drupal\Tests\field\Kernel\FieldKernelTestBase;
use Drupal\Component\Uuid\Uuid;

/**
 * Tests the UUID field.
 *
 * @group field
 */
class UuidItemTest extends FieldKernelTestBase {
    
    /**
     * Tests 'uuid' random values.
     */
    public function testSampleValue() : void {
        $entity = EntityTest::create([]);
        $entity->save();
        $uuid_field = $entity->get('uuid');
        // Test the generateSampleValue() method.
        $uuid_field->generateSampleItems();
        $this->assertTrue(Uuid::isValid($uuid_field->value));
    }

}

Classes

Title Deprecated Summary
UuidItemTest Tests the UUID field.

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