silverstripe-framework/tests/php/Security/RandomGeneratorTest.php

39 lines
1019 B
PHP
Raw Permalink Normal View History

<?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;
2022-11-15 18:20:54 +13:00
use SilverStripe\Dev\Deprecation;
use SilverStripe\Dev\SapphireTest;
/**
* @author Ingo Schommer
*/
class RandomGeneratorTest extends SapphireTest
{
public function testGenerateEntropy()
{
2022-11-15 18:20:54 +13:00
if (Deprecation::isEnabled()) {
$this->markTestSkipped('Test calls deprecated code');
}
$r = new RandomGenerator();
$this->assertNotNull($r->generateEntropy());
$this->assertNotEquals($r->generateEntropy(), $r->generateEntropy());
}
2014-08-15 18:53:05 +12: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
public function testGenerateHashWithAlgorithm()
{
$r = new RandomGenerator();
$this->assertNotNull($r->randomToken('md5'));
$this->assertNotEquals($r->randomToken(), $r->randomToken('md5'));
}
}