/** * @dataProvider outputDataProvider */ public function testProcessAndRetrieveContent($parameters, $expected) { $this->applicationFactory->getSettings()->set('smwgNamespacesWithSemanticLinks', $parameters['smwgNamespacesWithSemanticLinks']); $this->applicationFactory->getSettings()->set('smwgShowFactbox', $parameters['smwgShowFactbox']); $this->applicationFactory->registerObject('Store', $parameters['store']); $outputPage = $parameters['outputPage']; $instance = new FactboxCache($outputPage); $this->assertEmpty($instance->retrieveContent()); $instance->process($parameters['parserOutput']); $result = $outputPage->mSMWFactboxText; $this->assertPreProcess($expected, $result, $outputPage, $instance); // Re-run on the same instance $instance->process($parameters['parserOutput']); $this->assertPostProcess($expected, $result, $outputPage, $instance); }
/** * @see FunctionHook::process * * @since 1.9 * * @return true */ public function process() { $pageId = $this->wikiPage->getTitle()->getArticleID(); /** * @var Settings $settings */ $settings = ApplicationFactory::getInstance()->getSettings(); /** * @var CacheHandler $cache */ $cache = ApplicationFactory::getInstance()->getCache(); $cache->setCacheEnabled($pageId > 0)->setKey($this->newCacheId($pageId))->set($settings->get('smwgAutoRefreshOnPurge')); $cache->setCacheEnabled($settings->get('smwgFactboxCacheRefreshOnPurge'))->setKey(FactboxCache::newCacheId($pageId))->delete(); 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; }
/** * @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'); }
private function updateStore($parserData) { $cache = $this->applicationFactory->getCache(); $cache->setKey(FactboxCache::newCacheId($this->getTitle()->getArticleID()))->delete(); // TODO // Rebuild the factbox // Set a different updateIndentifier to ensure that the updateJob // will force a comparison of old/new data during the store update $parserData->getSemanticData()->setUpdateIdentifier('update-job'); $parserData->disableBackgroundUpdateJobs(); $parserData->updateStore(); return true; }