You are here

public function ReadonlymodeTest::testReadOnlyModeEnabled in Read only mode 2.0.x

Same name and namespace in other branches
  1. 8 tests/src/Functional/ReadonlymodeTest.php \Drupal\Tests\readonlymode\Functional\ReadOnlyModeTest::testReadOnlyModeEnabled()

File

tests/src/Functional/ReadonlymodeTest.php, line 34

Class

ReadonlymodeTest
Functional readonly mode test.

Namespace

Drupal\Tests\readonlymode\Functional

Code

public function testReadOnlyModeEnabled() {

  // Log in as admin.
  $account = $this
    ->drupalCreateUser([], [], TRUE);
  $this
    ->drupalLogin($account);
  $this
    ->drupalGet('admin/config/development/maintenance');
  $this
    ->assertSession()
    ->responseContains('Read Only Mode');

  // Turn on the read-only mode.
  $page = $this
    ->getSession()
    ->getPage();
  $page
    ->findField('enable_readonly')
    ->setValue(TRUE);
  $page
    ->findButton('Save configuration')
    ->press();
  $this
    ->assertSession()
    ->responseContains('The configuration options have been saved.');

  // This is the default configuration.
  $this
    ->assertSession()
    ->responseContains('Drupal is currently under maintenance. During this maintenance it is not possible to change site content (like comments, pages and users).');
}