@@ -498,20 +498,58 @@ public function testInvalidate()
498498
499499 public function testPurge ()
500500 {
501- $ request = Request:: create ( ' https://foobar.com/ ' );
502- $ response = new Response ( ' hello world ' , 200 );
503- $ response -> headers -> set ( ' Foobar ' , ' whatever ' );
501+ // Request 1
502+ $ request1 = Request:: create ( ' https://foobar.com/ ' );
503+ $ response1 = new Response ( ' hello world ' , 200 );
504504
505- $ this ->store ->write ($ request , $ response );
506- $ cacheKey = $ this ->store ->getCacheKey ($ request );
505+ // Request 2
506+ $ request2 = Request::create ('https://foobar.com/foobar ' );
507+ $ response2 = new Response ('hello world ' , 200 );
507508
508- $ cacheItem = $ this ->getCache ()->getItem ($ cacheKey );
509- $ this ->assertTrue ($ cacheItem ->isHit ());
509+ $ this ->store ->write ($ request1 , $ response1 );
510+ $ this ->store ->write ($ request2 , $ response2 );
511+ $ cacheKey1 = $ this ->store ->getCacheKey ($ request1 );
512+ $ cacheKey2 = $ this ->store ->getCacheKey ($ request2 );
513+
514+ $ cacheItem1 = $ this ->getCache ()->getItem ($ cacheKey1 );
515+ $ cacheItem2 = $ this ->getCache ()->getItem ($ cacheKey2 );
516+ $ this ->assertTrue ($ cacheItem1 ->isHit ());
517+ $ this ->assertTrue ($ cacheItem2 ->isHit ());
510518
511519 $ this ->store ->purge ('https://foobar.com/ ' );
512520
513- $ cacheItem = $ this ->getCache ()->getItem ($ cacheKey );
514- $ this ->assertFalse ($ cacheItem ->isHit ());
521+ $ cacheItem1 = $ this ->getCache ()->getItem ($ cacheKey1 );
522+ $ cacheItem2 = $ this ->getCache ()->getItem ($ cacheKey2 );
523+ $ this ->assertFalse ($ cacheItem1 ->isHit ());
524+ $ this ->assertTrue ($ cacheItem2 ->isHit ());
525+ }
526+
527+ public function testClear ()
528+ {
529+ // Request 1
530+ $ request1 = Request::create ('https://foobar.com/ ' );
531+ $ response1 = new Response ('hello world ' , 200 );
532+
533+ // Request 2
534+ $ request2 = Request::create ('https://foobar.com/foobar ' );
535+ $ response2 = new Response ('hello world ' , 200 );
536+
537+ $ this ->store ->write ($ request1 , $ response1 );
538+ $ this ->store ->write ($ request2 , $ response2 );
539+ $ cacheKey1 = $ this ->store ->getCacheKey ($ request1 );
540+ $ cacheKey2 = $ this ->store ->getCacheKey ($ request2 );
541+
542+ $ cacheItem1 = $ this ->getCache ()->getItem ($ cacheKey1 );
543+ $ cacheItem2 = $ this ->getCache ()->getItem ($ cacheKey2 );
544+ $ this ->assertTrue ($ cacheItem1 ->isHit ());
545+ $ this ->assertTrue ($ cacheItem2 ->isHit ());
546+
547+ $ this ->store ->clear ();
548+
549+ $ cacheItem1 = $ this ->getCache ()->getItem ($ cacheKey1 );
550+ $ cacheItem2 = $ this ->getCache ()->getItem ($ cacheKey2 );
551+ $ this ->assertFalse ($ cacheItem1 ->isHit ());
552+ $ this ->assertFalse ($ cacheItem2 ->isHit ());
515553 }
516554
517555 public function testPruneIgnoredIfCacheBackendDoesNotImplementPrunableInterface ()
0 commit comments