X-Git-Url: https://git.heureux-cyclage.org/index.php?a=blobdiff_plain;f=tests%2Fphpunit%2Fmaintenance%2FDumpTestCase.php;h=1d55ab8434f0a088825e139bffd980266794718f;hb=b86ef89dd17f51841a220e8ef9b3b8b2402e2547;hp=8c76397053335b471e8ec5fd3b0cdd7ae1b44759;hpb=b9e0a89536c0ba9332dbf9aaf015b3aaaf1d41a8;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/maintenance/DumpTestCase.php b/tests/phpunit/maintenance/DumpTestCase.php index 8c76397053..1d55ab8434 100644 --- a/tests/phpunit/maintenance/DumpTestCase.php +++ b/tests/phpunit/maintenance/DumpTestCase.php @@ -25,6 +25,26 @@ abstract class DumpTestCase extends MediaWikiLangTestCase { */ protected $xml = null; + /** @var bool|null Whether the 'gzip' utility is available */ + protected static $hasGzip = null; + + /** + * Skip the test if 'gzip' is not in $PATH. + * + * @return bool + */ + protected function checkHasGzip() { + if ( self::$hasGzip === null ) { + self::$hasGzip = ( Installer::locateExecutableInDefaultPaths( 'gzip' ) !== false ); + } + + if ( !self::$hasGzip ) { + $this->markTestSkipped( "Skip test, requires the gzip utility in PATH" ); + } + + return self::$hasGzip; + } + /** * Adds a revision to a page, while returning the resuting revision's id * @@ -49,11 +69,12 @@ abstract class DumpTestCase extends MediaWikiLangTestCase { $text_id = $revision->getTextId(); if ( ( $revision_id > 0 ) && ( $text_id > 0 ) ) { - return array( $revision_id, $text_id ); + return [ $revision_id, $text_id ]; } } - throw new MWException( "Could not determine revision id (" . $status->getWikiText() . ")" ); + throw new MWException( "Could not determine revision id (" + . $status->getWikiText( false, false, 'en' ) . ")" ); } /** @@ -102,7 +123,7 @@ abstract class DumpTestCase extends MediaWikiLangTestCase { // expectOutput[...] functions. However, the PHPUnit shipped prediactes // do not allow to check /each/ line of the output using /readable/ REs. // So we ... - // + // 1. ... add a dummy output checking to make PHPUnit not complain // about unchecked test output $this->expectOutputRegex( '//' );