Skip to content

Commit c5330f1

Browse files
author
Pascal Querner
committed
feat: add "hasPath" test
1 parent b9de406 commit c5330f1

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

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

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

201+
/**
202+
* @runInSeparateProcess
203+
* @dataProvider envHasPathDataProvider
204+
* @group Mage_Core
205+
*
206+
* @param array<string, string> $config
207+
*/
208+
public function testHasPath(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->hasPath($config['xml_path']);
217+
$expected = $config['expected'];
218+
$this->assertSame($expected, $actual);
219+
}
220+
221+
public function envHasPathDataProvider(): Generator
222+
{
223+
yield 'hasPath' => [
224+
[
225+
'env_path' => 'OPENMAGE_CONFIG__DEFAULT__GENERAL__STORE_INFORMATION__NAME',
226+
'xml_path' => 'default/general/store_information/name',
227+
'expected' => true,
228+
]
229+
];
230+
yield 'hasNotPath' => [
231+
[
232+
'env_path' => 'OPENMAGE_CONFIG__DEFAULT__GENERAL__STORE_INFORMATION__NAME',
233+
'xml_path' => 'foo/foo/foo',
234+
'expected' => false,
235+
]
236+
];
237+
}
238+
201239
/**
202240
* @runInSeparateProcess
203241
* @dataProvider envDoesNotOverrideOnWrongConfigKeysDataProvider

0 commit comments

Comments
 (0)