[BUGFIX] Some unit tests fail with "Cannot modify header information"
authorXavier Perseguers <typo3@perseguers.ch>
Mon, 11 Jul 2011 08:29:08 +0000 (10:29 +0200)
committerXavier Perseguers <xavier@typo3.org>
Mon, 24 Oct 2011 19:04:19 +0000 (21:04 +0200)
Method template::endPage() should only send Content-Encoding header
if no headers have been sent to prevent fatal errors.

Change-Id: I57b84ac777a3e5dd7be601a670da7601116fd035
Fixes: #28083
Reviewed-on: http://review.typo3.org/3237
Reviewed-by: Steffen Gebert
Tested-by: Steffen Gebert
Reviewed-by: Xavier Perseguers
Tested-by: Xavier Perseguers
tests/t3lib/class.t3lib_beuserauthTest.php
typo3/template.php

index 3460101..98004aa 100644 (file)
@@ -36,7 +36,24 @@ class t3lib_beUserAuthTest extends tx_phpunit_testcase {
         */
        private $fixture = NULL;
 
+       /**
+        * 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');
+
        public function setUp() {
+                       // reset hooks
+               $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'] = array();
                $this->fixture = new t3lib_beUserAuth();
        }
 
index 0006084..272188e 100644 (file)
@@ -825,7 +825,9 @@ $str.=$this->docBodyTagBegin().
                        // if something is in buffer like debug, put it to end of page
                if (ob_get_contents()) {
                        $str .= ob_get_clean();
-                       header('Content-Encoding: None');
+                       if (!headers_sent()) {
+                               header('Content-Encoding: None');
+                       }
                }
 
                if ($this->docType !== 'xhtml_frames') {