You are here

public function UpdateScriptTest::testNoUpdateFunctionality in Drupal 9

Same name and namespace in other branches
  1. 8 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 504

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('Continue');
  $this
    ->assertSession()
    ->pageTextContains('No pending updates.');
  $this
    ->assertSession()
    ->linkNotExists('Administration pages');
  $this
    ->assertSession()
    ->elementNotExists('xpath', '//main//a[contains(@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('Continue');
  $this
    ->assertSession()
    ->pageTextContains('No pending updates.');
  $this
    ->assertSession()
    ->linkExists('Administration pages');
  $this
    ->assertSession()
    ->elementNotExists('xpath', '//main//a[contains(@href, "update.php")]');
  $this
    ->clickLink('Administration pages');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
}