? patches
? modules/system/custom_access_denied_test_2.patch
? sites/patchwork.jonathan.local
Index: modules/system/system.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.test,v
retrieving revision 1.12
diff -u -p -r1.12 system.test
--- modules/system/system.test	15 Sep 2008 20:48:09 -0000	1.12
+++ modules/system/system.test	9 Oct 2008 12:05:25 -0000
@@ -321,7 +321,7 @@ class AdminMetaTagTestCase extends Drupa
   }
 }
 
-class PageNotFoundTestCase extends DrupalWebTestCase {
+class PageNotFoundAndAccessDeniedTestCase extends DrupalWebTestCase {
   protected $admin_user;
 
   /**
@@ -329,8 +329,8 @@ class PageNotFoundTestCase extends Drupa
    */
   function getInfo() {
     return array(
-      'name' => t('404 functionality'),
-      'description' => t("Tests page not found functionality, including custom 404 pages."),
+      'name' => t('404/403 error pages'),
+      'description' => t("Tests page not found and access denied functionality, including custom 404/403 pages."),
       'group' => t('System')
     );
   }
@@ -348,6 +348,7 @@ class PageNotFoundTestCase extends Drupa
 
   function testPageNotFound() {
     $this->drupalGet($this->randomName(10));
+    $this->assertResponse('404', 'Page response is a 404.');
     $this->assertText(t('Page not found'), t('Found the default 404 page'));
 
     $edit = array(
@@ -360,12 +361,14 @@ class PageNotFoundTestCase extends Drupa
     $this->drupalPost('admin/settings/error-reporting', array('site_404' => 'node/' . $node->nid), t('Save configuration'));
 
     $this->drupalGet($this->randomName(10));
+    $this->assertResponse('404', 'Page response is a 404.');
     $this->assertText($node->title, t('Found the custom 404 page'));
 
     // Logout and check that the user login block is not shown on custom 404 pages.
     $this->drupalLogout();
 
     $this->drupalGet($this->randomName(10));
+    $this->assertResponse('404', 'Page response is a 404.');
     $this->assertText($node->title, t('Found the custom 404 page'));
     $this->assertNoText(t('User login'), t('Blocks are not shown on the custom 404 page'));
 
@@ -377,7 +380,45 @@ class PageNotFoundTestCase extends Drupa
     $this->drupalLogout();
 
     $this->drupalGet($this->randomName(10));
+    $this->assertResponse('404', 'Page response is a 404.');
     $this->assertText(t('Page not found'), t('Found the default 404 page'));
     $this->assertNoText(t('User login'), t('Blocks are not shown on the default 404 page'));
   }
-}
+
+  function testAccessDenied() {
+    $this->drupalGet('node/add');
+    $this->assertResponse('403', 'Page response is a 403.');
+    $this->assertText(t('Access denied'), t('Found the default 403 page'));
+
+    $edit = array(
+      'title' => $this->randomName(10),
+      'body' => $this->randomName(100)
+    );
+    $node = $this->drupalCreateNode($edit);
+
+    // Use a custom 403 page.
+    $this->drupalPost('admin/settings/error-reporting', array('site_403' => 'node/' . $node->nid), t('Save configuration'));
+
+    $this->drupalGet('node/add');
+    $this->assertResponse('403', 'Page response is a 403.');
+    $this->assertText($node->title, t('Found the custom 403 page'));
+
+    // Logout and check another page other than node/add.
+    $this->drupalLogout();
+
+    $this->drupalGet('admin');
+    $this->assertResponse('403', 'Page response is a 403.');
+    $this->assertText($node->title, t('Found the custom 403 page'));
+
+    // Log back in and remove the custom 403 page.
+    $this->drupalLogin($this->admin_user);
+    $this->drupalPost('admin/settings/error-reporting', array(), t('Reset to defaults'));
+
+    // Logout and check that default 403 page is restored.
+    $this->drupalLogout();
+
+    $this->drupalGet('admin');
+    $this->assertResponse('403', 'Page response is a 403.');
+    $this->assertText(t('Access denied'), t('Found the default 403 page'));
+  }
+}
\ No newline at end of file
