Skip to content

Commit

Permalink
Unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
mathmarques committed Mar 10, 2016
1 parent 60927c3 commit 5c72d63
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/Http/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,30 @@ public function testGetParsedBodyWhenBodyDoesNotExist()
$this->assertNull($request->getParsedBody());
}

public function testGetParsedBodyAfterCallReparseBody()
{
$uri = Uri::createFromString('https://example.com:443/?one=1');
$headers = new Headers([
'Content-Type' => 'application/x-www-form-urlencoded;charset=utf8',
]);
$cookies = [];
$serverParams = [];
$body = new RequestBody();
$body->write('foo=bar');
$body->rewind();
$request = new Request('POST', $uri, $headers, $cookies, $serverParams, $body);

$this->assertEquals(['foo' => 'bar'], $request->getParsedBody());

$newBody = new RequestBody();
$newBody->write('abc=123');
$newBody->rewind();
$request = $request->withBody($newBody);
$request->reparseBody();

$this->assertEquals(['abc' => '123'], $request->getParsedBody());
}

/**
* @expectedException \RuntimeException
*/
Expand Down

0 comments on commit 5c72d63

Please sign in to comment.