File
- core/modules/system/tests/system.test, line 956
- Tests for system.module.
Class
- AccessDeniedTestCase
- Tests custom access denied functionality.
Code
function testAccessDenied() {
$this->backdropLogout();
$this->backdropGet('admin');
$this->assertText(t('Access denied'), 'Found the default 403 page');
$this->assertResponse(403);
$this->backdropLogin($this->admin_user);
$edit = array(
'title' => $this->randomName(10),
'body' => array(LANGUAGE_NONE => array(array('value' => $this->randomName(100)))),
);
$node = $this->backdropCreateNode($edit);
$this->backdropPost('admin/config/system/site-information', array('site_403' => 'node/' . $node->nid), t('Save configuration'));
$this->backdropLogout();
$this->backdropGet('admin');
$this->assertText($node->title, 'Found the custom 403 page');
$this->backdropLogout();
$this->backdropGet('admin');
$this->assertText($node->title, 'Found the custom 403 page');
$this->assertText('Powered by Backdrop CMS', 'Blocks are shown on the custom 403 page');
$this->backdropLogin($this->admin_user);
$this->backdropPost('admin/config/system/site-information', array('site_403' => ''), t('Save configuration'));
$this->backdropLogout();
$this->backdropGet('admin');
$this->assertText(t('Access denied'), 'Found the default 403 page');
$this->assertResponse(403);
$this->assertText('Powered by Backdrop CMS', 'Blocks are shown on the default 403 page');
$this->backdropLogin($this->admin_user);
config_set('system.core', 'site_403', 'user/login');
$this->backdropLogout();
$edit = array(
'name' => $this->admin_user->name,
'pass' => $this->admin_user->pass_raw,
);
$this->backdropPost('admin/config/system/site-information', $edit, t('Log in'));
$this->assertText(t('Site information'));
}