Skip to content

Commit 0b1dc9a

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

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

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

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

211+
/**
212+
* @runInSeparateProcess
213+
* @dataProvider envHasPathDataProvider
214+
* @group Mage_Core
215+
*
216+
* @param array<string, string> $config
217+
*/
218+
public function testHasPath(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->hasPath($config['xml_path']);
227+
$expected = $config['expected'];
228+
$this->assertSame($expected, $actual);
229+
}
230+
231+
public function envHasPathDataProvider(): Generator
232+
{
233+
yield 'hasPath' => [
234+
[
235+
'env_path' => 'OPENMAGE_CONFIG__DEFAULT__GENERAL__STORE_INFORMATION__NAME',
236+
'xml_path' => 'default/general/store_information/name',
237+
'expected' => true,
238+
]
239+
];
240+
yield 'hasNotPath' => [
241+
[
242+
'env_path' => 'OPENMAGE_CONFIG__DEFAULT__GENERAL__STORE_INFORMATION__NAME',
243+
'xml_path' => 'foo/foo/foo',
244+
'expected' => false,
245+
]
246+
];
247+
}
248+
211249
/**
212250
* @runInSeparateProcess
213251
* @dataProvider envDoesNotOverrideOnWrongConfigKeysDataProvider

0 commit comments

Comments
 (0)