Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[HttpFoundation] fixed testGetContentCanBeCalledTwiceWithResources test
After calling Request::getContent(true), subsequent calls to the
same instance method (withouth the $asResource flag) always returned
false instead of the request body as a plain string.
A unit test already existed to guard against this behaviour but it
yielded a false positive because it was comparing '' to false using
PHPUnit's assertEquals() instead of assertSame().
For completeness sake I also added the missing usage permutations in
the test data provider.
  • Loading branch information
1ma committed Aug 5, 2016
commit 0a12ce48ffd2a4148ac5ffb12bcec96f97abe302
2 changes: 1 addition & 1 deletion src/Symfony/Component/HttpFoundation/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -1505,7 +1505,7 @@ public function getContent($asResource = false)
return $resource;
}

$this->content = false;
$this->content = null;

return fopen('php://input', 'rb');
}
Expand Down
4 changes: 3 additions & 1 deletion src/Symfony/Component/HttpFoundation/Tests/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1060,12 +1060,14 @@ public function testGetContentCanBeCalledTwiceWithResources($first, $second)
$b = stream_get_contents($b);
}

$this->assertEquals($a, $b);
$this->assertSame($a, $b);
}

public function getContentCantBeCalledTwiceWithResourcesProvider()
{
return array(
'Fetch then fetch' => array(false, false),
'Fetch then resource' => array(false, true),
'Resource then fetch' => array(true, false),
'Resource then resource' => array(true, true),
);
Expand Down