@@ -289,9 +289,9 @@ public function testCacheControlMerging(array $expects, array $master, array $su
289
289
$ cacheStrategy ->update ($ response );
290
290
291
291
foreach ($ expects as $ key => $ value ) {
292
- if ($ key === ' expires ' ) {
292
+ if (' expires ' === $ key ) {
293
293
$ this ->assertSame ($ value , $ response ->getExpires ()->format ('U ' ) - $ response ->getDate ()->format ('U ' ));
294
- } else if ( $ key === ' age ' ) {
294
+ } elseif ( ' age ' === $ key ) {
295
295
$ this ->assertSame ($ value , $ response ->getAge ());
296
296
} elseif (true === $ value ) {
297
297
$ this ->assertTrue ($ response ->headers ->hasCacheControlDirective ($ key ), sprintf ('Cache-Control header must have "%s" flag ' , $ key ));
@@ -308,160 +308,160 @@ public function testCacheControlMerging(array $expects, array $master, array $su
308
308
309
309
public function cacheControlMergingProvider ()
310
310
{
311
- yield 'result is public if all responses are public ' => array (
312
- array ( 'private ' => false , 'public ' => true ) ,
313
- array ( 'public ' => true ) ,
314
- array (
315
- array ( 'public ' => true ) ,
316
- ) ,
317
- ) ;
318
-
319
- yield 'result is private by default ' => array (
320
- array ( 'private ' => true , 'public ' => false ) ,
321
- array ( 'public ' => true ) ,
322
- array (
323
- array () ,
324
- ) ,
325
- ) ;
326
-
327
- yield 'combines public and private responses ' => array (
328
- array ( 'must-revalidate ' => false , 'private ' => true , 'public ' => false ) ,
329
- array ( 'public ' => true ) ,
330
- array (
331
- array ( 'private ' => true ) ,
332
- ) ,
333
- ) ;
334
-
335
- yield 'inherits no-cache from surrogates ' => array (
336
- array ( 'no-cache ' => true , 'public ' => false ) ,
337
- array ( 'public ' => true ) ,
338
- array (
339
- array ( 'no-cache ' => true ) ,
340
- ) ,
341
- ) ;
342
-
343
- yield 'inherits no-store from surrogate ' => array (
344
- array ( 'no-store ' => true , 'public ' => false ) ,
345
- array ( 'public ' => true ) ,
346
- array (
347
- array ( 'no-store ' => true ) ,
348
- ) ,
349
- ) ;
350
-
351
- yield 'resolve to lowest possible max-age ' => array (
352
- array ( 'public ' => false , 'private ' => true , 's-maxage ' => false , 'max-age ' => '60 ' ) ,
353
- array ( 'public ' => true , 'max-age ' => 3600 ) ,
354
- array (
355
- array ( 'private ' => true , 'max-age ' => 60 ) ,
356
- ) ,
357
- ) ;
358
-
359
- yield 'resolves multiple max-age ' => array (
360
- array ( 'public ' => false , 'private ' => true , 's-maxage ' => false , 'max-age ' => '60 ' ) ,
361
- array ( 'private ' => true , 'max-age ' => 100 ) ,
362
- array (
363
- array ( 'private ' => true , 'max-age ' => 3600 ) ,
364
- array ( 'public ' => true , 'max-age ' => 60 , 's-maxage ' => 60 ) ,
365
- array ( 'private ' => true , 'max-age ' => 60 ) ,
366
- ) ,
367
- ) ;
368
-
369
- yield 'merge max-age and s-maxage ' => array (
370
- array ( 'public ' => true , 's-maxage ' => '60 ' , 'max-age ' => null ) ,
371
- array ( 'public ' => true , 's-maxage ' => 3600 ) ,
372
- array (
373
- array ( 'public ' => true , 'max-age ' => 60 ) ,
374
- ) ,
375
- ) ;
376
-
377
- yield 'result is private when combining private responses ' => array (
378
- array ( 'no-cache ' => false , 'must-revalidate ' => false , 'private ' => true ) ,
379
- array ( 's-maxage ' => 60 , 'private ' => true ) ,
380
- array (
381
- array ( 's-maxage ' => 60 , 'private ' => true ) ,
382
- ) ,
383
- ) ;
384
-
385
- yield 'result can have s-maxage and max-age ' => array (
386
- array ( 'public ' => true , 'private ' => false , 's-maxage ' => '60 ' , 'max-age ' => '30 ' ) ,
387
- array ( 's-maxage ' => 100 , 'max-age ' => 2000 ) ,
388
- array (
389
- array ( 's-maxage ' => 1000 , 'max-age ' => 30 ) ,
390
- array ( 's-maxage ' => 500 , 'max-age ' => 500 ) ,
391
- array ( 's-maxage ' => 60 , 'max-age ' => 1000 ) ,
392
- ) ,
393
- ) ;
394
-
395
- yield 'does not set headers without value ' => array (
396
- array ( 'max-age ' => null , 's-maxage ' => null , 'public ' => null ) ,
397
- array ( 'private ' => true ) ,
398
- array (
399
- array ( 'private ' => true ) ,
400
- ) ,
401
- ) ;
402
-
403
- yield 'max-age 0 is sent to the client ' => array (
404
- array ( 'private ' => true , 'max-age ' => '0 ' ) ,
405
- array ( 'max-age ' => 0 , 'private ' => true ) ,
406
- array (
407
- array ( 'max-age ' => 60 , 'private ' => true ) ,
408
- ) ,
409
- ) ;
410
-
411
- yield 'max-age is relative to age ' => array (
412
- array ( 'max-age ' => '240 ' , 'age ' => 60 ) ,
413
- array ( 'max-age ' => 180 ) ,
414
- array (
415
- array ( 'max-age ' => 600 , 'age ' => 60 ) ,
416
- ) ,
417
- ) ;
418
-
419
- yield 'retains lowest age of all responses ' => array (
420
- array ( 'max-age ' => '160 ' , 'age ' => 60 ) ,
421
- array ( 'max-age ' => 600 , 'age ' => 60 ) ,
422
- array (
423
- array ( 'max-age ' => 120 , 'age ' => 20 ) ,
424
- ) ,
425
- ) ;
426
-
427
- yield 'max-age can be less than age, essentially expiring the response ' => array (
428
- array ( 'age ' => 120 , 'max-age ' => '90 ' ) ,
429
- array ( 'max-age ' => 90 , 'age ' => 120 ) ,
430
- array (
431
- array ( 'max-age ' => 120 , 'age ' => 60 ) ,
432
- ) ,
433
- ) ;
434
-
435
- yield 'max-age is 0 regardless of age ' => array (
436
- array ( 'max-age ' => '0 ' ) ,
437
- array ( 'max-age ' => 60 ) ,
438
- array (
439
- array ( 'max-age ' => 0 , 'age ' => 60 ) ,
440
- ) ,
441
- ) ;
442
-
443
- yield 'max-age is not negative ' => array (
444
- array ( 'max-age ' => '0 ' ) ,
445
- array ( 'max-age ' => 0 ) ,
446
- array (
447
- array ( 'max-age ' => 0 , 'age ' => 60 ) ,
448
- ) ,
449
- ) ;
450
-
451
- yield 'calculates lowest Expires header ' => array (
452
- array ( 'expires ' => 60 ) ,
453
- array ( 'expires ' => 60 ) ,
454
- array (
455
- array ( 'expires ' => 120 ) ,
456
- ) ,
457
- ) ;
458
-
459
- yield 'calculates Expires header relative to age ' => array (
460
- array ( 'expires ' => 210 , 'age ' => 120 ) ,
461
- array ( 'expires ' => 90 ) ,
462
- array (
463
- array ( 'expires ' => 600 , 'age ' => '120 ' ) ,
464
- ) ,
465
- ) ;
311
+ yield 'result is public if all responses are public ' => [
312
+ [ 'private ' => false , 'public ' => true ] ,
313
+ [ 'public ' => true ] ,
314
+ [
315
+ [ 'public ' => true ] ,
316
+ ] ,
317
+ ] ;
318
+
319
+ yield 'result is private by default ' => [
320
+ [ 'private ' => true , 'public ' => false ] ,
321
+ [ 'public ' => true ] ,
322
+ [
323
+ [] ,
324
+ ] ,
325
+ ] ;
326
+
327
+ yield 'combines public and private responses ' => [
328
+ [ 'must-revalidate ' => false , 'private ' => true , 'public ' => false ] ,
329
+ [ 'public ' => true ] ,
330
+ [
331
+ [ 'private ' => true ] ,
332
+ ] ,
333
+ ] ;
334
+
335
+ yield 'inherits no-cache from surrogates ' => [
336
+ [ 'no-cache ' => true , 'public ' => false ] ,
337
+ [ 'public ' => true ] ,
338
+ [
339
+ [ 'no-cache ' => true ] ,
340
+ ] ,
341
+ ] ;
342
+
343
+ yield 'inherits no-store from surrogate ' => [
344
+ [ 'no-store ' => true , 'public ' => false ] ,
345
+ [ 'public ' => true ] ,
346
+ [
347
+ [ 'no-store ' => true ] ,
348
+ ] ,
349
+ ] ;
350
+
351
+ yield 'resolve to lowest possible max-age ' => [
352
+ [ 'public ' => false , 'private ' => true , 's-maxage ' => false , 'max-age ' => '60 ' ] ,
353
+ [ 'public ' => true , 'max-age ' => 3600 ] ,
354
+ [
355
+ [ 'private ' => true , 'max-age ' => 60 ] ,
356
+ ] ,
357
+ ] ;
358
+
359
+ yield 'resolves multiple max-age ' => [
360
+ [ 'public ' => false , 'private ' => true , 's-maxage ' => false , 'max-age ' => '60 ' ] ,
361
+ [ 'private ' => true , 'max-age ' => 100 ] ,
362
+ [
363
+ [ 'private ' => true , 'max-age ' => 3600 ] ,
364
+ [ 'public ' => true , 'max-age ' => 60 , 's-maxage ' => 60 ] ,
365
+ [ 'private ' => true , 'max-age ' => 60 ] ,
366
+ ] ,
367
+ ] ;
368
+
369
+ yield 'merge max-age and s-maxage ' => [
370
+ [ 'public ' => true , 's-maxage ' => '60 ' , 'max-age ' => null ] ,
371
+ [ 'public ' => true , 's-maxage ' => 3600 ] ,
372
+ [
373
+ [ 'public ' => true , 'max-age ' => 60 ] ,
374
+ ] ,
375
+ ] ;
376
+
377
+ yield 'result is private when combining private responses ' => [
378
+ [ 'no-cache ' => false , 'must-revalidate ' => false , 'private ' => true ] ,
379
+ [ 's-maxage ' => 60 , 'private ' => true ] ,
380
+ [
381
+ [ 's-maxage ' => 60 , 'private ' => true ] ,
382
+ ] ,
383
+ ] ;
384
+
385
+ yield 'result can have s-maxage and max-age ' => [
386
+ [ 'public ' => true , 'private ' => false , 's-maxage ' => '60 ' , 'max-age ' => '30 ' ] ,
387
+ [ 's-maxage ' => 100 , 'max-age ' => 2000 ] ,
388
+ [
389
+ [ 's-maxage ' => 1000 , 'max-age ' => 30 ] ,
390
+ [ 's-maxage ' => 500 , 'max-age ' => 500 ] ,
391
+ [ 's-maxage ' => 60 , 'max-age ' => 1000 ] ,
392
+ ] ,
393
+ ] ;
394
+
395
+ yield 'does not set headers without value ' => [
396
+ [ 'max-age ' => null , 's-maxage ' => null , 'public ' => null ] ,
397
+ [ 'private ' => true ] ,
398
+ [
399
+ [ 'private ' => true ] ,
400
+ ] ,
401
+ ] ;
402
+
403
+ yield 'max-age 0 is sent to the client ' => [
404
+ [ 'private ' => true , 'max-age ' => '0 ' ] ,
405
+ [ 'max-age ' => 0 , 'private ' => true ] ,
406
+ [
407
+ [ 'max-age ' => 60 , 'private ' => true ] ,
408
+ ] ,
409
+ ] ;
410
+
411
+ yield 'max-age is relative to age ' => [
412
+ [ 'max-age ' => '240 ' , 'age ' => 60 ] ,
413
+ [ 'max-age ' => 180 ] ,
414
+ [
415
+ [ 'max-age ' => 600 , 'age ' => 60 ] ,
416
+ ] ,
417
+ ] ;
418
+
419
+ yield 'retains lowest age of all responses ' => [
420
+ [ 'max-age ' => '160 ' , 'age ' => 60 ] ,
421
+ [ 'max-age ' => 600 , 'age ' => 60 ] ,
422
+ [
423
+ [ 'max-age ' => 120 , 'age ' => 20 ] ,
424
+ ] ,
425
+ ] ;
426
+
427
+ yield 'max-age can be less than age, essentially expiring the response ' => [
428
+ [ 'age ' => 120 , 'max-age ' => '90 ' ] ,
429
+ [ 'max-age ' => 90 , 'age ' => 120 ] ,
430
+ [
431
+ [ 'max-age ' => 120 , 'age ' => 60 ] ,
432
+ ] ,
433
+ ] ;
434
+
435
+ yield 'max-age is 0 regardless of age ' => [
436
+ [ 'max-age ' => '0 ' ] ,
437
+ [ 'max-age ' => 60 ] ,
438
+ [
439
+ [ 'max-age ' => 0 , 'age ' => 60 ] ,
440
+ ] ,
441
+ ] ;
442
+
443
+ yield 'max-age is not negative ' => [
444
+ [ 'max-age ' => '0 ' ] ,
445
+ [ 'max-age ' => 0 ] ,
446
+ [
447
+ [ 'max-age ' => 0 , 'age ' => 60 ] ,
448
+ ] ,
449
+ ] ;
450
+
451
+ yield 'calculates lowest Expires header ' => [
452
+ [ 'expires ' => 60 ] ,
453
+ [ 'expires ' => 60 ] ,
454
+ [
455
+ [ 'expires ' => 120 ] ,
456
+ ] ,
457
+ ] ;
458
+
459
+ yield 'calculates Expires header relative to age ' => [
460
+ [ 'expires ' => 210 , 'age ' => 120 ] ,
461
+ [ 'expires ' => 90 ] ,
462
+ [
463
+ [ 'expires ' => 600 , 'age ' => '120 ' ] ,
464
+ ] ,
465
+ ] ;
466
466
}
467
467
}
0 commit comments