Commit 88345451 authored by Theresa Grannum's avatar Theresa Grannum Committed by Ted Bowman
Browse files

Issue #3277815 by Theresa.Grannum, tedbow, Shiraz Dindar, phenaproxima: Update...

Issue #3277815 by Theresa.Grannum, tedbow, Shiraz Dindar, phenaproxima: Update Extensions tab needs link to check for updates
parent 11bb19bd
Loading
Loading
Loading
Loading
+18 −2
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ use Drupal\automatic_updates_extensions\ExtensionUpdater;
use Drupal\Core\Batch\BatchBuilder;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\State\StateInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Render\RendererInterface;
use Drupal\Core\Url;
@@ -41,6 +42,13 @@ final class UpdaterForm extends FormBase {
   */
  private $eventDispatcher;

  /**
   * The state service.
   *
   * @var \Drupal\Core\State\StateInterface
   */
  private $state;

  /**
   * The renderer service.
   *
@@ -55,7 +63,8 @@ final class UpdaterForm extends FormBase {
    return new static(
      $container->get('automatic_updates_extensions.updater'),
      $container->get('event_dispatcher'),
      $container->get('renderer')
      $container->get('renderer'),
      $container->get('state')
    );
  }

@@ -68,11 +77,14 @@ final class UpdaterForm extends FormBase {
   *   The extension event dispatcher service.
   * @param \Drupal\Core\Render\RendererInterface $renderer
   *   The renderer service.
   * @param \Drupal\Core\State\StateInterface $state
   *   The state service.
   */
  public function __construct(ExtensionUpdater $extension_updater, EventDispatcherInterface $event_dispatcher, RendererInterface $renderer) {
  public function __construct(ExtensionUpdater $extension_updater, EventDispatcherInterface $event_dispatcher, RendererInterface $renderer, StateInterface $state) {
    $this->extensionUpdater = $extension_updater;
    $this->eventDispatcher = $event_dispatcher;
    $this->renderer = $renderer;
    $this->state = $state;
  }

  /**
@@ -141,6 +153,10 @@ final class UpdaterForm extends FormBase {
      $form['actions'] = $this->actions($form_state);
    }

    $form['last_check'] = [
      '#theme' => 'update_last_check',
      '#last' => $this->state->get('update.last_check', 0),
    ];
    return $form;
  }

+11 −3
Original line number Diff line number Diff line
@@ -234,13 +234,12 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase {
    $user = $this->createUser(['administer site configuration']);
    $this->drupalLogin($user);
    $this->setProjectInstalledVersion(['semver_test' => '8.1.0']);
    $this->checkForUpdates();
    $this->drupalGet('admin/reports/updates/automatic-update-extensions');
    $assert->pageTextContains('Access Denied');
    $assert->pageTextNotContains('Automatic Updates Form');
    $user = $this->createUser(['administer software updates']);
    $user = $this->createUser(['administer software updates', 'administer site configuration']);
    $this->drupalLogin($user);
    $this->drupalGet('admin/reports/updates/automatic-update-extensions');
    $this->checkForUpdates();
    $this->assertTableShowsUpdates('Semver Test', '8.1.0', '8.1.1');
    $assert->pageTextContains('Automatic Updates Form');
    $assert->buttonExists('Update');
@@ -262,6 +261,15 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase {
    $this->assertNoUpdates();
  }

  /**
   * {@inheritdoc}
   */
  protected function checkForUpdates(): void {
    $this->drupalGet('/admin/modules/automatic-update-extensions');
    $this->clickLink('Check manually');
    $this->checkForMetaRefresh();
  }

  /**
   * Test the form for errors.
   */