Skip to content

Commit

Permalink
Fix not display response body if option is false
Browse files Browse the repository at this point in the history
  • Loading branch information
aaa2000 authored and Oliboy50 committed Oct 10, 2023
1 parent ca1074a commit 9a05f85
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,15 @@ public function getLogContent(Request $request, Response $response, array $optio

// Render post parameters
if (array_key_exists('post_parameters', $options)
&& $options['post_parameters'] == true
&& $options['post_parameters'] === true
&& in_array($request->getMethod(), ['POST', 'PUT', 'PATCH'])) {
$responseContent .= "Post parameters\n";
$responseContent .= $this->formatParameters($request->request->all());
}

// Render response body content
if (isset($options['response_body'])) {
if (array_key_exists('response_body', $options)
&& $options['response_body'] === true) {
$responseContent .= "Response body\n------------------------\n";
$responseContent .= $response->getContent()."\n";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ public function testProvider(): void
->string($provider->getLogContent($request, $response, ['response_body' => true]))
->contains("Response body\n")
->contains($response->getContent())
->string($provider->getLogContent($request, $response, ['response_body' => false]))
->notContains("Response body\n")
->notContains($response->getContent())
->array($logContext = $provider->getLogContext($request, $response, []))
->hasSize(7)
->hasKeys(['environment', 'route', 'method', 'status', 'user', 'key', 'uri'])
Expand Down

0 comments on commit 9a05f85

Please sign in to comment.