mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-11-29 18:27:44 +08:00
Fixed bug that the numeric keys will be reset when using $request->all()
. (#6566)
Co-authored-by: 李铭昕 <715557344@qq.com>
This commit is contained in:
parent
ef45a0cbfe
commit
572c9ef307
@ -1,5 +1,9 @@
|
||||
# v3.1.12 - TBD
|
||||
|
||||
## Fixed
|
||||
|
||||
- [#6566](https://github.com/hyperf/hyperf/pull/6566) Fixed bug that the numeric keys will be reset when using `$request->all()`.
|
||||
|
||||
# v3.1.11 - 2024-03-01
|
||||
|
||||
## Fixed
|
||||
|
@ -566,7 +566,7 @@ class Request implements RequestInterface
|
||||
$data = [];
|
||||
}
|
||||
|
||||
return array_merge($data, $request->getQueryParams());
|
||||
return $request->getQueryParams() + $data;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -80,12 +80,32 @@ class RequestTest extends TestCase
|
||||
public function testRequestAll()
|
||||
{
|
||||
$psrRequest = Mockery::mock(ServerRequestPlusInterface::class);
|
||||
$psrRequest->shouldReceive('getParsedBody')->andReturn(['id' => 1]);
|
||||
$psrRequest->shouldReceive('getParsedBody')->andReturn(['id' => 1, '123' => '123']);
|
||||
$psrRequest->shouldReceive('getQueryParams')->andReturn(['name' => 'Hyperf']);
|
||||
RequestContext::set($psrRequest);
|
||||
|
||||
$psrRequest = new Request();
|
||||
$this->assertSame(['id' => 1, 'name' => 'Hyperf'], $psrRequest->all());
|
||||
$this->assertSame(['name' => 'Hyperf', 'id' => 1, 123 => '123'], $psrRequest->all());
|
||||
|
||||
$psrRequest = Mockery::mock(ServerRequestPlusInterface::class);
|
||||
$psrRequest->shouldReceive('getParsedBody')->andReturn(['name' => 'Hyperf']);
|
||||
$psrRequest->shouldReceive('getQueryParams')->andReturn(['id' => 1, '123' => '123']);
|
||||
RequestContext::set($psrRequest);
|
||||
|
||||
$psrRequest = new Request();
|
||||
|
||||
$this->assertSame(['name' => 'Hyperf', 'id' => 1, 123 => '123'], $psrRequest->all());
|
||||
}
|
||||
|
||||
public function testRequestAllByReplace()
|
||||
{
|
||||
$psrRequest = Mockery::mock(ServerRequestPlusInterface::class);
|
||||
$psrRequest->shouldReceive('getParsedBody')->andReturn(['id' => 1, 'data' => ['id' => 2]]);
|
||||
$psrRequest->shouldReceive('getQueryParams')->andReturn(['data' => 'Hyperf']);
|
||||
RequestContext::set($psrRequest);
|
||||
|
||||
$psrRequest = new Request();
|
||||
$this->assertEquals(['id' => 1, 'data' => 'Hyperf'], $psrRequest->all());
|
||||
}
|
||||
|
||||
public function testRequestInputs()
|
||||
|
Loading…
Reference in New Issue
Block a user