Skip to content

Commit

Permalink
Ensure that dumping the content dumps non-json content (#530)
Browse files Browse the repository at this point in the history
  • Loading branch information
srtfisher authored Apr 16, 2024
1 parent ebd3c31 commit b43b242
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/mantle/testing/class-test-response.php
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,13 @@ public function json( ?string $key = null ) {
public function dump(): static {
$content = $this->get_content();

// If the content is not JSON, dump it as is.
if ( 'application/json' !== $this->get_header( 'Content-Type' ) ) {
dump( $content );

return $this;
}

$json = json_decode( $content );

if ( json_last_error() === JSON_ERROR_NONE ) {
Expand Down

0 comments on commit b43b242

Please sign in to comment.