You are here

public function UpdateSemverCoreTest::testModulePageSecurityUpdate in Drupal 10

Same name and namespace in other branches
  1. 9 core/modules/update/tests/src/Functional/UpdateSemverCoreTest.php \Drupal\Tests\update\Functional\UpdateSemverCoreTest::testModulePageSecurityUpdate()

Checks the messages at admin/modules when a security update is missing.

File

core/modules/update/tests/src/Functional/UpdateSemverCoreTest.php, line 395

Class

UpdateSemverCoreTest
Tests the Update Manager module through a series of functional tests using mock XML data.

Namespace

Drupal\Tests\update\Functional

Code

public function testModulePageSecurityUpdate() {
  $this
    ->drupalLogin($this
    ->drupalCreateUser([
    'administer site configuration',
    'administer modules',
    'administer themes',
    'view update notifications',
  ]));
  $this
    ->setProjectInstalledVersion('8.0.0');

  // Instead of using refreshUpdateStatus(), set these manually.
  $this
    ->config('update.settings')
    ->set('fetch.url', Url::fromRoute('update_test.update_test')
    ->setAbsolute()
    ->toString())
    ->save();
  $this
    ->config('update_test.settings')
    ->set('xml_map', [
    'drupal' => 'sec.0.2',
  ])
    ->save();
  $this
    ->drupalGet('admin/reports/updates');
  $this
    ->clickLink('Check manually');
  $this
    ->checkForMetaRefresh();
  $this
    ->assertSession()
    ->pageTextContains('Checked available update data for one project.');
  $this
    ->drupalGet('admin/modules');
  $this
    ->assertSession()
    ->pageTextNotContains('There are updates available for your version of Drupal.');
  $this
    ->assertSession()
    ->pageTextContains('There is a security update available for your version of Drupal.');

  // Make sure admin/appearance warns you you're missing a security update.
  $this
    ->drupalGet('admin/appearance');
  $this
    ->assertSession()
    ->pageTextNotContains('There are updates available for your version of Drupal.');
  $this
    ->assertSession()
    ->pageTextContains('There is a security update available for your version of Drupal.');

  // Make sure duplicate messages don't appear on Update status pages.
  $this
    ->drupalGet('admin/reports/status');
  $this
    ->assertSession()
    ->pageTextContainsOnce('There is a security update available for your version of Drupal.');
  $this
    ->drupalGet('admin/reports/updates');
  $this
    ->assertSession()
    ->pageTextNotContains('There is a security update available for your version of Drupal.');
  $this
    ->drupalGet('admin/reports/updates/settings');
  $this
    ->assertSession()
    ->pageTextNotContains('There is a security update available for your version of Drupal.');
}