? modules/simpletest/tests/343502.test
Index: includes/path.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/path.inc,v
retrieving revision 1.28
diff -u -p -r1.28 path.inc
--- includes/path.inc	14 Oct 2008 11:01:08 -0000	1.28
+++ includes/path.inc	6 Dec 2008 23:38:40 -0000
@@ -212,6 +212,7 @@ function drupal_set_title($title = NULL,
   if (isset($title)) {
     $stored_title = ($output == PASS_THROUGH) ? $title : check_plain($title);
   }
+
   return $stored_title;
 }
 
@@ -222,9 +223,15 @@ function drupal_set_title($title = NULL,
  *   Boolean value: TRUE if the current page is the front page; FALSE if otherwise.
  */
 function drupal_is_front_page() {
-  // As drupal_init_path updates $_GET['q'] with the 'site_frontpage' path,
-  // we can check it against the 'site_frontpage' variable.
-  return $_GET['q'] == drupal_get_normal_path(variable_get('site_frontpage', 'node'));
+  static $is_front_page;
+
+  if (!isset($is_front_page)) {
+    // As drupal_init_path updates $_GET['q'] with the 'site_frontpage' path,
+    // we can check it against the 'site_frontpage' variable.
+    $is_front_page = ($_GET['q'] == drupal_get_normal_path(variable_get('site_frontpage', 'node')));
+  }
+
+  return $is_front_page;
 }
 
 /**
Index: modules/simpletest/tests/system_test.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/tests/system_test.module,v
retrieving revision 1.6
diff -u -p -r1.6 system_test.module
--- modules/simpletest/tests/system_test.module	22 Nov 2008 13:33:00 -0000	1.6
+++ modules/simpletest/tests/system_test.module	6 Dec 2008 23:39:00 -0000
@@ -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() {
Index: modules/system/system.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.test,v
retrieving revision 1.28
diff -u -p -r1.28 system.test
--- modules/system/system.test	5 Dec 2008 22:18:45 -0000	1.28
+++ modules/system/system.test	6 Dec 2008 23:39:04 -0000
@@ -4,9 +4,6 @@
 class EnableDisableCoreTestCase extends DrupalWebTestCase {
   protected $admin_user;
 
-  /**
-   * Implementation of getInfo().
-   */
   function getInfo() {
     return array(
       'name' => t('Module list functionality'),
@@ -15,9 +12,6 @@ class EnableDisableCoreTestCase extends 
     );
   }
 
-  /**
-   * Implementation of setUp().
-   */
   function setUp() {
     parent::setUp('system_test');
 
@@ -149,9 +143,6 @@ class EnableDisableCoreTestCase extends 
 class IPAddressBlockingTestCase extends DrupalWebTestCase {
   protected $blocking_user;
 
-  /**
-   * Implementation of getInfo().
-   */
   function getInfo() {
     return array(
       'name' => t('IP address blocking'),
@@ -160,9 +151,6 @@ class IPAddressBlockingTestCase extends 
     );
   }
 
-  /**
-   * Implementation of setUp().
-   */
   function setUp() {
     parent::setUp();
 
@@ -219,9 +207,7 @@ class IPAddressBlockingTestCase extends 
 }
 
 class CronRunTestCase extends DrupalWebTestCase {
-  /**
-   * Implementation of getInfo().
-   */
+
   function getInfo() {
     return array(
       'name' => t('Cron run'),
@@ -255,9 +241,7 @@ class CronRunTestCase extends DrupalWebT
 }
 
 class AdminOverviewTestCase extends DrupalWebTestCase {
-  /**
-   * Implementation of getInfo().
-   */
+
   function getInfo() {
     return array(
       'name' => t('Admin overview'),
@@ -322,9 +306,7 @@ class AdminOverviewTestCase extends Drup
 }
 
 class AdminMetaTagTestCase extends DrupalWebTestCase {
-  /**
-   * Implementation of getInfo().
-   */
+  
   function getInfo() {
     return array(
       'name' => t('Fingerprinting meta tag'),
@@ -350,9 +332,6 @@ class AdminMetaTagTestCase extends Drupa
 class AccessDeniedTestCase extends DrupalWebTestCase {
   protected $admin_user;
 
-  /**
-   * Implementation of getInfo().
-   */
   function getInfo() {
     return array(
       'name' => t('403 functionality'),
@@ -361,9 +340,6 @@ class AccessDeniedTestCase extends Drupa
     );
   }
 
-  /**
-   * Implementation of setUp().
-   */
   function setUp() {
     parent::setUp();
 
@@ -411,9 +387,6 @@ class AccessDeniedTestCase extends Drupa
 class PageNotFoundTestCase extends DrupalWebTestCase {
   protected $admin_user;
 
-  /**
-   * Implementation of getInfo().
-   */
   function getInfo() {
     return array(
       'name' => t('404 functionality'),
@@ -422,9 +395,6 @@ class PageNotFoundTestCase extends Drupa
     );
   }
 
-  /**
-   * Implementation of setUp().
-   */
   function setUp() {
     parent::setUp();
 
@@ -473,6 +443,7 @@ class PageNotFoundTestCase extends Drupa
  * Tests generic date and time handling capabilities of Drupal.
  */
 class DateTimeFunctionalTest extends DrupalWebTestCase {
+
   function getInfo() {
     return array(
       'name' => t('Date and time'),
@@ -517,9 +488,6 @@ class PageTitleFiltering extends DrupalW
   protected $content_user;
   protected $saved_title;
 
-  /**
-   * Implementation of getInfo().
-   */
   function getInfo() {
     return array(
       'name' => t('HTML in page titles'),
@@ -528,9 +496,6 @@ class PageTitleFiltering extends DrupalW
     );
   }
 
-  /**
-   * Implementation of setUp().
-   */
   function setUp() {
     parent::setUp();
 
@@ -539,9 +504,6 @@ class PageTitleFiltering extends DrupalW
     $this->saved_title = drupal_get_title();
   }
 
-  /**
-   * Reset page title.
-   */
   function tearDown() {
     // Restore the page title.
     drupal_set_title($this->saved_title, PASS_THROUGH);
@@ -576,3 +538,61 @@ class PageTitleFiltering extends DrupalW
     $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_mail' => 'simpletest@example.com',
+      '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('Saved configuration.'));
+
+    $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.'));
+  }
+}
