3030use Enlight_Controller_Response_ResponseTestCase ;
3131use PHPUnit \Framework \TestCase ;
3232use Shopware \Tests \Functional \Traits \ContainerTrait ;
33+ use Symfony \Component \HttpFoundation \Cookie ;
3334use Symfony \Component \HttpFoundation \Response ;
3435
3536class BootstrapTest extends TestCase
@@ -52,4 +53,32 @@ public function testOnRouteShutdown(): void
5253 static ::assertSame (Response::HTTP_MOVED_PERMANENTLY , $ response ->getStatusCode ());
5354 static ::assertSame ('shopware.php/www.test.de ' , $ response ->getHeader ('location ' ));
5455 }
56+
57+ public function testOnRouteStartupClearShopCookie (): void
58+ {
59+ $ pluginBootstrap = $ this ->getContainer ()->get ('plugins ' )->Core ()->Router ();
60+
61+ $ request = new Enlight_Controller_Request_RequestTestCase ();
62+ $ request ->setRequestUri ('shopware.php/www.test.de ' );
63+ $ request ->setCookie ('shop ' , 2 );
64+ $ response = new Enlight_Controller_Response_ResponseTestCase ();
65+ $ args = new Enlight_Controller_EventArgs ([
66+ 'request ' => $ request ,
67+ 'response ' => $ response ,
68+ ]);
69+ $ pluginBootstrap ->onRouteStartup ($ args );
70+
71+ static ::assertSame (Response::HTTP_OK , $ response ->getStatusCode ());
72+
73+ // Option A
74+ static ::assertIsString ($ response ->headers ->get ('Set-Cookie ' ));
75+ static ::assertStringContainsString ('shop=deleted ' , $ response ->headers ->get ('Set-Cookie ' ));
76+
77+ // Option B
78+ $ cookie = $ response ->headers ->getCookies ();
79+ static ::assertCount (1 , $ cookie );
80+ static ::assertInstanceOf (Cookie::class, $ cookie [0 ]);
81+ static ::assertSame ('shop ' , $ cookie [0 ]->getName ());
82+ static ::assertTrue ($ cookie [0 ]->isCleared ());
83+ }
5584}
0 commit comments