You are here

function UpdateCoreTest::testNormalUpdateAvailable in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/update/src/Tests/UpdateCoreTest.php \Drupal\update\Tests\UpdateCoreTest::testNormalUpdateAvailable()

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

File

core/modules/update/src/Tests/UpdateCoreTest.php, line 71
Contains \Drupal\update\Tests\UpdateCoreTest.

Class

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

Namespace

Drupal\update\Tests

Code

function testNormalUpdateAvailable() {
  $this
    ->setSystemInfo('8.0.0');
  foreach (array(
    0,
    1,
  ) as $minor_version) {
    foreach (array(
      '-alpha1',
      '-beta1',
      '',
    ) as $extra_version) {
      $this
        ->refreshUpdateStatus(array(
        'drupal' => "{$minor_version}.1" . $extra_version,
      ));
      $this
        ->standardTests();
      $this
        ->drupalGet('admin/reports/updates/check');
      $this
        ->assertNoText(t('Security update required!'));
      $this
        ->assertRaw(\Drupal::l("8.{$minor_version}.1" . $extra_version, Url::fromUri("http://example.com/drupal-8-{$minor_version}-1{$extra_version}-release")), 'Link to release appears.');
      $this
        ->assertRaw(\Drupal::l(t('Download'), Url::fromUri("http://example.com/drupal-8-{$minor_version}-1{$extra_version}.tar.gz")), 'Link to download appears.');
      $this
        ->assertRaw(\Drupal::l(t('Release notes'), Url::fromUri("http://example.com/drupal-8-{$minor_version}-1{$extra_version}-release")), 'Link to release notes appears.');
      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
              ->assertText(t('Recommended 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
              ->assertText(t('Latest 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
              ->assertText(t('Recommended 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
              ->assertText(t('Recommended version:'));
            $this
              ->assertText(t('Latest version:'));
            $this
              ->assertRaw('warning.svg', 'Warning icon was found.');
          }
          break;
      }
    }
  }
}