You are here

public function UuidItemTest::testSampleValue in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/field/tests/src/Kernel/String/UuidItemTest.php \Drupal\Tests\field\Kernel\String\UuidItemTest::testSampleValue()

Tests 'uuid' random values.

File

core/modules/field/tests/src/Kernel/String/UuidItemTest.php, line 19

Class

UuidItemTest
Tests the UUID field.

Namespace

Drupal\Tests\field\Kernel\String

Code

public function testSampleValue() {
  $entity = EntityTest::create([]);
  $entity
    ->save();
  $uuid_field = $entity
    ->get('uuid');

  // Test the generateSampleValue() method.
  $uuid_field
    ->generateSampleItems();
  $this
    ->assertTrue(Uuid::isValid($uuid_field->value));
}