From: Erik Bernhardson Date: Mon, 8 Dec 2014 18:28:21 +0000 (-0800) Subject: Handle phpunit being autoloaded from checkLess.php X-Git-Tag: 1.31.0-rc.0~13030^2 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/operations/recherche.php?a=commitdiff_plain;h=13406eca22c5c4cf9a1e31e75d5ba408e5feabda;p=lhc%2Fweb%2Fwiklou.git Handle phpunit being autoloaded from checkLess.php When phpunit is available via the autoloader, rather than directly in the include path, checkLess was erroring out. Additionally RequestContext::resetMain() was outputting warnings due to MW_PHPUNIT_TEST not being defined. Change-Id: I28921c018daa59b2da78ffb5312690d1ce8fbb0a --- diff --git a/maintenance/checkLess.php b/maintenance/checkLess.php index b97e1b0b23..2f533cf4b0 100644 --- a/maintenance/checkLess.php +++ b/maintenance/checkLess.php @@ -22,7 +22,6 @@ */ require_once __DIR__ . '/Maintenance.php'; -require_once 'PHPUnit/Autoload.php'; /** * @ingroup Maintenance @@ -43,6 +42,17 @@ class CheckLess extends Maintenance { // require it here. require_once __DIR__ . '/../tests/TestsAutoLoader.php'; + // If phpunit isn't available by autoloader try pulling it in + if ( !class_exists( 'PHPUnit_Framework_TestCase' ) ) { + require_once 'PHPUnit/Autoload.php'; + } + + // RequestContext::resetMain() will print warnings unless this + // is defined. + if ( !defined( 'MW_PHPUNIT_TEST' ) ) { + define( 'MW_PHPUNIT_TEST', true ); + } + $textUICommand = new PHPUnit_TextUI_Command(); $argv = array( "$IP/tests/phpunit/phpunit.php",