Add tests for DiffEngine tooltips
[lhc/web/wiklou.git] / tests / phpunit / includes / PrefixSearchTest.php
index bc43709..2f3e569 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+
+use Wikimedia\TestingAccessWrapper;
+
 /**
  * @group Search
  * @group Database
@@ -59,13 +62,16 @@ class PrefixSearchTest extends MediaWikiLangTestCase {
                TestingAccessWrapper::newFromClass( 'Hooks' )->handlers = [];
 
                // Clear caches so that our new namespace appears
-               MWNamespace::getCanonicalNamespaces( true );
+               MWNamespace::clearCaches();
                Language::factory( 'en' )->resetNamespaces();
 
                SpecialPageFactory::resetList();
        }
 
        public function tearDown() {
+               MWNamespace::clearCaches();
+               Language::factory( 'en' )->resetNamespaces();
+
                parent::tearDown();
 
                TestingAccessWrapper::newFromClass( 'Hooks' )->handlers = $this->originalHandlers;
@@ -129,11 +135,11 @@ class PrefixSearchTest extends MediaWikiLangTestCase {
                                'results' => [
                                        'Special:ActiveUsers',
                                        'Special:AllMessages',
-                                       'Special:AllMyFiles',
+                                       'Special:AllMyUploads',
                                ],
                                // Third result when testing offset
                                'offsetresult' => [
-                                       'Special:AllMyUploads',
+                                       'Special:AllPages',
                                ],
                        ] ],
                        [ [
@@ -146,7 +152,7 @@ class PrefixSearchTest extends MediaWikiLangTestCase {
                                ],
                                // Third result when testing offset
                                'offsetresult' => [
-                                       'Special:UncategorizedImages',
+                                       'Special:UncategorizedPages',
                                ],
                        ] ],
                        [ [
@@ -207,6 +213,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(
@@ -229,6 +240,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
@@ -260,7 +276,7 @@ class PrefixSearchTest extends MediaWikiLangTestCase {
                                ],
                        ] ],
                        [ [
-                               'Exact match not on top (bug 70958)',
+                               'Exact match not on top (T72958)',
                                'provision' => [
                                        'Barcelona',
                                        'Bar',
@@ -274,7 +290,7 @@ class PrefixSearchTest extends MediaWikiLangTestCase {
                                ],
                        ] ],
                        [ [
-                               'Exact match missing (bug 70958)',
+                               'Exact match missing (T72958)',
                                'provision' => [
                                        'Barcelona',
                                        'Barbara',