From 2750384b7dcb444be54bbef34d79a4007e918006 Mon Sep 17 00:00:00 2001 From: Chris Hallberg <crhallberg@gmail.com> Date: Thu, 23 Jun 2016 14:40:48 -0400 Subject: [PATCH] Changes to config modification for tests. Tests can now change configs back to back without error. --- .../src/VuFindTest/Unit/MinkTestCase.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/module/VuFind/src/VuFindTest/Unit/MinkTestCase.php b/module/VuFind/src/VuFindTest/Unit/MinkTestCase.php index 31e61878e0b..a3add8100ee 100644 --- a/module/VuFind/src/VuFindTest/Unit/MinkTestCase.php +++ b/module/VuFind/src/VuFindTest/Unit/MinkTestCase.php @@ -75,7 +75,6 @@ abstract class MinkTestCase extends DbTestCase { foreach ($configs as $file => $settings) { $this->changeConfigFile($file, $settings, in_array($file, $replace)); - $this->modifiedConfigs[] = $file; } } @@ -93,14 +92,17 @@ abstract class MinkTestCase extends DbTestCase { $file = $configName . '.ini'; $local = ConfigLocator::getLocalConfigPath($file, null, true); - if (file_exists($local)) { - // File exists? Make a backup! - copy($local, $local . '.bak'); - } else { - // File doesn't exist? Make a baseline version. - copy(ConfigLocator::getBaseConfigPath($file), $local); - } + if (!in_array($configName, $this->modifiedConfigs)) { + if (file_exists($local)) { + // File exists? Make a backup! + copy($local, $local . '.bak'); + } else { + // File doesn't exist? Make a baseline version. + copy(ConfigLocator::getBaseConfigPath($file), $local); + } + $this->modifiedConfigs[] = $configName; + } // If we're replacing the existing file, wipe it out now: if ($replace) { file_put_contents($local, ''); @@ -218,6 +220,7 @@ abstract class MinkTestCase extends DbTestCase rename($backup, $local); } } + $this->modifiedConfigs = []; } /** -- GitLab