You are here

public function CustomErrorTestCase::testAccessDeniedMessage in Customerror 7

Tests 403 pages.

File

./customerror.test, line 57
Tests for the CustomError module.

Class

CustomErrorTestCase
@file Tests for the CustomError 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_title', $title);
  variable_set('customerror_403', $description);

  // Access error page directly, check for response code, title
  // and description of error message.
  $this
    ->drupalGet('customerror/403');
  $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 directly');
  $this
    ->assertText($description, 'Description on 403 error page set when accessed directly');

  // Access admin page as an anonymous 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');
}