jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/329596 )

Change subject: Update composer.json to use DataTypes 1.0.0
......................................................................


Update composer.json to use DataTypes 1.0.0

This requires a 1.0.0 release of the DataTypes component, including
these two patches:
https://github.com/wmde/DataTypes/pull/63
https://github.com/wmde/DataTypes/pull/62

Change-Id: Id95bdc6f12014f6b50c103debb3257b6907008e6
---
M composer.json
M repo/includes/DataTypeSelector.php
M repo/tests/phpunit/includes/DataTypeSelectorTest.php
M view/src/PropertyView.php
4 files changed, 18 insertions(+), 17 deletions(-)

Approvals:
  WMDE-leszek: Looks good to me, approved
  Aleksey Bekh-Ivanov (WMDE): Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/composer.json b/composer.json
index ff6f467..384ccbc 100644
--- a/composer.json
+++ b/composer.json
@@ -29,7 +29,7 @@
                "data-values/number": "~0.8.2",
                "data-values/time": "~0.8.4",
                "data-values/validators": "~0.1.0",
-               "data-values/data-types": "~0.5.0",
+               "data-values/data-types": "~1.0.0",
                "data-values/serialization": "~1.1",
                "data-values/javascript": "~0.8.3",
                "data-values/value-view": "~0.18.0",
diff --git a/repo/includes/DataTypeSelector.php 
b/repo/includes/DataTypeSelector.php
index 920f646..1028346 100644
--- a/repo/includes/DataTypeSelector.php
+++ b/repo/includes/DataTypeSelector.php
@@ -61,7 +61,8 @@
                $byId = [];
 
                foreach ( $this->dataTypes as $dataType ) {
-                       $label = $dataType->getLabel( $this->languageCode );
+                       $label = wfMessage( $dataType->getMessageKey() 
)->inLanguage( $this->languageCode )
+                               ->text();
                        $id = $dataType->getId();
 
                        $byLabel[$label] = $id;
diff --git a/repo/tests/phpunit/includes/DataTypeSelectorTest.php 
b/repo/tests/phpunit/includes/DataTypeSelectorTest.php
index fc05140..05cb3a2 100644
--- a/repo/tests/phpunit/includes/DataTypeSelectorTest.php
+++ b/repo/tests/phpunit/includes/DataTypeSelectorTest.php
@@ -18,13 +18,16 @@
  */
 class DataTypeSelectorTest extends PHPUnit_Framework_TestCase {
 
+       /** @see \LanguageQqx */
+       const DUMMY_LANGUAGE = 'qqx';
+
        /**
         * @param string $propertyType
-        * @param string $label
+        * @param string $messageKey
         *
         * @return DataType
         */
-       private function newDataType( $propertyType, $label ) {
+       private function newDataType( $propertyType, $messageKey ) {
                $dataType = $this->getMockBuilder( DataType::class )
                        ->disableOriginalConstructor()
                        ->getMock();
@@ -34,9 +37,8 @@
                        ->will( $this->returnValue( $propertyType ) );
 
                $dataType->expects( $this->any() )
-                       ->method( 'getLabel' )
-                       ->with( 'en' )
-                       ->will( $this->returnValue( $label ) );
+                       ->method( 'getMessageKey' )
+                       ->will( $this->returnValue( $messageKey ) );
 
                return $dataType;
        }
@@ -62,10 +64,10 @@
        public function testGetOptionsArrayWithOneElement() {
                $selector = new DataTypeSelector( [
                        $this->newDataType( '<PROPERTY-TYPE>', '<LABEL>' ),
-               ], 'en' );
+               ], self::DUMMY_LANGUAGE );
 
                $expected = [
-                       '<LABEL>' => '<PROPERTY-TYPE>',
+                       '(<LABEL>)' => '<PROPERTY-TYPE>',
                ];
                $this->assertSame( $expected, $selector->getOptionsArray() );
        }
@@ -74,7 +76,7 @@
                $selector = new DataTypeSelector( [
                        $this->newDataType( '<PROPERTY-TYPE-B>', '<LABEL>' ),
                        $this->newDataType( '<PROPERTY-TYPE-A>', '<LABEL>' ),
-               ], 'en' );
+               ], self::DUMMY_LANGUAGE );
 
                $expected = [
                        '<PROPERTY-TYPE-A>' => '<PROPERTY-TYPE-A>',
@@ -87,11 +89,11 @@
                $selector = new DataTypeSelector( [
                        $this->newDataType( '<PROPERTY-TYPE-A>', '<LABEL-10>' ),
                        $this->newDataType( '<PROPERTY-TYPE-B>', '<label-2>' ),
-               ], 'en' );
+               ], self::DUMMY_LANGUAGE );
 
                $expected = [
-                       '<label-2>' => '<PROPERTY-TYPE-B>',
-                       '<LABEL-10>' => '<PROPERTY-TYPE-A>',
+                       '(<label-2>)' => '<PROPERTY-TYPE-B>',
+                       '(<LABEL-10>)' => '<PROPERTY-TYPE-A>',
                ];
                $this->assertSame( $expected, $selector->getOptionsArray() );
        }
diff --git a/view/src/PropertyView.php b/view/src/PropertyView.php
index 3802453..6a83c75 100644
--- a/view/src/PropertyView.php
+++ b/view/src/PropertyView.php
@@ -99,19 +99,17 @@
         * @return string HTML
         */
        private function getHtmlForDataType( $propertyType ) {
-
                $html = $this->templateFactory->render( 'wb-section-heading',
                        htmlspecialchars( $this->textProvider->get( 
'wikibase-propertypage-datatype' ) ),
                        'datatype',
                        'wikibase-propertypage-datatype'
                );
 
-               $dataTypeLabelHtml = '';
                try {
                        $dataType = $this->dataTypeFactory->getType( 
$propertyType );
-                       $dataTypeLabelHtml = htmlspecialchars( 
$dataType->getLabel( $this->languageCode ) );
+                       $dataTypeLabelHtml = htmlspecialchars( 
$this->textProvider->get( $dataType->getMessageKey() ) );
                } catch ( OutOfBoundsException $ex ) {
-                       $dataTypeLabelHtml .= '<span class="error">' .
+                       $dataTypeLabelHtml = '<span class="error">' .
                                htmlspecialchars( $this->textProvider->get( 
'wikibase-propertypage-bad-datatype', [ $propertyType ] ) ) .
                                '</span>';
                }

-- 
To view, visit https://gerrit.wikimedia.org/r/329596
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Id95bdc6f12014f6b50c103debb3257b6907008e6
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de>
Gerrit-Reviewer: Aleksey Bekh-Ivanov (WMDE) <aleksey.bekh-iva...@wikimedia.de>
Gerrit-Reviewer: Jeroen De Dauw <jeroended...@gmail.com>
Gerrit-Reviewer: Legoktm <lego...@member.fsf.org>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de>
Gerrit-Reviewer: WMDE-leszek <leszek.mani...@wikimedia.de>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to