You are here

public function UpdateCoreTest::testNormalUpdateAvailable in Drupal 8

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

File

core/modules/update/tests/src/Functional/UpdateCoreTest.php, line 100

Class

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

Namespace

Drupal\Tests\update\Functional

Code

public function testNormalUpdateAvailable() {
  $this
    ->setSystemInfo('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([
        'drupal' => "{$minor_version}.1" . $extra_version,
      ]);
      $this
        ->standardTests();
      $this
        ->drupalGet('admin/reports/updates');
      $this
        ->clickLink(t('Check manually'));
      $this
        ->checkForMetaRefresh();
      $this
        ->assertNoText(t('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
        ->assertNoRaw('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
              ->assertNoText(t('Up to date'));
            $this
              ->assertText(t('Update available'));
            $this
              ->assertVersionUpdateLinks('Recommended version:', $full_version);
            $this
              ->assertNoText(t('Latest version:'));
            $this
              ->assertRaw('warning.svg', 'Warning icon was found.');
          }
          else {
            $this
              ->assertText(t('Up to date'));
            $this
              ->assertNoText(t('Update available'));
            $this
              ->assertNoText(t('Recommended version:'));
            $this
              ->assertVersionUpdateLinks('Latest version:', $full_version);
            $this
              ->assertRaw('check.svg', 'Check icon was found.');
          }
          break;
        case 1:

          // Both stable and unstable releases are available.
          // A stable release is the latest.
          if ($extra_version == '') {
            $this
              ->assertNoText(t('Up to date'));
            $this
              ->assertText(t('Update available'));
            $this
              ->assertVersionUpdateLinks('Recommended version:', $full_version);
            $this
              ->assertNoText(t('Latest version:'));
            $this
              ->assertRaw('warning.svg', 'Warning icon was found.');
          }
          else {
            $this
              ->assertNoText(t('Up to date'));
            $this
              ->assertText(t('Update available'));
            $this
              ->assertVersionUpdateLinks('Recommended version:', '8.1.0');
            $this
              ->assertVersionUpdateLinks('Latest version:', $full_version);
            $this
              ->assertRaw('warning.svg', 'Warning icon was found.');
          }
          break;
      }
    }
  }
}