/** * @dataProvider preferredLabelValueProvider */ public function testFormatWithPreferredLabel($property, $preferredLabel, $type, $linker, $expected) { // Ensures the mocked instance is injected and registered with the // PropertyRegistry instance \SMW\PropertyRegistry::clear(); $this->propertyLabelFinder = $this->getMockBuilder('\\SMW\\PropertyLabelFinder')->disableOriginalConstructor()->getMock(); $this->propertyLabelFinder->expects($this->any())->method('findPropertyListByLabelAndLanguageCode')->will($this->returnValue(array())); $this->propertyLabelFinder->expects($this->any())->method('findPreferredPropertyLabelByLanguageCode')->will($this->returnValue($preferredLabel)); $this->propertyLabelFinder->expects($this->any())->method('searchPropertyIdByLabel')->will($this->returnValue(false)); $this->testEnvironment->registerObject('PropertyLabelFinder', $this->propertyLabelFinder); $propertyValue = new PropertyValue(); $propertyValue->setOption('smwgDVFeatures', SMW_DV_PROV_LHNT); $propertyValue->setOption(PropertyValue::OPT_CONTENT_LANGUAGE, 'en'); $propertyValue->setOption(PropertyValue::OPT_USER_LANGUAGE, 'en'); $propertyValue->setUserValue($property); $instance = new PropertyValueFormatter($propertyValue); $expected = $this->testEnvironment->getLocalizedTextByNamespace(SMW_NS_PROPERTY, $expected); $this->assertEquals($expected, $instance->format($type, $linker)); \SMW\PropertyRegistry::clear(); }
/** * Static function for creating a new property object from a * propertyname (string) as a user might enter it. * @note The resulting property object might be invalid if * the provided name is not allowed. An object is returned * in any case. * * @param string $propertyName * * @return SMWPropertyValue */ public static function makeUserProperty($propertyName) { $property = new SMWPropertyValue('__pro'); $property->setUserValue($propertyName); return $property; }