From: daniel Date: Fri, 4 May 2012 14:02:09 +0000 (+0200) Subject: Let tablesUsed imply needsDB in MediaWikiTestCase. X-Git-Tag: 1.31.0-rc.0~23703^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22sites_tous%22%29%20.%20%22?a=commitdiff_plain;h=650e33efa42536028be2985586611cb0d12f09d0;p=lhc%2Fweb%2Fwiklou.git Let tablesUsed imply needsDB in MediaWikiTestCase. If the test says it uses database tables, then it needs the database. And while we are at it, make the check for the test group declaration more lenient. Patch set 2: tweaked according to demon's comments. Change-Id: Ib123745d45b85cebeab5ec87ea7d8227ec3d1dea --- diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php index f6264593b8..07917117e9 100644 --- a/tests/phpunit/MediaWikiTestCase.php +++ b/tests/phpunit/MediaWikiTestCase.php @@ -132,8 +132,18 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase { } function needsDB() { + # if the test says it uses database tables, it needs the database + if ( $this->tablesUsed ) { + return true; + } + + # if the test says it belongs to the Database group, it needs the database $rc = new ReflectionClass( $this ); - return strpos( $rc->getDocComment(), '@group Database' ) !== false; + if ( preg_match( '/@group +Database/im', $rc->getDocComment() ) ) { + return true; + } + + return false; } /**