示例#1
0
 /**
  * @since 2.0
  *
  * @return SMWExporter
  */
 public static function getInstance()
 {
     if (self::$instance === null) {
         self::$instance = new self();
         self::$instance->initBaseURIs();
         $cacheFactory = ApplicationFactory::getInstance()->newCacheFactory();
         // There is no better way of getting around the static use without BC
         self::$dataItemToElementEncoder = new DataItemToElementEncoder();
         self::$cachedDataItemToExpResourceEncoder = new CachedDataItemToExpResourceEncoder(ApplicationFactory::getInstance()->getStore(), $cacheFactory->newFixedInMemoryCache(500));
         self::$cachedDataItemToExpResourceEncoder->setCachePrefix($cacheFactory->getCachePrefix());
     }
     return self::$instance;
 }
 public function testResetCache()
 {
     $store = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass();
     $cache = $this->getMockBuilder('\\Onoi\\Cache\\Cache')->disableOriginalConstructor()->getMock();
     $key = 'bar:smw:expresourceencoder-cache:' . 'Foo#0#';
     $cache->expects($this->at(0))->method('delete')->with($this->equalTo($key));
     $cache->expects($this->at(1))->method('delete')->with($this->equalTo($key . CachedDataItemToExpResourceEncoder::AUX_MARKER));
     $instance = new CachedDataItemToExpResourceEncoder($store, $cache);
     $instance->setCachePrefix('bar');
     $instance->resetCacheFor(new DIWikiPage('Foo', NS_MAIN));
 }