File
- drupal/core/modules/system/lib/Drupal/system/Tests/System/AccessDeniedTest.php, line 44
- Definition of Drupal\system\Tests\System\AccessDeniedTest.
Class
- AccessDeniedTest
- Tests custom access denied functionality.
Namespace
Drupal\system\Tests\System
Code
function testAccessDenied() {
$this
->drupalGet('admin');
$this
->assertText(t('Access denied'), 'Found the default 403 page');
$this
->assertResponse(403);
$this
->drupalLogin($this->admin_user);
$edit = array(
'site_403' => 'user/' . $this->admin_user->uid,
);
$this
->drupalPost('admin/config/system/site-information', $edit, t('Save configuration'));
$this
->drupalPlaceBlock('user_login_block', array(
'machine_name' => 'login',
));
$this
->drupalLogout();
$this
->drupalGet('admin');
$this
->assertText($this->admin_user->name, 'Found the custom 403 page');
$this
->assertText(t('Username'), 'Blocks are shown on the custom 403 page');
$this
->drupalLogin($this->admin_user);
$edit = array(
'site_403' => '',
);
$this
->drupalPost('admin/config/system/site-information', $edit, t('Save configuration'));
$this
->drupalLogout();
$this
->drupalGet('admin');
$this
->assertText(t('Access denied'), 'Found the default 403 page');
$this
->assertResponse(403);
$this
->assertText(t('Username'), 'Blocks are shown on the default 403 page');
$this
->drupalLogin($this->admin_user);
config('system.site')
->set('page.403', 'user')
->save();
$edit = array(
'region' => -1,
);
$this
->drupalPost('admin/structure/block/manage/stark.login/configure', $edit, t('Save block'));
$this
->drupalLogout();
$edit = array(
'name' => $this->admin_user->name,
'pass' => $this->admin_user->pass_raw,
);
$this
->drupalPost('admin/config/system/site-information', $edit, t('Log in'));
$this
->assertText(t('Site information'));
}