public function testRegisterAdditionalDataValueFormatter()
 {
     $dataValueFormatter = $this->getMockBuilder('\\SMW\\DataValues\\ValueFormatters\\DataValueFormatter')->disableOriginalConstructor()->setMethods(array('isFormatterFor'))->getMockForAbstractClass();
     $dataValueFormatter->expects($this->once())->method('isFormatterFor')->will($this->returnValue(true));
     $dataValue = $this->getMockBuilder('\\SMWDataValue')->disableOriginalConstructor()->getMockForAbstractClass();
     $instance = new ValueFormatterRegistry();
     $instance->registerDataValueFormatter($dataValueFormatter);
     $this->assertInstanceOf('\\SMW\\DataValues\\ValueFormatters\\DataValueFormatter', $instance->getDataValueFormatterFor($dataValue));
 }
Пример #2
0
 /**
  * Returns a DataValueFormatter that was matched and dispatched for the current
  * DV instance.
  *
  * @since 2.4
  *
  * @return DataValueFormatter
  */
 public function getDataValueFormatter()
 {
     return ValueFormatterRegistry::getInstance()->getDataValueFormatterFor($this);
 }
 /**
  * @since 2.4
  *
  * @param DataValueFormatter $dataValueFormatter
  */
 public function registerDataValueFormatter(DataValueFormatter $dataValueFormatter)
 {
     ValueFormatterRegistry::getInstance()->registerDataValueFormatter($dataValueFormatter);
 }