本文整理匯總了PHP中SMW\DIProperty::setPropertyTypeId方法的典型用法代碼示例。如果您正苦於以下問題:PHP DIProperty::setPropertyTypeId方法的具體用法?PHP DIProperty::setPropertyTypeId怎麽用?PHP DIProperty::setPropertyTypeId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SMW\DIProperty
的用法示例。
在下文中一共展示了DIProperty::setPropertyTypeId方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testAddUserDefinedBlobPropertyAsObjectToSemanticDataForStorage
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());
}
示例2: testUserDefinedPropertyUsedForInvalidValueAssignment
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());
}
示例3: testDescendingOrderedQueryResult
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());
}
示例4: testUserDefinedBlobProperty
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);
}
示例5: testUserDefinedDateProperty
public function testUserDefinedDateProperty()
{
$property = new DIProperty('SomeDateProperty');
$property->setPropertyTypeId('_dat');
$dataValue = $this->dataValueFactory->newDataValueByProperty($property, '1 January 1970');
$semanticData = $this->semanticDataFactory->newEmptySemanticData(__METHOD__);
$semanticData->addDataValue($dataValue);
$this->getStore()->updateData($semanticData);
Exporter::getInstance()->clear();
$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($dataValue, $queryResult);
$this->subjectsToBeCleared[] = $semanticData->getSubject();
}
示例6: testSubpropertyToQueryFromTopHierarchy
public function testSubpropertyToQueryFromTopHierarchy()
{
if (!$this->getStore() instanceof \SMWSQLStore3) {
$this->markTestSkipped("Subproperty/property hierarchies are currently only supported by the SQLStore");
}
$semanticDataOfSpouse = $this->semanticDataFactory->setSubject(new DIWikiPage('Spouse', SMW_NS_PROPERTY, ''))->newEmptySemanticData();
$property = new DIProperty('Wife');
$property->setPropertyTypeId('_wpg');
$this->addPropertyHierarchy($property, 'Spouse');
$dataValue = $this->dataValueFactory->newPropertyObjectValue($property, 'Lien');
$semanticData = $this->semanticDataFactory->newEmptySemanticData(__METHOD__);
$semanticData->addDataValue($dataValue);
$this->getStore()->updateData($semanticDataOfSpouse);
$this->getStore()->updateData($semanticData);
$description = new SomeProperty(new DIProperty('Spouse'), new ThingDescription());
$propertyValue = new PropertyValue('__pro');
$propertyValue->setDataItem($property);
$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($dataValue, $queryResult);
$this->subjectsToBeCleared = array($semanticData->getSubject(), $semanticDataOfSpouse->getSubject(), $property->getDiWikiPage());
}
示例7: descriptionProvider
public function descriptionProvider()
{
$stringBuilder = UtilityFactory::getInstance()->newStringBuilder();
# 0
$conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\FalseCondition';
$description = new SomeProperty(new DIProperty('Foo'), new Disjunction());
$orderByProperty = null;
$sortkeys = array();
$expected = $stringBuilder->addString('<http://www.example.org> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#nothing> .')->addNewLine()->getString();
$provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
# 1
$conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
$description = new SomeProperty(new DIProperty('Foo'), new ThingDescription());
$orderByProperty = null;
$sortkeys = array();
$expected = $stringBuilder->addString('?result property:Foo ?v1 .')->addNewLine()->getString();
$provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
# 2 Inverse
$conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
$description = new SomeProperty(new DIProperty('Foo', true), new ThingDescription());
$orderByProperty = null;
$sortkeys = array();
$expected = $stringBuilder->addString('?v1 property:Foo ?result .')->addNewLine()->getString();
$provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
# 3
$conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
$description = new SomeProperty(new DIProperty('Foo'), new ThingDescription());
$orderByProperty = new DIProperty('Foo');
$sortkeys = array();
$expected = $stringBuilder->addString('?result swivt:wikiPageSortKey ?resultsk .')->addNewLine()->addString('?result property:Foo ?v1 .')->addNewLine()->getString();
$provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
# 4
$conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
$property = new DIProperty('Foo');
$property->setPropertyTypeId('_txt');
$description = new SomeProperty($property, new ValueDescription(new DIBlob('SomePropertyBlobValue')));
$orderByProperty = null;
$sortkeys = array();
$expected = $stringBuilder->addString('?result property:Foo "SomePropertyBlobValue" .')->addNewLine()->getString();
$provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
# 5
$conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
$property = new DIProperty('Foo');
$property->setPropertyTypeId('_txt');
$description = new SomeProperty($property, new ValueDescription(new DIBlob('SomePropertyBlobValue')));
$orderByProperty = $property;
$sortkeys = array();
$expected = $stringBuilder->addString('?result swivt:wikiPageSortKey ?resultsk .')->addNewLine()->addString('?result property:Foo "SomePropertyBlobValue" .')->addNewLine()->getString();
$provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
# 6
$conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
$property = new DIProperty('Foo');
$property->setPropertyTypeId('_wpg');
$propertyValue = new DIWikiPage('SomePropertyPageValue', NS_HELP);
$propertyValueName = \SMWTurtleSerializer::getTurtleNameForExpElement(\SMWExporter::getInstance()->getResourceElementForWikiPage($propertyValue));
$description = new SomeProperty($property, new ValueDescription($propertyValue));
$orderByProperty = $property;
$sortkeys = array();
$expected = $stringBuilder->addString('?result swivt:wikiPageSortKey ?resultsk .')->addNewLine()->addString("?result property:Foo {$propertyValueName} .")->addNewLine()->getString();
$provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
# 7
$conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
$property = new DIProperty('Foo');
$property->setPropertyTypeId('_wpg');
$description = new SomeProperty($property, new ValueDescription(new DIWikiPage('SomePropertyPageValue', NS_HELP), $property, SMW_CMP_LEQ));
$orderByProperty = new DIProperty('SomePropertyPageValue');
$sortkeys = array();
$expected = $stringBuilder->addString('?result swivt:wikiPageSortKey ?resultsk .')->addNewLine()->addString('?result property:Foo ?v1 .')->addNewLine()->addString('FILTER( ?v1sk <= "SomePropertyPageValue" )')->addNewLine()->addString('?v1 swivt:wikiPageSortKey ?v1sk .')->addNewLine()->getString();
$provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
# 8
$conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
$property = new DIProperty('Foo');
$property->setPropertyTypeId('_wpg');
$description = new SomeProperty($property, new ValueDescription(new DIWikiPage('SomePropertyPageValue', NS_HELP), $property, SMW_CMP_LEQ));
$description = new SomeProperty(new DIProperty('Bar'), $description);
$orderByProperty = new DIProperty('Bar');
$sortkeys = array('Foo' => 'ASC');
$expected = $stringBuilder->addString('?result swivt:wikiPageSortKey ?resultsk .')->addNewLine()->addString('?result property:Bar ?v1 .')->addNewLine()->addString('{ ?v1 property:Foo ?v2 .')->addNewLine()->addString('FILTER( ?v2sk <= "SomePropertyPageValue" )')->addNewLine()->addString('?v2 swivt:wikiPageSortKey ?v2sk .')->addNewLine()->addString('}')->addNewLine()->getString();
$provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
# 9 Inverse -> ?v1 property:Foo ?v2 vs. ?v2 property:Foo ?v1
$conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
$property = new DIProperty('Foo', true);
$property->setPropertyTypeId('_wpg');
$description = new SomeProperty($property, new ValueDescription(new DIWikiPage('SomePropertyPageValue', NS_HELP), $property, SMW_CMP_LEQ));
$description = new SomeProperty(new DIProperty('Bar'), $description);
$expected = $stringBuilder->addString('?result swivt:wikiPageSortKey ?resultsk .')->addNewLine()->addString('?result property:Bar ?v1 .')->addNewLine()->addString('{ ?v2 property:Foo ?v1 .')->addNewLine()->addString('FILTER( ?v2sk <= "SomePropertyPageValue" )')->addNewLine()->addString('?v2 swivt:wikiPageSortKey ?v2sk .')->addNewLine()->addString('}')->addNewLine()->getString();
$provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
# 10
$conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
$property = new DIProperty('_MDAT');
$description = new SomeProperty($property, new ThingDescription());
$sortkeys = array('_MDAT' => 'ASC');
$propertyLabel = str_replace(' ', '_', $property->getLabel());
$expected = $stringBuilder->addString('?result swivt:wikiPageSortKey ?resultsk .')->addNewLine()->addString("?result property:{$propertyLabel}-23aux ?v1 .")->addNewLine()->getString();
$provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
# 11, issue 556
$conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
$property = new DIProperty('Foo');
$property->setPropertyTypeId('_txt');
$description = new SomeProperty($property, new Disjunction(array(new ValueDescription(new DIBlob('Bar')), new ValueDescription(new DIBlob('Baz')))));
//.........這裏部分代碼省略.........
示例8: newDataValueForPagePropertyValue
private function newDataValueForPagePropertyValue($property, $value)
{
$property = new DIProperty($property);
$property->setPropertyTypeId('_wpg');
$dataItem = new DIWikiPage($value, NS_MAIN, '');
return $this->dataValueFactory->newDataItemValue($dataItem, $property);
}
示例9: testSetPropertyTypeIdOnPredefinedPropertyThrowsException
public function testSetPropertyTypeIdOnPredefinedPropertyThrowsException()
{
$property = new DIProperty('_MDAT');
$this->setExpectedException('InvalidArgumentException');
$property->setPropertyTypeId('_txt');
}
示例10: dateConjunctionFilterProvider
public function dateConjunctionFilterProvider()
{
$property = new DIProperty('SomeDatePropertyToFilter');
$property->setPropertyTypeId('_dat');
#7 Date, Greater Equal, Less Equal
$provider[] = array(array('197001' => new DITime(1, 1970, 01, 01, 1, 1), '197002' => new DITime(1, 1970, 02, 01, 1, 1), '197003' => new DITime(1, 1970, 03, 01, 1, 1)), array('lower' => new DITime(1, 1970, 01, 01), 'upper' => new DITime(1, 1970, 03, 01), 'lowerComp' => SMW_CMP_GEQ, 'upperComp' => SMW_CMP_LEQ, 'property' => $property), array('count' => 2, 'subjects' => array('197001', '197002')));
#7 Date, Greater Equal, Less Equal
$provider[] = array(array('1970011' => new DITime(1, 1970, 01, 01, 1, 1), '1970012' => new DITime(1, 1970, 01, 02, 1, 1), '1970013' => new DITime(1, 1970, 01, 03, 1, 1)), array('lower' => new DITime(1, 1970, 01, 01, 2), 'upper' => new DITime(1, 1970, 01, 02, 2), 'lowerComp' => SMW_CMP_GRTR, 'upperComp' => SMW_CMP_LESS, 'property' => $property), array('count' => 1, 'subjects' => array('1970012')));
return $provider;
}
示例11: descriptionProvider
public function descriptionProvider()
{
$stringBuilder = UtilityFactory::getInstance()->newStringBuilder();
# 0
$conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\FalseCondition';
$description = new SomeProperty(new DIProperty('Foo'), new Disjunction());
$orderByProperty = null;
$sortkeys = array();
$expected = $stringBuilder->addString('<http://www.example.org> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2002/07/owl#nothing> .')->addNewLine()->getString();
$provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
# 1
$conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
$description = new SomeProperty(new DIProperty('Foo'), new ThingDescription());
$orderByProperty = null;
$sortkeys = array();
$expected = $stringBuilder->addString('?result property:Foo ?v1 .')->addNewLine()->getString();
$provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
# 2 Inverse
$conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
$description = new SomeProperty(new DIProperty('Foo', true), new ThingDescription());
$orderByProperty = null;
$sortkeys = array();
$expected = $stringBuilder->addString('?v1 property:Foo ?result .')->addNewLine()->getString();
$provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
# 3
$conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
$description = new SomeProperty(new DIProperty('Foo'), new ThingDescription());
$orderByProperty = new DIProperty('Foo');
$sortkeys = array();
$expected = $stringBuilder->addString('?result swivt:wikiPageSortKey ?resultsk .')->addNewLine()->addString('?result property:Foo ?v1 .')->addNewLine()->getString();
$provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
# 4
$conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
$property = new DIProperty('Foo');
$property->setPropertyTypeId('_txt');
$description = new SomeProperty($property, new ValueDescription(new DIBlob('SomePropertyBlobValue')));
$orderByProperty = null;
$sortkeys = array();
$expected = $stringBuilder->addString('?result property:Foo "SomePropertyBlobValue" .')->addNewLine()->getString();
$provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
# 5
$conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
$property = new DIProperty('Foo');
$property->setPropertyTypeId('_txt');
$description = new SomeProperty($property, new ValueDescription(new DIBlob('SomePropertyBlobValue')));
$orderByProperty = $property;
$sortkeys = array();
$expected = $stringBuilder->addString('?result swivt:wikiPageSortKey ?resultsk .')->addNewLine()->addString('?result property:Foo "SomePropertyBlobValue" .')->addNewLine()->getString();
$provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
# 6
$conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
$property = new DIProperty('Foo');
$property->setPropertyTypeId('_wpg');
$description = new SomeProperty($property, new ValueDescription(new DIWikiPage('SomePropertyPageValue', NS_HELP)));
$orderByProperty = $property;
$sortkeys = array();
$expected = $stringBuilder->addString('?result swivt:wikiPageSortKey ?resultsk .')->addNewLine()->addString('?result property:Foo wiki:Help-3ASomePropertyPageValue .')->addNewLine()->getString();
$provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
# 7
$conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
$property = new DIProperty('Foo');
$property->setPropertyTypeId('_wpg');
$description = new SomeProperty($property, new ValueDescription(new DIWikiPage('SomePropertyPageValue', NS_HELP), $property, SMW_CMP_LEQ));
$orderByProperty = new DIProperty('SomePropertyPageValue');
$sortkeys = array();
$expected = $stringBuilder->addString('?result swivt:wikiPageSortKey ?resultsk .')->addNewLine()->addString('?result property:Foo ?v1 .')->addNewLine()->addString('FILTER( ?v1sk <= "SomePropertyPageValue" )')->addNewLine()->addString('?v1 swivt:wikiPageSortKey ?v1sk .')->addNewLine()->getString();
$provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
# 8
$conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
$property = new DIProperty('Foo');
$property->setPropertyTypeId('_wpg');
$description = new SomeProperty($property, new ValueDescription(new DIWikiPage('SomePropertyPageValue', NS_HELP), $property, SMW_CMP_LEQ));
$description = new SomeProperty(new DIProperty('Bar'), $description);
$orderByProperty = new DIProperty('Bar');
$sortkeys = array('Foo' => 'ASC');
$expected = $stringBuilder->addString('?result swivt:wikiPageSortKey ?resultsk .')->addNewLine()->addString('?result property:Bar ?v1 .')->addNewLine()->addString('{ ?v1 property:Foo ?v2 .')->addNewLine()->addString('FILTER( ?v2sk <= "SomePropertyPageValue" )')->addNewLine()->addString('?v2 swivt:wikiPageSortKey ?v2sk .')->addNewLine()->addString('}')->addNewLine()->getString();
$provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
# 9 Inverse -> ?v1 property:Foo ?v2 vs. ?v2 property:Foo ?v1
$conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
$property = new DIProperty('Foo', true);
$property->setPropertyTypeId('_wpg');
$description = new SomeProperty($property, new ValueDescription(new DIWikiPage('SomePropertyPageValue', NS_HELP), $property, SMW_CMP_LEQ));
$description = new SomeProperty(new DIProperty('Bar'), $description);
$expected = $stringBuilder->addString('?result swivt:wikiPageSortKey ?resultsk .')->addNewLine()->addString('?result property:Bar ?v1 .')->addNewLine()->addString('{ ?v2 property:Foo ?v1 .')->addNewLine()->addString('FILTER( ?v2sk <= "SomePropertyPageValue" )')->addNewLine()->addString('?v2 swivt:wikiPageSortKey ?v2sk .')->addNewLine()->addString('}')->addNewLine()->getString();
$provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
# 10
$conditionType = '\\SMW\\SPARQLStore\\QueryEngine\\Condition\\WhereCondition';
$property = new DIProperty('_MDAT');
$description = new SomeProperty($property, new ThingDescription());
$sortkeys = array('_MDAT' => 'ASC');
$propertyLabel = str_replace(' ', '_', $property->getLabel());
$expected = $stringBuilder->addString('?result swivt:wikiPageSortKey ?resultsk .')->addNewLine()->addString("?result property:{$propertyLabel}-23aux ?v1 .")->addNewLine()->getString();
$provider[] = array($description, $orderByProperty, $sortkeys, $conditionType, $expected);
return $provider;
}
示例12: testQuerySubobjects_afterUpdatingWithEmptyContainerAllAssociatedEntitiesGetRemovedFromGraph
public function testQuerySubobjects_afterUpdatingWithEmptyContainerAllAssociatedEntitiesGetRemovedFromGraph()
{
$semanticData = $this->semanticDataFactory->newEmptySemanticData(__METHOD__);
$subobject = new Subobject($semanticData->getSubject()->getTitle());
$subobject->setEmptyContainerForId('SubobjectToTestReferenceAfterUpdate');
$property = new DIProperty('SomeNumericPropertyToCompareReference');
$property->setPropertyTypeId('_num');
$dataItem = new DINumber(99999);
$subobject->addDataValue($this->dataValueFactory->newDataItemValue($dataItem, $property));
$semanticData->addPropertyObjectValue($subobject->getProperty(), $subobject->getContainer());
$this->store->doSparqlDataUpdate($semanticData);
$description = new SomeProperty($property, new ValueDescription($dataItem, null, SMW_CMP_EQ));
$query = new Query($description, false, false);
$query->querymode = Query::MODE_INSTANCES;
$this->assertSame(1, $this->store->getQueryResult($query)->getCount());
$this->queryResultValidator->assertThatQueryResultHasSubjects($subobject->getSemanticData()->getSubject(), $this->store->getQueryResult($query));
$this->store->doSparqlDataUpdate($this->semanticDataFactory->newEmptySemanticData(__METHOD__));
$this->assertSame(0, $this->store->getQueryResult($query)->getCount());
}
示例13: testSubqueryDisjunction
public function testSubqueryDisjunction()
{
$property = new DIProperty('HasSomeProperty');
$property->setPropertyTypeId('_wpg');
/**
* Page annotated with [[HasSomeProperty:Foo]]
*/
$semanticData = $this->semanticDataFactory->newEmptySemanticData(__METHOD__ . '1');
$semanticData->addPropertyObjectValue($property, new DIWikiPage('Foo', NS_MAIN));
$expectedSubjects[] = $semanticData->getSubject();
$this->subjectsToBeCleared[] = $semanticData->getSubject();
$this->getStore()->updateData($semanticData);
/**
* Page annotated with [[HasSomeProperty:Bar]]
*/
$semanticData = $this->semanticDataFactory->newEmptySemanticData(__METHOD__ . '2');
$semanticData->addPropertyObjectValue($property, new DIWikiPage('Bar', NS_MAIN));
$expectedSubjects[] = $semanticData->getSubject();
$this->subjectsToBeCleared[] = $semanticData->getSubject();
$this->getStore()->updateData($semanticData);
/**
* Query with [[HasSomeProperty::Foo||Bar]]
*/
$disjunction = new Disjunction(array(new ValueDescription(new DIWikiPage('Foo', NS_MAIN), $property), new ValueDescription(new DIWikiPage('Bar', NS_MAIN), $property)));
$description = new SomeProperty($property, $disjunction);
$query = new Query($description, false, false);
$this->assertEquals($description, $this->queryParser->getQueryDescription('[[HasSomeProperty::Foo||Bar]]'));
$query->querymode = Query::MODE_INSTANCES;
$queryResult = $this->getStore()->getQueryResult($query);
$this->assertEquals(2, $queryResult->getCount());
$this->queryResultValidator->assertThatQueryResultHasSubjects($expectedSubjects, $queryResult);
}
示例14: newDataValueForNumericPropertyValue
private function newDataValueForNumericPropertyValue($property, $value)
{
$property = new DIProperty($property);
$property->setPropertyTypeId('_num');
$dataItem = new DINumber($value);
return $this->dataValueFactory->newDataItemValue($dataItem, $property);
}
示例15: testSubqueryDisjunction
public function testSubqueryDisjunction()
{
$property = new DIProperty('HasSomeProperty');
$property->setPropertyTypeId('_wpg');
$disjunction = new Disjunction(array(new ValueDescription(new DIWikiPage('Foo', NS_MAIN), $property), new ValueDescription(new DIWikiPage('Bar', NS_MAIN), $property)));
$description = new SomeProperty($property, $disjunction);
$this->assertEquals($description, $this->queryParser->getQueryDescription('[[HasSomeProperty::Foo||Bar]]'));
}