public function dropDatabase($dbName = null) { $dbName = $dbName ?: $this->dbName ?: Config::getInstance()->database_tests['dbname']; $this->log("Dropping database '{$dbName}'..."); $config = _parse_ini_file(PIWIK_INCLUDE_PATH . '/config/config.ini.php', true); $originalDbName = $config['database']['dbname']; if ($dbName == $originalDbName && $dbName != 'piwik_tests') { // santity check throw new \Exception("Trying to drop original database '{$originalDbName}'. Something's wrong w/ the tests."); } DbHelper::dropDatabase($dbName); }
public function dropDatabase($dbName = null) { $dbName = $dbName ?: $this->dbName ?: self::getConfig()->database_tests['dbname']; $this->log("Dropping database '{$dbName}'..."); $iniReader = new IniReader(); $config = $iniReader->readFile(PIWIK_INCLUDE_PATH . '/config/config.ini.php'); $originalDbName = $config['database']['dbname']; if ($dbName == $originalDbName && $dbName != 'piwik_tests') { // santity check throw new \Exception("Trying to drop original database '{$originalDbName}'. Something's wrong w/ the tests."); } try { DbHelper::dropDatabase($dbName); } catch (Exception $e) { printf("Dropping database %s failed: %s\n", $dbName, $e->getMessage()); } }