Follow up r79109.
authorPlatonides <platonides@users.mediawiki.org>
Wed, 29 Dec 2010 15:01:47 +0000 (15:01 +0000)
committerPlatonides <platonides@users.mediawiki.org>
Wed, 29 Dec 2010 15:01:47 +0000 (15:01 +0000)
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).

tests/phpunit/bootstrap.php
tests/phpunit/includes/BlockTest.php
tests/phpunit/includes/LocalFileTest.php
tests/phpunit/includes/NewDBTest.php

index 480954a..9ee4d47 100644 (file)
@@ -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() {}
        
index 28fe3c0..9a531a2 100644 (file)
@@ -1,5 +1,8 @@
 <?php
 
+/**
+ * @group Database
+ */
 class BlockTest extends MediaWikiTestCase {
        
        private $block, $madeAt;
index e72561f..98c0de5 100644 (file)
@@ -2,6 +2,7 @@
 
 /**
  * These tests should work regardless of $wgCapitalLinks
+ * @group Database
  */
 
 class LocalFileTest extends MediaWikiTestCase {
index 487549c..cea3bfd 100644 (file)
@@ -1,5 +1,8 @@
 <?php
 
+/**
+ * @group Database
+ */
 class NewDBTest extends MediaWikiTestCase {
 
        function setUp() {