'application/json'], '{"message":"Server Message"}'); $exception = HttpClientException::badRequest($response); $this->assertStringEndsWith('Server Message', $exception->getMessage()); $response = new Response(400, ['Content-Type' => 'application/json'], '{"Foo":"Server Message"}'); $exception = HttpClientException::badRequest($response); $this->assertStringEndsWith('{"Foo":"Server Message"}', $exception->getMessage()); } public function testBadRequestGetMessage() { $response = new Response(400, ['Content-Type' => 'text/html'], 'Server HTML'); $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()); } }