You are here

public function RandomTest::_RandomStringValidate in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Component/Utility/RandomTest.php \Drupal\Tests\Component\Utility\RandomTest::_RandomStringValidate()
  2. 10 core/tests/Drupal/Tests/Component/Utility/RandomTest.php \Drupal\Tests\Component\Utility\RandomTest::_RandomStringValidate()

Callback for random string validation.

Parameters

string $string: The random string to validate.

Return value

bool TRUE if the random string is valid, FALSE if not.

See also

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

\Drupal\Tests\Component\Utility\RandomTest::testRandomStringValidator()

File

core/tests/Drupal/Tests/Component/Utility/RandomTest.php, line 177

Class

RandomTest
Tests random data generation.

Namespace

Drupal\Tests\Component\Utility

Code

public function _RandomStringValidate($string) {

  // Return FALSE for the first generated string and any string that is the
  // same, as the test expects a different string to be returned.
  if (empty($this->firstStringGenerated) || $string == $this->firstStringGenerated) {
    $this->firstStringGenerated = $string;
    return FALSE;
  }
  return TRUE;
}