Skip to content

Commit d273222

Browse files
committed
fix: [BC] change priority for request body
"withBodyFormat() and $params of call()" has higher priority than withBody().
1 parent 963b2e2 commit d273222

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

system/Test/FeatureTestTrait.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,10 @@ protected function populateGlobals(string $method, Request $request, ?array $par
371371
*/
372372
protected function setRequestBody(Request $request, ?array $params = null): Request
373373
{
374+
if ($this->requestBody !== '') {
375+
$request->setBody($this->requestBody);
376+
}
377+
374378
if ($this->bodyFormat !== '') {
375379
$formatMime = '';
376380
if ($this->bodyFormat === 'json') {
@@ -385,15 +389,11 @@ protected function setRequestBody(Request $request, ?array $params = null): Requ
385389

386390
if ($params !== null && $formatMime !== '') {
387391
$formatted = Services::format()->getFormatter($formatMime)->format($params);
392+
// "withBodyFormat() and $params of call()" has higher priority than withBody().
388393
$request->setBody($formatted);
389394
}
390395
}
391396

392-
// withBody() has higher priority than $params of withBodyFormat().
393-
if ($this->requestBody !== '') {
394-
$request->setBody($this->requestBody);
395-
}
396-
397397
return $request;
398398
}
399399
}

0 commit comments

Comments
 (0)