3 * Test class to run the query of most of all our special pages
5 * Copyright © 2011, Antoine Musso
7 * @author Antoine Musso
10 use MediaWiki\SpecialPage\QueryPage
;
11 use MediaWiki\SpecialPage\SpecialPage
;
12 use MediaWiki\Specials\SpecialLinkSearch
;
13 use Wikimedia\Rdbms\ResultWrapper
;
17 * @covers \MediaWiki\SpecialPage\QueryPage<extended>
19 class QueryAllSpecialPagesTest
extends MediaWikiIntegrationTestCase
{
26 /** @var string[] List query pages that cannot be tested automatically */
27 protected $manualTest = [
28 SpecialLinkSearch
::class
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 = [
42 * Initialize all query page objects
44 protected function setUp(): void
{
47 foreach ( QueryPage
::getPages() as [ $class, $name ] ) {
48 if ( !in_array( $class, $this->manualTest
) ) {
49 $this->queryPages
[$class] =
50 $this->getServiceContainer()->getSpecialPageFactory()->getPage( $name );
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
63 $this->getDb()->getType() === 'mysql' &&
64 str_contains( $this->getDb()->getSoftwareLink(), 'MySQL' ) &&
65 in_array( $page->getName(), $this->reopensTempTable
)
67 $this->markTestSkipped( "SQL query for page {$page->getName()} "
68 . "cannot be tested on MySQL backend (it reopens a temporary table)" );
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 );