Skip to content

Commit 8cfee33

Browse files
committed
fix: add test
1 parent 9260215 commit 8cfee33

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

system/Config/BaseConfig.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,8 @@ protected function registerProperties()
246246
if (static::$discovering) {
247247
throw new ConfigException(
248248
'During Auto-Discovery of Registrars,'
249-
. ' "' . static::class . '" executes Auto-Discovery again.'
250-
. ' "' . clean_path(static::$registrarFile) . '" seems to have bad code.',
249+
. ' "' . static::class . '" executes Auto-Discovery again.'
250+
. ' "' . clean_path(static::$registrarFile) . '" seems to have bad code.',
251251
);
252252
}
253253

@@ -291,7 +291,7 @@ protected function registerProperties()
291291

292292
foreach ($properties as $property => $value) {
293293
if (isset($this->{$property}) && is_array($this->{$property}) && is_array($value)) {
294-
$this->{$property} = array_replace_recursive($this->{$property}, $value);
294+
$this->{$property} = array_merge_recursive($this->{$property}, $value);
295295
} else {
296296
$this->{$property} = $value;
297297
}

tests/_support/Config/TestRegistrar.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ public static function RegistrarConfig()
2727
'first',
2828
'second',
2929
],
30+
'baz' => [
31+
'bar' => 'ber'
32+
]
3033
];
3134
}
3235
}

tests/system/Config/BaseConfigTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,9 @@ public function testRegistrars(): void
270270
$this->assertSame('bar', $config->foo);
271271
// add to an existing array property
272272
$this->assertSame(['baz', 'first', 'second'], $config->bar);
273+
274+
// add to an existing nested array property
275+
$this->assertSame(['foo', 'bar' => ['bir', 'bur', 'ber']], $config->baz);
273276
}
274277

275278
public function testBadRegistrar(): void

tests/system/Config/fixtures/RegistrarConfig.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,11 @@ class RegistrarConfig extends BaseConfig
1919
public $bar = [
2020
'baz',
2121
];
22+
public $baz = [
23+
'foo',
24+
'bar' => [
25+
'bir',
26+
'bur'
27+
]
28+
];
2229
}

0 commit comments

Comments
 (0)