X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2FMediaWikiTestCase.php;h=ac214a29ef77321d6b3e02d5c9a6e1d464373039;hb=804cc6885a5a98401cdef2617f1f61a9ba7d5851;hp=72cac05194d3b5a97f142c113bc1c33bdaca4f76;hpb=bab1f09f9c0a48949cdb5351a61917bdd7ee9397;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php index 72cac05194..ac214a29ef 100644 --- a/tests/phpunit/MediaWikiTestCase.php +++ b/tests/phpunit/MediaWikiTestCase.php @@ -204,13 +204,11 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { while ( $this->db->trxLevel() > 0 ) { $this->db->rollback(); } - - // don't ignore DB errors - $this->db->ignoreErrors( false ); } DeferredUpdates::clearPendingUpdates(); + ob_start( 'MediaWikiTestCase::wfResetOutputBuffersBarrier' ); } protected function addTmpFiles( $files ) { @@ -218,6 +216,11 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { } protected function tearDown() { + $status = ob_get_status(); + if ( isset( $status['name'] ) && $status['name'] === 'MediaWikiTestCase::wfResetOutputBuffersBarrier' ) { + ob_end_flush(); + } + $this->called['tearDown'] = true; // Cleaning up temporary files foreach ( $this->tmpFiles as $fileName ) { @@ -233,9 +236,6 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { while ( $this->db->trxLevel() > 0 ) { $this->db->rollback(); } - - // don't ignore DB errors - $this->db->ignoreErrors( false ); } // Restore mw globals @@ -716,9 +716,9 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { * @param string $function */ public function hideDeprecated( $function ) { - wfSuppressWarnings(); + MediaWiki\suppressWarnings(); wfDeprecated( $function ); - wfRestoreWarnings(); + MediaWiki\restoreWarnings(); } /** @@ -1002,9 +1002,9 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { # This check may also protect against code injection in # case of broken installations. - wfSuppressWarnings(); + MediaWiki\suppressWarnings(); $haveDiff3 = $wgDiff3 && file_exists( $wgDiff3 ); - wfRestoreWarnings(); + MediaWiki\restoreWarnings(); if ( !$haveDiff3 ) { $this->markTestSkipped( "Skip test, since diff3 is not configured" ); @@ -1180,4 +1180,12 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { self::assertFalse( self::tagMatch( $matcher, $actual, $isHtml ), $message ); } + + /** + * Used as a marker to prevent wfResetOutputBuffers from breaking PHPUnit. + * @return string + */ + public static function wfResetOutputBuffersBarrier( $buffer ) { + return $buffer; + } }