? patches
? sites/patchwork.jonathan.local
Index: modules/simpletest/tests/common.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/tests/common.test,v
retrieving revision 1.7
diff -u -p -r1.7 common.test
--- modules/simpletest/tests/common.test	17 Sep 2008 07:01:31 -0000	1.7
+++ modules/simpletest/tests/common.test	2 Oct 2008 11:22:24 -0000
@@ -251,3 +251,115 @@ class DrupalSetContentTestCase extends D
     }
   }
 }
+
+/**
+ * Test for setting a custom access denied page.
+ */
+class DrupalCustomAccessDeniedTestCase extends DrupalWebTestCase {
+  /**
+   * Implementation of getInfo().
+   */
+  function getInfo() {
+    return array(
+      'name' => t('Custom access denied'),
+      'description' => t("Performs tests on Drupal's custom access denied page."),
+      'group' => t('System')
+    );
+  }
+
+  /**
+   * Tests custom access denied pages.
+   */
+  function testDrupalCustomAccessDenied() {
+    $user = $this->drupalCreateUser(array('administer site configuration'));
+    $this->drupalLogin($user);
+
+    // Create the custom 403 page.
+    $node = $this->drupalCreateNode();
+
+    // Set the drupal setting for the custom 403 page.
+    $edit = array('site_403' => 'node/'. $node->nid);
+    $this->drupalPost('admin/settings/error-reporting', $edit, t('Save configuration'));
+
+    // Log the admin user out.
+    $this->drupalLogout();
+
+    // Try to go to arbitrary page that should respond in a 403 error.
+    $this->drupalGet('node/add/page');
+
+    // We should get our custom 404 page.
+    $this->assertResponse(403, 'Access denied code.');
+    $this->assertText($node->title, t('The custom access denied title was displayed.'));
+    $this->assertText($node->body, t('The custom access denied body was displayed.'));
+  }
+}
+
+/**
+ * Test for the drupal_get_headers() function.
+ */
+class DrupalGetHeadersTestCase extends DrupalWebTestCase {
+  /**
+   * Implementation of getInfo().
+   */
+  function getInfo() {
+    return array(
+      'name' => t('Drupal get headers'),
+      'description' => t("Performs tests on Drupal's get headers function."),
+      'group' => t('System'),
+    );
+  }
+
+  /**
+   * Tests the drupal_get_headers() function indirectly by calling a cached
+   * page with non-standard headers.
+   */
+  function testDrupalGetHeaders() {
+    $user = $this->drupalCreateUser(array('administer site configuration'));
+    $this->drupalLogin($user);
+
+    // Create a page so that the rss.xml will be generated.
+    $this->drupalCreateNode(array(
+      'promote' => 1
+    ));
+
+    // Turn page caching on because page caching uses drupal_get_headers() to
+    // send out the proper headers.
+    $edit = array();
+    $edit['cache'] = CACHE_NORMAL;
+    $this->drupalPost('admin/settings/performance', $edit, t('Save configuration'));
+    $this->refreshVariables();
+
+    // Log the admin user out, so that we can have cached pages
+    $this->drupalLogout();
+
+    // Clear out any already existing caches.
+    cache_clear_all();
+
+    $this->drupalGet('node');
+    $content_type = curl_getinfo($this->ch, CURLINFO_CONTENT_TYPE);
+    $this->drupalGet('node');
+    $cached_content_type = curl_getinfo($this->ch, CURLINFO_CONTENT_TYPE);
+
+    // Make sure that the node page content type header and the cached node
+    // page content type header are the same.
+    $this->assertEqual($content_type, $cached_content_type);
+
+    $this->drupalGet('rss.xml');
+    $content_type = curl_getinfo($this->ch, CURLINFO_CONTENT_TYPE);
+    $this->drupalGet('rss.xml');
+    $cached_content_type = curl_getinfo($this->ch, CURLINFO_CONTENT_TYPE);
+
+    // Make sure that the rss.xml page content type header and the cached
+    // rss.xml page content type header are the same.
+    $this->assertEqual($content_type, $cached_content_type);
+
+    $this->drupalGet('rss.xml');
+    $rss_content_type = curl_getinfo($this->ch, CURLINFO_CONTENT_TYPE);
+    $this->drupalGet('node');
+    $node_content_type = curl_getinfo($this->ch, CURLINFO_CONTENT_TYPE);
+
+    // Make sure that the cached node page content type header and the
+    // cached rss.xml page content type header are the same.
+    $this->assertNotEqual($rss_content_type, $node_content_type);
+  }
+}
\ No newline at end of file
