summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2008-12-09 07:16:10 +0000
committerDries Buytaert <dries@buytaert.net>2008-12-09 07:16:10 +0000
commitc50651f7fb348ec2dc6e29cdf462f22d64045002 (patch)
tree55f4e31257b073ab98401ecdd74a1a903c855ebb /modules
parent1ffa4fe38bb6b3612092cc65897ab30e0bc9954f (diff)
downloadbrdo-c50651f7fb348ec2dc6e29cdf462f22d64045002.tar.gz
brdo-c50651f7fb348ec2dc6e29cdf462f22d64045002.tar.bz2
- Patch #340557 by Dave Reid: use static caching in drupal_is_front_page().
Diffstat (limited to 'modules')
-rw-r--r--modules/simpletest/tests/system_test.module10
-rw-r--r--modules/system/system.test55
2 files changed, 65 insertions, 0 deletions
diff --git a/modules/simpletest/tests/system_test.module b/modules/simpletest/tests/system_test.module
index fadc05e3c..dfe25bbf8 100644
--- a/modules/simpletest/tests/system_test.module
+++ b/modules/simpletest/tests/system_test.module
@@ -150,6 +150,16 @@ function system_test_boot() {
}
/**
+ * Implementation of hook_init().
+ */
+function system_test_init() {
+ // Used by FrontPageTestCase to get the results of drupal_is_front_page().
+ if (variable_get('front_page_output', 0) && drupal_is_front_page()) {
+ drupal_set_message(t('On front page.'));
+ }
+}
+
+/**
* Implementation of hook_exit().
*/
function system_test_exit() {
diff --git a/modules/system/system.test b/modules/system/system.test
index 8a888a052..9b1b2cbdc 100644
--- a/modules/system/system.test
+++ b/modules/system/system.test
@@ -576,3 +576,58 @@ class PageTitleFiltering extends DrupalWebTestCase {
$this->assertText(check_plain($edit['title']), 'Check to make sure tags in the node title are converted.');
}
}
+
+/**
+ * Test front page functionality and administration.
+ */
+class FrontPageTestCase extends DrupalWebTestCase {
+
+ function getInfo() {
+ return array(
+ 'name' => t('Front page'),
+ 'description' => t('Tests front page functionality and administration.'),
+ 'group' => t('System'),
+ );
+ }
+
+ function setUp() {
+ parent::setUp('system_test');
+
+ // Create admin user, log in admin user, and create one node.
+ $this->admin_user = $this->drupalCreateUser(array('access content', 'administer site configuration'));
+ $this->drupalLogin($this->admin_user);
+ $this->node_path = "node/" . $this->drupalCreateNode(array('promote' => 1))->nid;
+
+ // Enable front page logging in system_test.module.
+ variable_set('front_page_output', 1);
+ }
+
+ /**
+ * Test front page functionality.
+ */
+ function testDrupalIsFrontPage() {
+ $this->drupalGet('');
+ $this->assertText(t('On front page.'), t('Path is the front page.'));
+ $this->drupalGet('node');
+ $this->assertText(t('On front page.'), t('Path is the front page.'));
+ $this->drupalGet($this->node_path);
+ $this->assertNoText(t('On front page.'), t('Path is not the front page.'));
+
+ // Change the front page to an invalid path.
+ $edit = array('site_frontpage' => 'kittens');
+ $this->drupalPost('admin/settings/site-information', $edit, t('Save configuration'));
+ $this->assertText(t("The path '@path' is either invalid or you do not have access to it.", array('@path' => $edit['site_frontpage'])));
+
+ // Change the front page to a valid path.
+ $edit['site_frontpage'] = $this->node_path;
+ $this->drupalPost('admin/settings/site-information', $edit, t('Save configuration'));
+ $this->assertText(t('The configuration options have been saved.'), t('The front page path has been saved.'));
+
+ $this->drupalGet('');
+ $this->assertText(t('On front page.'), t('Path is the front page.'));
+ $this->drupalGet('node');
+ $this->assertNoText(t('On front page.'), t('Path is not the front page.'));
+ $this->drupalGet($this->node_path);
+ $this->assertText(t('On front page.'), t('Path is the front page.'));
+ }
+}