From: Platonides Date: Wed, 29 Dec 2010 15:01:47 +0000 (+0000) Subject: Follow up r79109. X-Git-Tag: 1.31.0-rc.0~33013 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=84709ae3b36410e21182281cc6a9f2d2994dc543 Follow up r79109. Don't setup/destroy for databaseless tests. Make needsDB() return based on the DocComment. Delayed db init until the test is run, so that it isn't set for excluded tests (the exclusion is done after all the classes are instantiated). --- diff --git a/tests/phpunit/bootstrap.php b/tests/phpunit/bootstrap.php index 480954ae04..9ee4d47ed6 100644 --- a/tests/phpunit/bootstrap.php +++ b/tests/phpunit/bootstrap.php @@ -60,21 +60,27 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { $this->data = $data; $this->dataName = $dataName; - + } + + function run( PHPUnit_Framework_TestResult $result = NULL ) { if( $this->needsDB() && !is_object( $this->dbClone ) ) { $this->initDB(); $this->addCoreDBData(); $this->addDBData(); } + parent::run( $result ); } - + function __destruct() { - if( $this->needsDB() && is_object( $this->dbClone ) && $this->dbClone instanceof CloneDatabase ) { + if( is_object( $this->dbClone ) && $this->dbClone instanceof CloneDatabase ) { $this->destroyDB(); } } - function needsDB() { return true; } + function needsDB() { + $rc = new ReflectionClass( $this ); + return strpos( '@group Database', $rc->getDocComment() ) !== false; + } function addDBData() {} diff --git a/tests/phpunit/includes/BlockTest.php b/tests/phpunit/includes/BlockTest.php index 28fe3c0925..9a531a2f46 100644 --- a/tests/phpunit/includes/BlockTest.php +++ b/tests/phpunit/includes/BlockTest.php @@ -1,5 +1,8 @@