jenkins-bot has submitted this change and it was merged. Change subject: Drop unused, trivial EntityLabelUnitFormatter ......................................................................
Drop unused, trivial EntityLabelUnitFormatter Change-Id: Iec4ab8591a4abc21d4962f5857f5ca459341ae77 --- D lib/includes/formatters/EntityLabelUnitFormatter.php D lib/tests/phpunit/formatters/EntityLabelUnitFormatterTest.php 2 files changed, 0 insertions(+), 114 deletions(-) Approvals: Daniel Kinzler: Looks good to me, approved jenkins-bot: Verified diff --git a/lib/includes/formatters/EntityLabelUnitFormatter.php b/lib/includes/formatters/EntityLabelUnitFormatter.php deleted file mode 100644 index 12c3c57..0000000 --- a/lib/includes/formatters/EntityLabelUnitFormatter.php +++ /dev/null @@ -1,54 +0,0 @@ -<?php - -namespace Wikibase\Lib; - -use ValueFormatters\QuantityUnitFormatter; - -/** - * QuantityUnitFormatter for representing units by their respective entity label. - * - * @since 0.5 - * @deprecated since 0.5 - * - * @licence GNU GPL v2+ - * @author Daniel Kinzler - */ -class EntityLabelUnitFormatter implements QuantityUnitFormatter { - - /** - * @var VocabularyUriFormatter - */ - private $vocabularyUriFormatter; - - /** - * @param VocabularyUriFormatter $vocabularyUriFormatter - */ - public function __construct( VocabularyUriFormatter $vocabularyUriFormatter ) { - $this->vocabularyUriFormatter = $vocabularyUriFormatter; - } - - /** - * @see QuantityUnitFormatter::applyUnit - * - * This implementation will interpret $unit as an external entity ID (typically a URI), which - * can be parsed using the EntityIdParser supplied to the constructor. If $unit is successfully - * parsed, the label of the entity is looked up, and appended to $numberText with a single - * space as a separator. - * - * @param string $conceptUri - * @param string $numberText - * - * @return string Text - */ - public function applyUnit( $conceptUri, $numberText ) { - $label = $this->vocabularyUriFormatter->format( $conceptUri ); - - if ( $label === null ) { - return $numberText; - } - - // TODO: localizable pattern for placement (before/after, separator) - return $numberText . ' ' . $label; - } - -} diff --git a/lib/tests/phpunit/formatters/EntityLabelUnitFormatterTest.php b/lib/tests/phpunit/formatters/EntityLabelUnitFormatterTest.php deleted file mode 100644 index b775a59..0000000 --- a/lib/tests/phpunit/formatters/EntityLabelUnitFormatterTest.php +++ /dev/null @@ -1,60 +0,0 @@ -<?php - -namespace Wikibase\Lib\Test; - -use PHPUnit_Framework_TestCase; -use Wikibase\DataModel\Entity\EntityId; -use Wikibase\DataModel\Entity\BasicEntityIdParser; -use Wikibase\DataModel\Term\Term; -use Wikibase\Lib\EntityLabelUnitFormatter; -use Wikibase\Lib\VocabularyUriFormatter; - -/** - * @covers Wikibase\Lib\EntityLabelUnitFormatter - * - * @group ValueFormatters - * @group DataValueExtensions - * @group WikibaseLib - * @group Wikibase - * - * @licence GNU GPL v2+ - * @author Daniel Kinzler - */ -class EntityLabelUnitFormatterTest extends PHPUnit_Framework_TestCase { - - public function provideApplyUnit() { - return array( - 'empty unit' => array( '', '12345', '12345' ), - 'unit is 1' => array( '1', '12345', '12345' ), - 'unit is "NotAUnit"' => array( 'NotAUnit', '12345', '12345' ), - 'unit is bad id' => array( 'kittens', '12345', '12345 kittens' ), - 'unit has label' => array( 'Q7', '12345', '12345 LABEL:Q7' ), - 'unit has no label' => array( 'Q112233', '12345', '12345 Q112233' ), - 'unknown int' => array( '2', '123', '123 2' ), - 'unknown URI' => array( 'http://www.wikidata.org/entity/Q200', '123', '123 http://www.wikidata.org/entity/Q200' ), - 'property id' => array( 'P7', '123', '123 LABEL:P7' ), - ); - } - - /** - * @dataProvider provideApplyUnit - */ - public function testApplyUnit( $unit, $number, $expected ) { - $labelLookup = $this->getMock( 'Wikibase\DataModel\Services\Lookup\LabelDescriptionLookup' ); - $labelLookup->expects( $this->any() ) - ->method( 'getLabel' ) - ->will( $this->returnCallback( function( EntityId $id ) { - if ( $id->getNumericId() > 1000 ) { - return null; - } - return new Term( 'en', 'LABEL:' . $id->getSerialization() ); - } ) ); - - $idParser = new BasicEntityIdParser(); - - $vocabularyUriFormatter = new VocabularyUriFormatter( $idParser, $labelLookup, array( 'NotAUnit' ) ); - $formatter = new EntityLabelUnitFormatter( $vocabularyUriFormatter ); - $this->assertEquals( $expected, $formatter->applyUnit( $unit, $number ) ); - } - -} -- To view, visit https://gerrit.wikimedia.org/r/238142 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Iec4ab8591a4abc21d4962f5857f5ca459341ae77 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de> Gerrit-Reviewer: Daniel Kinzler <daniel.kinz...@wikimedia.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits