From 6d9faa3ca3b87b450fafd71b6aaab0bdb65db371 Mon Sep 17 00:00:00 2001 From: Trevor Parscal Date: Wed, 29 Sep 2010 18:02:56 +0000 Subject: [PATCH] Added support for PHPUnit 3.5, where PHPUnit_Util_Timer is replaced with PHP_Timer. --- .../phpunit/includes/parser/ParserHelpers.php | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/maintenance/tests/phpunit/includes/parser/ParserHelpers.php b/maintenance/tests/phpunit/includes/parser/ParserHelpers.php index 893bf8b420..165b93d9b2 100644 --- a/maintenance/tests/phpunit/includes/parser/ParserHelpers.php +++ b/maintenance/tests/phpunit/includes/parser/ParserHelpers.php @@ -19,7 +19,13 @@ class ParserUnitTest extends PHPUnit_Framework_TestCase { $backend = $this->suite->getBackend(); $result->startTest( $this ); - PHPUnit_Util_Timer::start(); + + // Support the transition to PHPUnit 3.5 where PHPUnit_Util_Timer is replaced with PHP_Timer + if ( class_exists( 'PHP_Timer' ) ) { + PHP_Timer::start(); + } else { + PHPUnit_Util_Timer::start(); + } $r = false; try { @@ -35,13 +41,29 @@ class ParserUnitTest extends PHPUnit_Framework_TestCase { ); } catch ( PHPUnit_Framework_AssertionFailedError $e ) { - $result->addFailure( $this, $e, PHPUnit_Util_Timer::stop() ); + + // PHPUnit_Util_Timer -> PHP_Timer support (see above) + if ( class_exists( 'PHP_Timer' ) ) { + $result->addFailure( $this, $e, PHP_Timer::stop() ); + } else { + $result->addFailure( $this, $e, PHPUnit_Util_Timer::stop() ); + } } catch ( Exception $e ) { - $result->addError( $this, $e, PHPUnit_Util_Timer::stop() ); + // PHPUnit_Util_Timer -> PHP_Timer support (see above) + if ( class_exists( 'PHP_Timer' ) ) { + $result->addFailure( $this, $e, PHP_Timer::stop() ); + } else { + $result->addFailure( $this, $e, PHPUnit_Util_Timer::stop() ); + } } - $result->endTest( $this, PHPUnit_Util_Timer::stop() ); + // PHPUnit_Util_Timer -> PHP_Timer support (see above) + if ( class_exists( 'PHP_Timer' ) ) { + $result->endTest( $this, PHP_Timer::stop() ); + } else { + $result->endTest( $this, PHPUnit_Util_Timer::stop() ); + } $backend->recorder->record( $this->test['test'], $r ); $this->addToAssertionCount( PHPUnit_Framework_Assert::getCount() ); -- 2.20.1