2011-11-08 16:22:42 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* Test class to run the query of most of all our special pages
|
|
|
|
|
*
|
|
|
|
|
* Copyright © 2011, Antoine Musso
|
|
|
|
|
*
|
|
|
|
|
* @author Antoine Musso
|
|
|
|
|
*/
|
2012-01-07 22:42:05 +00:00
|
|
|
|
2018-08-12 09:08:58 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
|
|
|
|
|
2013-10-24 19:35:04 +00:00
|
|
|
/**
|
2018-03-09 21:56:41 +00:00
|
|
|
* @group Database
|
2013-10-24 19:35:04 +00:00
|
|
|
* @covers QueryPage<extended>
|
|
|
|
|
*/
|
2020-06-30 15:09:24 +00:00
|
|
|
class QueryAllSpecialPagesTest extends MediaWikiIntegrationTestCase {
|
2011-11-08 16:22:42 +00:00
|
|
|
|
2017-01-03 16:25:52 +00:00
|
|
|
/**
|
|
|
|
|
* @var SpecialPage[]
|
|
|
|
|
*/
|
|
|
|
|
private $queryPages;
|
|
|
|
|
|
2021-01-08 22:04:05 +00:00
|
|
|
/** @var string[] List query pages that can not be tested automatically */
|
2016-02-17 09:09:32 +00:00
|
|
|
protected $manualTest = [
|
2019-04-14 15:14:22 +00:00
|
|
|
SpecialLinkSearch::class
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2011-11-08 16:22:42 +00:00
|
|
|
|
2012-01-16 10:33:24 +00:00
|
|
|
/**
|
2021-01-08 22:04:05 +00:00
|
|
|
* @var string[] Names of pages whose query use the same DB table more than once.
|
2012-01-16 10:33:24 +00:00
|
|
|
* This is used to skip testing those pages when run against a MySQL backend
|
2020-06-22 15:36:17 +00:00
|
|
|
* which does not support reopening a temporary table.
|
|
|
|
|
* For more info, see https://phabricator.wikimedia.org/T256006
|
2012-01-16 10:33:24 +00:00
|
|
|
*/
|
2016-02-17 09:09:32 +00:00
|
|
|
protected $reopensTempTable = [
|
2020-06-22 15:36:17 +00:00
|
|
|
'BrokenRedirects',
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2012-01-16 10:33:24 +00:00
|
|
|
|
2011-11-08 16:22:42 +00:00
|
|
|
/**
|
|
|
|
|
* Initialize all query page objects
|
|
|
|
|
*/
|
2019-11-25 13:55:03 +00:00
|
|
|
protected function setUp() : void {
|
|
|
|
|
parent::setUp();
|
2011-11-08 16:22:42 +00:00
|
|
|
|
2020-06-18 14:57:50 +00:00
|
|
|
foreach ( QueryPage::getPages() as [ $class, $name ] ) {
|
2013-02-15 10:24:31 +00:00
|
|
|
if ( !in_array( $class, $this->manualTest ) ) {
|
2018-08-12 09:08:58 +00:00
|
|
|
$this->queryPages[$class] =
|
|
|
|
|
MediaWikiServices::getInstance()->getSpecialPageFactory()->getPage( $name );
|
2011-11-08 16:22:42 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Test SQL for each of our QueryPages objects
|
|
|
|
|
* @group Database
|
|
|
|
|
*/
|
2013-10-23 22:51:31 +00:00
|
|
|
public function testQuerypageSqlQuery() {
|
2012-01-16 10:33:24 +00:00
|
|
|
global $wgDBtype;
|
|
|
|
|
|
2013-02-15 10:24:31 +00:00
|
|
|
foreach ( $this->queryPages as $page ) {
|
2012-01-16 10:33:24 +00:00
|
|
|
// With MySQL, skips special pages reopening a temporary table
|
2016-10-13 05:34:26 +00:00
|
|
|
// See https://bugs.mysql.com/bug.php?id=10327
|
2013-02-15 10:24:31 +00:00
|
|
|
if (
|
2012-01-16 10:33:24 +00:00
|
|
|
$wgDBtype === 'mysql'
|
|
|
|
|
&& in_array( $page->getName(), $this->reopensTempTable )
|
|
|
|
|
) {
|
2014-04-24 17:52:34 +00:00
|
|
|
$this->markTestSkipped( "SQL query for page {$page->getName()} "
|
|
|
|
|
. "can not be tested on MySQL backend (it reopens a temporary table)" );
|
2013-02-15 10:24:31 +00:00
|
|
|
continue;
|
|
|
|
|
}
|
2012-01-16 10:33:24 +00:00
|
|
|
|
2013-02-15 10:24:31 +00:00
|
|
|
$msg = "SQL query for page {$page->getName()} should give a result wrapper object";
|
2011-11-08 16:22:42 +00:00
|
|
|
|
|
|
|
|
$result = $page->reallyDoQuery( 50 );
|
2013-02-15 10:24:31 +00:00
|
|
|
if ( $result instanceof ResultWrapper ) {
|
2011-11-08 16:22:42 +00:00
|
|
|
$this->assertTrue( true, $msg );
|
|
|
|
|
} else {
|
|
|
|
|
$this->assertFalse( false, $msg );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|