function RandomTest::_RandomStringValidate

Same name in other branches
  1. 8.9.x 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()
  3. 11.x 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;
}

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