/** * Enable test environment * * @param string $pathLocal * @param string $pathGlobal * @param string $pathCommon */ public function setTestEnvironment($pathLocal = null, $pathGlobal = null, $pathCommon = null, $allowSaving = false) { if (!$allowSaving) { $this->isTest = true; } $this->clear(); $this->pathLocal = $pathLocal ?: Config::getLocalConfigPath(); $this->pathGlobal = $pathGlobal ?: Config::getGlobalConfigPath(); $this->pathCommon = $pathCommon ?: Config::getCommonConfigPath(); $this->init(); // this proxy will not record any data in the production database. // this provides security for Piwik installs and tests were setup. if (isset($this->configGlobal['database_tests']) || isset($this->configLocal['database_tests'])) { $this->__get('database_tests'); $this->configCache['database'] = $this->configCache['database_tests']; } // Ensure local mods do not affect tests if (empty($pathGlobal)) { $this->configCache['log'] = $this->configGlobal['log']; $this->configCache['Debug'] = $this->configGlobal['Debug']; $this->configCache['mail'] = $this->configGlobal['mail']; $this->configCache['General'] = $this->configGlobal['General']; $this->configCache['Segments'] = $this->configGlobal['Segments']; $this->configCache['Tracker'] = $this->configGlobal['Tracker']; $this->configCache['Deletelogs'] = $this->configGlobal['Deletelogs']; $this->configCache['Deletereports'] = $this->configGlobal['Deletereports']; $this->configCache['Development'] = $this->configGlobal['Development']; } // for unit tests, we set that no plugin is installed. This will force // the test initialization to create the plugins tables, execute ALTER queries, etc. $this->configCache['PluginsInstalled'] = array('PluginsInstalled' => array()); }
/** * Enable test environment * * @param string $pathLocal * @param string $pathGlobal * @param string $pathCommon */ public function setTestEnvironment($pathLocal = null, $pathGlobal = null, $pathCommon = null, $allowSaving = false) { if (!$allowSaving) { $this->doNotWriteConfigInTests = true; } $this->pathLocal = $pathLocal ?: Config::getLocalConfigPath(); $this->pathGlobal = $pathGlobal ?: Config::getGlobalConfigPath(); $this->pathCommon = $pathCommon ?: Config::getCommonConfigPath(); $this->reload(); $databaseTestsSettings = $this->database_tests; if (!empty($databaseTestsSettings)) { $this->database = $databaseTestsSettings; } // Ensure local mods do not affect tests if (empty($pathGlobal)) { $this->Debug = $this->settings->getFrom($this->pathGlobal, 'Debug'); $this->mail = $this->settings->getFrom($this->pathGlobal, 'mail'); $this->General = $this->settings->getFrom($this->pathGlobal, 'General'); $this->Segments = $this->settings->getFrom($this->pathGlobal, 'Segments'); $this->Tracker = $this->settings->getFrom($this->pathGlobal, 'Tracker'); $this->Deletelogs = $this->settings->getFrom($this->pathGlobal, 'Deletelogs'); $this->Deletereports = $this->settings->getFrom($this->pathGlobal, 'Deletereports'); $this->Development = $this->settings->getFrom($this->pathGlobal, 'Development'); } // for unit tests, we set that no plugin is installed. This will force // the test initialization to create the plugins tables, execute ALTER queries, etc. $this->PluginsInstalled = array('PluginsInstalled' => array()); }