function RandomTest::testRandomStringValidator

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Component/Utility/RandomTest.php \Drupal\Tests\Component\Utility\RandomTest::testRandomStringValidator()
  2. 8.9.x core/tests/Drupal/Tests/Component/Utility/RandomTest.php \Drupal\Tests\Component\Utility\RandomTest::testRandomStringValidator()
  3. 11.x 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 185

Class

RandomTest
Tests random data generation.

Namespace

Drupal\Tests\Component\Utility

Code

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

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