I write a test using Drupal\simpletest\WebTestBase for a custom module, which implements hook_cron(). The test saves a configuration object, which should be used by the cron, and then runs the cron:
function testCron()
{
$config = \Drupal::service('config.factory')->getEditable('mymodule.settings');
$config
->set('some_setting', 'some value')
->set('another_setting', 'another value');
\Drupal::service('cron')->run();
}
The settings are saved and can be used during the test. But when I want to use them in the cron (in mymodule.module):
/**
* Implements hook_cron().
*/
function mymodule_cron()
{
$config = \Drupal::config('mymodule.settings');
...
}
then instead of the saved values, the default settings from config/import/mymodule.settings.yml are used.
How can I force the cron to use the settings saved in the test?