[BUGFIX] t3lib_utility_mailTest fails 17/21617/2
authorPhilipp Gampe <philipp.gampe@typo3.org>
Sun, 23 Jun 2013 15:22:38 +0000 (17:22 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sun, 23 Jun 2013 20:29:03 +0000 (22:29 +0200)
The tested method always adds a From address to the mail header. This
is not reflected in the test.
Additionally clean up the test header a bit (backup globals).

Resolves: #49361
Releases: 4.5
Change-Id: I33d85916980eea34331d7d87682de9f71119af25
Reviewed-on: https://review.typo3.org/21617
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
tests/t3lib/utility/t3lib_utility_mailTest.php

index 041d125..c354de3 100644 (file)
  * @author Oliver Klee <typo3-coding@oliverklee.de>
  */
 class t3lib_utility_mailTest extends tx_phpunit_testcase {
+
        /**
-        * backed-up TYPO3_CONF_VARS SC_OPTIONS
+        * Enable backup of global and system variables
         *
-        * @var array
+        * @var boolean
         */
-       private $scOptionsBackup = array();
+       protected $backupGlobals = TRUE;
 
        /**
-        * backed-up T3_VAR callUserFunction
+        * Exclude TYPO3_DB from backup/ restore of $GLOBALS
+        * because resource types cannot be handled during serializing
         *
         * @var array
         */
-       private $callUserFunctionBackup = array();
-
-       public function setUp() {
-               $this->scOptionsBackup = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'];
-               $this->callUserFunctionBackup = $GLOBALS['T3_VAR']['callUserFunction'];
-       }
+       protected $backupGlobalsBlacklist = array('TYPO3_DB');
 
        public function tearDown() {
                t3lib_div::purgeInstances();
-               $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'] = $this->scOptionsBackup;
-               $GLOBALS['T3_VAR']['callUserFunction'] = $this->callUserFunctionBackup;
        }
 
 
@@ -65,10 +60,13 @@ class t3lib_utility_mailTest extends tx_phpunit_testcase {
         * @test
         */
        public function mailCallsHook() {
+               $GLOBALS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromName'] = 'Unit Test';
+               $GLOABLS['TYPO3_CONF_VARS']['MAIL']['defaultMailFromAddress'] = 'unittest@example.org';
                $to = 'john@example.com';
                $subject = 'Good news everybody!';
                $messageBody = 'The hooks works!';
-               $additionalHeaders = 'Reply-to: jane@example.com';
+               $additionalHeaders = 'Reply-to: jane@example.com' . LF .
+                       'From: Unit Test <unittest@example.org>';
                $additionalParameters = '-f postmaster@example.com';
 
                $mockMailer = $this->getMock('mockMailer', array('mail'));