fix: #33454 Site config was not set in the correct order #2
5 changed files with 39 additions and 7 deletions
|
|
@ -153,7 +153,7 @@ class Settings implements \Iterator, \Countable
|
||||||
|
|
||||||
// load local config without merging - we need it here for the mode
|
// load local config without merging - we need it here for the mode
|
||||||
$conf = $this->buildFileName();
|
$conf = $this->buildFileName();
|
||||||
$localConf = false;
|
$localConf = [];
|
||||||
if (file_exists($conf)) $localConf = require($conf);
|
if (file_exists($conf)) $localConf = require($conf);
|
||||||
|
|
||||||
// if a mode was set in the constructor do not overwrite it
|
// if a mode was set in the constructor do not overwrite it
|
||||||
|
|
@ -169,7 +169,7 @@ class Settings implements \Iterator, \Countable
|
||||||
$siteConf = $this->buildFileName(self::SITE);
|
$siteConf = $this->buildFileName(self::SITE);
|
||||||
if (file_exists($siteConf))
|
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 ] ) )
|
if ( isset( $this->modes[ $this->mode ] ) )
|
||||||
{
|
{
|
||||||
$modeConf = $this->buildFileName( $this->modes[ $this->mode ] );
|
$modeConf = $this->buildFileName( $this->modes[ $this->mode ] );
|
||||||
|
|
||||||
if ( file_exists($modeConf) )
|
if ( file_exists($modeConf) )
|
||||||
{
|
{
|
||||||
$this->settings = array_replace_recursive( $this->settings, require($modeConf) );
|
$this->settings = array_replace_recursive( $this->settings, require($modeConf) );
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ class SettingsTest extends TestCase
|
||||||
public function testConstruct()
|
public function testConstruct()
|
||||||
{
|
{
|
||||||
$cfg = new Settings();
|
$cfg = new Settings();
|
||||||
$this->assertNotEmpty($cfg);
|
$this->assertIsObject($cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -69,7 +69,7 @@ class SettingsTest extends TestCase
|
||||||
{
|
{
|
||||||
$cfg = new Settings();
|
$cfg = new Settings();
|
||||||
$cfg = $this->appPath($cfg)->load();
|
$cfg = $this->appPath($cfg)->load();
|
||||||
$this->assertNotEmpty($cfg);
|
$this->assertIsObject($cfg);
|
||||||
return $cfg;
|
return $cfg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -129,7 +129,23 @@ class SettingsTest extends TestCase
|
||||||
$this->assertEquals('site', $cfg->testFile);
|
$this->assertEquals('site', $cfg->testFile);
|
||||||
$this->assertEquals(42, $cfg->answer);
|
$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()
|
public function testTestingOverride()
|
||||||
|
|
@ -224,4 +240,4 @@ class SettingsTest extends TestCase
|
||||||
|
|
||||||
/* jEdit buffer local properties {{{
|
/* jEdit buffer local properties {{{
|
||||||
* :folding=explicit:collapseFolds=1:
|
* :folding=explicit:collapseFolds=1:
|
||||||
}}}*/
|
}}}*/
|
||||||
|
|
|
||||||
5
tests/cfg/order/config/conf.php
Normal file
5
tests/cfg/order/config/conf.php
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?php return [
|
||||||
|
'answer' => 1,
|
||||||
|
'testFile' => 'conf',
|
||||||
|
'testFiles2' => 'conf'
|
||||||
|
];
|
||||||
7
tests/cfg/order/config/default.conf.php
Normal file
7
tests/cfg/order/config/default.conf.php
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
<?php return [
|
||||||
|
'mode' => 'prod',
|
||||||
|
'answer' => 0,
|
||||||
|
'testFile' => 'default',
|
||||||
|
'testFiles' => 'default',
|
||||||
|
'testFiles2' => 'default'
|
||||||
|
];
|
||||||
4
tests/cfg/order/config/site/conf.php
Normal file
4
tests/cfg/order/config/site/conf.php
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
<?php return [
|
||||||
|
'answer' => 42,
|
||||||
|
'testFile' => 'site'
|
||||||
|
];
|
||||||
Loading…
Add table
Add a link
Reference in a new issue