function PageNotFoundTest::testPageNotFound in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/system/src/Tests/System/PageNotFoundTest.php \Drupal\system\Tests\System\PageNotFoundTest::testPageNotFound()
File
- core/
modules/ system/ src/ Tests/ System/ PageNotFoundTest.php, line 32 - Contains \Drupal\system\Tests\System\PageNotFoundTest.
Class
- PageNotFoundTest
- Tests page not found functionality, including custom 404 pages.
Namespace
Drupal\system\Tests\SystemCode
function testPageNotFound() {
$this
->drupalLogin($this->adminUser);
$this
->drupalGet($this
->randomMachineName(10));
$this
->assertText(t('Page not found'), 'Found the default 404 page');
// Set a custom 404 page without a starting slash.
$edit = [
'site_404' => 'user/' . $this->adminUser
->id(),
];
$this
->drupalPostForm('admin/config/system/site-information', $edit, t('Save configuration'));
$this
->assertRaw(SafeMarkup::format("The path '%path' has to start with a slash.", [
'%path' => $edit['site_404'],
]));
// Use a custom 404 page.
$edit = array(
'site_404' => '/user/' . $this->adminUser
->id(),
);
$this
->drupalPostForm('admin/config/system/site-information', $edit, t('Save configuration'));
$this
->drupalGet($this
->randomMachineName(10));
$this
->assertText($this->adminUser
->getUsername(), 'Found the custom 404 page');
}