function run(PHPUnit_Framework_TestResult $result = null) { /* Some functions require some kind of caching, and will end up using the db, * which we can't allow, as that would open a new connection for mysql. * Replace with a HashBag. They would not be going to persist anyway. */ ObjectCache::$instances[CACHE_DB] = new HashBagOStuff(); $needsResetDB = false; $logName = get_class($this) . '::' . $this->getName(false); if ($this->needsDB()) { // set up a DB connection for this test to use self::$useTemporaryTables = !$this->getCliArg('use-normal-tables'); self::$reuseDB = $this->getCliArg('reuse-db'); $this->db = wfGetDB(DB_MASTER); $this->checkDbIsSupported(); if (!self::$dbSetup) { wfProfileIn($logName . ' (clone-db)'); // switch to a temporary clone of the database self::setupTestDB($this->db, $this->dbPrefix()); if (($this->db->getType() == 'oracle' || !self::$useTemporaryTables) && self::$reuseDB) { $this->resetDB(); } wfProfileOut($logName . ' (clone-db)'); } wfProfileIn($logName . ' (prepare-db)'); $this->addCoreDBData(); $this->addDBData(); wfProfileOut($logName . ' (prepare-db)'); $needsResetDB = true; } wfProfileIn($logName); parent::run($result); wfProfileOut($logName); if ($needsResetDB) { wfProfileIn($logName . ' (reset-db)'); $this->resetDB(); wfProfileOut($logName . ' (reset-db)'); } }
public function run(PHPUnit_Framework_TestResult $result = null) { /* Some functions require some kind of caching, and will end up using the db, * which we can't allow, as that would open a new connection for mysql. * Replace with a HashBag. They would not be going to persist anyway. */ ObjectCache::$instances[CACHE_DB] = new HashBagOStuff(); // Sandbox APC by replacing with in-process hash instead. // Ensures values are removed between tests. ObjectCache::$instances['apc'] = ObjectCache::$instances['xcache'] = ObjectCache::$instances['wincache'] = new HashBagOStuff(); $needsResetDB = false; if ($this->needsDB()) { // set up a DB connection for this test to use self::$useTemporaryTables = !$this->getCliArg('use-normal-tables'); self::$reuseDB = $this->getCliArg('reuse-db'); $this->db = wfGetDB(DB_MASTER); $this->checkDbIsSupported(); if (!self::$dbSetup) { // switch to a temporary clone of the database self::setupTestDB($this->db, $this->dbPrefix()); if (($this->db->getType() == 'oracle' || !self::$useTemporaryTables) && self::$reuseDB) { $this->resetDB(); } } $this->addCoreDBData(); $this->addDBData(); $needsResetDB = true; } parent::run($result); if ($needsResetDB) { $this->resetDB(); } }
public function run(PHPUnit_Framework_TestResult $result = null) { // Reset all caches between tests. $this->doLightweightServiceReset(); $needsResetDB = false; if (!self::$dbSetup || $this->needsDB()) { // set up a DB connection for this test to use self::$useTemporaryTables = !$this->getCliArg('use-normal-tables'); self::$reuseDB = $this->getCliArg('reuse-db'); $this->db = wfGetDB(DB_MASTER); $this->checkDbIsSupported(); 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 // is available in subclass's setUpBeforeClass() and setUp() methods. // This would also remove the need for the HACK that is oncePerClass(). if ($this->oncePerClass()) { $this->addDBDataOnce(); } $this->addDBData(); $needsResetDB = true; } parent::run($result); if ($needsResetDB) { $this->resetDB($this->db, $this->tablesUsed); } }