You are here

protected function RandomGeneratorTrait::randomMachineName in Drupal 8

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

920 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.
AggregatorTestBase::createSampleNodes in core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php
Creates sample article nodes.
AggregatorTestBase::createSampleNodes in core/modules/aggregator/src/Tests/AggregatorTestBase.php
Creates sample article nodes.
AggregatorTestBase::getFeedEditArray in core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php
Returns a randomly generated feed edit array.

... See full list

1 method overrides RandomGeneratorTrait::randomMachineName()
FeedAdminDisplayTest::randomMachineName in core/modules/aggregator/tests/src/Functional/FeedAdminDisplayTest.php
Generates a unique random string containing letters and numbers.

File

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

Class

RandomGeneratorTrait
Provides random generator utility methods.

Namespace

Drupal\Tests

Code

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