test: add test values with various types

This commit is contained in:
kenjis 2023-06-21 10:06:22 +09:00
parent 5f2cdd2bd0
commit f7ef2780b8
No known key found for this signature in database
GPG Key ID: BD254878922AF198

View File

@ -421,9 +421,19 @@ final class FeatureTestTraitTest extends CIUnitTestCase
'\Tests\Support\Controllers\Popcorn::echoJson',
],
]);
$response = $this->withBodyFormat('json')->call('post', 'home', ['foo' => 'bar']);
$data = [
'true' => true,
'false' => false,
'int' => 2,
'null' => null,
'float' => 1.23,
'string' => 'foo',
];
$response = $this->withBodyFormat('json')
->call('post', 'home', $data);
$response->assertOK();
$response->assertJSONExact(['foo' => 'bar']);
$response->assertJSONExact($data);
}
public function testSetupRequestBodyWithParams()
@ -440,10 +450,18 @@ final class FeatureTestTraitTest extends CIUnitTestCase
{
$request = $this->setupRequest('post', 'home');
$request = $this->withBodyFormat('xml')->setRequestBody($request, ['foo' => 'bar']);
$data = [
'true' => true,
'false' => false,
'int' => 2,
'null' => null,
'float' => 1.23,
'string' => 'foo',
];
$request = $this->withBodyFormat('xml')->setRequestBody($request, $data);
$expectedXml = '<?xml version="1.0"?>
<response><foo>bar</foo></response>
<response><true>1</true><false/><int>2</int><null/><float>1.23</float><string>foo</string></response>
';
$this->assertSame($expectedXml, $request->getBody());