You are here

DisplayAccessDeniedMessageTest.php in Redirect 403 to User Login 8

Same filename and directory in other branches
  1. 2.x tests/src/Functional/DisplayAccessDeniedMessageTest.php

File

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

namespace Drupal\Tests\r4032login\Functional;

use Drupal\Tests\BrowserTestBase;

/**
 * Test that it is possible to change the "User login access denied" message.
 *
 * @group r4032login
 */
class DisplayAccessDeniedMessageTest extends BrowserTestBase {

  /**
   * {@inheritdoc}
   */
  protected static $modules = [
    'r4032login',
  ];

  /**
   * Test activation and deactivation of the "User login access denied" message.
   *
   * @throws \Behat\Mink\Exception\ExpectationException
   */
  public function testDisplayAccessDeniedMessage() {
    $config = $this
      ->config('r4032login.settings');
    $config
      ->set('display_denied_message', TRUE);
    $config
      ->save();
    $this
      ->drupalGet('admin/config');
    $this
      ->assertSession()
      ->elementTextContains('css', '.messages', 'Access denied. You must log in to view this page.');
    $config = $this
      ->config('r4032login.settings');
    $config
      ->set('display_denied_message', FALSE);
    $config
      ->save();
    $this
      ->drupalGet('admin/config');
    $this
      ->assertSession()
      ->elementNotExists('css', '.messages');
  }

}

Classes

Namesort descending Description
DisplayAccessDeniedMessageTest Test that it is possible to change the "User login access denied" message.