You are here

public function RandomTest::testRandomStringValidator in Drupal 10

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

Tests random string validation callbacks.

@covers ::string

File

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

Class

RandomTest
Tests random data generation.

Namespace

Drupal\Tests\Component\Utility

Code

public function testRandomStringValidator() {
  $random = new Random();
  $this->firstStringGenerated = '';
  $str = $random
    ->string(1, TRUE, [
    $this,
    '_RandomStringValidate',
  ]);
  $this
    ->assertNotEquals($this->firstStringGenerated, $str);
}