function PageNotFoundTestCase::testPageNotFound in Drupal 7
File
- modules/
system/ system.test, line 1132 - Tests for system.module.
Class
Code
function testPageNotFound() {
$this
->drupalGet($this
->randomName(10));
$this
->assertText(t('Page not found'), 'Found the default 404 page');
$edit = array(
'title' => $this
->randomName(10),
'body' => array(
LANGUAGE_NONE => array(
array(
'value' => $this
->randomName(100),
),
),
),
);
$node = $this
->drupalCreateNode($edit);
// As node IDs must be integers, make sure requests for non-integer IDs
// return a page not found error.
$this
->drupalGet('node/invalid');
$this
->assertResponse(404);
// Use a custom 404 page.
$this
->drupalPost('admin/config/system/site-information', array(
'site_404' => 'node/' . $node->nid,
), t('Save configuration'));
$this
->drupalGet($this
->randomName(10));
$this
->assertText($node->title, 'Found the custom 404 page');
}