15
15
use Hyperf \Codec \Json ;
16
16
use Hyperf \Engine \Http \WritableConnection ;
17
17
use Hyperf \HttpMessage \Cookie \Cookie ;
18
+ use Hyperf \HttpMessage \Server \Request ;
18
19
use Hyperf \HttpMessage \Server \Response ;
19
20
use Hyperf \HttpMessage \Stream \SwooleStream ;
21
+ use Hyperf \HttpMessage \Uri \Uri ;
20
22
use Mockery ;
21
23
use PHPUnit \Framework \Attributes \CoversNothing ;
22
24
use PHPUnit \Framework \TestCase ;
@@ -73,7 +75,7 @@ public function testWrite()
73
75
$ this ->assertTrue ($ status );
74
76
}
75
77
76
- public function testToString ()
78
+ public function testToResponseString ()
77
79
{
78
80
$ response = $ this ->newResponse ();
79
81
if (! $ response instanceof ResponsePlusInterface) {
@@ -95,6 +97,25 @@ public function testToString()
95
97
" , $ response ->toString (true ));
96
98
}
97
99
100
+ public function testToRequestString ()
101
+ {
102
+ $ request = new Request ('GET ' , new Uri ('https://www.baidu.com/ ' ), body: 'q=Hyperf ' );
103
+
104
+ $ this ->assertSame ("GET / HTTP/1.1 \r
105
+ host: www.baidu.com \r
106
+ Connection: close \r
107
+ Content-Length: 8 \r
108
+ \r
109
+ q=Hyperf " , $ request ->toString ());
110
+
111
+ $ this ->assertSame ("GET / HTTP/1.1 \r
112
+ host: www.baidu.com \r
113
+ Connection: close \r
114
+ Content-Length: 8 \r
115
+ \r
116
+ " , $ request ->toString (true ));
117
+ }
118
+
98
119
protected function newResponse ()
99
120
{
100
121
return new Response ();
0 commit comments