diff --git a/core/modules/system/src/Tests/Update/AutomatedCronUpdateWithAutomaticCronTest.php b/core/modules/system/src/Tests/Update/AutomatedCronUpdateWithAutomaticCronTest.php new file mode 100644 index 0000000..d0c6eca --- /dev/null +++ b/core/modules/system/src/Tests/Update/AutomatedCronUpdateWithAutomaticCronTest.php @@ -0,0 +1,35 @@ +databaseDumpFiles = [ + __DIR__ . '/../../../tests/fixtures/update/drupal-8.bare.standard.php.gz', + __DIR__ . '/../../../tests/fixtures/update/drupal-8.automated_cron.php', + ]; + } + + /** + * Ensures that automatic cron module isn installed and the config migrated. + */ + public function testUpdate() { + $this->runUpdates(); + $this->assertTrue(\Drupal::moduleHandler()->moduleExists('automatic_cron'), 'The automatic cron module is enabled'); + } + +} diff --git a/core/modules/system/src/Tests/Update/AutomatedCronUpdateWithoutAutomaticCronTest.php b/core/modules/system/src/Tests/Update/AutomatedCronUpdateWithoutAutomaticCronTest.php new file mode 100644 index 0000000..0deed8a --- /dev/null +++ b/core/modules/system/src/Tests/Update/AutomatedCronUpdateWithoutAutomaticCronTest.php @@ -0,0 +1,34 @@ +databaseDumpFiles = [ + __DIR__ . '/../../../tests/fixtures/update/drupal-8.bare.standard.php.gz', + ]; + } + + /** + * Ensures that automatic cron module isn't installed and the config migrated. + */ + public function testUpdate() { + $this->runUpdates(); + $this->assertFalse(\Drupal::moduleHandler()->moduleExists('automatic_cron'), 'The automatic cron module is enabled'); + } + +} diff --git a/core/modules/system/src/Tests/Update/UpdatePathTestBase.php b/core/modules/system/src/Tests/Update/UpdatePathTestBase.php index 5fae5a0..e5780a1 100644 --- a/core/modules/system/src/Tests/Update/UpdatePathTestBase.php +++ b/core/modules/system/src/Tests/Update/UpdatePathTestBase.php @@ -263,6 +263,7 @@ protected function runUpdates() { $names = $this->container->get('config.storage')->listAll(); /** @var \Drupal\Core\Config\TypedConfigManagerInterface $typed_config */ $typed_config = $this->container->get('config.typed'); + $typed_config->clearCachedDefinitions(); foreach ($names as $name) { $config = $this->config($name); $this->assertConfigSchema($typed_config, $name, $config->get()); diff --git a/core/modules/system/system.install b/core/modules/system/system.install index 836c00b..402490c 100644 --- a/core/modules/system/system.install +++ b/core/modules/system/system.install @@ -1647,9 +1647,8 @@ function system_update_8007() { */ function system_update_8008() { $config_factory = \Drupal::configFactory(); - $autorun = \Drupal::config('system.cron')->get('threshold.autorun'); - - if ($autorun) { + $system_cron_config = $config_factory->getEditable('system.cron'); + if ($autorun = $system_cron_config->get('threshold.autorun')) { // Enable 'automated_cron' module. \Drupal::service('module_installer')->install(['automated_cron'], FALSE); @@ -1660,7 +1659,7 @@ function system_update_8008() { } // Remove the 'autorun' key in system module config. - $config_factory->getEditable('system.cron') + $system_cron_config ->clear('threshold.autorun') ->save(TRUE); } diff --git a/core/modules/system/tests/fixtures/update/drupal-8.automated_cron.php b/core/modules/system/tests/fixtures/update/drupal-8.automated_cron.php new file mode 100644 index 0000000..12cd1cf --- /dev/null +++ b/core/modules/system/tests/fixtures/update/drupal-8.automated_cron.php @@ -0,0 +1,14 @@ +merge('config') + ->condition('name', 'system.cron') + ->condition('collection', '') + ->fields([ + 'name' => 'system.cron', + 'collection' => '', + 'data' => serialize(['threshold' => ['autorun' => 10]]), + ]) + ->execute();