I am trying to use environment-variable-behat-params to overwrite the following value in my YAML
:
my_profile:
suites:
domain:
contexts:
- MyContext:
- my_config:
setting_setting: data
other_setting_setting: other_data
This is the export command:
export BEHAT_PARAMS='{"suites":{"domain":{"contexts":{"MyContext":{"my_config":{"my_setting":"on"}}}}}}'
And this is the PHP code:
/** @BeforeSuite */
public static function prepare(BeforeSuiteScope $scope) {
$my_settings = $scope->getEnvironment()
->getContextClassesWithArguments()['MyContext'][0];
if (isset($my_settings['my_setting']) && $my_settings['my_setting'] == 'on') {
//do something here
}
}
It seems to match the documentation, but my_setting
remains off
instead of being updated to on
.
If I try to use a key which is at the root level of my_profile
like this:
my_profile:
my_config:
setting_setting: data
With this is the export command:
export BEHAT_PARAMS='{"my_config":{"my_setting":"on"}}'
Then I get this error:
In ArrayNode.php line 311:
[Symfony\Component\Config\Definition\Exception\InvalidConfigurationException] Unrecognized option "my_settings" under "testwork"
Exception trace: Symfony\Component\Config\Definition\ArrayNode->normalizeValue() at /sites/scorecards/vendor/symfony/config/Definition/BaseNode.php:368 Symfony\Component\Config\Definition\BaseNode->normalize() at /sites/scorecards/vendor/symfony/config/Definition/Processor.php:35 Symfony\Component\Config\Definition\Processor->process() at /sites/scorecards/vendor/behat/behat/src/Behat/Testwork/ServiceContainer/ContainerLoader.php:81 Behat\Testwork\ServiceContainer\ContainerLoader->processConfig() at /sites/scorecards/vendor/behat/behat/src/Behat/Testwork/ServiceContainer/ContainerLoader.php:65 Behat\Testwork\ServiceContainer\ContainerLoader->load() at /sites/scorecards/vendor/behat/behat/src/Behat/Testwork/Cli/Application.php:185 Behat\Testwork\Cli\Application->createContainer() at /sites/scorecards/vendor/behat/behat/src/Behat/Testwork/Cli/Application.php:161 Behat\Testwork\Cli\Application->createCommand() at /sites/scorecards/vendor/behat/behat/src/Behat/Testwork/Cli/Application.php:122 Behat\Testwork\Cli\Application->doRun() at /sites/scorecards/vendor/symfony/console/Application.php:148 Symfony\Component\Console\Application->run() at /sites/scorecards/vendor/behat/behat/bin/behat:34
.. how can I fix this?
DomainContext
on you env variable and then looking forMyContext
in your code, could it be that? – gvf