diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/simpletest/drupal_web_test_case.php | 2 | ||||
-rw-r--r-- | modules/simpletest/tests/bootstrap.test | 33 |
2 files changed, 33 insertions, 2 deletions
diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php index 985d0c0bd..9b0bf7275 100644 --- a/modules/simpletest/drupal_web_test_case.php +++ b/modules/simpletest/drupal_web_test_case.php @@ -1516,7 +1516,7 @@ class DrupalWebTestCase extends DrupalTestCase { * Either the new page content or FALSE. */ protected function checkForMetaRefresh() { - if ($this->drupalGetContent() != '' && $this->parse()) { + if (strpos($this->drupalGetContent(), '<meta ') && $this->parse()) { $refresh = $this->xpath('//meta[@http-equiv="Refresh"]'); if (!empty($refresh)) { // Parse the content attribute of the meta tag for the format: diff --git a/modules/simpletest/tests/bootstrap.test b/modules/simpletest/tests/bootstrap.test index b6bfd54e8..cac805897 100644 --- a/modules/simpletest/tests/bootstrap.test +++ b/modules/simpletest/tests/bootstrap.test @@ -91,7 +91,7 @@ class BootstrapPageCacheTestCase extends DrupalWebTestCase { public static function getInfo() { return array( 'name' => 'Page cache test', - 'description' => 'Enable the page cache and test it with conditional HTTP requests.', + 'description' => 'Enable the page cache and test it with various HTTP requests.', 'group' => 'Bootstrap' ); } @@ -177,6 +177,37 @@ class BootstrapPageCacheTestCase extends DrupalWebTestCase { $this->assertEqual($this->drupalGetHeader('Foo'), 'bar', t('Custom header was sent.')); } + + /** + * Test page compression. + * + * The test should pass even if zlib.output_compression is enabled in php.ini, + * .htaccess or similar, or if compression is done outside PHP, e.g. by the + * mod_deflate Apache module. + */ + function testPageCompression() { + variable_set('cache', CACHE_NORMAL); + + // Fill the cache and verify that output is compressed. + $this->drupalGet('', array(), array('Accept-Encoding: gzip,deflate')); + $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'MISS', t('Page was not cached.')); + $this->drupalSetContent(gzinflate(substr($this->drupalGetContent(), 10, -8))); + $this->assertRaw('</html>', t('Page was gzip compressed.')); + + // Verify that cached output is compressed. + $this->drupalGet('', array(), array('Accept-Encoding: gzip,deflate')); + $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', t('Page was cached.')); + $this->assertEqual($this->drupalGetHeader('Content-Encoding'), 'gzip', t('A Content-Encoding header was sent.')); + $this->drupalSetContent(gzinflate(substr($this->drupalGetContent(), 10, -8))); + $this->assertRaw('</html>', t('Page was gzip compressed.')); + + // Verify that a client without compression support gets an uncompressed page. + $this->drupalGet(''); + $this->assertEqual($this->drupalGetHeader('X-Drupal-Cache'), 'HIT', t('Page was cached.')); + $this->assertFalse($this->drupalGetHeader('Content-Encoding'), t('A Content-Encoding header was not sent.')); + $this->assertTitle(t('Welcome to @site-name | @site-name', array('@site-name' => variable_get('site_name', 'Drupal'))), t('Site title matches.')); + $this->assertRaw('</html>', t('Page was not compressed.')); + } } class BootstrapVariableTestCase extends DrupalWebTestCase { |