You are here

public function CustomErrorAltTestCase::testAccessDeniedMessage in Customerror 7

Tests 403 pages.

File

customerroralt/customerroralt.test, line 30
Tests for the CustomErrorAlt module.

Class

CustomErrorAltTestCase
@file Tests for the CustomErrorAlt module.

Code

public function testAccessDeniedMessage() {

  // Set title and description of error message.
  $title = $this
    ->randomName(10);
  $description = $this
    ->randomName(80);
  variable_set('site_403', 'customerror/403');
  variable_set('customerror_403_authenticated_title', $title);
  variable_set('customerror_403_authenticated', $description);

  // Create and log in as authenticated user
  $this->authenticated_user = drupalCreateUser();
  $this
    ->drupalLogin($this->authenticated_user);

  // Access admin page as an authenticated user, check for response code,
  // title and description of error message.
  $this
    ->drupalGet('admin');
  $this
    ->assertResponse(403, 'Response code on 403 error page set when accessed at non-existent URL');
  $this
    ->assertText($title, 'Title on 403 error page set when accessed at non-existent URL');
  $this
    ->assertText($description, 'Description on 403 error page set when accessed at non-existent URL');
}