Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix not display response body if option is false
Browse files Browse the repository at this point in the history
aaa2000 committed Oct 9, 2023
1 parent f169f8c commit 5cc2d4c
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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";
}
Original file line number Diff line number Diff line change
@@ -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'])

0 comments on commit 5cc2d4c

Please sign in to comment.