Skip to content

Commit a280f56

Browse files
authored
fix(mapper): don't overwrite request fields (#1487)
1 parent 01287b6 commit a280f56

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

packages/http/src/Mappers/PsrRequestToGenericRequestMapper.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ public function map(mixed $from, mixed $to): GenericRequest
5656
'query' => $query,
5757
'files' => $uploads,
5858
'cookies' => Arr\map_iterable($_COOKIE, static fn (string $value, string $key) => new Cookie($key, $value)),
59-
...$data,
60-
...$uploads,
6159
])
6260
->to(GenericRequest::class);
6361
}

tests/Integration/Mapper/PsrRequestToRequestMapperTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Laminas\Diactoros\Uri;
1111
use Tempest\Http\GenericRequest;
1212
use Tempest\Http\Mappers\PsrRequestToGenericRequestMapper;
13+
use Tempest\Http\Method;
1314
use Tempest\Http\Request;
1415
use Tempest\Http\Upload;
1516
use Tests\Tempest\Integration\FrameworkIntegrationTestCase;
@@ -90,4 +91,26 @@ public function test_files(): void
9091
$this->assertSame('hello', $upload->getClientFilename());
9192
$this->assertSame('application/octet-stream', $upload->getClientMediaType());
9293
}
94+
95+
public function test_body_field_in_body(): void
96+
{
97+
$psrRequest = $this->http->makePsrRequest(
98+
'/',
99+
Method::POST,
100+
body: [
101+
'body' => 'text',
102+
],
103+
);
104+
105+
$mapper = new PsrRequestToGenericRequestMapper();
106+
107+
$request = $mapper->map($psrRequest, GenericRequest::class);
108+
109+
$this->assertSame(
110+
[
111+
'body' => 'text',
112+
],
113+
$request->body,
114+
);
115+
}
93116
}

0 commit comments

Comments
 (0)