From: Bartosz DziewoƄski Date: Tue, 22 Jul 2014 14:34:12 +0000 (+0200) Subject: LessFileCompilationTest: Check $file during the test, not in constructor X-Git-Tag: 1.31.0-rc.0~14823^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/comptes/journal.php?a=commitdiff_plain;h=805f6a43b8f9207728511fc623983e502247af80;p=lhc%2Fweb%2Fwiklou.git LessFileCompilationTest: Check $file during the test, not in constructor This will result in a neat little test failure instead of an unreadable thirty-line traceback when the test fails. Change-Id: Ie0b564a95586d72eb730ab8a70a6175eb3ae743d --- diff --git a/tests/phpunit/LessFileCompilationTest.php b/tests/phpunit/LessFileCompilationTest.php index f67fe02f3f..6ebbcb2e6e 100644 --- a/tests/phpunit/LessFileCompilationTest.php +++ b/tests/phpunit/LessFileCompilationTest.php @@ -23,14 +23,8 @@ class LessFileCompilationTest extends MediaWikiTestCase { * @param string $file * @param ResourceLoaderModule $module The ResourceLoader module that * contains the file - * @throws PHPUnit_Framework_Exception When the file parameter isn't a - * string or readable file */ public function __construct( $file, ResourceLoaderModule $module ) { - if ( !is_string( $file ) || !is_file( $file ) || !is_readable( $file ) ) { - throw PHPUnit_Util_InvalidArgumentHelper::factory( 1, 'readable file' ); - } - parent::__construct( 'testLessFileCompilation' ); $this->file = $file; @@ -38,6 +32,12 @@ class LessFileCompilationTest extends MediaWikiTestCase { } public function testLessFileCompilation() { + $thisString = $this->toString(); + $this->assertTrue( + is_string( $this->file ) && is_file( $this->file ) && is_readable( $this->file ), + "$thisString must refer to a readable file" + ); + $compiler = ResourceLoader::getLessCompiler(); $this->assertNotNull( $compiler->compileFile( $this->file ) ); }