Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
...@@ -9,6 +9,7 @@ use Drupal\automatic_updates_extensions\ExtensionUpdater; ...@@ -9,6 +9,7 @@ use Drupal\automatic_updates_extensions\ExtensionUpdater;
use Drupal\Core\Batch\BatchBuilder; use Drupal\Core\Batch\BatchBuilder;
use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\State\StateInterface;
use Drupal\Core\Messenger\MessengerInterface; use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Render\RendererInterface; use Drupal\Core\Render\RendererInterface;
use Drupal\Core\Url; use Drupal\Core\Url;
...@@ -41,6 +42,13 @@ final class UpdaterForm extends FormBase { ...@@ -41,6 +42,13 @@ final class UpdaterForm extends FormBase {
*/ */
private $eventDispatcher; private $eventDispatcher;
/**
* The state service.
*
* @var \Drupal\Core\State\StateInterface
*/
private $state;
/** /**
* The renderer service. * The renderer service.
* *
...@@ -55,7 +63,8 @@ final class UpdaterForm extends FormBase { ...@@ -55,7 +63,8 @@ final class UpdaterForm extends FormBase {
return new static( return new static(
$container->get('automatic_updates_extensions.updater'), $container->get('automatic_updates_extensions.updater'),
$container->get('event_dispatcher'), $container->get('event_dispatcher'),
$container->get('renderer') $container->get('renderer'),
$container->get('state')
); );
} }
...@@ -68,11 +77,14 @@ final class UpdaterForm extends FormBase { ...@@ -68,11 +77,14 @@ final class UpdaterForm extends FormBase {
* The extension event dispatcher service. * The extension event dispatcher service.
* @param \Drupal\Core\Render\RendererInterface $renderer * @param \Drupal\Core\Render\RendererInterface $renderer
* The renderer service. * 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->extensionUpdater = $extension_updater;
$this->eventDispatcher = $event_dispatcher; $this->eventDispatcher = $event_dispatcher;
$this->renderer = $renderer; $this->renderer = $renderer;
$this->state = $state;
} }
/** /**
...@@ -141,6 +153,10 @@ final class UpdaterForm extends FormBase { ...@@ -141,6 +153,10 @@ final class UpdaterForm extends FormBase {
$form['actions'] = $this->actions($form_state); $form['actions'] = $this->actions($form_state);
} }
$form['last_check'] = [
'#theme' => 'update_last_check',
'#last' => $this->state->get('update.last_check', 0),
];
return $form; return $form;
} }
......
...@@ -234,13 +234,12 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { ...@@ -234,13 +234,12 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase {
$user = $this->createUser(['administer site configuration']); $user = $this->createUser(['administer site configuration']);
$this->drupalLogin($user); $this->drupalLogin($user);
$this->setProjectInstalledVersion(['semver_test' => '8.1.0']); $this->setProjectInstalledVersion(['semver_test' => '8.1.0']);
$this->checkForUpdates();
$this->drupalGet('admin/reports/updates/automatic-update-extensions'); $this->drupalGet('admin/reports/updates/automatic-update-extensions');
$assert->pageTextContains('Access Denied'); $assert->pageTextContains('Access Denied');
$assert->pageTextNotContains('Automatic Updates Form'); $assert->pageTextNotContains('Automatic Updates Form');
$user = $this->createUser(['administer software updates']); $user = $this->createUser(['administer software updates', 'administer site configuration']);
$this->drupalLogin($user); $this->drupalLogin($user);
$this->drupalGet('admin/reports/updates/automatic-update-extensions'); $this->checkForUpdates();
$this->assertTableShowsUpdates('Semver Test', '8.1.0', '8.1.1'); $this->assertTableShowsUpdates('Semver Test', '8.1.0', '8.1.1');
$assert->pageTextContains('Automatic Updates Form'); $assert->pageTextContains('Automatic Updates Form');
$assert->buttonExists('Update'); $assert->buttonExists('Update');
...@@ -262,6 +261,15 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase { ...@@ -262,6 +261,15 @@ class UpdaterFormTest extends AutomaticUpdatesFunctionalTestBase {
$this->assertNoUpdates(); $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. * Test the form for errors.
*/ */
......
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