You are here

protected function UnitTestCase::getRandomGenerator in Drupal 10

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

Gets the random generator for the utility methods.

Return value

\Drupal\Component\Utility\Random The random generator

11 calls to UnitTestCase::getRandomGenerator()
AccessResultForbiddenTest::testConstruction in core/tests/Drupal/Tests/Core/Access/AccessResultForbiddenTest.php
Tests the construction of an AccessResultForbidden object.
AccessResultForbiddenTest::testSetReason in core/tests/Drupal/Tests/Core/Access/AccessResultForbiddenTest.php
Tests setReason()
AccessResultNeutralTest::testConstruction in core/tests/Drupal/Tests/Core/Access/AccessResultNeutralTest.php
Tests the construction of an AccessResultForbidden object.
AccessResultNeutralTest::testSetReason in core/tests/Drupal/Tests/Core/Access/AccessResultNeutralTest.php
Tests setReason()
AccessResultTest::testAccessForbiddenReason in core/tests/Drupal/Tests/Core/Access/AccessResultTest.php
@covers ::forbidden

... See full list

File

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

Class

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

Namespace

Drupal\Tests

Code

protected function getRandomGenerator() {
  if (!is_object($this->randomGenerator)) {
    $this->randomGenerator = new Random();
  }
  return $this->randomGenerator;
}