@@ -28,12 +28,16 @@ public function setUp(): void
2828 'SERVER_PORT ' => '443 ' ,
2929 'REQUEST_METHOD ' => 'GET ' ,
3030 'SERVER_PROTOCOL ' => 'HTTP/1.1 ' ,
31+ 'SERVER_NAME ' => 'example.org ' ,
3132 'HTTP_HOST ' => 'example.com ' ,
3233 'HTTP_CACHE_CONTROL ' => 'max-age=0 ' ,
3334 'HTTP_X_FORWARDED_PROTO ' => 'https ' ,
3435 'CONTENT_TYPE ' => 'text/html; charset=UTF-8 ' ,
3536 'REQUEST_URI ' => '/path?name=value ' ,
3637 'QUERY_STRING ' => 'name=value ' ,
38+ 'REDIRECT_STATUS ' => '200 ' ,
39+ 'REDIRECT_HTTP_HOST ' => 'example.org ' ,
40+ 'REDIRECT_HTTP_CONNECTION ' => 'keep-alive ' ,
3741 ];
3842 }
3943
@@ -97,6 +101,19 @@ public function testNormalizeUri(): void
97101 $ this ->assertSame ('/path ' , $ uri ->getPath ());
98102 $ this ->assertSame ($ this ->server ['QUERY_STRING ' ], $ uri ->getQuery ());
99103 $ this ->assertSame ('https://example.com/path?name=value ' , (string ) $ uri );
104+
105+ unset($ this ->server ['HTTPS ' ], $ this ->server ['HTTP_HOST ' ]);
106+
107+ $ uri = $ this ->normalizer ->normalizeUri ($ this ->server );
108+ $ this ->assertInstanceOf (UriInterface::class, $ uri );
109+ $ this ->assertSame ($ this ->server ['HTTP_X_FORWARDED_PROTO ' ], $ uri ->getScheme ());
110+ $ this ->assertSame ($ this ->server ['SERVER_NAME ' ], $ uri ->getAuthority ());
111+ $ this ->assertSame ('' , $ uri ->getUserInfo ());
112+ $ this ->assertSame ($ this ->server ['SERVER_NAME ' ], $ uri ->getHost ());
113+ $ this ->assertSame (null , $ uri ->getPort ());
114+ $ this ->assertSame ('/path ' , $ uri ->getPath ());
115+ $ this ->assertSame ($ this ->server ['QUERY_STRING ' ], $ uri ->getQuery ());
116+ $ this ->assertSame ('https://example.org/path?name=value ' , (string ) $ uri );
100117 }
101118
102119 public function testNormalizeUriIfServerIsEmpty (): void
@@ -117,17 +134,13 @@ public function testNormalizeHeaders(): void
117134 {
118135 $ headers = $ this ->normalizer ->normalizeHeaders ($ this ->server );
119136
120- $ this ->assertSame ($ this ->server ['HTTP_HOST ' ], $ headers ['Host ' ]);
121- $ this ->assertSame ($ this ->server ['HTTP_CACHE_CONTROL ' ], $ headers ['Cache-Control ' ]);
122- $ this ->assertSame ($ this ->server ['HTTP_X_FORWARDED_PROTO ' ], $ headers ['X-Forwarded-Proto ' ]);
123- $ this ->assertSame ($ this ->server ['CONTENT_TYPE ' ], $ headers ['Content-Type ' ]);
124-
125- $ this ->assertFalse (isset ($ headers ['HTTPS ' ]));
126- $ this ->assertFalse (isset ($ headers ['SERVER_PORT ' ]));
127- $ this ->assertFalse (isset ($ headers ['REQUEST_METHOD ' ]));
128- $ this ->assertFalse (isset ($ headers ['SERVER_PROTOCOL ' ]));
129- $ this ->assertFalse (isset ($ headers ['REQUEST_URI ' ]));
130- $ this ->assertFalse (isset ($ headers ['QUERY_STRING ' ]));
137+ $ this ->assertSame ($ headers , [
138+ 'Host ' => 'example.com ' ,
139+ 'Cache-Control ' => 'max-age=0 ' ,
140+ 'X-Forwarded-Proto ' => 'https ' ,
141+ 'Content-Type ' => 'text/html; charset=UTF-8 ' ,
142+ 'Connection ' => 'keep-alive ' ,
143+ ]);
131144 }
132145
133146 public function testNormalizeHeadersIfServerIsEmpty (): void
0 commit comments