Index: tests/t3lib/t3lib_pagerendererTest.php =================================================================== --- tests/t3lib/t3lib_pagerendererTest.php (revision 8713) +++ tests/t3lib/t3lib_pagerendererTest.php (working copy) @@ -32,6 +32,22 @@ * @author Steffen Kamper (info@sk-typo3.de) */ class t3lib_PageRendererTest extends tx_phpunit_testcase { + + /** + * Enable backup of global and system variables + * + * @var boolean + */ + protected $backupGlobals = TRUE; + + /** + * Exclude TYPO3_DB from backup/ restore of $GLOBALS + * because resource types cannot be handled during serializing + * + * @var array + */ + protected $backupGlobalsBlacklist = array('TYPO3_DB'); + /** * @var t3lib_PageRenderer */ @@ -433,7 +449,74 @@ * * @test */ - public function isScriptaculousLoadedCompressed() { + public function isScriptaculousLoadedCompressedIfConfiguredAndClientIsCapable() { + $_SERVER['HTTP_ACCEPT_ENCODING'] = 'gzip,deflate'; + $GLOBALS['TYPO3_CONF_VARS']['BE']['compressionLevel'] = '5'; + + $this->fixture->loadScriptaculous('slider,controls'); + $this->fixture->enableCompressJavascript(); + $out = $this->fixture->render(); + + $this->assertRegExp( + '##', + $out + ); + $this->assertRegExp( + '##', + $out + ); + $this->assertRegExp( + '##', + $out + ); + $this->assertRegExp( + '##', + $out + ); + } + + /** + * Tests whether scriptaculous is correctly loaded, but without compression + * if the browser did not send the appropriate headers. + * + * @test + */ + public function isScriptaculousNotLoadedCompressedIfClientCannotHandleCompression() { + $_SERVER['HTTP_ACCEPT_ENCODING'] = ''; + $GLOBALS['TYPO3_CONF_VARS']['BE']['compressionLevel'] = '5'; + + $this->fixture->loadScriptaculous('slider,controls'); + $this->fixture->enableCompressJavascript(); + $out = $this->fixture->render(); + + $this->assertRegExp( + '##', + $out + ); + $this->assertRegExp( + '##', + $out + ); + $this->assertRegExp( + '##', + $out + ); + $this->assertRegExp( + '##', + $out + ); + } + + /** + * Tests whether scriptaculous is correctly loaded, but without compression + * if no compression is configured. + * + * @test + */ + public function isScriptaculousNotLoadedCompressedIfCompressionIsNotConfigured() { + $_SERVER['HTTP_ACCEPT_ENCODING'] = 'gzip,deflate'; + $GLOBALS['TYPO3_CONF_VARS']['BE']['compressionLevel'] = ''; + $this->fixture->loadScriptaculous('slider,controls'); $this->fixture->enableCompressJavascript(); $out = $this->fixture->render();