function UpdateScriptTest::testMaintenanceModeLink

Same name in other branches
  1. 8.9.x core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php \Drupal\Tests\system\Functional\UpdateSystem\UpdateScriptTest::testMaintenanceModeLink()
  2. 10 core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php \Drupal\Tests\system\Functional\UpdateSystem\UpdateScriptTest::testMaintenanceModeLink()
  3. 11.x core/modules/system/tests/src/Functional/UpdateSystem/UpdateScriptTest.php \Drupal\Tests\system\Functional\UpdateSystem\UpdateScriptTest::testMaintenanceModeLink()

Tests maintenance mode link on update.php.

File

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

Class

UpdateScriptTest
Tests the update script access and functionality.

Namespace

Drupal\Tests\system\Functional\UpdateSystem

Code

public function testMaintenanceModeLink() {
    $full_admin_user = $this->drupalCreateUser([
        'administer software updates',
        'access administration pages',
        'administer site configuration',
    ]);
    $this->drupalLogin($full_admin_user);
    $this->drupalGet($this->updateUrl, [
        'external' => TRUE,
    ]);
    $this->assertSession()
        ->statusCodeEquals(200);
    $this->updateRequirementsProblem();
    $this->clickLink('maintenance mode');
    $this->assertSession()
        ->statusCodeEquals(200);
    $this->assertSession()
        ->elementContains('css', 'main h1', 'Maintenance mode');
    // Now login as a user with only 'administer software updates' (but not
    // 'administer site configuration') permission and try again.
    $this->drupalLogin($this->updateUser);
    $this->drupalGet($this->updateUrl, [
        'external' => TRUE,
    ]);
    $this->assertSession()
        ->statusCodeEquals(200);
    $this->updateRequirementsProblem();
    $this->clickLink('maintenance mode');
    $this->assertSession()
        ->statusCodeEquals(200);
    $this->assertSession()
        ->elementContains('css', 'main h1', 'Maintenance mode');
}

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