Daniel Kinzler has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/233989

Change subject: Special:ListProperties should sort output
......................................................................

Special:ListProperties should sort output

Change-Id: I4416d2b2785bf61bd2cda3b5e263bf445650c7ae
---
M repo/includes/specials/SpecialListProperties.php
M repo/tests/phpunit/includes/specials/SpecialListPropertiesTest.php
2 files changed, 14 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/89/233989/1

diff --git a/repo/includes/specials/SpecialListProperties.php 
b/repo/includes/specials/SpecialListProperties.php
index d459176..34009eb 100644
--- a/repo/includes/specials/SpecialListProperties.php
+++ b/repo/includes/specials/SpecialListProperties.php
@@ -290,14 +290,21 @@
                return $propertyIds;
        }
 
+       /**
+        * @return array[] An associative array mapping property IDs to info 
arrays.
+        */
        private function getPropertyInfo() {
                if ( $this->dataType === '' ) {
-                       return $this->propertyInfoStore->getAllPropertyInfo();
+                       $propertyInfo = 
$this->propertyInfoStore->getAllPropertyInfo();
                } else {
-                       return 
$this->propertyInfoStore->getPropertyInfoForDataType(
+                       $propertyInfo = 
$this->propertyInfoStore->getPropertyInfoForDataType(
                                $this->dataType
                        );
                }
+
+               // NOTE: $propertyInfo uses numerical property IDs as keys!
+               ksort( $propertyInfo );
+               return $propertyInfo;
        }
 
 }
diff --git a/repo/tests/phpunit/includes/specials/SpecialListPropertiesTest.php 
b/repo/tests/phpunit/includes/specials/SpecialListPropertiesTest.php
index 06d72e2..1049d88 100644
--- a/repo/tests/phpunit/includes/specials/SpecialListPropertiesTest.php
+++ b/repo/tests/phpunit/includes/specials/SpecialListPropertiesTest.php
@@ -53,8 +53,8 @@
                $propertyInfoStore = new MockPropertyInfoStore();
 
                $propertyInfoStore->setPropertyInfo(
-                       new PropertyId( 'P123' ),
-                       array( PropertyInfoStore::KEY_DATA_TYPE => 
'wikibase-item' )
+                       new PropertyId( 'P789' ),
+                       array( PropertyInfoStore::KEY_DATA_TYPE => 'string' )
                );
 
                $propertyInfoStore->setPropertyInfo(
@@ -63,8 +63,8 @@
                );
 
                $propertyInfoStore->setPropertyInfo(
-                       new PropertyId( 'P789' ),
-                       array( PropertyInfoStore::KEY_DATA_TYPE => 'string' )
+                       new PropertyId( 'P123' ),
+                       array( PropertyInfoStore::KEY_DATA_TYPE => 
'wikibase-item' )
                );
 
                return $propertyInfoStore;
@@ -135,9 +135,7 @@
                $this->assertContains( 'wikibase-listproperties-summary', 
$output );
                $this->assertContains( 'wikibase-listproperties-legend', 
$output );
                $this->assertNotContains( 
'wikibase-listproperties-invalid-datatype', $output );
-               $this->assertContains( 'P123', $output );
-               $this->assertContains( 'P456', $output );
-               $this->assertContains( 'P789', $output );
+               $this->assertRegExp( '/P123.*P456.*P789/', $output ); // order 
is relevant
        }
 
        public function testOffsetAndLimit() {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4416d2b2785bf61bd2cda3b5e263bf445650c7ae
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Daniel Kinzler <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to