You are here

ReadonlymodeTest.php in Read only mode 2.0.x

Same filename and directory in other branches
  1. 8 tests/src/Functional/ReadonlymodeTest.php

File

tests/src/Functional/ReadonlymodeTest.php
View source
<?php

namespace Drupal\Tests\readonlymode\Functional;

use Drupal\Tests\BrowserTestBase;

/**
 * Functional readonly mode test.
 *
 * @group readonlymode
 */
class ReadonlymodeTest extends BrowserTestBase {

  /**
   * Modules to enable.
   *
   * @var array
   */
  public static $modules = [
    'readonlymode',
  ];

  /**
   * {@inheritdoc}
   */
  protected $profile = 'minimal';

  /**
   * {@inheritdoc}
   */
  protected $defaultTheme = 'stark';

  /**
   * {@inheritdoc}
   */
  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).');
  }

}

Classes

Namesort descending Description
ReadonlymodeTest Functional readonly mode test.