Let tablesUsed imply needsDB in MediaWikiTestCase.
authordaniel <daniel.kinzler@wikimedia.de>
Fri, 4 May 2012 14:02:09 +0000 (16:02 +0200)
committerAntoine Musso <hashar@free.fr>
Mon, 7 May 2012 21:56:33 +0000 (14:56 -0700)
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

index f626459..0791711 100644 (file)
@@ -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;
        }
 
        /**