2010-12-05 01:18:19 +01:00
|
|
|
<?php
|
2016-06-23 01:37:22 +02:00
|
|
|
|
2016-10-14 03:30:05 +02:00
|
|
|
namespace SilverStripe\Security\Tests;
|
|
|
|
|
2016-06-23 01:37:22 +02:00
|
|
|
use SilverStripe\Security\RandomGenerator;
|
2016-08-19 00:51:35 +02:00
|
|
|
use SilverStripe\Dev\SapphireTest;
|
|
|
|
|
2010-12-05 01:18:19 +01:00
|
|
|
/**
|
|
|
|
* @author Ingo Schommer
|
|
|
|
*/
|
|
|
|
class RandomGeneratorTest extends SapphireTest {
|
|
|
|
|
2012-09-19 12:07:39 +02:00
|
|
|
public function testGenerateEntropy() {
|
2010-12-05 01:18:19 +01:00
|
|
|
$r = new RandomGenerator();
|
|
|
|
$this->assertNotNull($r->generateEntropy());
|
|
|
|
$this->assertNotEquals($r->generateEntropy(), $r->generateEntropy());
|
|
|
|
}
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2012-09-19 12:07:39 +02:00
|
|
|
public function testGenerateHash() {
|
2010-12-05 01:18:19 +01:00
|
|
|
$r = new RandomGenerator();
|
2012-11-08 04:33:19 +01:00
|
|
|
$this->assertNotNull($r->randomToken());
|
|
|
|
$this->assertNotEquals($r->randomToken(), $r->randomToken());
|
2010-12-05 01:18:19 +01:00
|
|
|
}
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2012-09-19 12:07:39 +02:00
|
|
|
public function testGenerateHashWithAlgorithm() {
|
2010-12-05 01:18:19 +01:00
|
|
|
$r = new RandomGenerator();
|
2012-11-08 04:33:19 +01:00
|
|
|
$this->assertNotNull($r->randomToken('md5'));
|
|
|
|
$this->assertNotEquals($r->randomToken(), $r->randomToken('md5'));
|
2010-12-05 01:18:19 +01:00
|
|
|
}
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2012-03-24 04:04:52 +01:00
|
|
|
}
|