Merge "Make some replication logging more structured"
[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 /**
12 * @covers QueryPage<extended>
13 */
14 class QueryAllSpecialPagesTest extends MediaWikiTestCase {
15
16 /** List query pages that can not be tested automatically */
17 protected $manualTest = [
18 'LinkSearchPage'
19 ];
20
21 /**
22 * Pages whose query use the same DB table more than once.
23 * This is used to skip testing those pages when run against a MySQL backend
24 * which does not support reopening a temporary table. See upstream bug:
25 * https://bugs.mysql.com/bug.php?id=10327
26 */
27 protected $reopensTempTable = [
28 'BrokenRedirects',
29 ];
30
31 /**
32 * Initialize all query page objects
33 */
34 function __construct() {
35 parent::__construct();
36
37 foreach ( QueryPage::getPages() as $page ) {
38 $class = $page[0];
39 $name = $page[1];
40 if ( !in_array( $class, $this->manualTest ) ) {
41 $this->queryPages[$class] = SpecialPageFactory::getPage( $name );
42 }
43 }
44 }
45
46 /**
47 * Test SQL for each of our QueryPages objects
48 * @group Database
49 */
50 public function testQuerypageSqlQuery() {
51 global $wgDBtype;
52
53 foreach ( $this->queryPages as $page ) {
54 // With MySQL, skips special pages reopening a temporary table
55 // See https://bugs.mysql.com/bug.php?id=10327
56 if (
57 $wgDBtype === 'mysql'
58 && in_array( $page->getName(), $this->reopensTempTable )
59 ) {
60 $this->markTestSkipped( "SQL query for page {$page->getName()} "
61 . "can not be tested on MySQL backend (it reopens a temporary table)" );
62 continue;
63 }
64
65 $msg = "SQL query for page {$page->getName()} should give a result wrapper object";
66
67 $result = $page->reallyDoQuery( 50 );
68 if ( $result instanceof ResultWrapper ) {
69 $this->assertTrue( true, $msg );
70 } else {
71 $this->assertFalse( false, $msg );
72 }
73 }
74 }
75 }