@@ -18,7 +18,7 @@ public function testResponseWithCustomHeaders(): void
1818 $ response = Response::noContent ();
1919
2020 /** @And by default, the response contains the 'Content-Type' header set to 'application/json; charset=utf-8' */
21- self ::assertSame (['Content-Type ' => 'application/json; charset=utf-8 ' ], $ response ->getHeaders ());
21+ self ::assertSame (['Content-Type ' => [ 'application/json; charset=utf-8 ' ] ], $ response ->getHeaders ());
2222
2323 /** @When we add custom headers to the response */
2424 $ actual = $ response
@@ -27,7 +27,7 @@ public function testResponseWithCustomHeaders(): void
2727
2828 /** @Then the response should contain the correct headers */
2929 self ::assertSame (
30- ['Content-Type ' => 'application/json; charset=utf-8 ' , 'X-ID ' => 100 , 'X-NAME ' => 'Xpto ' ],
30+ ['Content-Type ' => [ 'application/json; charset=utf-8 ' ] , 'X-ID ' => [ 100 ] , 'X-NAME ' => [ 'Xpto ' ] ],
3131 $ actual ->getHeaders ()
3232 );
3333
@@ -37,15 +37,18 @@ public function testResponseWithCustomHeaders(): void
3737 /** @Then the response should contain the updated 'X-ID' header value */
3838 self ::assertSame ('200 ' , $ actual ->withAddedHeader (name: 'X-ID ' , value: 200 )->getHeaderLine (name: 'X-ID ' ));
3939 self ::assertSame (
40- ['Content-Type ' => 'application/json; charset=utf-8 ' , 'X-ID ' => 200 , 'X-NAME ' => 'Xpto ' ],
40+ ['Content-Type ' => [ 'application/json; charset=utf-8 ' ] , 'X-ID ' => [ 200 ] , 'X-NAME ' => [ 'Xpto ' ] ],
4141 $ actual ->getHeaders ()
4242 );
4343
4444 /** @And when we remove the 'X-NAME' header */
4545 $ actual = $ actual ->withoutHeader (name: 'X-NAME ' );
4646
4747 /** @Then the response should contain only the 'X-ID' header and the default 'Content-Type' header */
48- self ::assertSame (['Content-Type ' => 'application/json; charset=utf-8 ' , 'X-ID ' => 200 ], $ actual ->getHeaders ());
48+ self ::assertSame (
49+ ['Content-Type ' => ['application/json; charset=utf-8 ' ], 'X-ID ' => [200 ]],
50+ $ actual ->getHeaders ()
51+ );
4952 }
5053
5154 public function testResponseWithDuplicatedHeader (): void
@@ -62,7 +65,19 @@ public function testResponseWithDuplicatedHeader(): void
6265 self ::assertSame ('application/json; charset=ISO-8859-1 ' , $ actual ->getHeaderLine (name: 'Content-Type ' ));
6366
6467 /** @And the headers should only contain the last 'Content-Type' value */
65- self ::assertSame (['Content-Type ' => 'application/json; charset=ISO-8859-1 ' ], $ actual ->getHeaders ());
68+ self ::assertSame (['Content-Type ' => ['application/json; charset=ISO-8859-1 ' ]], $ actual ->getHeaders ());
69+ }
70+
71+ public function testResponseHeadersWithNoCustomHeader (): void
72+ {
73+ /** @Given an HTTP response with no custom headers */
74+ $ response = Response::noContent ();
75+
76+ /** @When we retrieve the header that doesn't exist */
77+ $ actual = $ response ->getHeader (name: 'Non-Existent-Header ' );
78+
79+ /** @Then the header should return an empty array */
80+ self ::assertSame ([], $ actual );
6681 }
6782
6883 public function testResponseWithCacheControl (): void
@@ -108,7 +123,7 @@ public function testResponseWithContentTypePDF(): void
108123
109124 self ::assertSame ($ expected , $ actual ->getHeaderLine (name: 'Content-Type ' ));
110125 self ::assertSame ([$ expected ], $ actual ->getHeader (name: 'Content-Type ' ));
111- self ::assertSame (['Content-Type ' => $ expected ], $ actual ->getHeaders ());
126+ self ::assertSame (['Content-Type ' => [ $ expected] ], $ actual ->getHeaders ());
112127 }
113128
114129 public function testResponseWithContentTypeHTML (): void
@@ -127,7 +142,7 @@ public function testResponseWithContentTypeHTML(): void
127142
128143 self ::assertSame ($ expected , $ actual ->getHeaderLine (name: 'Content-Type ' ));
129144 self ::assertSame ([$ expected ], $ actual ->getHeader (name: 'Content-Type ' ));
130- self ::assertSame (['Content-Type ' => $ expected ], $ actual ->getHeaders ());
145+ self ::assertSame (['Content-Type ' => [ $ expected] ], $ actual ->getHeaders ());
131146 }
132147
133148 public function testResponseWithContentTypeJSON (): void
@@ -146,7 +161,7 @@ public function testResponseWithContentTypeJSON(): void
146161
147162 self ::assertSame ($ expected , $ actual ->getHeaderLine (name: 'Content-Type ' ));
148163 self ::assertSame ([$ expected ], $ actual ->getHeader (name: 'Content-Type ' ));
149- self ::assertSame (['Content-Type ' => $ expected ], $ actual ->getHeaders ());
164+ self ::assertSame (['Content-Type ' => [ $ expected] ], $ actual ->getHeaders ());
150165 }
151166
152167 public function testResponseWithContentTypePlainText (): void
@@ -165,7 +180,7 @@ public function testResponseWithContentTypePlainText(): void
165180
166181 self ::assertSame ($ expected , $ actual ->getHeaderLine (name: 'Content-Type ' ));
167182 self ::assertSame ([$ expected ], $ actual ->getHeader (name: 'Content-Type ' ));
168- self ::assertSame (['Content-Type ' => $ expected ], $ actual ->getHeaders ());
183+ self ::assertSame (['Content-Type ' => [ $ expected] ], $ actual ->getHeaders ());
169184 }
170185
171186 public function testResponseWithContentTypeOctetStream (): void
@@ -184,7 +199,7 @@ public function testResponseWithContentTypeOctetStream(): void
184199
185200 self ::assertSame ($ expected , $ actual ->getHeaderLine (name: 'Content-Type ' ));
186201 self ::assertSame ([$ expected ], $ actual ->getHeader (name: 'Content-Type ' ));
187- self ::assertSame (['Content-Type ' => $ expected ], $ actual ->getHeaders ());
202+ self ::assertSame (['Content-Type ' => [ $ expected] ], $ actual ->getHeaders ());
188203 }
189204
190205 public function testResponseWithContentTypeFormUrlencoded (): void
@@ -203,6 +218,6 @@ public function testResponseWithContentTypeFormUrlencoded(): void
203218
204219 self ::assertSame ($ expected , $ actual ->getHeaderLine (name: 'Content-Type ' ));
205220 self ::assertSame ([$ expected ], $ actual ->getHeader (name: 'Content-Type ' ));
206- self ::assertSame (['Content-Type ' => $ expected ], $ actual ->getHeaders ());
221+ self ::assertSame (['Content-Type ' => [ $ expected] ], $ actual ->getHeaders ());
207222 }
208223}
0 commit comments