本文整理汇总了PHP中SMWPropertyValue::setUserValue方法的典型用法代码示例。如果您正苦于以下问题:PHP SMWPropertyValue::setUserValue方法的具体用法?PHP SMWPropertyValue::setUserValue怎么用?PHP SMWPropertyValue::setUserValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMWPropertyValue
的用法示例。
在下文中一共展示了SMWPropertyValue::setUserValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testFormatWithPreferredLabel
/**
* @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();
}
示例2: makeUserProperty
/**
* 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;
}