59 lines
2 KiB
Text
59 lines
2 KiB
Text
<?php
|
|
|
|
/**
|
|
* @file
|
|
* Automated tests CustomError.
|
|
*/
|
|
|
|
class CustomerrorAccessDeniedTest extends DrupalTestCase {
|
|
|
|
/**
|
|
* Implements getInfo().
|
|
*/
|
|
public function getInfo() {
|
|
return array(
|
|
'name' => '403 Access Denied',
|
|
'desc' => 'Check that the custom error message is displayed when access is denied.',
|
|
'group' => 'CustomError',
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Tests 403 pages.
|
|
*/
|
|
public function testAccessDeniedMessage() {
|
|
|
|
/* Enable CustomError module */
|
|
$this->drupalModuleEnable('customerror');
|
|
|
|
/* Set title and text of error message */
|
|
$error_code = 403;
|
|
$title = $this->randomName(10, 'simpletest_');
|
|
$this->drupalVariableSet('customerror_' . $error_code . '_title', $title);
|
|
|
|
$description = $this->randomName(512, 'simpletest_');
|
|
$this->drupalVariableSet('customerror_' . $error_code, $description);
|
|
|
|
/* Access error page directly, check for title and text of error message */
|
|
$this->get(url('customerror/' . $error_code, NULL, NULL, TRUE));
|
|
$this->assertText($title, 'Title on ' . $error_code . ' error page set when accessed directly');
|
|
$this->assertText($description, 'Description on ' . $error_code . ' error page set when accessed directly');
|
|
|
|
/* Point Drupal to the new error message */
|
|
$this->drupalVariableSet('site_' . $error_code, 'customerror/' . $error_code);
|
|
|
|
/* Log in as a user with no privileges */
|
|
$user = $this->drupalCreateUserRolePerm();
|
|
$this->drupalLoginUser($user);
|
|
|
|
/* Attempt to access CustomError module settings page */
|
|
$this->get(url('admin/settings/customerror', NULL, NULL, TRUE));
|
|
|
|
/* Check for response code, title and text of error message */
|
|
$this->assertResponse($error_code, 'Response code on ' . $error_code . ' error page set when accessed at non-existent URL');
|
|
$this->assertText($title, 'Title on ' . $error_code . ' error page set when accessed at non-existent URL');
|
|
$this->assertText($description, 'Description on ' . $error_code . ' error page set when accessed at non-existent URL');
|
|
|
|
}
|
|
|
|
}
|