Skip to content
Snippets Groups Projects
Commit 5ca5dc56 authored by Ted Bowman's avatar Ted Bowman
Browse files

Issue #3374175: automatic_updates_test_cron test module is not needed any more

parent 99a864a0
No related branches found
No related tags found
No related merge requests found
name: 'Automatic Updates Test: Cron'
type: module
description: 'Enables cron updates for testing purposes.'
package: Testing
<?php
/**
* @file
* Contains hook implementations to enable automatic updates during cron.
*
* @todo Move into automatic_updates when TUF integration is stable in
* https://www.drupal.org/i/3284443.
*/
declare(strict_types=1);
use Drupal\package_manager\ProjectInfo;
use Drupal\automatic_updates\CronUpdateStage;
use Drupal\Core\Extension\ExtensionVersion;
use Drupal\Core\Form\FormStateInterface;
use Drupal\update\ProjectSecurityData;
/**
* Implements hook_form_FORM_ID_alter() for 'update_settings' form.
*/
function automatic_updates_test_cron_form_update_settings_alter(array &$form, FormStateInterface $form_state, string $form_id) {
$project_info = new ProjectInfo('drupal');
$version = ExtensionVersion::createFromVersionString($project_info->getInstalledVersion());
$current_minor = $version->getMajorVersion() . '.' . $version->getMinorVersion();
// @todo In https://www.drupal.org/node/2998285 use the update XML to
// determine when the installed of core will become unsupported.
$supported_until_version = $version->getMajorVersion() . '.'
. ((int) $version->getMinorVersion() + ProjectSecurityData::CORE_MINORS_WITH_SECURITY_COVERAGE)
. '.0';
$form['automatic_updates_cron'] = [
'#type' => 'radios',
'#title' => t('Automatically update Drupal core'),
'#options' => [
CronUpdateStage::DISABLED => t('Disabled'),
CronUpdateStage::ALL => t('All supported updates'),
CronUpdateStage::SECURITY => t('Security updates only'),
],
'#default_value' => \Drupal::config('automatic_updates.settings')->get('unattended.level'),
'#description' => t(
'If enabled, Drupal core will be automatically updated when an update is available. Automatic updates are only supported for @current_minor.x versions of Drupal core. Drupal @current_minor will receive security updates until @supported_until_version is released.',
[
'@current_minor' => $current_minor,
'@supported_until_version' => $supported_until_version,
]
),
];
$form += [
'#submit' => ['::submitForm'],
];
$form['#submit'][] = '_automatic_updates_test_cron_update_settings_form_submit';
}
/**
* Submit function for the 'update_settings' form.
*/
function _automatic_updates_test_cron_update_settings_form_submit(array &$form, FormStateInterface $form_state) {
\Drupal::configFactory()
->getEditable('automatic_updates.settings')
->set('unattended.level', $form_state->getValue('automatic_updates_cron'))
->save();
}
......@@ -31,7 +31,6 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
/**
* @covers \Drupal\automatic_updates\CronUpdateStage
* @covers \automatic_updates_test_cron_form_update_settings_alter
* @group automatic_updates
* @internal
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment