Skip to content

Commit

Permalink
test of method getJsonRawBody() when body is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
sinbadxiii committed Jul 25, 2023
1 parent 2ceaea5 commit 987ab0d
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/unit/Http/Request/GetJsonRawBodyCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,28 @@ public function httpRequestGetJsonRawBody(UnitTester $I)

stream_wrapper_restore('php');
}

public function httpRequestGetJsonRawBodyWhenBodyIsEmpty(UnitTester $I)
{
$I->wantToTest('Http\Request - getJsonRawBody() when Body is Empty');

$request = new Request();

stream_wrapper_unregister('php');
stream_wrapper_register('php', PhpStream::class);

$input = json_encode(new \stdClass());

file_put_contents('php://input', $input);

$expected = json_decode($input);
$actual = $request->getJsonRawBody();

$I->assertEquals($expected, $actual);

//and not null
$I->assertNotNull($actual);

stream_wrapper_restore('php');
}
}

0 comments on commit 987ab0d

Please sign in to comment.