Skip to content

Commit bae16d3

Browse files
author
Pascal Querner
committed
feat: add "asArray" test
1 parent 0b1dc9a commit bae16d3

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

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

+40
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,46 @@ public function envOverridesCorrectConfigKeysDataProvider(): Generator
208208
]];
209209
}
210210

211+
/**
212+
* @runInSeparateProcess
213+
* @dataProvider envAsArrayDataProvider
214+
* @group Mage_Core
215+
*
216+
* @param array<string, string> $config
217+
*/
218+
public function testAsArray(array $config): void
219+
{
220+
// phpcs:ignore Ecg.Classes.ObjectInstantiation.DirectInstantiation
221+
$loader = new Mage_Core_Helper_EnvironmentConfigLoader();
222+
$loader->setEnvStore([
223+
'OPENMAGE_CONFIG_OVERRIDE_ALLOWED' => 1,
224+
$config['env_path'] => 1,
225+
]);
226+
$actual = $loader->getAsArray($config['scope']);
227+
$expected = $config['expected'];
228+
$this->assertSame($expected, $actual);
229+
}
230+
231+
public function envAsArrayDataProvider(): Generator
232+
{
233+
yield 'defaultScope' => [
234+
[
235+
'env_path' => 'OPENMAGE_CONFIG__DEFAULT__GENERAL__STORE_INFORMATION__NAME',
236+
'scope' => 'default',
237+
'expected' => [
238+
'general/store_information/name' => 1,
239+
],
240+
]
241+
];
242+
yield 'invalidScope' => [
243+
[
244+
'env_path' => '',
245+
'scope' => 'foo',
246+
'expected' => [],
247+
]
248+
];
249+
}
250+
211251
/**
212252
* @runInSeparateProcess
213253
* @dataProvider envHasPathDataProvider

0 commit comments

Comments
 (0)