private function newMockCacheHandler($id, $status) { $cacheHandler = $this->getMockBuilder('SMW\\Cache\\CacheHandler')->disableOriginalConstructor()->getMock(); $cacheHandler->expects($this->any())->method('setKey')->with($this->equalTo(ArticlePurge::newCacheId($id))); $cacheHandler->expects($this->any())->method('get')->will($this->returnValue($status)); return $cacheHandler; }
/** * @note Article purge: In case an article was manually purged/moved * the store is updated as well; for all other cases LinksUpdateConstructed * will handle the store update */ private function checkForRequestedUpdateByPagePurge($parserData) { $cache = $this->applicationFactory->getCache(); $cache->setKey(ArticlePurge::newCacheId($this->parser->getTitle()->getArticleID())); if ($cache->get()) { $cache->delete(); $parserData->updateStore(); } return true; }
public function testPagePurge() { $this->applicationFactory->registerObject('CacheHandler', new \SMW\CacheHandler(new \HashBagOStuff())); $this->title = Title::newFromText(__METHOD__); $pageCreator = new PageCreator(); $pageCreator->createPage($this->title)->doEdit('[[Has function hook test::page purge]]'); $id = ArticlePurge::newCacheId($this->title->getArticleID()); $pageCreator->getPage()->doPurge(); $result = ApplicationFactory::getInstance()->getcache()->setKey($id)->get(); $this->assertTrue($result); }
/** * @dataProvider titleDataProvider */ public function testProcess($setup, $expected) { $wikiPage = new WikiPage($setup['title']); $pageId = $wikiPage->getTitle()->getArticleID(); ApplicationFactory::getInstance()->registerObject('Settings', Settings::newFromArray(array('smwgCacheType' => 'hash', 'smwgAutoRefreshOnPurge' => $setup['smwgAutoRefreshOnPurge'], 'smwgFactboxCacheRefreshOnPurge' => $setup['smwgFactboxCacheRefreshOnPurge']))); $instance = new ArticlePurge($wikiPage); $cache = ApplicationFactory::getInstance()->getCache(); $id = FactboxCache::newCacheId($pageId); // $cache->setKey( $id )->set( true ); $this->assertEquals($expected['autorefreshPreProcess'], $cache->setKey($instance->newCacheId($pageId))->get(), 'Asserts the autorefresh cache status before processing'); // Travis 210.5, 305.3 $travis = $cache->setKey($id)->get(); $travisText = json_encode($travis); $this->assertEquals($expected['factboxPreProcess'], $travis, "Asserts the factbox cache status before processing, {$travisText}"); $this->assertFalse($cache->setKey($instance->newCacheId($pageId))->get(), 'Asserts that before processing ...'); $result = $instance->process(); // Post-process check $this->assertTrue($result, 'Asserts that process() always returns true'); $this->assertEquals($expected['autorefreshPostProcess'], $cache->setKey($instance->newCacheId($pageId))->get(), 'Asserts the autorefresh cache status after processing'); $this->assertEquals($expected['factboxPostProcess'], $cache->setCacheEnabled(true)->setKey($id)->get(), 'Asserts the factbox cache status after processing'); }
/** * @since 1.9 * * @return true */ public function process() { /** * @var Settings $settings */ $settings = ApplicationFactory::getInstance()->getSettings(); /** * @var CacheHandler $cache */ $cache = ApplicationFactory::getInstance()->getCache(); $cache->setCacheEnabled($this->newId > 0)->setKey(ArticlePurge::newCacheId($this->newId))->set($settings->get('smwgAutoRefreshOnPageMove')); $cache->setCacheEnabled($this->oldId > 0)->setKey(ArticlePurge::newCacheId($this->oldId))->set($settings->get('smwgAutoRefreshOnPageMove')); ApplicationFactory::getInstance()->getStore()->changeTitle($this->oldTitle, $this->newTitle, $this->oldId, $this->newId); return true; }
/** * @since 1.9 * * @return true */ public function process() { /** * @var Settings $settings */ $settings = $this->applicationFactory->getSettings(); $cache = $this->applicationFactory->newCacheFactory()->newMediaWikiCompositeCache(); // Delete all data for a non-enabled target NS if (!$this->applicationFactory->getNamespaceExaminer()->isSemanticEnabled($this->newTitle->getNamespace())) { $cache->delete(FactboxCache::newCacheId($this->oldId)->generateId()); $this->applicationFactory->getStore()->deleteSubject($this->oldTitle); } else { $cache->save(ArticlePurge::newCacheId($this->newId)->generateId(), $settings->get('smwgAutoRefreshOnPageMove')); $cache->save(ArticlePurge::newCacheId($this->oldId)->generateId(), $settings->get('smwgAutoRefreshOnPageMove')); $this->applicationFactory->getStore()->changeTitle($this->oldTitle, $this->newTitle, $this->oldId, $this->newId); } return true; }