function UuidItemTest::testSampleValue

Same name in other branches
  1. 9 core/modules/field/tests/src/Kernel/String/UuidItemTest.php \Drupal\Tests\field\Kernel\String\UuidItemTest::testSampleValue()
  2. 8.9.x core/modules/field/tests/src/Kernel/String/UuidItemTest.php \Drupal\Tests\field\Kernel\String\UuidItemTest::testSampleValue()
  3. 11.x core/modules/field/tests/src/Kernel/KernelString/UuidItemTest.php \Drupal\Tests\field\Kernel\KernelString\UuidItemTest::testSampleValue()

Tests 'uuid' random values.

File

core/modules/field/tests/src/Kernel/KernelString/UuidItemTest.php, line 21

Class

UuidItemTest
Tests the UUID field.

Namespace

Drupal\Tests\field\Kernel\KernelString

Code

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));
}

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