Skip to content

Commit 63296de

Browse files
committed
test: add tests for call() params and REQUEST
1 parent d96be52 commit 63296de

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

tests/system/Test/FeatureTestTraitTest.php

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,33 @@ public function testCallGetWithParams()
385385
);
386386
}
387387

388+
public function testCallGetWithParamsAndREQEST()
389+
{
390+
$this->withRoutes([
391+
[
392+
'get',
393+
'home',
394+
static fn () => json_encode(Services::request()->fetchGlobal('request')),
395+
],
396+
]);
397+
$data = [
398+
'true' => true,
399+
'false' => false,
400+
'int' => 2,
401+
'null' => null,
402+
'float' => 1.23,
403+
'string' => 'foo',
404+
];
405+
$response = $this->get('home', $data);
406+
407+
$response->assertOK();
408+
$this->assertStringContainsString(
409+
// All GET values will be strings.
410+
'{"true":"1","false":"","int":"2","null":"","float":"1.23","string":"foo"}',
411+
$response->getBody()
412+
);
413+
}
414+
388415
public function testCallPostWithParams()
389416
{
390417
$this->withRoutes([
@@ -412,6 +439,33 @@ public function testCallPostWithParams()
412439
);
413440
}
414441

442+
public function testCallPostWithParamsAndREQUEST()
443+
{
444+
$this->withRoutes([
445+
[
446+
'post',
447+
'home',
448+
static fn () => json_encode(Services::request()->fetchGlobal('request')),
449+
],
450+
]);
451+
$data = [
452+
'true' => true,
453+
'false' => false,
454+
'int' => 2,
455+
'null' => null,
456+
'float' => 1.23,
457+
'string' => 'foo',
458+
];
459+
$response = $this->post('home', $data);
460+
461+
$response->assertOK();
462+
$this->assertStringContainsString(
463+
// All POST values will be strings.
464+
'{"true":"1","false":"","int":"2","null":"","float":"1.23","string":"foo"}',
465+
$response->getBody()
466+
);
467+
}
468+
415469
public function testCallWithJsonRequest()
416470
{
417471
$this->withRoutes([

0 commit comments

Comments
 (0)