public function testPurgeForContent() { $contentId = 123; $contentInfo = new ContentInfo(['id' => $contentId]); // Assume listeners have added locations. // Adding duplicates on purpose. $locationIds = [123, 456, 789, 234, 567]; $this->contentService->expects($this->once())->method('loadContentInfo')->with($contentId)->will($this->returnValue($contentInfo)); $eventDispatcher = new EventDispatcher(); $eventDispatcher->addListener(MVCEvents::CACHE_CLEAR_CONTENT, function (ContentCacheClearEvent $event) use($locationIds) { foreach ($locationIds as $id) { $event->addLocationToClear(new Location(['id' => $id])); } // Adding a few duplicates on purpose. $event->addLocationToClear(new Location(['id' => 123])); $event->addLocationToClear(new Location(['id' => 567])); }); $this->purgeClient->expects($this->once())->method('purge')->with($locationIds); $purger = new InstantCachePurger($this->purgeClient, $this->contentService, $eventDispatcher); $purger->purgeForContent($contentId); }
/** * @covers \eZ\Publish\Core\MVC\Symfony\Cache\Http\InstantCachePurger::purgeAll */ public function testPurgeAll() { $this->purgeClient->expects($this->once())->method('purgeAll'); $purger = new InstantCachePurger($this->purgeClient); $purger->purgeAll(); }