-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added test showing section override #116
base: develop
Are you sure you want to change the base?
Conversation
Hi @intco . Pay attention because |
I know :-) I created specifically a new instance to demonstrate that default options from getDefaults will be overridden entirely. The application.name is lost even if i set only the application.secret. |
Please, take a look to the source code of getDefaults to better understand it. It should be overridden to work as you want. Tell me in details if I'm missing something and if I'm missing your point. |
consider the SimpleConfig class used in the test https://github.com/hassankhan/config/blob/develop/tests/Fixture/SimpleConfig.php its getDefaults() is: config/tests/Fixture/SimpleConfig.php Lines 11 to 23 in a2b9931
If you instantiate the class providing an array like this: $config = new SimpleConfig(
[
'application' => ['secret' => 'verysecret']
]
); then this will fail $this->assertEquals('configuration', $config->get('application.name')); because [
'host' => 'localhost',
'port' => 80,
'servers' => [
'host1',
'host2',
'host3'
],
'application' => [
'secret' => 's3cr3t'
]
]; just add these lines to your local copy of AbstractConfigTest and try yourself config/tests/AbstractConfigTest.php Lines 506 to 515 in c72f0f0
|
I've tried with array_merge_recursive but a lot of tests failed, see below
|
Hi @intco, thanks for the detailed response and for posting your findings. I haven't had the chance to properly look, but I think those failing test cases are mainly due to test fixtures that weren't set up for recursive merging of properties. |
currently you can not overwrite a single key (e.g. 'secret' in the test method) without overwriting the whole section (e.g. 'application' in the test method).