add array replace feature

This commit is contained in:
sunxyw
2022-08-23 15:37:31 +08:00
parent 5d8a1deb35
commit afa6411004
2 changed files with 14 additions and 2 deletions

View File

@@ -44,6 +44,9 @@ class RefactoredConfigTest extends TestCase
'b.c' => 'd',
],
'global' => 'yes',
'another array' => [
'foo', 'bar',
],
];
// 下方测试需要临时写入的文件
@@ -58,7 +61,7 @@ class RefactoredConfigTest extends TestCase
);
file_put_contents(
$mock_dir . '/test.patch.php',
'<?php return ["patch" => "yes"];'
'<?php return ["patch" => "yes", "another array" => ["far", "baz"]];'
);
$config = new RefactoredConfig([
@@ -158,4 +161,11 @@ class RefactoredConfigTest extends TestCase
'invalid' => ['test.patch.development', 'undefined'],
];
}
public function testArrayReplaceInsteadOfMerge(): void
{
// using of space inside config key is not an officially supported feature,
// it may be removed in the future, please avoid using it in your project.
$this->assertSame(['far', 'baz'], self::$config->get('test.another array'));
}
}