public function test_forceSave_writesNothingIfThereAreNoChanges() { $sourceConfigFile = PIWIK_INCLUDE_PATH . '/tests/resources/Config/config.ini.php'; $configFile = PIWIK_INCLUDE_PATH . '/tmp/tmp.config.ini.php'; if (file_exists($configFile)) { @unlink($configFile); } copy($sourceConfigFile, $configFile); $config = new Config(new GlobalSettingsProvider($sourceConfigFile, $configFile)); $config->forceSave(); $this->assertEquals(file_get_contents($sourceConfigFile), file_get_contents($configFile)); if (file_exists($configFile)) { @unlink($configFile); } }
function prepareTestDatabaseConfig(Config $config) { $testDb = $config->database_tests; Factory::setTest(true); if ('@USERNAME@' !== $testDb['username']) { return; // testDb is already configured, we do not want to overwrite any existing settings. } $db = $config->database; $testDb['username'] = $db['username']; if (empty($testDb['password'])) { $testDb['password'] = $db['password']; } if (empty($testDb['host'])) { $testDb['host'] = $db['host']; } $testDb['tables_prefix'] = ''; // tables_prefix has to be empty for UI tests $config->database_tests = $testDb; $config->forceSave(); }
public function forceSave() { if ($this->allowSave) { parent::forceSave(); } }