You are here

public function UnitTestCase::randomMachineName in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/UnitTestCase.php \Drupal\Tests\UnitTestCase::randomMachineName()
  2. 9 core/tests/Drupal/Tests/UnitTestCase.php \Drupal\Tests\UnitTestCase::randomMachineName()

Generates a unique random string containing letters and numbers.

Parameters

int $length: Length of random string to generate.

Return value

string Randomly generated unique string.

See also

\Drupal\Component\Utility\Random::name()

94 calls to UnitTestCase::randomMachineName()
AttributeTest::testPrint in core/tests/Drupal/Tests/Core/Template/AttributeTest.php
Tests printing of an attribute.
AuthenticationCollectorTest::testAuthenticationCollector in core/tests/Drupal/Tests/Core/Authentication/AuthenticationCollectorTest.php
Tests adding, getting, and order of priorities.
BaseFieldDefinitionTest::setUp in core/tests/Drupal/Tests/Core/Entity/BaseFieldDefinitionTest.php
BaseFieldDefinitionTest::testFieldDefaultValue in core/tests/Drupal/Tests/Core/Entity/BaseFieldDefinitionTest.php
Tests field default value.
BaseFieldDefinitionTest::testFieldDescription in core/tests/Drupal/Tests/Core/Entity/BaseFieldDefinitionTest.php
Tests field description methods.

... See full list

File

core/tests/Drupal/Tests/UnitTestCase.php, line 83

Class

UnitTestCase
Provides a base class and helpers for Drupal unit tests.

Namespace

Drupal\Tests

Code

public function randomMachineName($length = 8) {
  return $this
    ->getRandomGenerator()
    ->name($length, TRUE);
}