function UnitTestCase::randomMachineName

Same name and namespace in other branches
  1. 8.9.x 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()

15 calls to UnitTestCase::randomMachineName()
AuthenticationCollectorTest::testAuthenticationCollector in core/tests/Drupal/Tests/Core/Authentication/AuthenticationCollectorTest.php
Tests adding, getting, and order of priorities.
BigPipeResponseAttachmentsProcessorTest::attachmentsProvider in core/modules/big_pipe/tests/src/Unit/Render/BigPipeResponseAttachmentsProcessorTest.php
CachedStorageTest::testListAllStaticCache in core/tests/Drupal/Tests/Core/Config/CachedStorageTest.php
Tests listAll static cache.
CsrfTokenGeneratorTest::setUp in core/tests/Drupal/Tests/Core/Access/CsrfTokenGeneratorTest.php
CsrfTokenGeneratorTest::testGet in core/tests/Drupal/Tests/Core/Access/CsrfTokenGeneratorTest.php
Tests CsrfTokenGenerator::get().

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

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