dataValueFactory = DataValueFactory::getInstance(); $this->queryResultValidator = new QueryResultValidator(); $this->semanticDataFactory = new SemanticDataFactory(); } protected function tearDown() { foreach ( $this->subjectsToBeCleared as $subject ) { $this->getStore()->deleteSubject( $subject->getTitle() ); } parent::tearDown(); } public function testPropertyBeforeAfterDataRemoval() { $property = new DIProperty( 'SomePagePropertyBeforeAfter' ); $property->setPropertyTypeId( '_wpg' ); $this->assertEmpty( $this->searchForResultsThatCompareEqualToOnlySingularPropertyOf( $property )->getResults() ); $semanticData = $this->semanticDataFactory->newEmptySemanticData( __METHOD__ ); $semanticData->addDataValue( $this->dataValueFactory->newDataItemValue( $semanticData->getSubject(), $property ) ); $this->getStore()->updateData( $semanticData ); $this->queryResultValidator->assertThatQueryResultContains( $semanticData->getSubject(), $this->searchForResultsThatCompareEqualToOnlySingularPropertyOf( $property ) ); $this->assertNotEmpty( $this->searchForResultsThatCompareEqualToOnlySingularPropertyOf( $property )->getResults() ); $this->getStore()->clearData( $semanticData->getSubject() ); $this->assertEmpty( $this->searchForResultsThatCompareEqualToOnlySingularPropertyOf( $property )->getResults() ); $this->subjectsToBeCleared = array( $semanticData->getSubject() ); } public function testUserDefinedPropertyUsedForInvalidValueAssignment() { $property = new DIProperty( 'SomePropertyWithInvalidValueAssignment' ); $property->setPropertyTypeId( '_tem' ); $dataValue = $this->dataValueFactory->newPropertyObjectValue( $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() ); } private function searchForResultsThatCompareEqualToOnlySingularPropertyOf( DIProperty $property ) { $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; return $this->getStore()->getQueryResult( $query ); } }