Avoid postgres PrefixSearchTest failures due to collation differences
authorAaron Schulz <aschulz@wikimedia.org>
Fri, 19 May 2017 00:40:06 +0000 (17:40 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Fri, 19 May 2017 02:04:03 +0000 (19:04 -0700)
Bug: T75174
Change-Id: I6b1df27ca6ae5c2da46134be3dbd7aed404d9601

tests/phpunit/includes/PrefixSearchTest.php

index 31ee75b..a6cf14a 100644 (file)
@@ -210,6 +210,11 @@ class PrefixSearchTest extends MediaWikiLangTestCase {
 
                $namespaces = isset( $case['namespaces'] ) ? $case['namespaces'] : [];
 
+               if ( wfGetDB( DB_REPLICA )->getType() === 'postgres' ) {
+                       // Postgres will sort lexicographically on utf8 code units (" " before "/")
+                       sort( $case['results'], SORT_STRING );
+               }
+
                $searcher = new StringPrefixSearch;
                $results = $searcher->search( $case['query'], 3, $namespaces );
                $this->assertEquals(
@@ -232,6 +237,11 @@ class PrefixSearchTest extends MediaWikiLangTestCase {
                $searcher = new StringPrefixSearch;
                $results = $searcher->search( $case['query'], 3, $namespaces, 1 );
 
+               if ( wfGetDB( DB_REPLICA )->getType() === 'postgres' ) {
+                       // Postgres will sort lexicographically on utf8 code units (" " before "/")
+                       sort( $case['results'], SORT_STRING );
+               }
+
                // We don't expect the first result when offsetting
                array_shift( $case['results'] );
                // And sometimes we expect a different last result