You are here

protected function RandomGeneratorTrait::randomMachineName in Drupal 10

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

Generates a unique random string containing letters and numbers.

Do not use this method when testing unvalidated user input. Instead, use \Drupal\Tests\RandomGeneratorTrait::randomString().

Parameters

int $length: Length of random string to generate.

Return value

string Randomly generated unique string.

See also

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

222 calls to RandomGeneratorTrait::randomMachineName()
ActionTest::testOperations in core/modules/system/tests/src/Kernel/Action/ActionTest.php
Tests the functionality of test actions.
AddFeedTest::testBasicFeedAddNoTitle in core/modules/system/tests/src/Kernel/Common/AddFeedTest.php
Tests attaching feeds with paths, URLs, and titles.
ArgumentTransformTermTest::termArgumentTransformationProvider in core/modules/taxonomy/tests/src/Kernel/Views/ArgumentTransformTermTest.php
Provides data for testTermArgumentTransformation().
ArgumentUidRevisionTest::testArgument in core/modules/node/tests/src/Kernel/Views/ArgumentUidRevisionTest.php
Tests the node_uid_revision argument.
ArgumentValidateTest::testArgumentValidateUserName in core/modules/user/tests/src/Kernel/Views/ArgumentValidateTest.php
Tests the UserName argument validator.

... See full list

File

core/tests/Drupal/Tests/RandomGeneratorTrait.php, line 92

Class

RandomGeneratorTrait
Provides random generator utility methods.

Namespace

Drupal\Tests

Code

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