diff --git a/tests/Exception/HttpClientExceptionTest.php b/tests/Exception/HttpClientExceptionTest.php index 0756855..c1504f9 100644 --- a/tests/Exception/HttpClientExceptionTest.php +++ b/tests/Exception/HttpClientExceptionTest.php @@ -34,4 +34,30 @@ class HttpClientExceptionTest extends MailgunTestCase $exception = HttpClientException::badRequest($response); $this->assertStringEndsWith('Server HTML', $exception->getMessage()); } + + public function testForbiddenRequestThrowException() + { + $response = new Response(403, ['Content-Type' => 'application/json'], '{"Error":"Business Verification"}'); + $exception = HttpClientException::forbidden($response); + $this->assertInstanceOf(HttpClientException::class, $exception); + $this->assertSame(403, $exception->getCode()); + } + + public function testForbiddenRequestGetMessageJson() + { + $response = new Response(403, ['Content-Type' => 'application/json'], '{"Error":"Business Verification"}'); + $exception = HttpClientException::forbidden($response); + $this->assertStringEndsWith('Business Verification', $exception->getMessage()); + + $response = new Response(403, ['Content-Type' => 'application/json'], '{"Message":"Business Verification"}'); + $exception = HttpClientException::forbidden($response); + $this->assertStringEndsWith('{"Message":"Business Verification"}', $exception->getMessage()); + } + + public function testForbiddenRequestGetMessage() + { + $response = new Response(400, ['Content-Type' => 'text/html'], 'Forbidden'); + $exception = HttpClientException::badRequest($response); + $this->assertStringEndsWith('Forbidden', $exception->getMessage()); + } }