public function testDeleteFor() { $subject = new DIWikiPage('Foobar', NS_MAIN, '', 'abc'); $semanticData = new SemanticData($subject); $semanticData->addPropertyObjectValue(new DIProperty('_REDI'), new DIWikiPage('Bar', NS_MAIN)); $store = $this->getMockBuilder('\\SMW\\SQLStore\\SQLStore')->disableOriginalConstructor()->getMock(); $container = $this->getMockBuilder('\\Onoi\\BlobStore\\Container')->disableOriginalConstructor()->getMock(); $container->expects($this->at(0))->method('has')->with($this->stringContains('sd:'))->will($this->returnValue(true)); $container->expects($this->at(1))->method('get')->with($this->stringContains('sd:'))->will($this->returnValue($semanticData)); $container->expects($this->at(2))->method('has')->with($this->stringContains('list'))->will($this->returnValue(true)); $container->expects($this->at(3))->method('get')->with($this->stringContains('list'))->will($this->returnValue(array('abc', '123'))); $blobStore = $this->getMockBuilder('\\Onoi\\BlobStore\\BlobStore')->disableOriginalConstructor()->getMock(); $blobStore->expects($this->any())->method('canUse')->will($this->returnValue(true)); $blobStore->expects($this->atLeastOnce())->method('read')->will($this->returnValue($container)); $blobStore->expects($this->exactly(4))->method('delete'); $instance = new CachedValueLookupStore($store, $blobStore); $instance->deleteFor($subject); }
/** * @since 2.3 * * @return CachedValueLookupStore */ public function newCachedValueLookupStore() { $circularReferenceGuard = new CircularReferenceGuard('vl:store'); $circularReferenceGuard->setMaxRecursionDepth(2); $cacheFactory = ApplicationFactory::getInstance()->newCacheFactory(); $blobStore = new BlobStore('smw:vl:store', $cacheFactory->newMediaWikiCompositeCache($GLOBALS['smwgValueLookupCacheType'])); // If CACHE_NONE is selected, disable the usage $blobStore->setUsageState($GLOBALS['smwgValueLookupCacheType'] !== CACHE_NONE); $blobStore->setExpiryInSeconds($GLOBALS['smwgValueLookupCacheLifetime']); $blobStore->setNamespacePrefix($cacheFactory->getCachePrefix()); $cachedValueLookupStore = new CachedValueLookupStore($this->store, $blobStore); $cachedValueLookupStore->setCircularReferenceGuard($circularReferenceGuard); return $cachedValueLookupStore; }