oauth2-server/tests/unit/util/SecureKeyTest.php
Graham Campbell 4c1cd04a24 CS fixes
2014-11-08 18:26:12 +00:00

36 lines
972 B
PHP

<?php
namespace LeagueTests\util;
use League\OAuth2\Server\Util\SecureKey;
class SecureKeyTest extends \PHPUnit_Framework_TestCase
{
public function testGenerate()
{
$v1 = SecureKey::generate();
$v2 = SecureKey::generate();
$v3 = SecureKey::generate(50);
$this->assertEquals(40, strlen($v1));
$this->assertTrue($v1 !== $v2);
$this->assertEquals(50, strlen($v3));
}
public function testGenerateWithDifferentAlgorithm()
{
$algorithm = $this->getMock('League\OAuth2\Server\Util\KeyAlgorithm\KeyAlgorithmInterface');
$result = 'dasdsdsaads';
$algorithm
->expects($this->once())
->method('generate')
->with(11)
->will($this->returnValue($result));
SecureKey::setAlgorithm($algorithm);
$this->assertSame($algorithm, SecureKey::getAlgorithm());
$this->assertEquals($result, SecureKey::generate(11));
}
}