2019-02-16 14:58:14 -06:00
|
|
|
<?php
|
2019-10-05 10:26:10 -05:00
|
|
|
|
2019-02-16 14:58:14 -06:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace ShlinkioTest\Shlink\Rest\Exception;
|
|
|
|
|
|
|
|
use Exception;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
use Shlinkio\Shlink\Rest\Exception\AuthenticationException;
|
|
|
|
use Throwable;
|
|
|
|
|
|
|
|
class AuthenticationExceptionTest extends TestCase
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
* @dataProvider providePrev
|
|
|
|
*/
|
|
|
|
public function expiredJWTCreatesExpectedException(?Throwable $prev): void
|
|
|
|
{
|
|
|
|
$e = AuthenticationException::expiredJWT($prev);
|
|
|
|
|
|
|
|
$this->assertEquals($prev, $e->getPrevious());
|
|
|
|
$this->assertEquals(-1, $e->getCode());
|
|
|
|
$this->assertEquals('The token has expired.', $e->getMessage());
|
|
|
|
}
|
|
|
|
|
2019-02-17 13:28:34 -06:00
|
|
|
public function providePrev(): iterable
|
2019-02-16 14:58:14 -06:00
|
|
|
{
|
|
|
|
yield 'with previous exception' => [new Exception('Prev')];
|
|
|
|
yield 'without previous exception' => [null];
|
|
|
|
}
|
|
|
|
}
|