Skip to content

Commit 9981d44

Browse files
committed
test: add tests for PUT JSON request and REQUEST
1 parent 63296de commit 9981d44

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

tests/system/Test/FeatureTestTraitTest.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,54 @@ public function testCallPostWithParamsAndREQUEST()
466466
);
467467
}
468468

469+
public function testCallPutWithJsonRequest()
470+
{
471+
$this->withRoutes([
472+
[
473+
'put',
474+
'home',
475+
'\Tests\Support\Controllers\Popcorn::echoJson',
476+
],
477+
]);
478+
$data = [
479+
'true' => true,
480+
'false' => false,
481+
'int' => 2,
482+
'null' => null,
483+
'float' => 1.23,
484+
'string' => 'foo',
485+
];
486+
$response = $this->withBodyFormat('json')
487+
->call('put', 'home', $data);
488+
489+
$response->assertOK();
490+
$response->assertJSONExact($data);
491+
}
492+
493+
public function testCallPutWithJsonRequestAndREQUEST()
494+
{
495+
$this->withRoutes([
496+
[
497+
'put',
498+
'home',
499+
static fn () => json_encode(Services::request()->fetchGlobal('request')),
500+
],
501+
]);
502+
$data = [
503+
'true' => true,
504+
'false' => false,
505+
'int' => 2,
506+
'null' => null,
507+
'float' => 1.23,
508+
'string' => 'foo',
509+
];
510+
$response = $this->withBodyFormat('json')
511+
->call('put', 'home', $data);
512+
513+
$response->assertOK();
514+
$this->assertStringContainsString('[]', $response->getBody());
515+
}
516+
469517
public function testCallWithJsonRequest()
470518
{
471519
$this->withRoutes([

0 commit comments

Comments
 (0)