File tree Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Original file line number Diff line number Diff line change 3939 "symfony/http-kernel" : " ^3.4 || ^4.3 || ^5.0"
4040 },
4141 "conflict" : {
42- "toflar/psr6-symfony-http-cache-store" : " <2.2.0 "
42+ "toflar/psr6-symfony-http-cache-store" : " <2.2.1 "
4343 },
4444 "suggest" : {
4545 "friendsofsymfony/http-cache-bundle" : " For integration with the Symfony framework" ,
Original file line number Diff line number Diff line change 1313
1414use Symfony \Component \HttpFoundation \Response ;
1515use Symfony \Component \OptionsResolver \OptionsResolver ;
16+ use Toflar \Psr6HttpCacheStore \ClearableInterface ;
1617use Toflar \Psr6HttpCacheStore \Psr6StoreInterface ;
1718
1819/**
@@ -98,9 +99,9 @@ public function handlePurge(CacheEvent $event)
9899
99100 // Purge whole cache
100101 if ($ request ->headers ->has ($ this ->clearCacheHeader )) {
101- if (!$ store instanceof Psr6StoreInterface ) {
102+ if (!$ store instanceof ClearableInterface ) {
102103 $ response ->setStatusCode (400 );
103- $ response ->setContent ('Store must be an instance of ' .Psr6StoreInterface ::class.'. Please check your proxy configuration. ' );
104+ $ response ->setContent ('Store must be an instance of ' .ClearableInterface ::class.'. Please check your proxy configuration. ' );
104105 $ event ->setResponse ($ response );
105106
106107 return ;
Original file line number Diff line number Diff line change @@ -88,6 +88,22 @@ public function testClearCache()
8888 $ this ->assertSame (200 , $ response ->getStatusCode ());
8989 }
9090
91+ public function testClearCacheWithoutPsr6Store ()
92+ {
93+ /** @var StoreInterface $store */
94+ $ store = \Mockery::mock (StoreInterface::class);
95+ $ kernel = $ this ->getKernelMock ($ store );
96+ $ purgeListener = new PurgeListener ();
97+ $ request = Request::create ('http://example.com/ ' , 'PURGE ' );
98+ $ request ->headers ->set ('Clear-Cache ' , 'true ' );
99+ $ event = new CacheEvent ($ kernel , $ request );
100+ $ purgeListener ->handlePurge ($ event );
101+ $ response = $ event ->getResponse ();
102+ $ this ->assertInstanceOf (Response::class, $ response );
103+ $ this ->assertSame (400 , $ response ->getStatusCode ());
104+ $ this ->assertSame ('Store must be an instance of Toflar\Psr6HttpCacheStore\ClearableInterface. Please check your proxy configuration. ' , $ response ->getContent ());
105+ }
106+
91107 public function testPurgeAllowedMiss ()
92108 {
93109 /** @var StoreInterface $store */
You can’t perform that action at this time.
0 commit comments