Reset relevant DB tables before the first test of a suite.
authordaniel <daniel.kinzler@wikimedia.de>
Thu, 7 Jun 2018 12:36:06 +0000 (14:36 +0200)
committerdaniel <daniel.kinzler@wikimedia.de>
Thu, 7 Jun 2018 12:53:26 +0000 (14:53 +0200)
MediaWikiTestCase truncates all the tables in the tablesUsed field
after each test. It should also do that before the first test of the
class.

Change-Id: I8c33be7b1bdd83559a9ea7803471a1f39e0eb870

tests/phpunit/MediaWikiTestCase.php

index a27e9f9..4c6caa3 100644 (file)
@@ -402,10 +402,6 @@ abstract class MediaWikiTestCase extends PHPUnit\Framework\TestCase {
                        if ( !self::$dbSetup ) {
                                $this->setupAllTestDBs();
                                $this->addCoreDBData();
-
-                               if ( ( $this->db->getType() == 'oracle' || !self::$useTemporaryTables ) && self::$reuseDB ) {
-                                       $this->resetDB( $this->db, $this->tablesUsed );
-                               }
                        }
 
                        // TODO: the DB setup should be done in setUpBeforeClass(), so the test DB
@@ -413,6 +409,7 @@ abstract class MediaWikiTestCase extends PHPUnit\Framework\TestCase {
                        // This would also remove the need for the HACK that is oncePerClass().
                        if ( $this->oncePerClass() ) {
                                $this->setUpSchema( $this->db );
+                               $this->resetDB( $this->db, $this->tablesUsed );
                                $this->addDBDataOnce();
                        }