Merge "Fix wrong @return type hints in Language::tsTo… methods"
[lhc/web/wiklou.git] / tests / phpunit / includes / specials / QueryAllSpecialPagesTest.php
index 3debaf7..061e598 100644 (file)
@@ -7,14 +7,26 @@
  * @author Antoine Musso
  * @group Database
  */
-global $IP;
-require_once("$IP/includes/QueryPage.php");
+
+/**
+ * @covers QueryPage<extended>
+ */
 class QueryAllSpecialPagesTest extends MediaWikiTestCase {
 
        /** List query pages that can not be tested automatically */
-       protected $manualTest = array(
+       protected $manualTest = [
                'LinkSearchPage'
-       );
+       ];
+
+       /**
+        * Pages whose query use the same DB table more than once.
+        * This is used to skip testing those pages when run against a MySQL backend
+        * which does not support reopening a temporary table. See upstream bug:
+        * http://bugs.mysql.com/bug.php?id=10327
+        */
+       protected $reopensTempTable = [
+               'BrokenRedirects',
+       ];
 
        /**
         * Initialize all query page objects
@@ -22,10 +34,9 @@ class QueryAllSpecialPagesTest extends MediaWikiTestCase {
        function __construct() {
                parent::__construct();
 
-               global $wgQueryPages;
-               foreach( $wgQueryPages as $page ) {
+               foreach ( QueryPage::getPages() as $page ) {
                        $class = $page[0];
-                       if( ! in_array( $class, $this->manualTest ) ) {
+                       if ( !in_array( $class, $this->manualTest ) ) {
                                $this->queryPages[$class] = new $class;
                        }
                }
@@ -35,13 +46,25 @@ class QueryAllSpecialPagesTest extends MediaWikiTestCase {
         * Test SQL for each of our QueryPages objects
         * @group Database
         */
-       function testQuerypageSqlQuery() {
-               foreach( $this->queryPages as $page ) {
+       public function testQuerypageSqlQuery() {
+               global $wgDBtype;
+
+               foreach ( $this->queryPages as $page ) {
+                       // With MySQL, skips special pages reopening a temporary table
+                       // See http://bugs.mysql.com/bug.php?id=10327
+                       if (
+                               $wgDBtype === 'mysql'
+                               && in_array( $page->getName(), $this->reopensTempTable )
+                       ) {
+                               $this->markTestSkipped( "SQL query for page {$page->getName()} "
+                                       . "can not be tested on MySQL backend (it reopens a temporary table)" );
+                               continue;
+                       }
 
-                       $msg = "SQL query for page {$page->getName()} should give a result wrapper object" ;
+                       $msg = "SQL query for page {$page->getName()} should give a result wrapper object";
 
                        $result = $page->reallyDoQuery( 50 );
-                       if( $result instanceof ResultWrapper ) {
+                       if ( $result instanceof ResultWrapper ) {
                                $this->assertTrue( true, $msg );
                        } else {
                                $this->assertFalse( false, $msg );