public function CryptTest::testRandomBytes in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Component/Utility/CryptTest.php \Drupal\Tests\Component\Utility\CryptTest::testRandomBytes()
Tests random byte generation.
@covers ::randomBytes
File
- core/
tests/ Drupal/ Tests/ Component/ Utility/ CryptTest.php, line 27 - Contains \Drupal\Tests\Component\Utility\CryptTest.
Class
- CryptTest
- Tests random byte generation.
Namespace
Drupal\Tests\Component\UtilityCode
public function testRandomBytes() {
for ($i = 1; $i < 10; $i++) {
$count = rand(10, 10000);
// Check that different values are being generated.
$this
->assertNotEquals(Crypt::randomBytes($count), Crypt::randomBytes($count));
// Check the length.
$this
->assertEquals(strlen(Crypt::randomBytes($count)), $count);
}
}