@@ -98,7 +98,7 @@ public function testNormalizeUri(): void
9898 $ this ->assertSame ($ this ->server ['HTTP_HOST ' ], $ uri ->getAuthority ());
9999 $ this ->assertSame ('' , $ uri ->getUserInfo ());
100100 $ this ->assertSame ($ this ->server ['HTTP_HOST ' ], $ uri ->getHost ());
101- $ this ->assertSame ( null , $ uri ->getPort ());
101+ $ this ->assertNull ( $ uri ->getPort ());
102102 $ this ->assertSame ('/path ' , $ uri ->getPath ());
103103 $ this ->assertSame ($ this ->server ['QUERY_STRING ' ], $ uri ->getQuery ());
104104 $ this ->assertSame ('https://example.com/path?name=value ' , (string ) $ uri );
@@ -111,21 +111,74 @@ public function testNormalizeUri(): void
111111 $ this ->assertSame ($ this ->server ['SERVER_NAME ' ], $ uri ->getAuthority ());
112112 $ this ->assertSame ('' , $ uri ->getUserInfo ());
113113 $ this ->assertSame ($ this ->server ['SERVER_NAME ' ], $ uri ->getHost ());
114- $ this ->assertSame ( null , $ uri ->getPort ());
114+ $ this ->assertNull ( $ uri ->getPort ());
115115 $ this ->assertSame ('/path ' , $ uri ->getPath ());
116116 $ this ->assertSame ($ this ->server ['QUERY_STRING ' ], $ uri ->getQuery ());
117117 $ this ->assertSame ('https://example.org/path?name=value ' , (string ) $ uri );
118118 }
119119
120+ public function testNormalizeUriIfHttpHostHeaderWithStandardPort (): void
121+ {
122+ $ uri = $ this ->normalizer ->normalizeUri ([
123+ 'SERVER_PORT ' => '443 ' ,
124+ 'REQUEST_SCHEME ' => 'https ' ,
125+ 'HTTP_HOST ' => 'example.com:443 ' ,
126+ ]);
127+
128+ $ this ->assertSame ('https ' , $ uri ->getScheme ());
129+ $ this ->assertSame ('example.com ' , $ uri ->getAuthority ());
130+ $ this ->assertSame ('' , $ uri ->getUserInfo ());
131+ $ this ->assertSame ('example.com ' , $ uri ->getHost ());
132+ $ this ->assertNull ($ uri ->getPort ());
133+ $ this ->assertSame ('' , $ uri ->getPath ());
134+ $ this ->assertSame ('' , $ uri ->getQuery ());
135+ $ this ->assertSame ('https://example.com ' , (string ) $ uri );
136+ }
137+
138+ public function testNormalizeUriIfHttpHostHeaderWithNotStandardPort (): void
139+ {
140+ $ uri = $ this ->normalizer ->normalizeUri ([
141+ 'SERVER_PORT ' => '443 ' ,
142+ 'REQUEST_SCHEME ' => 'https ' ,
143+ 'HTTP_HOST ' => 'example.com:8080 ' ,
144+ ]);
145+
146+ $ this ->assertSame ('https ' , $ uri ->getScheme ());
147+ $ this ->assertSame ('example.com:8080 ' , $ uri ->getAuthority ());
148+ $ this ->assertSame ('' , $ uri ->getUserInfo ());
149+ $ this ->assertSame ('example.com ' , $ uri ->getHost ());
150+ $ this ->assertSame (8080 , $ uri ->getPort ());
151+ $ this ->assertSame ('' , $ uri ->getPath ());
152+ $ this ->assertSame ('' , $ uri ->getQuery ());
153+ $ this ->assertSame ('https://example.com:8080 ' , (string ) $ uri );
154+ }
155+
156+ public function testNormalizeUriIfHttpHostHeaderWithNotEqualStandardPortWithScheme (): void
157+ {
158+ $ uri = $ this ->normalizer ->normalizeUri ([
159+ 'SERVER_PORT ' => '443 ' ,
160+ 'REQUEST_SCHEME ' => 'https ' ,
161+ 'HTTP_HOST ' => 'example.com:80 ' ,
162+ ]);
163+
164+ $ this ->assertSame ('https ' , $ uri ->getScheme ());
165+ $ this ->assertSame ('example.com:80 ' , $ uri ->getAuthority ());
166+ $ this ->assertSame ('' , $ uri ->getUserInfo ());
167+ $ this ->assertSame ('example.com ' , $ uri ->getHost ());
168+ $ this ->assertSame (80 , $ uri ->getPort ());
169+ $ this ->assertSame ('' , $ uri ->getPath ());
170+ $ this ->assertSame ('' , $ uri ->getQuery ());
171+ $ this ->assertSame ('https://example.com:80 ' , (string ) $ uri );
172+ }
173+
120174 public function testNormalizeUriIfServerIsEmpty (): void
121175 {
122176 $ uri = $ this ->normalizer ->normalizeUri ([]);
123- $ this ->assertInstanceOf (UriInterface::class, $ uri );
124177 $ this ->assertSame ('' , $ uri ->getScheme ());
125178 $ this ->assertSame ('' , $ uri ->getAuthority ());
126179 $ this ->assertSame ('' , $ uri ->getUserInfo ());
127180 $ this ->assertSame ('' , $ uri ->getHost ());
128- $ this ->assertSame ( null , $ uri ->getPort ());
181+ $ this ->assertNull ( $ uri ->getPort ());
129182 $ this ->assertSame ('' , $ uri ->getPath ());
130183 $ this ->assertSame ('' , $ uri ->getQuery ());
131184 $ this ->assertSame ('' , (string ) $ uri );
0 commit comments