From 650e33efa42536028be2985586611cb0d12f09d0 Mon Sep 17 00:00:00 2001 From: daniel Date: Fri, 4 May 2012 16:02:09 +0200 Subject: [PATCH] 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 --- tests/phpunit/MediaWikiTestCase.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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; } /** -- 2.20.1