Skip to content
Snippets Groups Projects

Issue #3285631: Make it impossible to call CronUpdater::begin() directly

Merged Issue #3285631: Make it impossible to call CronUpdater::begin() directly
All threads resolved!
All threads resolved!
1 file
+ 15
30
Compare changes
  • Side-by-side
  • Inline
@@ -217,7 +217,6 @@ class VersionPolicyValidatorTest extends AutomaticUpdatesKernelTestBase {
'valid target, dev snapshot installed' => [
'9.8.0-dev',
"$metadata_dir/drupal.9.8.1-security.xml",
[CronUpdater::SECURITY, CronUpdater::ALL],
['drupal' => '9.8.1'],
[
$this->createValidationResult('9.8.0-dev', '9.8.1', [
@@ -230,7 +229,6 @@ class VersionPolicyValidatorTest extends AutomaticUpdatesKernelTestBase {
'downgrade' => [
'9.8.1',
"$metadata_dir/drupal.9.8.2.xml",
[CronUpdater::SECURITY, CronUpdater::ALL],
['drupal' => '9.8.0'],
[
$this->createValidationResult('9.8.1', '9.8.0', [
@@ -241,7 +239,6 @@ class VersionPolicyValidatorTest extends AutomaticUpdatesKernelTestBase {
'major version upgrade' => [
'8.9.1',
"$metadata_dir/drupal.9.8.2.xml",
[CronUpdater::SECURITY, CronUpdater::ALL],
['drupal' => '9.8.2'],
[
$this->createValidationResult('8.9.1', '9.8.2', [
@@ -252,7 +249,6 @@ class VersionPolicyValidatorTest extends AutomaticUpdatesKernelTestBase {
'unsupported target version' => [
'9.8.0',
"$metadata_dir/drupal.9.8.2-unsupported_unpublished.xml",
[CronUpdater::SECURITY, CronUpdater::ALL],
['drupal' => '9.8.1'],
[
$this->createValidationResult('9.8.0', '9.8.1', [
@@ -265,7 +261,6 @@ class VersionPolicyValidatorTest extends AutomaticUpdatesKernelTestBase {
'attended update to normal release' => [
'9.8.1',
"$metadata_dir/drupal.9.8.2.xml",
[CronUpdater::SECURITY, CronUpdater::ALL],
['drupal' => '9.8.2'],
[],
],
@@ -275,7 +270,6 @@ class VersionPolicyValidatorTest extends AutomaticUpdatesKernelTestBase {
'attended update to next minor not allowed' => [
'9.7.9',
"$metadata_dir/drupal.9.8.2.xml",
[CronUpdater::SECURITY, CronUpdater::ALL],
['drupal' => '9.8.2'],
[
$this->createValidationResult('9.7.9', '9.8.2', [
@@ -286,7 +280,6 @@ class VersionPolicyValidatorTest extends AutomaticUpdatesKernelTestBase {
'attended update to next minor allowed' => [
'9.7.9',
"$metadata_dir/drupal.9.8.2.xml",
[CronUpdater::SECURITY, CronUpdater::ALL],
['drupal' => '9.8.2'],
[],
TRUE,
@@ -296,7 +289,6 @@ class VersionPolicyValidatorTest extends AutomaticUpdatesKernelTestBase {
'attended update from unsupported minor allowed' => [
'9.7.9',
"$metadata_dir/drupal.9.8.1-security.xml",
[CronUpdater::SECURITY, CronUpdater::ALL],
['drupal' => '9.8.1'],
[],
TRUE,
@@ -311,10 +303,6 @@ class VersionPolicyValidatorTest extends AutomaticUpdatesKernelTestBase {
* The installed version of Drupal core.
* @param string $release_metadata
* The path of the core release metadata to serve to the update system.
* @param string[] $cron_modes
* The modes for unattended updates. Can contain
* \Drupal\automatic_updates\CronUpdater::SECURITY or
* \Drupal\automatic_updates\CronUpdater::ALL.
* @param string[] $project_versions
* The desired project versions that should be passed to the updater.
* @param \Drupal\package_manager\ValidationResult[] $expected_results
@@ -325,29 +313,26 @@ class VersionPolicyValidatorTest extends AutomaticUpdatesKernelTestBase {
*
* @dataProvider providerApi
*/
public function testApi(string $installed_version, string $release_metadata, array $cron_modes, array $project_versions, array $expected_results, bool $allow_minor_updates = FALSE): void {
public function testApi(string $installed_version, string $release_metadata, array $project_versions, array $expected_results, bool $allow_minor_updates = FALSE): void {
$this->setCoreVersion($installed_version);
$this->setReleaseMetadata(['drupal' => $release_metadata]);
foreach ($cron_modes as $cron_mode) {
$this->config('automatic_updates.settings')
->set('cron', $cron_mode)
->set('allow_core_minor_updates', $allow_minor_updates)
->save();
$this->config('automatic_updates.settings')
->set('allow_core_minor_updates', $allow_minor_updates)
->save();
/** @var \Drupal\automatic_updates\Updater $updater */
$updater = $this->container->get('automatic_updates.updater');
/** @var \Drupal\automatic_updates\Updater $updater */
$updater = $this->container->get('automatic_updates.updater');
try {
$updater->begin($project_versions);
// Ensure that we did not, in fact, expect any errors.
$this->assertEmpty($expected_results);
// Reset the updater for the next iteration of the loop.
$updater->destroy();
}
catch (StageValidationException $e) {
$this->assertValidationResultsEqual($expected_results, $e->getResults());
}
try {
$updater->begin($project_versions);
// Ensure that we did not, in fact, expect any errors.
$this->assertEmpty($expected_results);
// Reset the updater for the next iteration of the loop.
$updater->destroy();
}
catch (StageValidationException $e) {
$this->assertValidationResultsEqual($expected_results, $e->getResults());
}
}
Loading