@@ -144,12 +144,14 @@ public function testSendResponseSendsEmptyResponseWithNoHeadersAndEmptyBodyAndAs
144
144
$ this ->markTestSkipped ('Test requires running phpunit with --stderr and Xdebug enabled ' );
145
145
}
146
146
147
+ header_remove ();
147
148
$ _SERVER ['SERVER_PROTOCOL ' ] = 'http/1.1 ' ;
148
149
$ sapi = new SapiHandler ();
149
150
$ response = new Response (200 , [], '' );
150
151
151
152
$ this ->expectOutputString ('' );
152
153
$ sapi ->sendResponse ($ response );
154
+
153
155
$ this ->assertEquals (['Content-Type: ' , 'Content-Length: 0 ' ], xdebug_get_headers ());
154
156
}
155
157
@@ -159,15 +161,15 @@ public function testSendResponseSendsJsonResponseWithGivenHeadersAndBodyAndAssig
159
161
$ this ->markTestSkipped ('Test requires running phpunit with --stderr and Xdebug enabled ' );
160
162
}
161
163
164
+ header_remove ();
162
165
$ _SERVER ['SERVER_PROTOCOL ' ] = 'http/1.1 ' ;
163
166
$ sapi = new SapiHandler ();
164
167
$ response = new Response (200 , ['Content-Type ' => 'application/json ' ], '{} ' );
165
168
166
169
$ this ->expectOutputString ('{} ' );
167
170
$ sapi ->sendResponse ($ response );
168
171
169
- $ previous = ['Content-Type: ' ];
170
- $ this ->assertEquals (array_merge ($ previous , ['Content-Type: application/json ' , 'Content-Length: 2 ' ]), xdebug_get_headers ());
172
+ $ this ->assertEquals (['Content-Type: application/json ' , 'Content-Length: 2 ' ], xdebug_get_headers ());
171
173
}
172
174
173
175
/**
@@ -179,6 +181,7 @@ public function testSendResponseSendsJsonResponseWithGivenHeadersAndMatchingCont
179
181
$ this ->markTestSkipped ('Test requires running phpunit with --stderr and Xdebug enabled ' );
180
182
}
181
183
184
+ header_remove ();
182
185
$ _SERVER ['REQUEST_METHOD ' ] = 'HEAD ' ;
183
186
$ _SERVER ['SERVER_PROTOCOL ' ] = 'http/1.1 ' ;
184
187
$ sapi = new SapiHandler ();
@@ -187,8 +190,7 @@ public function testSendResponseSendsJsonResponseWithGivenHeadersAndMatchingCont
187
190
$ this ->expectOutputString ('' );
188
191
$ sapi ->sendResponse ($ response );
189
192
190
- $ previous = ['Content-Type: ' ];
191
- $ this ->assertEquals (array_merge ($ previous , ['Content-Type: application/json ' , 'Content-Length: 2 ' ]), xdebug_get_headers ());
193
+ $ this ->assertEquals (['Content-Type: application/json ' , 'Content-Length: 2 ' ], xdebug_get_headers ());
192
194
}
193
195
194
196
public function testSendResponseSendsEmptyBodyWithGivenHeadersAndAssignsNoContentLengthForNoContentResponse (): void
@@ -197,15 +199,15 @@ public function testSendResponseSendsEmptyBodyWithGivenHeadersAndAssignsNoConten
197
199
$ this ->markTestSkipped ('Test requires running phpunit with --stderr and Xdebug enabled ' );
198
200
}
199
201
202
+ header_remove ();
200
203
$ _SERVER ['SERVER_PROTOCOL ' ] = 'http/1.1 ' ;
201
204
$ sapi = new SapiHandler ();
202
205
$ response = new Response (204 , ['Content-Type ' => 'application/json ' ], '{} ' );
203
206
204
207
$ this ->expectOutputString ('' );
205
208
$ sapi ->sendResponse ($ response );
206
209
207
- $ previous = ['Content-Type: ' , 'Content-Length: 2 ' ];
208
- $ this ->assertEquals (array_merge ($ previous , ['Content-Type: application/json ' ]), xdebug_get_headers ());
210
+ $ this ->assertEquals (['Content-Type: application/json ' ], xdebug_get_headers ());
209
211
}
210
212
211
213
public function testSendResponseSendsEmptyBodyWithGivenHeadersButWithoutExplicitContentLengthForNoContentResponse (): void
@@ -214,15 +216,15 @@ public function testSendResponseSendsEmptyBodyWithGivenHeadersButWithoutExplicit
214
216
$ this ->markTestSkipped ('Test requires running phpunit with --stderr and Xdebug enabled ' );
215
217
}
216
218
219
+ header_remove ();
217
220
$ _SERVER ['SERVER_PROTOCOL ' ] = 'http/1.1 ' ;
218
221
$ sapi = new SapiHandler ();
219
222
$ response = new Response (204 , ['Content-Type ' => 'application/json ' , 'Content-Length ' => '2 ' ], '{} ' );
220
223
221
224
$ this ->expectOutputString ('' );
222
225
$ sapi ->sendResponse ($ response );
223
226
224
- $ previous = ['Content-Type: ' , 'Content-Length: 2 ' ];
225
- $ this ->assertEquals (array_merge ($ previous , ['Content-Type: application/json ' ]), xdebug_get_headers ());
227
+ $ this ->assertEquals (['Content-Type: application/json ' ], xdebug_get_headers ());
226
228
}
227
229
228
230
public function testSendResponseSendsEmptyBodyWithGivenHeadersAndAssignsContentLengthForNotModifiedResponse (): void
@@ -231,15 +233,15 @@ public function testSendResponseSendsEmptyBodyWithGivenHeadersAndAssignsContentL
231
233
$ this ->markTestSkipped ('Test requires running phpunit with --stderr and Xdebug enabled ' );
232
234
}
233
235
236
+ header_remove ();
234
237
$ _SERVER ['SERVER_PROTOCOL ' ] = 'http/1.1 ' ;
235
238
$ sapi = new SapiHandler ();
236
239
$ response = new Response (304 , ['Content-Type ' => 'application/json ' ], 'null ' );
237
240
238
241
$ this ->expectOutputString ('' );
239
242
$ sapi ->sendResponse ($ response );
240
243
241
- $ previous = ['Content-Type: ' ];
242
- $ this ->assertEquals (array_merge ($ previous , ['Content-Type: application/json ' , 'Content-Length: 4 ' ]), xdebug_get_headers ());
244
+ $ this ->assertEquals (['Content-Type: application/json ' , 'Content-Length: 4 ' ], xdebug_get_headers ());
243
245
}
244
246
245
247
public function testSendResponseSendsEmptyBodyWithGivenHeadersAndExplicitContentLengthForNotModifiedResponse (): void
@@ -248,15 +250,15 @@ public function testSendResponseSendsEmptyBodyWithGivenHeadersAndExplicitContent
248
250
$ this ->markTestSkipped ('Test requires running phpunit with --stderr and Xdebug enabled ' );
249
251
}
250
252
253
+ header_remove ();
251
254
$ _SERVER ['SERVER_PROTOCOL ' ] = 'http/1.1 ' ;
252
255
$ sapi = new SapiHandler ();
253
256
$ response = new Response (304 , ['Content-Type ' => 'application/json ' , 'Content-Length ' => '2 ' ], '' );
254
257
255
258
$ this ->expectOutputString ('' );
256
259
$ sapi ->sendResponse ($ response );
257
260
258
- $ previous = ['Content-Type: ' ];
259
- $ this ->assertEquals (array_merge ($ previous , ['Content-Type: application/json ' , 'Content-Length: 2 ' ]), xdebug_get_headers ());
261
+ $ this ->assertEquals (['Content-Type: application/json ' , 'Content-Length: 2 ' ], xdebug_get_headers ());
260
262
}
261
263
262
264
public function testSendResponseSendsStreamingResponseWithNoHeadersAndBodyFromStreamData (): void
@@ -265,6 +267,7 @@ public function testSendResponseSendsStreamingResponseWithNoHeadersAndBodyFromSt
265
267
$ this ->markTestSkipped ('Test requires running phpunit with --stderr and Xdebug enabled ' );
266
268
}
267
269
270
+ header_remove ();
268
271
$ _SERVER ['SERVER_PROTOCOL ' ] = 'http/1.1 ' ;
269
272
$ sapi = new SapiHandler ();
270
273
$ body = new ThroughStream ();
@@ -273,8 +276,7 @@ public function testSendResponseSendsStreamingResponseWithNoHeadersAndBodyFromSt
273
276
$ this ->expectOutputString ('test ' );
274
277
$ sapi ->sendResponse ($ response );
275
278
276
- $ previous = ['Content-Type: ' , 'Content-Length: 2 ' ];
277
- $ this ->assertEquals (array_merge ($ previous , ['Content-Type: ' ]), xdebug_get_headers ());
279
+ $ this ->assertEquals (['Content-Type: ' ], xdebug_get_headers ());
278
280
279
281
$ body ->end ('test ' );
280
282
}
@@ -288,6 +290,7 @@ public function testSendResponseClosesStreamingResponseAndSendsResponseWithNoHea
288
290
$ this ->markTestSkipped ('Test requires running phpunit with --stderr and Xdebug enabled ' );
289
291
}
290
292
293
+ header_remove ();
291
294
$ _SERVER ['REQUEST_METHOD ' ] = 'HEAD ' ;
292
295
$ _SERVER ['SERVER_PROTOCOL ' ] = 'http/1.1 ' ;
293
296
$ sapi = new SapiHandler ();
@@ -297,8 +300,7 @@ public function testSendResponseClosesStreamingResponseAndSendsResponseWithNoHea
297
300
$ this ->expectOutputString ('' );
298
301
$ sapi ->sendResponse ($ response );
299
302
300
- $ previous = ['Content-Type: ' , 'Content-Length: 2 ' , 'Content-Type: ' ];
301
- $ this ->assertEquals (array_merge ($ previous , ['Content-Type: ' ]), xdebug_get_headers ());
303
+ $ this ->assertEquals (['Content-Type: ' ], xdebug_get_headers ());
302
304
$ this ->assertFalse ($ body ->isReadable ());
303
305
}
304
306
@@ -308,6 +310,7 @@ public function testSendResponseClosesStreamingResponseAndSendsResponseWithNoHea
308
310
$ this ->markTestSkipped ('Test requires running phpunit with --stderr and Xdebug enabled ' );
309
311
}
310
312
313
+ header_remove ();
311
314
$ _SERVER ['SERVER_PROTOCOL ' ] = 'http/1.1 ' ;
312
315
$ sapi = new SapiHandler ();
313
316
$ body = new ThroughStream ();
@@ -316,8 +319,7 @@ public function testSendResponseClosesStreamingResponseAndSendsResponseWithNoHea
316
319
$ this ->expectOutputString ('' );
317
320
$ sapi ->sendResponse ($ response );
318
321
319
- $ previous = ['Content-Type: ' , 'Content-Length: 2 ' , 'Content-Type: ' , 'Content-Type: ' ];
320
- $ this ->assertEquals (array_merge ($ previous , ['Content-Type: ' ]), xdebug_get_headers ());
322
+ $ this ->assertEquals (['Content-Type: ' ], xdebug_get_headers ());
321
323
$ this ->assertFalse ($ body ->isReadable ());
322
324
}
323
325
@@ -327,6 +329,7 @@ public function testSendResponseClosesStreamingResponseAndSendsResponseWithNoHea
327
329
$ this ->markTestSkipped ('Test requires running phpunit with --stderr and Xdebug enabled ' );
328
330
}
329
331
332
+ header_remove ();
330
333
$ _SERVER ['SERVER_PROTOCOL ' ] = 'http/1.1 ' ;
331
334
$ sapi = new SapiHandler ();
332
335
$ body = new ThroughStream ();
@@ -335,8 +338,7 @@ public function testSendResponseClosesStreamingResponseAndSendsResponseWithNoHea
335
338
$ this ->expectOutputString ('' );
336
339
$ sapi ->sendResponse ($ response );
337
340
338
- $ previous = ['Content-Type: ' , 'Content-Length: 2 ' , 'Content-Type: ' , 'Content-Type: ' , 'Content-Type: ' ];
339
- $ this ->assertEquals (array_merge ($ previous , ['Content-Type: ' ]), xdebug_get_headers ());
341
+ $ this ->assertEquals (['Content-Type: ' ], xdebug_get_headers ());
340
342
$ this ->assertFalse ($ body ->isReadable ());
341
343
}
342
344
@@ -346,6 +348,7 @@ public function testSendResponseSendsStreamingResponseWithNoHeadersAndBodyFromSt
346
348
$ this ->markTestSkipped ('Test requires running phpunit with --stderr and Xdebug enabled ' );
347
349
}
348
350
351
+ header_remove ();
349
352
$ _SERVER ['SERVER_PROTOCOL ' ] = 'http/1.1 ' ;
350
353
$ _SERVER ['SERVER_SOFTWARE ' ] = 'nginx/1 ' ;
351
354
$ sapi = new SapiHandler ();
@@ -355,12 +358,28 @@ public function testSendResponseSendsStreamingResponseWithNoHeadersAndBodyFromSt
355
358
$ this ->expectOutputString ('test ' );
356
359
$ sapi ->sendResponse ($ response );
357
360
358
- $ previous = ['Content-Type: ' , 'Content-Length: 2 ' , 'Content-Type: ' , 'Content-Type: ' , 'Content-Type: ' , 'Content-Type: ' ];
359
- $ this ->assertEquals (array_merge ($ previous , ['Content-Type: ' , 'X-Accel-Buffering: no ' ]), xdebug_get_headers ());
361
+ $ this ->assertEquals (['Content-Type: ' , 'X-Accel-Buffering: no ' ], xdebug_get_headers ());
360
362
361
363
$ body ->end ('test ' );
362
364
}
363
365
366
+ public function testSendResponseSetsMultipleCookieHeaders (): void
367
+ {
368
+ if (headers_sent () || !function_exists ('xdebug_get_headers ' )) {
369
+ $ this ->markTestSkipped ('Test requires running phpunit with --stderr and Xdebug enabled ' );
370
+ }
371
+
372
+ header_remove ();
373
+ $ _SERVER ['SERVER_PROTOCOL ' ] = 'http/1.1 ' ;
374
+ $ sapi = new SapiHandler ();
375
+ $ response = new Response (204 , ['Set-Cookie ' => ['1=1 ' , '2=2 ' ]], '' );
376
+
377
+ $ this ->expectOutputString ('' );
378
+ $ sapi ->sendResponse ($ response );
379
+
380
+ $ this ->assertEquals (['Content-Type: ' , 'Set-Cookie: 1=1 ' , 'Set-Cookie: 2=2 ' ], xdebug_get_headers ());
381
+ }
382
+
364
383
public function testLogPrintsMessageWithCurrentDateAndTime (): void
365
384
{
366
385
// 2021-01-29 12:22:01.717 Hello\n
0 commit comments