示例#1
0
 public function testCorrectInversePrefixForPredefinedProperty()
 {
     $property = new DIProperty('_SOBJ', true);
     $this->assertTrue($property->isInverse());
     $label = $property->getLabel();
     $this->assertEquals('-', $label[0]);
 }
示例#2
0
 public function testPredefinedProperty()
 {
     $instance = new HashBuilder();
     $property = new DIProperty('_MDAT');
     $dataItem = $property->getDiWikiPage();
     $this->assertEquals($dataItem, $instance->newDiWikiPageFromHash($instance->getHashIdForDiWikiPage($dataItem)));
     $this->assertEquals($dataItem, $instance->newDiWikiPageFromHash($instance->createHashIdFromSegments($property->getKey(), SMW_NS_PROPERTY)));
 }
 private function findBasePropertyToRedirectFor($label)
 {
     $property = new DIProperty(PropertyRegistry::getInstance()->findPropertyIdByLabel($label));
     if ($property->getLabel() !== '' && $label !== $property->getLabel()) {
         $outputPage = $this->getContext()->getOutput();
         $outputPage->redirect($property->getDiWikiPage()->getTitle()->getFullURL());
     }
 }
 public function testAddUserDefinedBlobPropertyAsObjectToSemanticDataForStorage()
 {
     $property = new DIProperty('SomeBlobProperty');
     $property->setPropertyTypeId('_txt');
     $this->subjects[] = $subject = DIWikiPage::newFromTitle(Title::newFromText(__METHOD__));
     $semanticData = new SemanticData($subject);
     $semanticData->addPropertyObjectValue($property, new DIBlob('SomePropertyBlobValue'));
     $this->getStore()->updateData($semanticData);
     $this->assertArrayHasKey($property->getKey(), $this->getStore()->getSemanticData($subject)->getProperties());
 }
示例#5
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));
 }
 public function testDescendingOrderedQueryResult()
 {
     $expectedSubjects = array(new DIWikiPage('AA', NS_MAIN), new DIWikiPage('AB', NS_MAIN), new DIWikiPage('AC', NS_MAIN));
     $property = new DIProperty('SomeDescendingPageProperty');
     $property->setPropertyTypeId('_wpg');
     $query = $this->createQueryForSamplePagesThatContain($property, $expectedSubjects);
     $query->sort = true;
     $query->sortkeys = array($property->getKey() => 'DESC');
     $query->setUnboundLimit(50);
     $this->assertResultOrder(array_reverse($expectedSubjects), $this->getStore()->getQueryResult($query)->getResults());
 }
 public function testUserDefinedPropertyUsedForInvalidValueAssignment()
 {
     $property = new DIProperty('SomePropertyWithInvalidValueAssignment');
     $property->setPropertyTypeId('_tem');
     $dataValue = $this->dataValueFactory->newDataValueByProperty($property, '1 Jan 1970');
     $semanticData = $this->semanticDataFactory->newEmptySemanticData(__METHOD__);
     $semanticData->addDataValue($dataValue);
     $this->getStore()->updateData($semanticData);
     $this->assertEquals(0, $this->searchForResultsThatCompareEqualToOnlySingularPropertyOf($property)->getCount());
     $this->subjectsToBeCleared = array($semanticData->getSubject());
 }
 /**
  * @since 2.4
  *
  * @param DIProperty $property
  *
  * @return DataItem|false
  */
 public function tryToFindAtLeastOneReferenceForProperty(DIProperty $property)
 {
     $dataItem = $property->getDiWikiPage();
     $sid = $this->store->getObjectIds()->getSMWPageID($dataItem->getDBkey(), $dataItem->getNamespace(), $dataItem->getInterwiki(), '');
     // Lets see if we have some lower/upper case matching for
     // when wgCapitalLinks setting was involved
     if (!$this->usesCapitalLinks && $sid == 0) {
         $sid = $this->store->getObjectIds()->getSMWPageID(lcfirst($dataItem->getDBkey()), $dataItem->getNamespace(), $dataItem->getInterwiki(), '');
     }
     return $this->tryToFindAtLeastOneReferenceForId($sid);
 }
 /**
  * @since 2.4
  *
  * @param DIWikiPage $subject
  * @param DIProperty $property
  * @param RequestOptions|null $requestOptions
  *
  * @return array
  */
 public function getPropertyValues(DIWikiPage $subject, DIProperty $property, RequestOptions $requestOptions = null)
 {
     $key = $property->getKey() . ':' . $subject->getSubobjectName() . ':' . ($requestOptions !== null ? $requestOptions->getHash() : null);
     $container = $this->blobStore->read($this->getRootHashFrom($subject));
     if ($container->has($key)) {
         return $container->get($key);
     }
     $dataItems = $this->store->getPropertyValues($subject, $property, $requestOptions);
     $container->set($key, $dataItems);
     $this->blobStore->save($container);
     return $dataItems;
 }
 /**
  * Create some initial DB entries for important built-in properties. Having the DB contents predefined
  * allows us to safe DB calls when certain data is needed. At the same time, the entries in the DB
  * make sure that DB-based functions work as with all other properties.
  */
 private function doCheckInternalPropertyIndices($connection)
 {
     $this->messageReporter->reportMessage("\nSetting up internal property indices ...\n");
     $this->doCheckPredefinedPropertyBorder($connection);
     // now write actual properties; do that each time, it is cheap enough and we can update sortkeys by current language
     $this->messageReporter->reportMessage("   ... writing entries for internal properties ...\n");
     foreach (SMWSql3SmwIds::$special_ids as $prop => $id) {
         $property = new DIProperty($prop);
         $connection->replace(SQLStore::ID_TABLE, array('smw_id'), array('smw_id' => $id, 'smw_title' => $property->getKey(), 'smw_namespace' => SMW_NS_PROPERTY, 'smw_iw' => $this->store->getObjectIds()->getPropertyInterwiki($property), 'smw_subobject' => '', 'smw_sortkey' => $property->getCanonicalLabel()), __METHOD__);
     }
     $this->messageReporter->reportMessage("   ... done.\n");
 }
 public function testFindSubpropertyList()
 {
     $property = new DIProperty('Foo');
     $store = $this->getMockBuilder('\\SMW\\Store')->disableOriginalConstructor()->getMockForAbstractClass();
     $store->expects($this->once())->method('getPropertySubjects')->with($this->equalTo(new DIProperty('_SUBP')), $this->equalTo($property->getDiWikiPage()), $this->anything())->will($this->returnValue(array(DIWikiPage::newFromText('Bar', SMW_NS_PROPERTY))));
     $cache = $this->getMockBuilder('\\Onoi\\Cache\\Cache')->disableOriginalConstructor()->getMock();
     $cache->expects($this->once())->method('contains')->will($this->returnValue(false));
     $cache->expects($this->once())->method('save')->with($this->equalTo('_SUBP#Foo#-1#0##1##1#'), $this->anything());
     $instance = new PropertyHierarchyLookup($store, $cache);
     $expected = array(DIWikiPage::newFromText('Bar', SMW_NS_PROPERTY));
     $this->assertEquals($expected, $instance->findSubpropertListFor($property));
 }
 /**
  * @since 2.5
  *
  * {@inheritDoc}
  */
 public function addResourceValue(ExpData $expData, DIProperty $property, DataItem $dataItem)
 {
     $diSubject = $expData->getSubject()->getDataItem();
     if ($diSubject === null) {
         return;
     }
     $expNsResource = $this->exporter->getSpecialPropertyResource($property->getKey(), $diSubject->getNamespace());
     $expElement = $this->exporter->getDataItemExpElement($dataItem);
     if ($expElement === null || $expNsResource === null) {
         return;
     }
     $expData->addPropertyObjectValue($expNsResource, $expElement);
     $this->addResourceHelperValue($expData, $property, $dataItem);
 }
 private function newDataValueForPagePropertyValue($property, $value)
 {
     $property = DIProperty::newFromUserLabel($property);
     $property->setPropertyTypeId('_wpg');
     $dataItem = new DIWikiPage($value, NS_MAIN, '');
     return $this->dataValueFactory->newDataItemValue($dataItem, $property);
 }
 public function testCreatePropertyFromLabelThatContainsInverseMarker()
 {
     $property = DIProperty::newFromUserLabel('-Foo');
     $property->setInterwiki('bar');
     $this->assertTrue($property->isInverse());
     $this->assertEquals(new DiWikiPage('Foo', SMW_NS_PROPERTY, 'bar'), $property->getDiWikiPage());
 }
 public function testRegister()
 {
     $instance = new PropertyRegistry();
     $instance->register();
     $this->assertNotEmpty(DIProperty::findPropertyLabel(PropertyRegistry::SBL_PARENTPAGE));
     $this->assertSame(SBL_PROP_PARENTPAGE, DIProperty::findPropertyLabel(PropertyRegistry::SBL_PARENTPAGE));
 }
 /**
  * @dataProvider propertyProvider
  */
 public function testFindTableIdForProperty($property, $expected)
 {
     $property = DIProperty::newFromUserLabel($property);
     $instance = new PropertyTableInfoFetcher();
     $instance->setCustomSpecialPropertyList(array('_MDAT', '_MEDIA', '_MIME'));
     $this->assertEquals($expected, $instance->findTableIdForProperty($property));
 }
 public function testPageMoveWithRemovalOfOldPage()
 {
     // PHPUnit query issue
     $this->skipTestForDatabase(array('postgres'));
     // Revison showed an issue on 1.19 not being null after the move
     $this->skipTestForMediaWikiVersionLowerThan('1.21');
     // Further hooks required to ensure in-text annotations can be used for queries
     $this->mwHooksHandler->register('InternalParseBeforeLinks', $this->mwHooksHandler->getHookRegistry()->getDefinition('InternalParseBeforeLinks'));
     $this->mwHooksHandler->register('LinksUpdateConstructed', $this->mwHooksHandler->getHookRegistry()->getDefinition('LinksUpdateConstructed'));
     $title = Title::newFromText(__METHOD__ . '-old');
     $expectedNewTitle = Title::newFromText(__METHOD__ . '-new');
     $this->assertNull(WikiPage::factory($expectedNewTitle)->getRevision());
     $this->pageCreator->createPage($title)->doEdit('[[Has function hook test::PageCompleteMove]]');
     $this->pageCreator->getPage()->getTitle()->moveTo($expectedNewTitle, false, 'test', false);
     $this->assertNull(WikiPage::factory($title)->getRevision());
     $this->assertNotNull(WikiPage::factory($expectedNewTitle)->getRevision());
     /**
      * @query {{#ask: [[Has function hook test::PageCompleteMove]] }}
      */
     $description = new SomeProperty(DIProperty::newFromUserLabel('Has function hook test'), new ValueDescription(new DIWikiPage('PageCompleteMove', 0), null, SMW_CMP_EQ));
     $query = new Query($description, false, true);
     $query->querymode = Query::MODE_INSTANCES;
     $queryResult = $this->getStore()->getQueryResult($query);
     // #566
     $this->assertCount(1, $queryResult->getResults());
     $this->queryResultValidator->assertThatQueryResultHasSubjects(DIWikiPage::newFromTitle($expectedNewTitle), $queryResult);
     $this->toBeDeleted = array($title, $expectedNewTitle);
 }
 public function testImportOfDifferentDateWithAssortmentOfOutputConversion()
 {
     $this->importedTitles = array('TimeDataTypeRegressionTest', 'Property:Has query date', 'Property:Has calendar date', 'Property:Has date');
     $this->titleValidator->assertThatTitleIsKnown($this->importedTitles);
     $title = Title::newFromText('TimeDataTypeRegressionTest');
     $expectedCategoryAsWikiValue = array('property' => new DIProperty('_INST'), 'propertyValues' => array('Regression test'));
     $expectedPropertiesFromImport = array('properties' => array(DIProperty::newFromUserLabel('Has date'), DIProperty::newFromUserLabel('Has calendar date'), DIProperty::newFromUserLabel('Has query date'), new DIProperty('_ASK'), new DIProperty('_MDAT'), new DIProperty('_SKEY'), new DIProperty('_SOBJ'), new DIProperty('_INST')));
     $expectedDateValuesAsISO = array('valueFormatter' => $this->setISO8601DateValueFormatter(), 'property' => DIProperty::newFromUserLabel('Has query date'), 'propertyValues' => array('2010-01-04T19:00:00', '2011-06-08', '1980-01-01', '2000-02-11T10:00:00', '2000-02-03'));
     $expectedDateValuesAsMediaWiki = array('valueFormatter' => $this->setMediaWikiDateValueFormatter(), 'property' => DIProperty::newFromUserLabel('Has query date'), 'propertyValues' => array('19:00, 4 January 2010', '8 June 2011', '1 January 1980', '10:00, 11 February 2000', '3 February 2000'));
     $expectedDateValuesAsWikiValue = array('valueFormatter' => $this->setWikiValueDateValueFormatter(), 'property' => DIProperty::newFromUserLabel('Has query date'), 'propertyValues' => array('4 January 2010 19:00:00', '8 June 2011', '1 January 1980', '11 February 2000 10:00:00', '3 February 2000'));
     // Note Windows vs Linux date conversion on PHP
     // where 14000000000 BC is 2147483647 BC on Windows
     $expectedCalendarSpecificDateValuesAsISO = array('valueFormatter' => $this->setISO8601DateValueFormatter(), 'property' => DIProperty::newFromUserLabel('Has calendar date'), 'propertyValues' => array('--301-12-28', '--2147483647-01-01', '--14000000000-01-01', '2000-02-24', '1492-02-11'));
     $expectedCalendarSpecificDateValuesAsWikiValue = array('valueFormatter' => $this->setWikiValueDateValueFormatter(), 'property' => DIProperty::newFromUserLabel('Has calendar date'), 'propertyValues' => array('1 January 300 BC', '2147483647 BC', '14000000000 BC', '24 February 2000', '2 February 1492'));
     $expectedCalendarSpecificDateValuesAsWikiValueWithGRCalendarModel = array('valueFormatter' => $this->setWikiValueDateWithGRCalendarModelValueFormatter(), 'property' => DIProperty::newFromUserLabel('Has calendar date'), 'propertyValues' => array('28 December 301 BC', '2147483647 BC', '14000000000 BC', '24 February 2000', '11 February 1492'));
     $expectedCalendarSpecificDateValuesAsWikiValueWithJLCalendarModel = array('valueFormatter' => $this->setWikiValueDateWithJLCalendarModelValueFormatter(), 'property' => DIProperty::newFromUserLabel('Has calendar date'), 'propertyValues' => array('1 January 300 BC', '2147483647 BC', '14000000000 BC', '11 February 2000', '2 February 1492'));
     $this->semanticDataFinder = new ByPageSemanticDataFinder();
     $this->semanticDataFinder->setTitle($title)->setStore($this->getStore());
     $semanticDataBatches = array($this->semanticDataFinder->fetchFromOutput(), $this->semanticDataFinder->fetchFromStore());
     $expectedDateValuesBatches = array($expectedDateValuesAsISO, $expectedDateValuesAsMediaWiki, $expectedDateValuesAsWikiValue, $expectedCalendarSpecificDateValuesAsISO, $expectedCalendarSpecificDateValuesAsWikiValue, $expectedCalendarSpecificDateValuesAsWikiValueWithGRCalendarModel, $expectedCalendarSpecificDateValuesAsWikiValueWithJLCalendarModel);
     foreach ($semanticDataBatches as $semanticData) {
         $this->semanticDataValidator->assertThatCategoriesAreSet($expectedCategoryAsWikiValue, $semanticData);
         $this->semanticDataValidator->assertThatPropertiesAreSet($expectedPropertiesFromImport, $semanticData);
         $this->assertBatchesOfDateValues($expectedDateValuesBatches, $semanticData);
     }
 }
 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);
 }
 /**
  * @since 2.5
  *
  * {@inheritDoc}
  */
 public function addResourceValue(ExpData $expData, DIProperty $property, DataItem $dataItem)
 {
     $diSubject = $expData->getSubject()->getDataItem();
     if ($diSubject === null) {
         return;
     }
     $expNsResource = $this->exporter->getSpecialPropertyResource($property->getKey(), $diSubject->getNamespace());
     if ($expNsResource === null) {
         return;
     }
     $dataValue = DataValueFactory::getInstance()->newDataValueByItem($dataItem, $property);
     if (!$dataValue instanceof ImportValue) {
         return;
     }
     $expData->addPropertyObjectValue($expNsResource, $this->exporter->getDataItemExpElement(new DIBlob($dataValue->getImportReference())));
     $this->addResourceHelperValue($expData, $property, $dataItem);
 }
 /**
  * @since 2.5
  *
  * {@inheritDoc}
  */
 public function addResourceValue(ExpData $expData, DIProperty $property, DataItem $dataItem)
 {
     $expElement = $this->exporter->getDataItemExpElement($dataItem);
     if ($expElement === null) {
         return;
     }
     if ($property->getKey() === $property->findPropertyTypeID()) {
         // Ensures that Boolean remains Boolean and not localized canonical
         // representation such as "Booléen" when the content languageis not
         // English
         $expNsResource = $this->getResourceElementForProperty(new DIProperty($property->getCanonicalDiWikiPage()->getDBKey()));
     } else {
         $expNsResource = $this->getResourceElementHelperForProperty($property);
     }
     $expData->addPropertyObjectValue($expNsResource, $expElement);
     $this->addResourceHelperValue($expData, $property, $dataItem);
 }
 /**
  * @see SMWOrderedListPage::initParameters()
  * @note We use a smaller limit here; property pages might become large.
  */
 protected function initParameters()
 {
     global $smwgPropertyPagingLimit;
     $this->limit = $smwgPropertyPagingLimit;
     $this->mProperty = DIProperty::newFromUserLabel($this->mTitle->getText());
     $this->store = ApplicationFactory::getInstance()->getStore();
     $this->propertyValue = DataValueFactory::getInstance()->newDataItemValue($this->mProperty);
     return true;
 }
 /**
  * @since 1.0
  *
  * @return boolean
  */
 public function register()
 {
     $propertyDefinitions = array(self::SBL_PARENTPAGE => array('label' => SBL_PROP_PARENTPAGE, 'type' => '_wpg', 'alias' => wfMessage('sbl-property-alias-parentpage')->text(), 'visbility' => true));
     foreach ($propertyDefinitions as $propertyId => $definition) {
         DIProperty::registerProperty($propertyId, $definition['type'], $definition['label'], $definition['visbility']);
         DIProperty::registerPropertyAlias($propertyId, $definition['alias']);
     }
     return true;
 }
 public function getQueryString($asValue = false)
 {
     $subDescription = $this->description;
     $propertyChainString = $this->property->getLabel();
     $propertyname = $propertyChainString;
     while ($propertyname !== '' && $subDescription instanceof SomeProperty) {
         // try to use property chain syntax
         $propertyname = $subDescription->getProperty()->getLabel();
         if ($propertyname !== '') {
             $propertyChainString .= '.' . $propertyname;
             $subDescription = $subDescription->getDescription();
         }
     }
     if ($asValue) {
         return '<q>[[' . $propertyChainString . '::' . $subDescription->getQueryString(true) . ']]</q>';
     }
     return '[[' . $propertyChainString . '::' . $subDescription->getQueryString(true) . ']]';
 }
 public function specialCharactersNameProvider()
 {
     $provider[] = array('特殊文字', 'Nuñez', DIProperty::newFromUserLabel('特殊文字')->setPropertyTypeId('_txt'), new DIBlob('Nuñez'));
     $provider[] = array('特殊字符', '^[0-9]*$', DIProperty::newFromUserLabel('特殊字符')->setPropertyTypeId('_txt'), new DIBlob('^[0-9]*$'));
     $provider[] = array('Caractères spéciaux', 'Caractères spéciaux', DIProperty::newFromUserLabel('Caractères spéciaux')->setPropertyTypeId('_wpg'), new DIWikiPage('âêîôûëïçé', NS_MAIN));
     $provider[] = array('áéíóúñÑü¡¿', 'áéíóúñÑü¡¿', DIProperty::newFromUserLabel('áéíóúñÑü¡¿')->setPropertyTypeId('_num'), new DINumber(8888));
     $provider[] = array('Foo', '{({[[&,,;-]]})}', DIProperty::newFromUserLabel('{({[[&,,;-]]})}')->setPropertyTypeId('_wpg'), new DIWikiPage('{({[[&,,;-]]})}', NS_MAIN));
     return $provider;
 }
 public function testUserDefinedBlobProperty()
 {
     $property = new DIProperty('SomeBlobProperty');
     $property->setPropertyTypeId('_txt');
     $dataItem = new DIBlob('SomePropertyBlobValue');
     $semanticData = $this->semanticDataFactory->newEmptySemanticData(__METHOD__);
     $semanticData->addDataValue($this->dataValueFactory->newDataItemValue($dataItem, $property));
     $this->getStore()->updateData($semanticData);
     $this->assertArrayHasKey($property->getKey(), $this->getStore()->getSemanticData($semanticData->getSubject())->getProperties());
     $propertyValue = new PropertyValue('__pro');
     $propertyValue->setDataItem($property);
     $description = new SomeProperty($property, new ThingDescription());
     $description->addPrintRequest(new PrintRequest(PrintRequest::PRINT_PROP, null, $propertyValue));
     $query = new Query($description, false, false);
     $query->querymode = Query::MODE_INSTANCES;
     $queryResult = $this->getStore()->getQueryResult($query);
     $this->queryResultValidator->assertThatQueryResultContains($dataItem, $queryResult);
 }
 public function testSerializeFormatForTimeValue()
 {
     $property = \SMW\DIProperty::newFromUserLabel('Foo');
     $property->setPropertyTypeId('_dat');
     $printRequestFactory = new \SMW\Query\PrintRequestFactory();
     $serialization = QueryResultSerializer::getSerialization(\SMWDITime::doUnserialize('2/1393/1/1'), $printRequestFactory->newPropertyPrintRequest($property));
     $expected = array('timestamp' => '-18208281600', 'raw' => '2/1393/1/1');
     $this->assertEquals($expected, $serialization);
 }
 /**
  * @since 2.0
  *
  * @return boolean
  */
 public function process()
 {
     // Avoid having "noarticletext" info being generated for predefined
     // properties as we are going to display an introductory text
     if ($this->article->getTitle()->getNamespace() === SMW_NS_PROPERTY) {
         return DIProperty::newFromUserLabel($this->article->getTitle()->getText())->isUserDefined();
     }
     return true;
 }
示例#29
0
 public function valueDescriptionProvider()
 {
     $dataItem = new DIWikiPage('Foo', NS_MAIN);
     $provider[] = array($dataItem, null, SMW_CMP_EQ, array('comparator' => SMW_CMP_EQ, 'dataItem' => $dataItem, 'property' => null, 'queryString' => '[[:Foo]]', 'queryStringAsValue' => 'Foo', 'isSingleton' => true));
     $provider[] = array($dataItem, null, SMW_CMP_LEQ, array('comparator' => SMW_CMP_LEQ, 'dataItem' => $dataItem, 'property' => null, 'queryString' => '[[≤Foo]]', 'queryStringAsValue' => '≤Foo', 'isSingleton' => false));
     $property = DIProperty::newFromUserLabel('Foo')->setPropertyTypeId('_num');
     $dataItem = new DINumber(9001);
     $provider[] = array($dataItem, $property, SMW_CMP_LEQ, array('comparator' => SMW_CMP_LEQ, 'dataItem' => $dataItem, 'property' => $property, 'queryString' => '[[≤9,001]]', 'queryStringAsValue' => '≤9,001', 'isSingleton' => false));
     return $provider;
 }
 public function testImportToVerifyAnnotationByTemplateInclusion()
 {
     $this->importedTitles = array('Foo-1-19-7', 'Template:FooAsk', 'Template:FooShow', 'Template:FooSubobject', 'Template:FooTemplate');
     $this->titleValidator->assertThatTitleIsKnown($this->importedTitles);
     $expectedProperties = array('properties' => array(DIProperty::newFromUserLabel('Foo'), DIProperty::newFromUserLabel('Quux'), new DIProperty('_ASK'), new DIProperty('_MDAT'), new DIProperty('_SKEY'), new DIProperty('_SOBJ'), new DIProperty('_INST')));
     $title = Title::newFromText('Foo-1-19-7');
     $semanticDataFinder = new ByPageSemanticDataFinder();
     $semanticDataFinder->setTitle($title)->setStore($this->getStore());
     $this->semanticDataValidator->assertThatPropertiesAreSet($expectedProperties, $semanticDataFinder->fetchFromOutput());
 }