Merge "(bug 42600) (bug 24375) Fix doMaintenance.php exit procedures."
[lhc/web/wiklou.git] / tests / phpunit / includes / specials / QueryAllSpecialPagesTest.php
1 <?php
2 /**
3 * Test class to run the query of most of all our special pages
4 *
5 * Copyright © 2011, Antoine Musso
6 *
7 * @author Antoine Musso
8 * @group Database
9 */
10
11 if ( !defined( 'MEDIAWIKI' ) ) {
12 die( 1 );
13 }
14
15 global $IP;
16 require_once "$IP/includes/QueryPage.php"; // Needed to populate $wgQueryPages
17
18 class QueryAllSpecialPagesTest extends MediaWikiTestCase {
19
20 /** List query pages that can not be tested automatically */
21 protected $manualTest = array(
22 'LinkSearchPage'
23 );
24
25 /**
26 * Pages whose query use the same DB table more than once.
27 * This is used to skip testing those pages when run against a MySQL backend
28 * which does not support reopening a temporary table. See upstream bug:
29 * http://bugs.mysql.com/bug.php?id=10327
30 */
31 protected $reopensTempTable = array(
32 'BrokenRedirects',
33 );
34
35 /**
36 * Initialize all query page objects
37 */
38 function __construct() {
39 parent::__construct();
40
41 global $wgQueryPages;
42 foreach ( $wgQueryPages as $page ) {
43 $class = $page[0];
44 if ( !in_array( $class, $this->manualTest ) ) {
45 $this->queryPages[$class] = new $class;
46 }
47 }
48 }
49
50 /**
51 * Test SQL for each of our QueryPages objects
52 * @group Database
53 */
54 function testQuerypageSqlQuery() {
55 global $wgDBtype;
56
57 foreach ( $this->queryPages as $page ) {
58
59 // With MySQL, skips special pages reopening a temporary table
60 // See http://bugs.mysql.com/bug.php?id=10327
61 if (
62 $wgDBtype === 'mysql'
63 && in_array( $page->getName(), $this->reopensTempTable )
64 ) {
65 $this->markTestSkipped( "SQL query for page {$page->getName()} can not be tested on MySQL backend (it reopens a temporary table)" );
66 continue;
67 }
68
69 $msg = "SQL query for page {$page->getName()} should give a result wrapper object";
70
71 $result = $page->reallyDoQuery( 50 );
72 if ( $result instanceof ResultWrapper ) {
73 $this->assertTrue( true, $msg );
74 } else {
75 $this->assertFalse( false, $msg );
76 }
77 }
78 }
79 }