Skip to content

Commit ce95f3e

Browse files
raffaelecarellefabpot
authored andcommitted
Enable JSON_PRESERVE_ZERO_FRACTION in jsonRequest method
1 parent 0c806f2 commit ce95f3e

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

AbstractBrowser.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public function xmlHttpRequest(string $method, string $uri, array $parameters =
170170
*/
171171
public function jsonRequest(string $method, string $uri, array $parameters = [], array $server = [], bool $changeHistory = true): Crawler
172172
{
173-
$content = json_encode($parameters);
173+
$content = json_encode($parameters, \JSON_PRESERVE_ZERO_FRACTION);
174174

175175
$this->setServerParameter('CONTENT_TYPE', 'application/json');
176176
$this->setServerParameter('HTTP_ACCEPT', 'application/json');

Tests/AbstractBrowserTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ public function testXmlHttpRequest()
6767
public function testJsonRequest()
6868
{
6969
$client = $this->getBrowser();
70-
$client->jsonRequest('GET', 'http://example.com/', ['param' => 1], [], true);
70+
$client->jsonRequest('GET', 'http://example.com/', ['param' => 1, 'float' => 10.0], [], true);
7171
$this->assertSame('application/json', $client->getRequest()->getServer()['CONTENT_TYPE']);
7272
$this->assertSame('application/json', $client->getRequest()->getServer()['HTTP_ACCEPT']);
7373
$this->assertFalse($client->getServerParameter('CONTENT_TYPE', false));
7474
$this->assertFalse($client->getServerParameter('HTTP_ACCEPT', false));
75-
$this->assertSame('{"param":1}', $client->getRequest()->getContent());
75+
$this->assertSame('{"param":1,"float":10.0}', $client->getRequest()->getContent());
7676
}
7777

7878
public function testGetRequestWithIpAsHttpHost()

0 commit comments

Comments
 (0)