You are here

public function UpdateScriptTest::testNoUpdateFunctionality in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php \Drupal\Tests\system\Functional\UpdateSystem\UpdateScriptTest::testNoUpdateFunctionality()
  2. 10 core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php \Drupal\Tests\system\Functional\UpdateSystem\UpdateScriptTest::testNoUpdateFunctionality()

Tests update.php when there are no updates to apply.

File

core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php, line 515

Class

UpdateScriptTest
Tests the update script access and functionality.

Namespace

Drupal\Tests\system\Functional\UpdateSystem

Code

public function testNoUpdateFunctionality() {

  // Click through update.php with 'administer software updates' permission.
  $this
    ->drupalLogin($this->updateUser);
  $this
    ->drupalGet($this->updateUrl, [
    'external' => TRUE,
  ]);
  $this
    ->updateRequirementsProblem();
  $this
    ->clickLink(t('Continue'));
  $this
    ->assertText(t('No pending updates.'));
  $this
    ->assertSession()
    ->linkNotExists('Administration pages');
  $this
    ->assertEmpty($this
    ->xpath('//main//a[contains(@href, :href)]', [
    ':href' => 'update.php',
  ]));
  $this
    ->clickLink('Front page');
  $this
    ->assertSession()
    ->statusCodeEquals(200);

  // Click through update.php with 'access administration pages' permission.
  $admin_user = $this
    ->drupalCreateUser([
    'administer software updates',
    'access administration pages',
  ]);
  $this
    ->drupalLogin($admin_user);
  $this
    ->drupalGet($this->updateUrl, [
    'external' => TRUE,
  ]);
  $this
    ->updateRequirementsProblem();
  $this
    ->clickLink(t('Continue'));
  $this
    ->assertText(t('No pending updates.'));
  $this
    ->assertSession()
    ->linkExists('Administration pages');
  $this
    ->assertEmpty($this
    ->xpath('//main//a[contains(@href, :href)]', [
    ':href' => 'update.php',
  ]));
  $this
    ->clickLink('Administration pages');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
}