Skip to content

Commit faa014c

Browse files
committed
test: add test for JSON request Content-Type
1 parent 79b83c0 commit faa014c

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

tests/system/Test/FeatureTestTraitTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,23 @@ public function testSetupRequestBodyWithParams()
548548
$this->assertSame('application/json', $request->header('Content-Type')->getValue());
549549
}
550550

551+
public function testSetupJSONRequestBodyWithBody()
552+
{
553+
$request = $this->setupRequest('post', 'home');
554+
$request = $this->withBodyFormat('json')
555+
->withBody(json_encode(['foo1' => 'bar1']))
556+
->setRequestBody($request);
557+
558+
$this->assertJsonStringEqualsJsonString(
559+
json_encode(['foo1' => 'bar1']),
560+
$request->getBody()
561+
);
562+
$this->assertSame(
563+
'application/json',
564+
$request->header('Content-Type')->getValue()
565+
);
566+
}
567+
551568
public function testSetupRequestBodyWithXml()
552569
{
553570
$request = $this->setupRequest('post', 'home');

0 commit comments

Comments
 (0)