27
27
use PHPUnit \Framework \Attributes \CoversNothing ;
28
28
use PHPUnit \Framework \TestCase ;
29
29
use Psr \Container \ContainerInterface ;
30
- use Psr \Http \Message \RequestInterface ;
30
+ use Psr \Http \Message \ServerRequestInterface ;
31
31
use ReflectionClass ;
32
32
use Swoole \Http \Request as SwooleRequest ;
33
33
@@ -55,19 +55,19 @@ public function testNormalizeParsedBody()
55
55
$ data = ['id ' => 1 ];
56
56
$ json = ['name ' => 'Hyperf ' ];
57
57
58
- $ request = Mockery::mock (RequestInterface ::class);
58
+ $ request = Mockery::mock (ServerRequestInterface ::class);
59
59
$ request ->shouldReceive ('getHeaderLine ' )->with ('content-type ' )->andReturn ('' );
60
60
61
61
$ this ->assertSame ($ data , RequestStub::normalizeParsedBody ($ data ));
62
62
$ this ->assertSame ($ data , RequestStub::normalizeParsedBody ($ data , $ request ));
63
63
64
- $ request = Mockery::mock (RequestInterface ::class);
64
+ $ request = Mockery::mock (ServerRequestInterface ::class);
65
65
$ request ->shouldReceive ('getHeaderLine ' )->with ('content-type ' )->andReturn ('application/xml; charset=utf-8 ' );
66
66
$ request ->shouldReceive ('getBody ' )->andReturn (new SwooleStream (Xml::toXml ($ json )));
67
67
68
68
$ this ->assertSame ($ json , RequestStub::normalizeParsedBody ($ json , $ request ));
69
69
70
- $ request = Mockery::mock (RequestInterface ::class);
70
+ $ request = Mockery::mock (ServerRequestInterface ::class);
71
71
$ request ->shouldReceive ('getHeaderLine ' )->with ('content-type ' )->andReturn ('application/json; charset=utf-8 ' );
72
72
$ request ->shouldReceive ('getBody ' )->andReturn (new SwooleStream (Json::encode ($ json )));
73
73
$ this ->assertSame ($ json , RequestStub::normalizeParsedBody ($ data , $ request ));
@@ -80,7 +80,7 @@ public function testNormalizeParsedBodyException()
80
80
$ this ->getContainer ();
81
81
82
82
$ json = ['name ' => 'Hyperf ' ];
83
- $ request = Mockery::mock (RequestInterface ::class);
83
+ $ request = Mockery::mock (ServerRequestInterface ::class);
84
84
$ request ->shouldReceive ('getHeaderLine ' )->with ('content-type ' )->andReturn ('application/json; charset=utf-8 ' );
85
85
$ request ->shouldReceive ('getBody ' )->andReturn (new SwooleStream ('xxxx ' ));
86
86
$ this ->assertSame ([], RequestStub::normalizeParsedBody ($ json , $ request ));
@@ -93,7 +93,7 @@ public function testXmlNormalizeParsedBodyException()
93
93
$ this ->getContainer ();
94
94
95
95
$ json = ['name ' => 'Hyperf ' ];
96
- $ request = Mockery::mock (RequestInterface ::class);
96
+ $ request = Mockery::mock (ServerRequestInterface ::class);
97
97
$ request ->shouldReceive ('getHeaderLine ' )->with ('content-type ' )->andReturn ('application/xml; charset=utf-8 ' );
98
98
$ request ->shouldReceive ('getBody ' )->andReturn (new SwooleStream ('xxxx ' ));
99
99
$ this ->assertSame ([], RequestStub::normalizeParsedBody ($ json , $ request ));
@@ -104,12 +104,12 @@ public function testNormalizeEmptyBody()
104
104
$ this ->getContainer ();
105
105
106
106
$ json = ['name ' => 'Hyperf ' ];
107
- $ request = Mockery::mock (RequestInterface ::class);
107
+ $ request = Mockery::mock (ServerRequestInterface ::class);
108
108
$ request ->shouldReceive ('getHeaderLine ' )->with ('content-type ' )->andReturn ('application/json; charset=utf-8 ' );
109
109
$ request ->shouldReceive ('getBody ' )->andReturn (new SwooleStream ('' ));
110
110
$ this ->assertSame ($ json , RequestStub::normalizeParsedBody ($ json , $ request ));
111
111
112
- $ request = Mockery::mock (RequestInterface ::class);
112
+ $ request = Mockery::mock (ServerRequestInterface ::class);
113
113
$ request ->shouldReceive ('getHeaderLine ' )->with ('content-type ' )->andReturn ('application/json; charset=utf-8 ' );
114
114
$ request ->shouldReceive ('getBody ' )->andReturn (new SwooleStream ('' ));
115
115
$ this ->assertSame ([], RequestStub::normalizeParsedBody ([], $ request ));
@@ -122,7 +122,7 @@ public function testNormalizeParsedBodyInvalidContentType()
122
122
$ data = ['id ' => 1 ];
123
123
$ json = ['name ' => 'Hyperf ' ];
124
124
125
- $ request = Mockery::mock (RequestInterface ::class);
125
+ $ request = Mockery::mock (ServerRequestInterface ::class);
126
126
$ request ->shouldReceive ('getHeaderLine ' )->with ('content-type ' )->andReturn ('application/JSON ' );
127
127
$ request ->shouldReceive ('getBody ' )->andReturn (new SwooleStream (json_encode ($ json )));
128
128
$ this ->assertSame ($ json , RequestStub::normalizeParsedBody ($ data , $ request ));
@@ -136,7 +136,7 @@ public function testOverrideRequestParser()
136
136
RequestStub::setParser (new ParserStub ());
137
137
$ json = ['name ' => 'Hyperf ' ];
138
138
139
- $ request = Mockery::mock (RequestInterface ::class);
139
+ $ request = Mockery::mock (ServerRequestInterface ::class);
140
140
$ request ->shouldReceive ('getHeaderLine ' )->with ('content-type ' )->andReturn ('application/JSON ' );
141
141
$ request ->shouldReceive ('getBody ' )->andReturn (new SwooleStream (json_encode ($ json )));
142
142
$ this ->assertSame (['mock ' => true ], RequestStub::normalizeParsedBody ([], $ request ));
0 commit comments