2017-02-05 01:18:40 +05:30
|
|
|
<?php
|
|
|
|
|
2018-05-25 14:30:21 +05:30
|
|
|
namespace LeagueTests\Exception;
|
2017-02-05 01:18:40 +05:30
|
|
|
|
2018-11-13 04:55:22 +05:30
|
|
|
use Exception;
|
2017-02-05 01:18:40 +05:30
|
|
|
use League\OAuth2\Server\Exception\OAuthServerException;
|
2018-05-25 14:30:21 +05:30
|
|
|
use PHPUnit\Framework\TestCase;
|
2017-02-05 01:18:40 +05:30
|
|
|
|
2018-05-25 14:30:21 +05:30
|
|
|
class OAuthServerExceptionTest extends TestCase
|
2017-02-05 01:18:40 +05:30
|
|
|
{
|
|
|
|
public function testHasRedirect()
|
|
|
|
{
|
|
|
|
$exceptionWithRedirect = OAuthServerException::accessDenied('some hint', 'https://example.com/error');
|
2018-05-25 14:30:21 +05:30
|
|
|
|
2017-02-05 01:18:40 +05:30
|
|
|
$this->assertTrue($exceptionWithRedirect->hasRedirect());
|
|
|
|
}
|
2018-05-25 14:30:21 +05:30
|
|
|
|
|
|
|
public function testDoesNotHaveRedirect()
|
|
|
|
{
|
|
|
|
$exceptionWithoutRedirect = OAuthServerException::accessDenied('Some hint');
|
|
|
|
|
|
|
|
$this->assertFalse($exceptionWithoutRedirect->hasRedirect());
|
|
|
|
}
|
2018-11-13 04:55:22 +05:30
|
|
|
|
|
|
|
public function testHasPrevious()
|
|
|
|
{
|
|
|
|
$previous = new Exception('This is the previous');
|
|
|
|
$exceptionWithPrevious = OAuthServerException::accessDenied(null, null, $previous);
|
|
|
|
|
|
|
|
$this->assertSame('This is the previous', $exceptionWithPrevious->getPrevious()->getMessage());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testDoesNotHavePrevious()
|
|
|
|
{
|
|
|
|
$exceptionWithoutPrevious = OAuthServerException::accessDenied();
|
|
|
|
|
|
|
|
$this->assertNull($exceptionWithoutPrevious->getPrevious());
|
|
|
|
}
|
2018-05-25 14:30:21 +05:30
|
|
|
}
|