Fixed bug #15615: Fix and improve page renderer unit tests (Thanks to Helmut Hummel)
authorSteffen Kamper <info@sk-typo3.de>
Wed, 1 Sep 2010 10:26:10 +0000 (10:26 +0000)
committerSteffen Kamper <info@sk-typo3.de>
Wed, 1 Sep 2010 10:26:10 +0000 (10:26 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@8748 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
tests/t3lib/t3lib_pagerendererTest.php

index 26308cf..f3f7b00 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2010-09-01  Steffen Kamper  <steffen@typo3.org>
+
+       * Fixed bug #15615: Fix and improve page renderer unit tests (Thanks to Helmut Hummel)
+
 2010-08-31  Stanislas Rolland  <typo3@sjbr.ca>
 
        * Fixed bug #15068: htmlArea RTE: Not loading in Firefox 3.0.3
index 91284df..21381bc 100644 (file)
  * @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 @@ class t3lib_PageRendererTest extends tx_phpunit_testcase {
         *
         * @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(
+                       '#<script src="[^"]*/typo3temp/compressor/scriptaculous-[a-f0-9]+.js.gzip" type="text/javascript"></script>#',
+                       $out
+               );
+               $this->assertRegExp(
+                       '#<script src="[^"]*/typo3temp/compressor/effects-[a-f0-9]+.js.gzip" type="text/javascript"></script>#',
+                       $out
+               );
+               $this->assertRegExp(
+                       '#<script src="[^"]*/typo3temp/compressor/controls-[a-f0-9]+.js.gzip" type="text/javascript"></script>#',
+                       $out
+               );
+               $this->assertRegExp(
+                       '#<script src="[^"]*/typo3temp/compressor/slider-[a-f0-9]+.js.gzip" type="text/javascript"></script>#',
+                       $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(
+                       '#<script src="[^"]*/typo3temp/compressor/scriptaculous-[a-f0-9]+.js" type="text/javascript"></script>#',
+                       $out
+               );
+               $this->assertRegExp(
+                       '#<script src="[^"]*/typo3temp/compressor/effects-[a-f0-9]+.js" type="text/javascript"></script>#',
+                       $out
+               );
+               $this->assertRegExp(
+                       '#<script src="[^"]*/typo3temp/compressor/controls-[a-f0-9]+.js" type="text/javascript"></script>#',
+                       $out
+               );
+               $this->assertRegExp(
+                       '#<script src="[^"]*/typo3temp/compressor/slider-[a-f0-9]+.js" type="text/javascript"></script>#',
+                       $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();