Skip to content

Commit

Permalink
Test assertStatus() on GZIP-encoded JSON
Browse files Browse the repository at this point in the history
Avoid exception "Invalid JSON was returned from the route"
when the TestResponse class is unable to discover the
JSON response body 'errors' key.
  • Loading branch information
tabuna authored and derekmd committed Aug 1, 2021
1 parent e96ccd8 commit e1c55d9
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/Testing/TestResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,18 @@ public function testAssertStatusWhenJsonIsFalse()
$response->assertStatus(200);
}

public function testAssertStatusWhenJsonIsEncoded()
{
$baseResponse = tap(new Response, function ($response) {
$response->header('Content-Type', 'application/json');
$response->header('Content-Encoding', 'gzip');
$response->setContent('b"x£½V*.I,)-V▓R╩¤V¬\x05\x00+ü\x059"');
});

$response = TestResponse::fromBaseResponse($baseResponse);
$response->assertStatus(200);
}

public function testAssertHeader()
{
$this->expectException(AssertionFailedError::class);
Expand Down

0 comments on commit e1c55d9

Please sign in to comment.