Skip to content

Commit 55be746

Browse files
author
Pascal Querner
committed
feat: add "asArray" test
1 parent c5330f1 commit 55be746

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

tests/unit/Mage/Core/Helper/EnvironmentConfigLoaderTest.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,46 @@ public function envOverridesCorrectConfigKeysDataProvider(): Generator
198198
]];
199199
}
200200

201+
/**
202+
* @runInSeparateProcess
203+
* @dataProvider envAsArrayDataProvider
204+
* @group Mage_Core
205+
*
206+
* @param array<string, string> $config
207+
*/
208+
public function testAsArray(array $config): void
209+
{
210+
// phpcs:ignore Ecg.Classes.ObjectInstantiation.DirectInstantiation
211+
$loader = new Mage_Core_Helper_EnvironmentConfigLoader();
212+
$loader->setEnvStore([
213+
'OPENMAGE_CONFIG_OVERRIDE_ALLOWED' => 1,
214+
$config['env_path'] => 1,
215+
]);
216+
$actual = $loader->getAsArray($config['scope']);
217+
$expected = $config['expected'];
218+
$this->assertSame($expected, $actual);
219+
}
220+
221+
public function envAsArrayDataProvider(): Generator
222+
{
223+
yield 'defaultScope' => [
224+
[
225+
'env_path' => 'OPENMAGE_CONFIG__DEFAULT__GENERAL__STORE_INFORMATION__NAME',
226+
'scope' => 'default',
227+
'expected' => [
228+
'general/store_information/name' => 1,
229+
],
230+
]
231+
];
232+
yield 'invalidScope' => [
233+
[
234+
'env_path' => '',
235+
'scope' => 'foo',
236+
'expected' => [],
237+
]
238+
];
239+
}
240+
201241
/**
202242
* @runInSeparateProcess
203243
* @dataProvider envHasPathDataProvider

0 commit comments

Comments
 (0)