function UpdateSemverTestBaselineTrait::testNormalUpdateAvailable

Same name and namespace in other branches
  1. 11.x core/modules/update/tests/src/Functional/UpdateSemverTestBaselineTrait.php \Drupal\Tests\update\Functional\UpdateSemverTestBaselineTrait::testNormalUpdateAvailable()

Tests the Update Manager module when one normal update is available.

File

core/modules/update/tests/src/Functional/UpdateSemverTestBaselineTrait.php, line 51

Class

UpdateSemverTestBaselineTrait
Provides test methods for semver tests shared between core and contrib.

Namespace

Drupal\Tests\update\Functional

Code

public function testNormalUpdateAvailable() : void {
  $this->setProjectInstalledVersion('8.0.0');
  // Ensure that the update check requires a token.
  $this->drupalGet('admin/reports/updates/check');
  $this->assertSession()
    ->statusCodeEquals(403);
  foreach ([
    0,
    1,
  ] as $minor_version) {
    foreach ([
      '-alpha1',
      '-beta1',
      '',
    ] as $extra_version) {
      $full_version = "8.{$minor_version}.1{$extra_version}";
      $this->refreshUpdateStatus([
        $this->updateProject => "8.{$minor_version}.1" . $extra_version,
      ]);
      $this->standardTests();
      $this->assertUpdateTableTextNotContains('Security update required!');
      // The XML test fixtures for this method all contain the '8.2.0' release
      // but because '8.2.0' is not in a supported branch it will not be in
      // the available updates.
      $this->assertSession()
        ->responseNotContains('8.2.0');
      switch ($minor_version) {
        case 0:
          // Both stable and unstable releases are available.
          // A stable release is the latest.
          if ($extra_version == '') {
            $this->assertNoExtraVersion($full_version);
          }
          else {
            $this->assertUpdateTableTextContains('Up to date');
            $this->assertUpdateTableTextNotContains('Update available');
            $this->assertUpdateTableTextNotContains('Recommended version:');
            $this->assertVersionUpdateLinks('Latest version:', $full_version);
            $this->assertUpdateTableElementContains('check.svg');
          }
          break;

        case 1:
          // Both stable and unstable releases are available.
          // A stable release is the latest.
          if ($extra_version == '') {
            $this->assertNoExtraVersion($full_version);
          }
          else {
            $this->assertUpdateTableTextNotContains('Up to date');
            $this->assertUpdateTableTextContains('Update available');
            $this->assertVersionUpdateLinks('Recommended version:', '8.1.0');
            $this->assertVersionUpdateLinks('Latest version:', $full_version);
            $this->assertUpdateTableElementContains('warning.svg');
          }
          break;

      }
    }
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.