From 167934a5104811c385d5bb7a91a74eb9a5e38ab0 Mon Sep 17 00:00:00 2001 From: parsilver Date: Mon, 15 May 2023 17:25:01 +0700 Subject: [PATCH] Revert "Fix test error" This reverts commit 0683686b784b47df71f92314da30dbc42648e5d4. --- src/Http/Response.php | 10 +++------- tests/ResponseTest.php | 2 +- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Http/Response.php b/src/Http/Response.php index 265b1f3..fa2e952 100644 --- a/src/Http/Response.php +++ b/src/Http/Response.php @@ -15,7 +15,7 @@ class Response implements ResponseInterface protected $jsonDecoded; /** - * @var string|null + * @var string */ protected $content; @@ -26,7 +26,7 @@ public function __construct( protected PsrRequestInterface $request, protected PsrResponseInterface $response ) { - // + $this->content = $this->response->getBody()->getContents(); } /** @@ -42,10 +42,6 @@ public function statusCode(): int */ public function body(): string { - if (is_null($this->content)) { - $this->content = $this->response->getBody()->getContents(); - } - return $this->content; } @@ -73,7 +69,7 @@ public function isSuccessfull(): bool public function json(?string $key = null): mixed { if (is_null($this->jsonDecoded)) { - $this->jsonDecoded = @json_decode($this->body(), true) ?: false; + $this->jsonDecoded = @json_decode($this->content, true) ?: false; } if ($this->jsonDecoded === false) { diff --git a/tests/ResponseTest.php b/tests/ResponseTest.php index 903f267..4dba719 100644 --- a/tests/ResponseTest.php +++ b/tests/ResponseTest.php @@ -8,7 +8,7 @@ it('should return the psr response', function () { $response = new Response( \Mockery::mock(PsrRequestInterface::class), - \Mockery::mock(PsrResponseInterface::class), + \Mockery::mock(PsrResponseInterface::class) ); expect($response->getPsrResponse())->toBeInstanceOf(PsrResponseInterface::class);