@@ -535,6 +535,43 @@ public function itDoesntSetAccessControlAllowOriginWithoutOrigin(): void
535
535
$ this ->assertFalse ($ response ->headers ->has ('Access-Control-Allow-Origin ' ));
536
536
}
537
537
538
+ /**
539
+ * @test
540
+ */
541
+ public function itConfiguresExposedHeadersWhenResponseHasNoExistingHeaders (): void
542
+ {
543
+ $ app = $ this ->createStackedApp ([], [
544
+ 'Access-Control-Expose-Headers ' => 'X-Custom-1, X-Custom-2 ' ,
545
+ ]);
546
+ $ request = $ this ->createValidActualRequest ();
547
+
548
+ $ response = $ app ->handle ($ request );
549
+
550
+ $ this ->assertTrue ($ response ->headers ->has ('Access-Control-Expose-Headers ' ));
551
+ $ this ->assertEquals ('X-Custom-1, X-Custom-2 ' , $ response ->headers ->get ('Access-Control-Expose-Headers ' ));
552
+ }
553
+
554
+ /**
555
+ * @test
556
+ */
557
+ public function itMergesExposedHeadersWhenResponseHasExistingHeaders (): void
558
+ {
559
+ $ app = $ this ->createStackedApp (
560
+ [
561
+ 'exposedHeaders ' => ['X-Option-1 ' , 'X-Option-2 ' ],
562
+ ],
563
+ [
564
+ 'Access-Control-Expose-Headers ' => 'X-Custom-1 ' ,
565
+ ]
566
+ );
567
+ $ request = $ this ->createValidActualRequest ();
568
+
569
+ $ result = $ app ->handle ($ request );
570
+
571
+ $ this ->assertTrue ($ result ->headers ->has ('Access-Control-Expose-Headers ' ));
572
+ $ this ->assertEquals ('X-Option-1, X-Option-2, X-Custom-1 ' , $ result ->headers ->get ('Access-Control-Expose-Headers ' ));
573
+ }
574
+
538
575
private function createValidActualRequest (): Request
539
576
{
540
577
$ request = new Request ();
0 commit comments