Merge "Made RepoGroup use ProcessCacheLRU"
[lhc/web/wiklou.git] / tests / phpunit / MediaWikiTestCase.php
index 8c849bc..7a7ec8f 100644 (file)
@@ -35,6 +35,13 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
        private static $dbSetup = false;
        private static $oldTablePrefix = false;
 
+       /**
+        * Original value of PHP's error_reporting setting.
+        *
+        * @var int
+        */
+       private $phpErrorLevel;
+
        /**
         * Holds the paths of temporary files/directories created through getNewTempFile,
         * and getNewTempDirectory
@@ -172,6 +179,8 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
                parent::setUp();
                $this->called['setUp'] = 1;
 
+               $this->phpErrorLevel = intval( ini_get( 'error_reporting' ) );
+
                /*
                // @todo global variables to restore for *every* test
                array(
@@ -233,6 +242,18 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
                }
                $this->mwGlobals = array();
 
+               $phpErrorLevel = intval( ini_get( 'error_reporting' ) );
+
+               if ( $phpErrorLevel !== $this->phpErrorLevel ) {
+                       ini_set( 'error_reporting', $this->phpErrorLevel );
+
+                       $oldHex = strtoupper( dechex( $this->phpErrorLevel ) );
+                       $newHex = strtoupper( dechex( $phpErrorLevel ) );
+                       $message = "PHP error_reporting setting was left dirty: was 0x$oldHex before test, 0x$newHex after test!";
+
+                       $this->fail( $message );
+               }
+
                parent::tearDown();
                wfProfileOut( __METHOD__ );
        }
@@ -537,6 +558,12 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
                global $wgDBprefix;
 
                $tables = $db->listTables( $wgDBprefix, __METHOD__ );
+
+               if ( $db->getType() === 'mysql' ) {
+                       # bug 43571: cannot clone VIEWs under MySQL
+                       $views = $db->listViews( $wgDBprefix, __METHOD__ );
+                       $tables = array_diff( $tables, $views );
+               }
                $tables = array_map( array( __CLASS__, 'unprefixTable' ), $tables );
 
                // Don't duplicate test tables from the previous fataled run