1818
1919final class RequestFactoryTest extends TestCase
2020{
21+ public static array |false $ getAllHeadersResult = false ;
22+
2123 private array $ globalServer = [];
2224 private array $ globalPost = [];
2325 private array $ globalFiles = [];
2426
27+ public static function setUpBeforeClass (): void
28+ {
29+ require_once __DIR__ . '/getallheaders_stub.php ' ;
30+ }
31+
2532 protected function setUp (): void
2633 {
2734 $ this ->globalServer = $ _SERVER ;
2835 $ this ->globalPost = $ _POST ;
2936 $ this ->globalFiles = $ _FILES ;
37+ self ::$ getAllHeadersResult = false ;
3038 }
3139
3240 protected function tearDown (): void
@@ -36,6 +44,11 @@ protected function tearDown(): void
3644 $ _FILES = $ this ->globalFiles ;
3745 }
3846
47+ public static function getAllHeadersStubResult (): array |false
48+ {
49+ return self ::$ getAllHeadersResult ;
50+ }
51+
3952 public function testUploadedFiles (): void
4053 {
4154 $ _SERVER = [
@@ -93,6 +106,23 @@ public function testHeadersParsing(): void
93106 $ this ->assertSame ($ expected , $ request ->getHeaders ());
94107 }
95108
109+ public function testHeadersFromGetAllHeadersDoNotDuplicateHost (): void
110+ {
111+ self ::$ getAllHeadersResult = [
112+ 'host ' => 'example.com ' ,
113+ 'X-Test ' => 'header-value ' ,
114+ ];
115+ $ _SERVER = [
116+ 'HTTP_HOST ' => 'example.com ' ,
117+ 'REQUEST_METHOD ' => 'GET ' ,
118+ ];
119+
120+ $ request = $ this ->createRequestFactory ()->create ();
121+
122+ $ this ->assertSame (['example.com ' ], $ request ->getHeader ('Host ' ));
123+ $ this ->assertSame (['header-value ' ], $ request ->getHeader ('X-Test ' ));
124+ }
125+
96126 public function testInvalidMethodException (): void
97127 {
98128 $ _SERVER = [];
0 commit comments