Update PHPUnit, run static analysis on tests

This commit is contained in:
Lukáš Unger
2018-02-11 23:14:34 +01:00
parent 97089ad49e
commit 1f87c7a7be
9 changed files with 33 additions and 30 deletions

View File

@@ -0,0 +1,45 @@
<?php
namespace LeagueTests\Utils;
use League\OAuth2\Server\CryptKey;
use PHPUnit\Framework\TestCase;
class CryptKeyTest extends TestCase
{
/**
* @expectedException \LogicException
*/
public function testNoFile()
{
new CryptKey('undefined file');
}
public function testKeyCreation()
{
$keyFile = __DIR__ . '/../Stubs/public.key';
$key = new CryptKey($keyFile, 'secret');
$this->assertEquals('file://' . $keyFile, $key->getKeyPath());
$this->assertEquals('secret', $key->getPassPhrase());
}
public function testKeyFileCreation()
{
$keyContent = file_get_contents(__DIR__ . '/../Stubs/public.key');
$key = new CryptKey($keyContent);
$this->assertEquals(
'file://' . sys_get_temp_dir() . '/' . sha1($keyContent) . '.key',
$key->getKeyPath()
);
$keyContent = file_get_contents(__DIR__ . '/../Stubs/private.key.crlf');
$key = new CryptKey($keyContent);
$this->assertEquals(
'file://' . sys_get_temp_dir() . '/' . sha1($keyContent) . '.key',
$key->getKeyPath()
);
}
}