Example #1
0
 public function testGetRedirectTargetFromInMemoryCache()
 {
     $inMemoryPoolCache = InMemoryPoolCache::getInstance();
     $instance = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass();
     $wikipage = new DIWikiPage('Foo', NS_MAIN);
     $expected = new DIWikiPage('Bar', NS_MAIN);
     $inMemoryPoolCache->getPoolCacheFor('store.redirectTarget.lookup')->save($wikipage->getHash(), $expected);
     $this->assertEquals($expected, $instance->getRedirectTarget($wikipage));
     $inMemoryPoolCache->resetPoolCacheFor('store.redirectTarget.lookup');
 }
Example #2
0
 /**
  * @since 2.4
  *
  * @param DIProperty $property
  * @param array|string $errorMsg
  *
  * @return DIContainer
  */
 public function getContainerFor(DIProperty $property = null, $errorMsg = '')
 {
     if ($property !== null && $property->isInverse()) {
         $property = new DIProperty($property->getKey());
     }
     $errorMsg = is_array($errorMsg) ? implode(' ', $errorMsg) : $errorMsg;
     $subject = new DIWikiPage($this->subject->getDBkey(), $this->subject->getNamespace(), $this->subject->getInterwiki(), '_ERR' . md5(($property !== null ? $property->getKey() : 'UNKNOWN') . $errorMsg));
     // Encode brackets to avoid an annotion is created/included
     return $this->newDiContainer($subject, $property, InTextAnnotationParser::obscureAnnotation($errorMsg));
 }
 /**
  * @depends testFileUploadForDummyTextFile
  */
 public function testReUploadDummyTextFileToEditFilePage()
 {
     $subject = new DIWikiPage('Foo.txt', NS_FILE);
     $dummyTextFile = $this->fixturesFileProvider->newUploadForDummyTextFile('Foo.txt');
     $dummyTextFile->doUpload();
     $this->pageEditor->editPage($subject->getTitle())->doEdit('[[Ichi::Maru|Kyū]]');
     // File page content is kept from the initial upload
     $expected = array('propertyCount' => 4, 'propertyKeys' => array('HasFile', '_MEDIA', '_MIME', '_SKEY', 'Ichi'), 'propertyValues' => array('File:Foo.txt', 'TEXT', 'text/plain', 'Foo.txt', 'Maru'));
     $this->semanticDataValidator->assertThatPropertiesAreSet($expected, $this->getStore()->getSemanticData($subject));
 }
 /**
  * #1416 create container manually to avoid any issues that may arise from
  * a failed Title::makeTitleSafe.
  */
 private function newDIContainer(Query $query)
 {
     $subject = $query->getContextPage();
     if ($subject === null) {
         $containerSemanticData = ContainerSemanticData::makeAnonymousContainer();
     } else {
         $subject = new DIWikiPage($subject->getDBkey(), $subject->getNamespace(), $subject->getInterwiki(), $query->getQueryId());
         $containerSemanticData = new ContainerSemanticData($subject);
     }
     return new DIContainer($containerSemanticData);
 }
 public function testResetCache()
 {
     $subject = new DIWikiPage('Foo', NS_MAIN);
     $poolCache = $this->inMemoryPoolCache->getPoolCacheFor('exporter.dataitem.resource.encoder');
     $poolCache->save($subject->getHash(), true);
     $poolCache->save($subject->getHash() . DataItemToExpResourceEncoder::AUX_MARKER, true);
     $store = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass();
     $instance = new DataItemToExpResourceEncoder($store);
     $instance->resetCacheFor($subject);
     $this->assertFalse($poolCache->contains($subject->getHash()));
 }
 public function testExportRedirect()
 {
     $semanticData = $this->semanticDataFactory->newEmptySemanticData(__METHOD__);
     $redirectProperty = new DIProperty('_REDI');
     $redirectTarget = new DIWikiPage('FooRedirectTarget', NS_MAIN, '');
     $semanticData->addPropertyObjectValue($redirectProperty, DIWikiPage::newFromTitle($redirectTarget->getTitle(), '__red'));
     $exportData = Exporter::getInstance()->makeExportData($semanticData);
     $this->assertCount(1, $exportData->getValues(Exporter::getInstance()->getSpecialNsResource('swivt', 'redirectsTo')));
     $this->assertCount(1, $exportData->getValues(Exporter::getInstance()->getSpecialNsResource('owl', 'sameAs')));
     $expectedResourceElement = new ExpNsResource('FooRedirectTarget', Exporter::getInstance()->getNamespaceUri('wiki'), 'wiki', $redirectTarget);
     $this->exportDataValidator->assertThatExportDataContainsResource($expectedResourceElement, Exporter::getInstance()->getSpecialNsResource('owl', 'sameAs'), $exportData);
 }
 public function testFileUploadForDummyTextFile()
 {
     $subject = new DIWikiPage('RdfLinkedFile.txt', NS_FILE);
     $fileNS = Localizer::getInstance()->getNamespaceTextById(NS_FILE);
     $dummyTextFile = $this->fixturesFileProvider->newUploadForDummyTextFile('RdfLinkedFile.txt');
     $dummyTextFile->doUpload('[[HasFile::File:RdfLinkedFile.txt]]');
     $exportController = new ExportController(new RDFXMLSerializer());
     $exportController->enableBacklinks(false);
     ob_start();
     $exportController->printPages(array($subject->getTitle()->getPrefixedDBKey()));
     $output = ob_get_clean();
     $expected = array("<rdfs:label>{$fileNS}:RdfLinkedFile.txt</rdfs:label>", '<swivt:file rdf:resource="' . $dummyTextFile->getLocalFile()->getFullURL() . '"/>', '<property:Media_type-23aux rdf:datatype="http://www.w3.org/2001/XMLSchema#string">TEXT</property:Media_type-23aux>', '<property:MIME_type-23aux rdf:datatype="http://www.w3.org/2001/XMLSchema#string">text/plain</property:MIME_type-23aux>');
     $this->stringValidator->assertThatStringContains($expected, $output);
 }
 public function testErrorContainerForSamePropertyButDifferentMsg()
 {
     $instance = new Error(DIWikiPage::newFromText('Foo'));
     $property = new DIProperty('Foo');
     $container = $instance->getContainerFor($property, array('Some error'));
     $this->assertNotSame($container->getHash(), $instance->getContainerFor($property, array('Different error'))->getHash());
 }
 /**
  * @dataProvider durationDataProvider
  */
 public function testCreateProfile($duration, $expected)
 {
     $profiler = new NullProfileAnnotator(new Subobject(DIWikiPage::newFromText(__METHOD__)->getTitle()), 'foo');
     $instance = new DurationProfileAnnotator($profiler, $duration);
     $instance->addAnnotation();
     $this->semanticDataValidator->assertThatPropertiesAreSet($expected, $instance->getContainer()->getSemanticData());
 }
 public function subjectProvider()
 {
     $provider[] = array(DIWikiPage::newFromText('Foo'));
     $provider[] = array(DIWikiPage::newFromText('Bar', SMW_NS_PROPERTY));
     $provider[] = array(DIWikiPage::newFromText('Modification date', SMW_NS_PROPERTY));
     return $provider;
 }
 public function testPageImportToCreateRedirect()
 {
     $this->importedTitles = array('SimplePageRedirectRegressionTest', 'ToBeSimplePageRedirect');
     $this->titleValidator->assertThatTitleIsKnown($this->importedTitles);
     $main = Title::newFromText('SimplePageRedirectRegressionTest');
     $expectedCategoryAsWikiValue = array('property' => new DIProperty(DIProperty::TYPE_CATEGORY), 'propertyValues' => array('Regression test', 'Redirect test', 'Simple redirect test'));
     $expectedSomeProperties = array('properties' => array(new DIProperty('Has regression test')));
     $expectedRedirectAsWikiValue = array('property' => new DIProperty('_REDI'), 'propertyValues' => array('ToBeSimplePageRedirect', 'NewPageRedirectRegressionTest', 'NewTargetPageRedirectRegressionTest'));
     $newRedirectPage = $this->createPageWithRedirectFor('NewPageRedirectRegressionTest', 'SimplePageRedirectRegressionTest');
     $this->testEnvironment->executePendingDeferredUpdates();
     $this->movePageToTargetRedirect($newRedirectPage, 'NewTargetPageRedirectRegressionTest');
     $this->testEnvironment->executePendingDeferredUpdates();
     $this->pageRefresher->doRefreshPoolOfPages(array($main, $newRedirectPage, 'NewTargetPageRedirectRegressionTest'));
     $this->testEnvironment->executePendingDeferredUpdates();
     $semanticDataBatches = array($this->getStore()->getSemanticData(DIWikiPage::newFromTitle($main)));
     $this->assertThatCategoriesAreSet($expectedCategoryAsWikiValue, $semanticDataBatches);
     $this->assertThatPropertiesAreSet($expectedSomeProperties, $semanticDataBatches);
     $inSemanticDataFetcher = new InSemanticDataFetcher($this->getStore());
     $inSemanticData = $inSemanticDataFetcher->getSemanticData(DIWikiPage::newFromTitle($main));
     // When running sqlite, the database select returns an empty result which
     // is probably due to some DB-prefix issues in MW's DatabaseBaseSqlite
     // implementation and for non-sqlite see #212 / bug 62856
     if ($inSemanticData->getProperties() === array()) {
         $this->markTestSkipped("Skipping test either because of sqlite or MW-{$GLOBALS['wgVersion']} / bug 62856");
     }
     $this->assertThatSemanticDataValuesForPropertyAreSet($expectedRedirectAsWikiValue, $inSemanticData);
 }
 /**
  * Creates a Semantic Data object with the incoming properties instead of the
  * usual outproperties.
  *
  * @return array(SMWSemanticData, bool)  The semantic data including all inproperties, and if there are more inproperties left
  */
 private function getInData()
 {
     $indata = new SemanticData($this->subject->getDataItem());
     $propRequestOptions = new RequestOptions();
     $propRequestOptions->sort = true;
     $propRequestOptions->limit = $this->incomingPropertiesCount;
     if ($this->offset > 0) {
         $propRequestOptions->offset = $this->offset;
     }
     $incomingProperties = $this->store->getInProperties($this->subject->getDataItem(), $propRequestOptions);
     $more = false;
     if (count($incomingProperties) == $this->incomingPropertiesCount) {
         $more = true;
         array_pop($incomingProperties);
         // drop the last one
     }
     $valRequestOptions = new RequestOptions();
     $valRequestOptions->sort = true;
     $valRequestOptions->limit = $this->incomingValuesCount;
     foreach ($incomingProperties as $property) {
         $values = $this->store->getPropertySubjects($property, $this->subject->getDataItem(), $valRequestOptions);
         foreach ($values as $value) {
             $indata->addPropertyObjectValue($property, $value);
         }
     }
     // Added in 2.3
     // Whether to show a more link or not can be set via
     // SMW::Browse::BeforeIncomingPropertyValuesFurtherLinkCreate
     \Hooks::run('SMW::Browse::AfterIncomingPropertiesLookupComplete', array($this->store, $indata, $valRequestOptions));
     return array($indata, $more);
 }
 public function testGetHash()
 {
     $diff = array();
     $instance = new CompositePropertyTableDiffIterator($diff);
     $instance->setSubject(DIWikiPage::newFromText(__METHOD__));
     $this->assertInternalType('string', $instance->getHash());
 }
 /**
  * @see SMWStore::deleteSubject
  *
  * @since 1.8
  * @param Title $title
  */
 public function deleteSubject(Title $title)
 {
     // @deprecated since 2.1, use 'SMW::SQLStore::BeforeDeleteSubjectComplete'
     wfRunHooks('SMWSQLStore3::deleteSubjectBefore', array($this->store, $title));
     wfRunHooks('SMW::SQLStore::BeforeDeleteSubjectComplete', array($this->store, $title));
     $id = $this->store->getObjectIds()->getSMWPageID($title->getDBkey(), $title->getNamespace(), $title->getInterwiki(), '', false);
     $emptySemanticData = new SemanticData(DIWikiPage::newFromTitle($title));
     $subobjects = $this->getSubobjects($emptySemanticData->getSubject());
     $this->doDataUpdate($emptySemanticData);
     if ($title->getNamespace() === SMW_NS_CONCEPT) {
         // make sure to clear caches
         $db = $this->store->getConnection();
         $db->delete('smw_fpt_conc', array('s_id' => $id), 'SMW::deleteSubject::Conc');
         $db->delete(SMWSQLStore3::CONCEPT_CACHE_TABLE, array('o_id' => $id), 'SMW::deleteSubject::Conccache');
     }
     // Mark subject/subobjects with a special IW, the final removal is being
     // triggered by the `ByIdDataRebuildDispatcher`
     $this->store->getObjectIds()->updateInterwikiField($id, $emptySemanticData->getSubject(), SMW_SQL3_SMWDELETEIW);
     foreach ($subobjects as $smw_id => $subobject) {
         $this->store->getObjectIds()->updateInterwikiField($smw_id, $subobject, SMW_SQL3_SMWDELETEIW);
     }
     // 1.9.0.1
     // The update of possible associative entities is handled by DeleteSubjectJob which is invoked during
     // the ArticleDelete hook
     // @deprecated since 2.1, use 'SMW::SQLStore::AfterDeleteSubjectComplete'
     wfRunHooks('SMWSQLStore3::deleteSubjectAfter', array($this->store, $title));
     wfRunHooks('SMW::SQLStore::AfterDeleteSubjectComplete', array($this->store, $title));
 }
 protected function createDataItemByPropertyId($propertyId)
 {
     $dataItem = null;
     switch ($propertyId) {
         case DIProperty::TYPE_MODIFICATION_DATE:
             $dataItem = DITime::newFromTimestamp($this->pageInfo->getModificationDate());
             break;
         case DIProperty::TYPE_CREATION_DATE:
             $dataItem = DITime::newFromTimestamp($this->pageInfo->getCreationDate());
             break;
         case DIProperty::TYPE_NEW_PAGE:
             $dataItem = new DIBoolean($this->pageInfo->isNewPage());
             break;
         case DIProperty::TYPE_LAST_EDITOR:
             $dataItem = $this->pageInfo->getLastEditor() ? DIWikiPage::newFromTitle($this->pageInfo->getLastEditor()) : null;
             break;
         case DIProperty::TYPE_MEDIA:
             $dataItem = $this->pageInfo->isFilePage() && $this->pageInfo->getMediaType() !== '' && $this->pageInfo->getMediaType() !== null ? new DIBlob($this->pageInfo->getMediaType()) : null;
             break;
         case DIProperty::TYPE_MIME:
             $dataItem = $this->pageInfo->isFilePage() && $this->pageInfo->getMimeType() !== '' && $this->pageInfo->getMimeType() !== null ? new DIBlob($this->pageInfo->getMimeType()) : null;
             break;
     }
     return $dataItem;
 }
 public function testGetPropertyValues()
 {
     $instance = StubSemanticData::newFromSemanticData(new SemanticData(DIWikiPage::newFromTitle(Title::newFromText(__METHOD__))), $this->store);
     $this->assertInstanceOf('SMW\\DIWikiPage', $instance->getSubject());
     $this->assertEmpty($instance->getPropertyValues(new DIProperty('unknownInverseProperty', true)));
     $this->assertEmpty($instance->getPropertyValues(new DIProperty('unknownProperty')));
 }
 public function testImportOfRecordValues()
 {
     $this->importedTitles = array('Property:Has record number field', 'Property:Has record page field', 'Property:Has record text field', 'Property:Has record type', 'Property:Has record type for single test', 'RecordDataTypePage', 'RecordDataTypeRegressionTest/WithSubpage', 'RecordDataTypeRegressionTest');
     $this->titleValidator->assertThatTitleIsKnown($this->importedTitles);
     $title = Title::newFromText('RecordDataTypeRegressionTest');
     $expectedCategoryAsWikiValue = array('property' => new DIProperty('_INST'), 'propertyValues' => array('Regression test', 'Data type regression test', 'Record type regression test'));
     $expectedSomeProperties = array('properties' => array(DIProperty::newFromUserLabel('RecordDataTypePage'), DIProperty::newFromUserLabel('BarText'), DIProperty::newFromUserLabel('BooPage'), DIProperty::newFromUserLabel('FooPage'), DIProperty::newFromUserLabel('QyuPage'), new DIProperty('_ASK'), new DIProperty('_MDAT'), new DIProperty('_SKEY'), new DIProperty('_SOBJ'), new DIProperty('_INST')));
     $property = DIProperty::newFromUserLabel('Has record type for single test');
     $valueString = 'ForSingleTestAsPage;ForSingleTestAsText;3333';
     if ($property->findPropertyTypeID() === '_rec') {
         $valueString = 'ForSingleTestAsPage; ForSingleTestAsText; 3333';
     }
     $expectedRecordTypeValuesAsWikiValue = array('subject' => DIWikiPage::newFromTitle($title), 'record' => $property, 'property' => $property, 'propertyValues' => array($valueString, '?; ?; ?'));
     $expectedRecordPageFieldValuesAsWikiValue = array('subject' => DIWikiPage::newFromTitle($title), 'record' => DIProperty::newFromUserLabel('Has record type'), 'property' => DIProperty::newFromUserLabel('Has record page field'), 'propertyValues' => array('FooPage', 'QyuPageOnSubobject', 'QyuPage', 'XeuiPageOnSubobject', 'RecordDataTypePage', 'BooPage'));
     $expectedRecordTextFieldValuesAsWikiValue = array('subject' => DIWikiPage::newFromTitle($title), 'record' => DIProperty::newFromUserLabel('Has record type'), 'property' => DIProperty::newFromUserLabel('Has record text field'), 'propertyValues' => array('BarText', 'ForSingleTestAsText', 'FooText', 'XeuiTextOnSubobject'));
     $expectedRecordNumberFieldValuesAsNumber = array('subject' => DIWikiPage::newFromTitle(Title::newFromText('RecordDataTypeRegressionTest/WithSubpage')), 'record' => DIProperty::newFromUserLabel('Has record type'), 'property' => DIProperty::newFromUserLabel('Has record number field'), 'propertyValues' => array(1111, 9001, 9999, 1009));
     $semanticDataFinder = new ByPageSemanticDataFinder();
     $semanticDataFinder->setTitle($title)->setStore($this->getStore());
     $semanticDataBatches = array($this->getStore()->getSemanticData(DIWikiPage::newFromTitle($title)));
     foreach ($semanticDataBatches as $semanticData) {
         $this->semanticDataValidator->assertThatCategoriesAreSet($expectedCategoryAsWikiValue, $semanticData);
         $this->semanticDataValidator->assertThatPropertiesAreSet($expectedSomeProperties, $semanticData);
         $this->assertThatSemanticDataValuesAreSet($expectedRecordTypeValuesAsWikiValue, $semanticData);
     }
     $this->assertThatRecordValuesAreSet($expectedRecordTypeValuesAsWikiValue);
     $this->assertThatRecordValuesAreSet($expectedRecordPageFieldValuesAsWikiValue);
     $this->assertThatRecordValuesAreSet($expectedRecordTextFieldValuesAsWikiValue);
     $this->assertThatRecordValuesAreSet($expectedRecordNumberFieldValuesAsNumber);
 }
 protected function createDataItemByPropertyId($propertyId)
 {
     $dataItem = null;
     switch ($propertyId) {
         case DIProperty::TYPE_MODIFICATION_DATE:
             $dataItem = DITime::newFromTimestamp($this->pageInfo->getModificationDate());
             break;
         case DIProperty::TYPE_CREATION_DATE:
             $dataItem = DITime::newFromTimestamp($this->pageInfo->getCreationDate());
             break;
         case DIProperty::TYPE_NEW_PAGE:
             $dataItem = new DIBoolean($this->pageInfo->isNewPage());
             break;
         case DIProperty::TYPE_LAST_EDITOR:
             $dataItem = $this->pageInfo->getLastEditor() ? DIWikiPage::newFromTitle($this->pageInfo->getLastEditor()) : null;
             break;
         case DIProperty::TYPE_MEDIA:
             // @codingStandardsIgnoreStart phpcs, ignore --sniffs=Generic.Files.LineLength
             $dataItem = $this->pageInfo->isFilePage() && $this->pageInfo->getMediaType() !== '' && $this->pageInfo->getMediaType() !== null ? new DIBlob($this->pageInfo->getMediaType()) : null;
             // @codingStandardsIgnoreEnd
             break;
         case DIProperty::TYPE_MIME:
             // @codingStandardsIgnoreStart phpcs, ignore --sniffs=Generic.Files.LineLength
             $dataItem = $this->pageInfo->isFilePage() && $this->pageInfo->getMimeType() !== '' && $this->pageInfo->getMimeType() !== null ? new DIBlob($this->pageInfo->getMimeType()) : null;
             // @codingStandardsIgnoreEnd
             break;
     }
     return $dataItem;
 }
 private function addListenersToCollection()
 {
     $this->eventListenerCollection->registerCallback('factbox.cache.delete', function ($dispatchContext) {
         if ($dispatchContext->has('subject')) {
             $title = $dispatchContext->get('subject')->getTitle();
         } else {
             $title = $dispatchContext->get('title');
         }
         $applicationFactory = ApplicationFactory::getInstance();
         $applicationFactory->getCache()->delete($applicationFactory->newCacheFactory()->getFactboxCacheKey($title->getArticleID()));
     });
     $this->eventListenerCollection->registerCallback('exporter.reset', function () {
         Exporter::getInstance()->clear();
     });
     $this->eventListenerCollection->registerCallback('query.comparator.reset', function () {
         QueryComparator::getInstance()->clear();
     });
     /**
      * Emitted during NewRevisionFromEditComplete, UpdateJob, ArticleDelete
      */
     $this->eventListenerCollection->registerCallback('cached.propertyvalues.prefetcher.reset', function ($dispatchContext) {
         if ($dispatchContext->has('title')) {
             $subject = DIWikiPage::newFromTitle($dispatchContext->get('title'));
         } else {
             $subject = $dispatchContext->get('subject');
         }
         wfDebugLog('smw', 'Clear CachedPropertyValuesPrefetcher for ' . $subject->getHash());
         $applicationFactory = ApplicationFactory::getInstance();
         $applicationFactory->getCachedPropertyValuesPrefetcher()->resetCacheBy($subject);
         $dispatchContext->set('propagationstop', true);
     });
     $this->registerStateChangeEvents();
     return $this->eventListenerCollection;
 }
 /**
  * @see PropertyAnnotatorDecorator::addPropertyValues
  */
 protected function addPropertyValues()
 {
     if (!$this->redirectTargetFinder->hasRedirectTarget()) {
         return;
     }
     $this->getSemanticData()->addPropertyObjectValue(new DIProperty('_REDI'), DIWikiPage::newFromTitle($this->redirectTargetFinder->getRedirectTarget()));
 }
 public function semanticDataProvider()
 {
     // Is a dataprovider therefore can't use the setUp
     $this->semanticDataFactory = UtilityFactory::getInstance()->newSemanticDataFactory();
     $this->dataValueFactory = DataValueFactory::getInstance();
     $title = Title::newFromText('Foo');
     #0 Empty container
     $foo = $this->semanticDataFactory->setSubject(DIWikiPage::newFromTitle($title))->newEmptySemanticData();
     $provider[] = array($foo);
     #1 Single entry
     $foo = $this->semanticDataFactory->setSubject(DIWikiPage::newFromTitle($title))->newEmptySemanticData();
     $foo->addDataValue($this->dataValueFactory->newPropertyValue('Has fooQuex', 'Bar'));
     $provider[] = array($foo);
     // #2 Single + single subobject entry
     $foo = $this->semanticDataFactory->setSubject(DIWikiPage::newFromTitle($title))->newEmptySemanticData();
     $foo->addDataValue($this->dataValueFactory->newPropertyValue('Has fooQuex', 'Bar'));
     $subobject = new Subobject($title);
     $subobject->setSemanticData('Foo');
     $subobject->addDataValue($this->dataValueFactory->newPropertyValue('Has subobjects', 'Bam'));
     $foo->addPropertyObjectValue($subobject->getProperty(), $subobject->getContainer());
     $provider[] = array($foo);
     #3 Multiple entries
     $foo = $this->semanticDataFactory->setSubject(DIWikiPage::newFromTitle($title))->newEmptySemanticData();
     $foo->addDataValue($this->dataValueFactory->newPropertyValue('Has fooQuex', 'Bar'));
     $foo->addDataValue($this->dataValueFactory->newPropertyValue('Has queez', 'Xeey'));
     $subobject = new Subobject($title);
     $subobject->setSemanticData('Foo');
     $subobject->addDataValue($this->dataValueFactory->newPropertyValue('Has subobjects', 'Bam'));
     $subobject->addDataValue($this->dataValueFactory->newPropertyValue('Has fooQuex', 'Fuz'));
     $subobject->setSemanticData('Bar');
     $subobject->addDataValue($this->dataValueFactory->newPropertyValue('Has fooQuex', 'Fuz'));
     $foo->addPropertyObjectValue($subobject->getProperty(), $subobject->getContainer());
     $provider[] = array($foo);
     return $provider;
 }
 protected function setUp()
 {
     parent::setUp();
     $idTable = $this->getMockBuilder('\\stdClass')->setMethods(array('getDataItemById'))->getMock();
     $idTable->expects($this->any())->method('getDataItemById')->will($this->returnValue(DIWikiPage::newFromText('Foo')));
     $this->store = $this->getMockBuilder('\\SMW\\SQLStore\\SQLStore')->disableOriginalConstructor()->getMock();
     $this->store->expects($this->any())->method('getObjectIds')->will($this->returnValue($idTable));
 }
 public function testRun()
 {
     $parameters = array('slot:id' => 42);
     $this->transitionalDiffStore->expects($this->once())->method('delete');
     $subject = DIWikiPage::newFromText(__METHOD__);
     $instance = new ChronologyPurgeJob($subject->getTitle(), $parameters);
     $this->assertTrue($instance->run());
 }
 /**
  * @depends testAddToEntityList
  */
 public function testAddAnotherToEntityList()
 {
     $dataItem = DIWikiPage::newFromText('Bar');
     $this->query->expects($this->any())->method('getQueryId')->will($this->returnValue('FOO:BAR'));
     $instance = new EntityListAccumulator($this->query);
     $instance->addToEntityList($dataItem);
     $this->assertEquals(array('FOO:BAR' => array('Bar#0#' => $dataItem)), $instance->getEntityList());
 }
 /**
  * @dataProvider preliminaryCheckProvider
  */
 public function testPreliminaryCheckForType($type, $parameters = array())
 {
     $httpRequest = $this->getMockBuilder('\\Onoi\\HttpRequest\\SocketRequest')->disableOriginalConstructor()->getMock();
     $httpRequest->expects($this->any())->method('ping')->will($this->returnValue(true));
     $instance = new DeferredRequestDispatchManager($httpRequest);
     $instance->reset();
     $this->assertNull($instance->dispatchJobRequestFor($type, DIWikiPage::newFromText(__METHOD__)->getTitle(), $parameters));
 }
 /**
  * @dataProvider removePropertyObjectProvider
  */
 public function testRemovePropertyObjectValue($title, $property, $dataItem)
 {
     $instance = StubSemanticData::newFromSemanticData(new SemanticData(DIWikiPage::newFromTitle($title)), $this->store);
     $instance->addPropertyObjectValue($property, $dataItem);
     $this->assertFalse($instance->isEmpty());
     $instance->removePropertyObjectValue($property, $dataItem);
     $this->assertTrue($instance->isEmpty());
 }
 public function testCreateProfile()
 {
     $profiler = new NullProfileAnnotator(new Subobject(DIWikiPage::newFromText(__METHOD__)->getTitle()), 'foo');
     $instance = new FormatProfileAnnotator($profiler, 'table');
     $instance->addAnnotation();
     $expected = array('propertyCount' => 1, 'propertyKeys' => array('_ASKFO'), 'propertyValues' => array('table'));
     $this->semanticDataValidator->assertThatPropertiesAreSet($expected, $instance->getContainer()->getSemanticData());
 }
 public function dataItemDataProvider()
 {
     // Single
     $subject = array(DIWikiPage::newFromTitle(Title::newFromText(__METHOD__)));
     // Multiple
     $subjects = array(DIWikiPage::newFromTitle(Title::newFromText(__METHOD__ . 'm-0')), DIWikiPage::newFromTitle(Title::newFromText(__METHOD__ . 'm-1')), DIWikiPage::newFromTitle(Title::newFromText(__METHOD__ . 'm-2')));
     return array(array($subjects, array(), array('_PVAL', '_LIST'), array('diff' => true, 'job' => true)), array(array(), $subjects, array('_PVAL', '_LIST'), array('diff' => true, 'job' => true)), array($subject, $subjects, array('_PVAL', '_LIST'), array('diff' => true, 'job' => true)), array($subject, array(), array('_PVAL', '_LIST'), array('diff' => true, 'job' => true)), array($subject, array(), array('_PVAL'), array('diff' => true, 'job' => true)), array($subjects, $subjects, array('_PVAL'), array('diff' => false, 'job' => false)), array($subject, $subject, array('_PVAL'), array('diff' => false, 'job' => false)), array($subjects, $subjects, array('_PVAL', '_LIST'), array('diff' => true, 'job' => true)), array($subject, $subject, array('_PVAL', '_LIST'), array('diff' => true, 'job' => true)));
 }
 /**
  * @since  1.0
  *
  * @param DIWikiPage $subject
  */
 public function tryToFindLinksFor(DIWikiPage $subject)
 {
     if (!isset($this->propertySearchPatternByNamespace[$subject->getNamespace()])) {
         return;
     }
     $propertySearchPattern = $this->propertySearchPatternByNamespace[$subject->getNamespace()];
     $requestOptions = new RequestOptions();
     $requestOptions->sort = true;
     // Use 3 as buffer to broaden match possibilities
     $requestOptions->limit = 3;
     $this->doResolveAntecedentHierarchyRecursively($subject, $propertySearchPattern, $requestOptions);
     krsort($this->antecedentHierarchyLinks);
     if (!$this->findClosestDescendant) {
         return;
     }
     $this->doFindClosestDescendantByInverseLink($subject, $propertySearchPattern, $requestOptions);
 }
 public function outputDataProvider()
 {
     $language = Language::factory('en');
     $title = MockTitle::buildMockForMainNamespace(__METHOD__ . 'mock-subject');
     $title->expects($this->atLeastOnce())->method('exists')->will($this->returnValue(true));
     $subject = DIWikiPage::newFromTitle($title);
     $semanticData = $this->getMockBuilder('\\SMW\\SemanticData')->disableOriginalConstructor()->getMock();
     $semanticData->expects($this->atLeastOnce())->method('getSubject')->will($this->returnValue($subject));
     $semanticData->expects($this->atLeastOnce())->method('hasVisibleProperties')->will($this->returnValue(true));
     $semanticData->expects($this->atLeastOnce())->method('getPropertyValues')->will($this->returnValue(array(DIWikiPage::newFromTitle($title))));
     $semanticData->expects($this->atLeastOnce())->method('getProperties')->will($this->returnValue(array(new DIProperty(__METHOD__ . 'property'))));
     #0 Simple factbox build, returning content
     $title = MockTitle::buildMock(__METHOD__ . 'title-with-content');
     $title->expects($this->atLeastOnce())->method('exists')->will($this->returnValue(true));
     $title->expects($this->atLeastOnce())->method('getNamespace')->will($this->returnValue(NS_MAIN));
     $title->expects($this->atLeastOnce())->method('getPageLanguage')->will($this->returnValue($language));
     $title->expects($this->atLeastOnce())->method('getArticleID')->will($this->returnValue(9098));
     $outputPage = $this->getMockBuilder('\\OutputPage')->disableOriginalConstructor()->getMock();
     $outputPage->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue($title));
     $outputPage->expects($this->atLeastOnce())->method('getContext')->will($this->returnValue(new \RequestContext()));
     $provider[] = array(array('smwgNamespacesWithSemanticLinks' => array(NS_MAIN => true), 'outputPage' => $outputPage, 'parserOutput' => $this->makeParserOutput($semanticData)), array('text' => $subject->getDBKey()));
     #1 Disabled namespace, no return value expected
     $title = MockTitle::buildMock(__METHOD__ . 'title-ns-disabled');
     $title->expects($this->atLeastOnce())->method('getNamespace')->will($this->returnValue(NS_MAIN));
     $title->expects($this->atLeastOnce())->method('getPageLanguage')->will($this->returnValue($language));
     $title->expects($this->atLeastOnce())->method('getArticleID')->will($this->returnValue(90000));
     $outputPage = $this->getMockBuilder('\\OutputPage')->disableOriginalConstructor()->getMock();
     $outputPage->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue($title));
     $outputPage->expects($this->atLeastOnce())->method('getContext')->will($this->returnValue(new \RequestContext()));
     $provider[] = array(array('smwgNamespacesWithSemanticLinks' => array(NS_MAIN => false), 'outputPage' => $outputPage, 'parserOutput' => $this->makeParserOutput($semanticData)), array('text' => ''));
     // #2 Specialpage, no return value expected
     $title = MockTitle::buildMock(__METHOD__ . 'mock-specialpage');
     $title->expects($this->atLeastOnce())->method('getPageLanguage')->will($this->returnValue($language));
     $title->expects($this->atLeastOnce())->method('isSpecialPage')->will($this->returnValue(true));
     $outputPage = $this->getMockBuilder('\\OutputPage')->disableOriginalConstructor()->getMock();
     $outputPage->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue($title));
     $outputPage->expects($this->atLeastOnce())->method('getContext')->will($this->returnValue(new \RequestContext()));
     $provider[] = array(array('smwgNamespacesWithSemanticLinks' => array(NS_MAIN => true), 'outputPage' => $outputPage, 'parserOutput' => $this->makeParserOutput($semanticData)), array('text' => ''));
     // #3 Redirect, no return value expected
     $title = MockTitle::buildMock(__METHOD__ . 'mock-redirect');
     $title->expects($this->atLeastOnce())->method('getPageLanguage')->will($this->returnValue($language));
     $title->expects($this->atLeastOnce())->method('isRedirect')->will($this->returnValue(true));
     $outputPage = $this->getMockBuilder('\\OutputPage')->disableOriginalConstructor()->getMock();
     $outputPage->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue($title));
     $outputPage->expects($this->atLeastOnce())->method('getContext')->will($this->returnValue(new \RequestContext()));
     $provider[] = array(array('smwgNamespacesWithSemanticLinks' => array(NS_MAIN => true), 'outputPage' => $outputPage, 'parserOutput' => $this->makeParserOutput($semanticData)), array('text' => ''));
     // #4 Oldid
     $title = MockTitle::buildMockForMainNamespace(__METHOD__ . 'mock-oldid');
     $title->expects($this->atLeastOnce())->method('exists')->will($this->returnValue(true));
     $title->expects($this->atLeastOnce())->method('getPageLanguage')->will($this->returnValue($language));
     $outputPage = $this->getMockBuilder('\\OutputPage')->disableOriginalConstructor()->getMock();
     $outputPage->expects($this->atLeastOnce())->method('getTitle')->will($this->returnValue($title));
     $context = new \RequestContext();
     $context->setRequest(new \FauxRequest(array('oldid' => 9001), true));
     $outputPage->expects($this->atLeastOnce())->method('getContext')->will($this->returnValue($context));
     $provider[] = array(array('smwgNamespacesWithSemanticLinks' => array(NS_MAIN => true), 'outputPage' => $outputPage, 'parserOutput' => $this->makeParserOutput($semanticData)), array('text' => $subject->getDBKey()));
     return $provider;
 }