jenkins-bot has submitted this change and it was merged. Change subject: Tests for more edge cases in InterwikiSorter ......................................................................
Tests for more edge cases in InterwikiSorter Bug: T103044 Change-Id: I06f646482b21ae40dfe002b2c03c0d685fc9d555 --- M client/includes/InterwikiSorter.php M client/tests/phpunit/includes/InterwikiSorterTest.php 2 files changed, 17 insertions(+), 2 deletions(-) Approvals: Jonas Kress (WMDE): Looks good to me, approved jenkins-bot: Verified diff --git a/client/includes/InterwikiSorter.php b/client/includes/InterwikiSorter.php index 7f95010..f0cb320 100644 --- a/client/includes/InterwikiSorter.php +++ b/client/includes/InterwikiSorter.php @@ -100,8 +100,9 @@ $aIndex = array_key_exists( $a, $this->sortOrder ) ? $this->sortOrder[$a] : null; $bIndex = array_key_exists( $b, $this->sortOrder ) ? $this->sortOrder[$b] : null; - // If we encounter an unknown language, which may happen if the sort table is not updated, we list it alphabetically. - return ( ( is_null( $aIndex ) || is_null( $bIndex ) ) ? strcmp( $a, $b ) : $aIndex - $bIndex ); + // If we encounter an unknown language, which may happen if the sort table is not updated, + // we list it alphabetically. + return $aIndex === null || $bIndex === null ? strcmp( $a, $b ) : $aIndex - $bIndex; } /** diff --git a/client/tests/phpunit/includes/InterwikiSorterTest.php b/client/tests/phpunit/includes/InterwikiSorterTest.php index 25081ec..03ac2f1 100644 --- a/client/tests/phpunit/includes/InterwikiSorterTest.php +++ b/client/tests/phpunit/includes/InterwikiSorterTest.php @@ -73,6 +73,20 @@ array( 'ja', 'de', 'pt', 'en', 'hu' ), 'mycustomorder', $sortOrders, array(), $sortOrders['mycustomorder'] ), + array( + array( 'x2', 'x1', 'x3' ), + 'alphabetic', + array( 'alphabetic' => array() ), + array(), + array( 'x1', 'x2', 'x3' ) + ), + array( + array( 'x2', 'x1', 'en', 'de', 'a2', 'a1' ), + 'alphabetic', + $sortOrders, + array(), + array( 'a1', 'a2', 'de', 'en', 'x1', 'x2' ) + ), ); } -- To view, visit https://gerrit.wikimedia.org/r/232939 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I06f646482b21ae40dfe002b2c03c0d685fc9d555 Gerrit-PatchSet: 3 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de> Gerrit-Reviewer: Addshore <addshorew...@gmail.com> Gerrit-Reviewer: Jonas Kress (WMDE) <jonas.kr...@wikimedia.de> Gerrit-Reviewer: Mjbmr <mjb...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits