mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-11-30 10:47:44 +08:00
Update ServerRequestTest.php
This commit is contained in:
parent
25e3f3c96b
commit
a1548ff30d
@ -44,14 +44,20 @@ class ServerRequestTest extends TestCase
|
||||
$request->shouldReceive('getBody')->andReturn(new SwooleStream(json_encode($json)));
|
||||
$this->assertSame($json, RequestStub::normalizeParsedBody($data, $request));
|
||||
|
||||
$request = Mockery::mock(RequestInterface::class);
|
||||
$request->shouldReceive('getHeaderLine')->with('Content-Type')->andReturn('application/JSON');
|
||||
$request->shouldReceive('getBody')->andReturn(new SwooleStream(json_encode($json)));
|
||||
$this->assertSame($json, RequestStub::normalizeParsedBody($data, $request));
|
||||
|
||||
$request = Mockery::mock(RequestInterface::class);
|
||||
$request->shouldReceive('getHeaderLine')->with('Content-Type')->andReturn('application/json; charset=utf-8');
|
||||
$request->shouldReceive('getBody')->andReturn(new SwooleStream('xxxx'));
|
||||
$this->assertSame([], RequestStub::normalizeParsedBody($data, $request));
|
||||
}
|
||||
|
||||
public function testNormalizeParsedBodyInvalidContentType()
|
||||
{
|
||||
$data = ['id' => 1];
|
||||
$json = ['name' => 'Hyperf'];
|
||||
|
||||
$request = Mockery::mock(RequestInterface::class);
|
||||
$request->shouldReceive('getHeaderLine')->with('Content-Type')->andReturn('application/JSON');
|
||||
$request->shouldReceive('getBody')->andReturn(new SwooleStream(json_encode($json)));
|
||||
$this->assertSame($json, RequestStub::normalizeParsedBody($data, $request));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user