Tests random bytes generation.
Expanded class hierarchy of CryptTest
\Drupal\Component\Utility\Crypt
class CryptTest extends UnitTestCase {
public static function getInfo() {
return array(
'name' => 'Crypt generator tests',
'description' => 'Test functionality of Crypt component.',
);
}
/**
* Tests \Drupal\Component\Utility\Crypt::randomBytes().
*/
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);
}
}
}
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CryptTest:: |
public static | function |
This method exists to support the simpletest UI runner. Overrides UnitTestCase:: |
|
CryptTest:: |
public | function | Tests \Drupal\Component\Utility\Crypt::randomBytes(). | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed in array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
public static | function | Generates a random string containing letters and numbers. |