Example #1
0
 /**
  * @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);
 }
Example #2
0
 /**
  * @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');
 }
Example #3
0
 private function updateStore(ParserOutput $parserOutput)
 {
     $cache = ApplicationFactory::getInstance()->getCache();
     $cache->setKey(FactboxCache::newCacheId($this->getTitle()->getArticleID()))->delete();
     // TODO
     // Rebuild the factbox
     $parserData = ApplicationFactory::getInstance()->newParserData($this->getTitle(), $parserOutput);
     // 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()->updateStore();
     return true;
 }