Index: modules/simpletest/tests/bootstrap.test =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/tests/bootstrap.test,v retrieving revision 1.7 diff -u -p -r1.7 bootstrap.test --- modules/simpletest/tests/bootstrap.test 23 Nov 2008 18:12:08 -0000 1.7 +++ modules/simpletest/tests/bootstrap.test 2 Dec 2008 18:19:19 -0000 @@ -84,6 +84,78 @@ 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', 1); + } + + /** + * Test page caching with language fallback. + */ + function testPageCacheLanguageFallback() { + $this->drupalLogout(); + global $base_url; + // Force browser language to 'fr'. + $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'fr'; + + // Confirm that the language has been returned successfully. + $browser_language = language_from_browser(); + $this->assertEqual($browser_language->language, 'fr'); + + // Fill the cache. + $this->drupalGet($base_url); + $this->assertRaw('xml:lang="fr"', t('Page returned in the correct language')); + + $this->drupalHead($base_url); + $this->assertText('ETag: ', t('Verify presence of ETag header indicating that page caching is enabled.')); + $this->drupalGet($base_url); + $this->assertRaw('xml:lang="fr"', t('Page returned in the correct language')); + + // Visit the page again in English. + $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'en'; + // Confirm that the language has been returned successfully. + $browser_language = language_from_browser(); + $this->assertEqual($browser_language->language, 'en'); + + // The page has not been visited in English, so should not be cached yet. + $this->drupalHead($base_url); + $this->assertNoText('ETag: ', t('Ensure no ETag header is present this means the page is not cached.')); + + // Fill the cache for English. + $this->drupalGet($base_url); + $this->drupalHead($base_url); + $this->assertText('ETag: ', t('Ensure the ETag header is present now that the page has been cached.')); + $this->drupalGet($base_url); + $this->assertRaw('xml:lang="en"', t('Page returned in the correct language')); + } +} + class BootstrapPageCacheTestCase extends DrupalWebTestCase { function getInfo() {