function RandomGeneratorTrait::randomMachineName

Same name and namespace in other branches
  1. 10 core/tests/Drupal/Tests/RandomGeneratorTrait.php \Drupal\Tests\RandomGeneratorTrait::randomMachineName()
  2. 11.x 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\simpletest\TestBase::randomString().

Parameters

int $length: Length of random string to generate.

Return value

string Randomly generated unique string.

See also

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

570 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.
AliasTest::testWhitelist in core/modules/path_alias/tests/src/Kernel/AliasTest.php
Tests the alias whitelist.
AliasTest::testWhitelistCacheDeletionMidRequest in core/modules/path_alias/tests/src/Kernel/AliasTest.php
Tests situation where the whitelist cache is deleted mid-request.
AreaEmptyTest::testRenderEmptyHeaderFooter in core/modules/views/tests/src/Kernel/Handler/AreaEmptyTest.php
Tests that the header and footer areas are not rendered if empty.

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

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