eZ\Publish\Core\MVC\Symfony\Cache\Tests\Http\InstantCachePurgerTest::testPurgeForContent PHP Метод

testPurgeForContent() публичный Метод

public testPurgeForContent ( )
    public function testPurgeForContent()
    {
        $contentId = 123;
        $contentInfo = new ContentInfo(['id' => $contentId, 'published' => true]);
        // 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);
    }