silverstripe-framework/tests/security/RandomGeneratorTest.php
2016-07-07 11:32:28 +12:00

30 lines
753 B
PHP

<?php
use SilverStripe\Security\RandomGenerator;
/**
* @package framework
* @subpackage tests
* @author Ingo Schommer
*/
class RandomGeneratorTest extends SapphireTest {
public function testGenerateEntropy() {
$r = new RandomGenerator();
$this->assertNotNull($r->generateEntropy());
$this->assertNotEquals($r->generateEntropy(), $r->generateEntropy());
}
public function testGenerateHash() {
$r = new RandomGenerator();
$this->assertNotNull($r->randomToken());
$this->assertNotEquals($r->randomToken(), $r->randomToken());
}
public function testGenerateHashWithAlgorithm() {
$r = new RandomGenerator();
$this->assertNotNull($r->randomToken('md5'));
$this->assertNotEquals($r->randomToken(), $r->randomToken('md5'));
}
}