1515use Hyperf \Codec \Json ;
1616use Hyperf \Engine \Http \WritableConnection ;
1717use Hyperf \HttpMessage \Cookie \Cookie ;
18+ use Hyperf \HttpMessage \Server \Request ;
1819use Hyperf \HttpMessage \Server \Response ;
1920use Hyperf \HttpMessage \Stream \SwooleStream ;
21+ use Hyperf \HttpMessage \Uri \Uri ;
2022use Mockery ;
2123use PHPUnit \Framework \Attributes \CoversNothing ;
2224use PHPUnit \Framework \TestCase ;
@@ -73,7 +75,7 @@ public function testWrite()
7375 $ this ->assertTrue ($ status );
7476 }
7577
76- public function testToString ()
78+ public function testToResponseString ()
7779 {
7880 $ response = $ this ->newResponse ();
7981 if (! $ response instanceof ResponsePlusInterface) {
@@ -95,6 +97,25 @@ public function testToString()
9597 " , $ response ->toString (true ));
9698 }
9799
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+
98119 protected function newResponse ()
99120 {
100121 return new Response ();
0 commit comments