Merge "Drop cache interwiki"
[mediawiki.git] / tests / phpunit / includes / specials / QueryAllSpecialPagesTest.php
blob054c418949d65bc3c7242fbe5b21ac4d586d0fde
1 <?php
2 /**
3 * Test class to run the query of most of all our special pages
5 * Copyright © 2011, Antoine Musso
7 * @author Antoine Musso
8 */
10 use MediaWiki\SpecialPage\QueryPage;
11 use MediaWiki\SpecialPage\SpecialPage;
12 use MediaWiki\Specials\SpecialLinkSearch;
13 use Wikimedia\Rdbms\ResultWrapper;
15 /**
16 * @group Database
17 * @covers \MediaWiki\SpecialPage\QueryPage<extended>
19 class QueryAllSpecialPagesTest extends MediaWikiIntegrationTestCase {
21 /**
22 * @var SpecialPage[]
24 private $queryPages;
26 /** @var string[] List query pages that cannot be tested automatically */
27 protected $manualTest = [
28 SpecialLinkSearch::class
31 /**
32 * @var string[] Names of pages whose query use the same DB table more than once.
33 * This is used to skip testing those pages when run against a MySQL backend
34 * which does not support reopening a temporary table.
35 * For more info, see https://phabricator.wikimedia.org/T256006
37 protected $reopensTempTable = [
38 'BrokenRedirects',
41 /**
42 * Initialize all query page objects
44 protected function setUp(): void {
45 parent::setUp();
47 foreach ( QueryPage::getPages() as [ $class, $name ] ) {
48 if ( !in_array( $class, $this->manualTest ) ) {
49 $this->queryPages[$class] =
50 $this->getServiceContainer()->getSpecialPageFactory()->getPage( $name );
55 /**
56 * Test SQL for each of our QueryPages objects
58 public function testQuerypageSqlQuery() {
59 foreach ( $this->queryPages as $page ) {
60 // With MySQL, skips special pages reopening a temporary table
61 // See https://bugs.mysql.com/bug.php?id=10327
62 if (
63 $this->getDb()->getType() === 'mysql' &&
64 str_contains( $this->getDb()->getSoftwareLink(), 'MySQL' ) &&
65 in_array( $page->getName(), $this->reopensTempTable )
66 ) {
67 $this->markTestSkipped( "SQL query for page {$page->getName()} "
68 . "cannot be tested on MySQL backend (it reopens a temporary table)" );
69 continue;
72 $msg = "SQL query for page {$page->getName()} should give a result wrapper object";
74 $result = $page->reallyDoQuery( 50 );
75 $this->assertInstanceOf( ResultWrapper::class, $result, $msg );