From 6f31664c05a29b1b996e6923ec64fce5e5b30455 Mon Sep 17 00:00:00 2001 From: Andreas Steiner Date: Wed, 24 Jul 2024 15:55:59 +0200 Subject: [PATCH 1/6] fix: #33454 Site config was not set in the correct order --- src/Settings.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Settings.php b/src/Settings.php index 6ffaa7e..52c4c06 100644 --- a/src/Settings.php +++ b/src/Settings.php @@ -169,7 +169,7 @@ class Settings implements \Iterator, \Countable $siteConf = $this->buildFileName(self::SITE); if (file_exists($siteConf)) { - $localConf = array_replace_recursive($this->settings, require($siteConf)); + $localConf = array_replace_recursive($localConf, require($siteConf)); } } @@ -177,7 +177,7 @@ class Settings implements \Iterator, \Countable if ( isset( $this->modes[ $this->mode ] ) ) { $modeConf = $this->buildFileName( $this->modes[ $this->mode ] ); - + if ( file_exists($modeConf) ) { $this->settings = array_replace_recursive( $this->settings, require($modeConf) ); From 42921d04567f55bbedf4321772a5ba7605692025 Mon Sep 17 00:00:00 2001 From: Andreas Steiner Date: Mon, 29 Jul 2024 11:41:28 +0200 Subject: [PATCH 2/6] fix: #33454 The localConf variable cannot be false by default; in which case the site test will fail --- src/Settings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Settings.php b/src/Settings.php index 52c4c06..0d0089a 100644 --- a/src/Settings.php +++ b/src/Settings.php @@ -153,7 +153,7 @@ class Settings implements \Iterator, \Countable // load local config without merging - we need it here for the mode $conf = $this->buildFileName(); - $localConf = false; + $localConf = []; if (file_exists($conf)) $localConf = require($conf); // if a mode was set in the constructor do not overwrite it From 31735d869278542bae28436170af92ff280f3211 Mon Sep 17 00:00:00 2001 From: Andreas Steiner Date: Mon, 29 Jul 2024 12:53:02 +0200 Subject: [PATCH 3/6] fix: #33454 Fix construct and load test --- tests/SettingsTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/SettingsTest.php b/tests/SettingsTest.php index dd78e34..758bbb9 100644 --- a/tests/SettingsTest.php +++ b/tests/SettingsTest.php @@ -30,7 +30,7 @@ class SettingsTest extends TestCase public function testConstruct() { $cfg = new Settings(); - $this->assertNotEmpty($cfg); + $this->assertIsObject($cfg); } /** @@ -69,7 +69,7 @@ class SettingsTest extends TestCase { $cfg = new Settings(); $cfg = $this->appPath($cfg)->load(); - $this->assertNotEmpty($cfg); + $this->assertIsObject($cfg); return $cfg; } @@ -224,4 +224,4 @@ class SettingsTest extends TestCase /* jEdit buffer local properties {{{ * :folding=explicit:collapseFolds=1: -}}}*/ \ No newline at end of file +}}}*/ From d57c247860bf1639d2c4d00609acb4486195c8cd Mon Sep 17 00:00:00 2001 From: Andreas Steiner Date: Mon, 29 Jul 2024 18:32:11 +0200 Subject: [PATCH 4/6] feat: #33454 Addition of a test to check the correct loading order --- tests/SettingsTest.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/SettingsTest.php b/tests/SettingsTest.php index 758bbb9..64ed411 100644 --- a/tests/SettingsTest.php +++ b/tests/SettingsTest.php @@ -129,7 +129,23 @@ class SettingsTest extends TestCase $this->assertEquals('site', $cfg->testFile); $this->assertEquals(42, $cfg->answer); } - + + /** + */ + public function testLoadingOrder() + { + $cfg = new Settings(); + $cfg = $this->appPath($cfg, 'order')->site('site')->load(); + + $this->assertEquals('default', $cfg->testFiles); + $this->assertEquals('conf', $cfg->testFiles2); + $this->assertEquals('site', $cfg->testFile); + $this->assertEquals(42, $cfg->answer); + + return $cfg; + } + + /** */ public function testTestingOverride() From a58fe8454f46c6d12a17624c5d4d0a08d879475f Mon Sep 17 00:00:00 2001 From: Andreas Steiner Date: Mon, 29 Jul 2024 18:44:48 +0200 Subject: [PATCH 5/6] fix: #33454 Add missing files for the correct loading order test --- tests/cfg/order/config/conf.php | 5 +++++ tests/cfg/order/config/default.conf.php | 4 ++++ tests/cfg/order/config/site/conf.php | 4 ++++ 3 files changed, 13 insertions(+) create mode 100644 tests/cfg/order/config/conf.php create mode 100644 tests/cfg/order/config/default.conf.php create mode 100644 tests/cfg/order/config/site/conf.php diff --git a/tests/cfg/order/config/conf.php b/tests/cfg/order/config/conf.php new file mode 100644 index 0000000..8ea09df --- /dev/null +++ b/tests/cfg/order/config/conf.php @@ -0,0 +1,5 @@ + 1, + 'testFile' => 'conf', + 'testFiles2' => 'conf' +]; diff --git a/tests/cfg/order/config/default.conf.php b/tests/cfg/order/config/default.conf.php new file mode 100644 index 0000000..1cdaca9 --- /dev/null +++ b/tests/cfg/order/config/default.conf.php @@ -0,0 +1,4 @@ + 'prod', + 'testFiles' => 'default', +]; diff --git a/tests/cfg/order/config/site/conf.php b/tests/cfg/order/config/site/conf.php new file mode 100644 index 0000000..54ad2b8 --- /dev/null +++ b/tests/cfg/order/config/site/conf.php @@ -0,0 +1,4 @@ + 42, + 'testFile' => 'site' +]; From b1ca44843b50b3af478ef6bdc6cb1339f760ec91 Mon Sep 17 00:00:00 2001 From: norb Date: Tue, 30 Jul 2024 14:37:57 +0200 Subject: [PATCH 6/6] fix: #33454 add config in default to be overwritten --- tests/cfg/order/config/default.conf.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/cfg/order/config/default.conf.php b/tests/cfg/order/config/default.conf.php index 1cdaca9..90020ca 100644 --- a/tests/cfg/order/config/default.conf.php +++ b/tests/cfg/order/config/default.conf.php @@ -1,4 +1,7 @@ 'prod', + 'answer' => 0, + 'testFile' => 'default', 'testFiles' => 'default', + 'testFiles2' => 'default' ];