X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2FPrefixSearchTest.php;h=ed34a8ab9bb940c79c307ab4f18d2424b7c06599;hb=7babd362babcbf7f20adb8e12edb4f4bc1d4249f;hp=31ee75b7883b9909c6ecfe56df33d684ce4f316b;hpb=2d71bf187d5a56ed808a5ae3845d14e51008f195;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/PrefixSearchTest.php b/tests/phpunit/includes/PrefixSearchTest.php index 31ee75b788..ed34a8ab9b 100644 --- a/tests/phpunit/includes/PrefixSearchTest.php +++ b/tests/phpunit/includes/PrefixSearchTest.php @@ -58,20 +58,23 @@ class PrefixSearchTest extends MediaWikiLangTestCase { 'wgCapitalLinkOverrides' => [ self::NS_NONCAP => false ], ] ); - $this->originalHandlers = TestingAccessWrapper::newFromClass( 'Hooks' )->handlers; - TestingAccessWrapper::newFromClass( 'Hooks' )->handlers = []; + $this->originalHandlers = TestingAccessWrapper::newFromClass( Hooks::class )->handlers; + TestingAccessWrapper::newFromClass( Hooks::class )->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; + TestingAccessWrapper::newFromClass( Hooks::class )->handlers = $this->originalHandlers; SpecialPageFactory::resetList(); } @@ -210,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( @@ -232,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