Index: modules/simpletest/tests/bootstrap.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/tests/bootstrap.test,v
retrieving revision 1.9
diff -u -p -r1.9 bootstrap.test
--- modules/simpletest/tests/bootstrap.test	3 Dec 2008 14:51:53 -0000	1.9
+++ modules/simpletest/tests/bootstrap.test	12 Dec 2008 19:20:31 -0000
@@ -84,6 +84,67 @@ class BootstrapIPAddressTestCase extends
   }
 }
 
+class BootstrapPageCacheWithLanguageFallbackTestCase extends DrupalWebTestCase {
+
+  function getInfo() {
+    return array(
+      'name' => t('Page cache test with language negotiation'),
+      'description' => t('Enable the page cache and language negotiation, ensure that cached pages are served in the correct language.'),
+      'group' => t('Bootstrap')
+    );
+  }
+
+  function setUp() {
+    parent::setUp('locale');
+    $web_user = $this->drupalCreateUser(array('administer languages', 'access administration pages'));
+    $this->drupalLogin($web_user);
+
+    // Enable French language.
+    $edit = array();
+    $edit['langcode'] = 'fr';
+
+    $this->drupalPost('admin/settings/language/add', $edit, t('Add language'));
+    $this->drupalLogout($web_user);
+
+    // Set language negotiation to "Path prefix with fallback".
+    variable_set('language_negotiation', LANGUAGE_NEGOTIATION_PATH);
+
+    // Force inclusion of language.inc.
+    drupal_init_language();
+    // Enable the page cache.
+    variable_set('cache', CACHE_NORMAL);
+  }
+
+  /**
+   * Test page caching with language fallback.
+   */
+  function testPageCacheLanguageFallback() {
+
+    // Fill the cache.
+    $this->drupalGet('', array(), array('Accept-Language: fr'));
+    $this->assertRaw('xml:lang="fr"', t('Page returned in the correct language'));
+
+    $this->drupalHead('', array(), array('Accept-Language: fr'));
+    $this->assertTrue(cache_get(url('', array('absolute' => TRUE)), 'cache_page'), t('Page has been cached.'));
+    $this->drupalGet('', array(), array('Accept-Language: fr'));
+    $this->assertRaw('xml:lang="fr"', t('Page returned in the correct language'));
+
+    // Visit the page again in English.
+    // The page has not been visited in English, so should not be cached yet.
+    $this->drupalHead('', array(), array('Accept-Language: en'));
+    $this->assertFalse(cache_get(url('', array('absolute' => TRUE)), 'cache_page'), t('Page has been not been cached.'));
+
+
+    // Fill the cache for English.
+    $this->drupalGet('', array(), array('Accept-Language: en'));
+    $this->drupalHead('', array(), array('Accept-Language: en'));
+    $this->assertTrue(cache_get(url('', array('absolute' => TRUE)), 'cache_page'), t('Page has been cached.'));
+
+    $this->drupalGet('', array(), array('Accept-Language: en'));
+    $this->assertRaw('xml:lang="en"', t('Page returned in the correct language'));
+  }
+}
+
 class BootstrapPageCacheTestCase extends DrupalWebTestCase {
 
   function getInfo() {
