From 58689969617ce65d537c855fda2a9dde038656ce Mon Sep 17 00:00:00 2001 From: Marc Ypes Date: Tue, 13 Nov 2018 00:25:22 +0100 Subject: [PATCH] Add test for previous exceptions --- tests/Exception/OAuthServerExceptionTest.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/Exception/OAuthServerExceptionTest.php b/tests/Exception/OAuthServerExceptionTest.php index 976362e3..201fb5dd 100644 --- a/tests/Exception/OAuthServerExceptionTest.php +++ b/tests/Exception/OAuthServerExceptionTest.php @@ -2,6 +2,7 @@ namespace LeagueTests\Exception; +use Exception; use League\OAuth2\Server\Exception\OAuthServerException; use PHPUnit\Framework\TestCase; @@ -20,4 +21,19 @@ class OAuthServerExceptionTest extends TestCase $this->assertFalse($exceptionWithoutRedirect->hasRedirect()); } + + 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()); + } }