You are here

public function UpdateSemverTestBase::testMajorUpdateAvailable in Drupal 9

Tests the Update Manager module when a major update is available.

File

core/modules/update/tests/src/Functional/UpdateSemverTestBase.php, line 154

Class

UpdateSemverTestBase
Common test methods for projects that use semver version releases.

Namespace

Drupal\Tests\update\Functional

Code

public function testMajorUpdateAvailable() {
  foreach ([
    0,
    1,
  ] as $minor_version) {
    foreach ([
      0,
      1,
    ] as $patch_version) {
      foreach ([
        '-alpha1',
        '-beta1',
        '',
      ] as $extra_version) {
        $this
          ->setProjectInstalledVersion("8.{$minor_version}.{$patch_version}" . $extra_version);
        $this
          ->refreshUpdateStatus([
          $this->updateProject => '9',
        ]);
        $this
          ->standardTests();
        $this
          ->drupalGet('admin/reports/updates');
        $this
          ->clickLink('Check manually');
        $this
          ->checkForMetaRefresh();
        $this
          ->assertUpdateTableTextNotContains('Security update required!');
        $this
          ->assertUpdateTableElementContains(Link::fromTextAndUrl('9.0.0', Url::fromUri("http://example.com/{$this->updateProject}-9-0-0-release"))
          ->toString());
        $this
          ->assertUpdateTableElementContains(Link::fromTextAndUrl('Download', Url::fromUri("http://example.com/{$this->updateProject}-9-0-0.tar.gz"))
          ->toString());
        $this
          ->assertUpdateTableElementContains(Link::fromTextAndUrl('Release notes', Url::fromUri("http://example.com/{$this->updateProject}-9-0-0-release"))
          ->toString());
        $this
          ->assertUpdateTableTextNotContains('Up to date');
        $this
          ->assertUpdateTableTextContains('Not supported!');
        $this
          ->assertUpdateTableTextContains('Recommended version:');
        $this
          ->assertUpdateTableTextNotContains('Latest version:');
        $this
          ->assertUpdateTableElementContains('error.svg');
      }
    }
  }
}