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