|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 2010-2011 Oliver Klee (typo3-coding@oliverklee.de) 00006 * All rights reserved 00007 * 00008 * This script is part of the TYPO3 project. The TYPO3 project is 00009 * free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * The GNU General Public License can be found at 00015 * http://www.gnu.org/copyleft/gpl.html. 00016 * 00017 * This script is distributed in the hope that it will be useful, 00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 * GNU General Public License for more details. 00021 * 00022 * This copyright notice MUST APPEAR in all copies of the script! 00023 ***************************************************************/ 00024 00025 /** 00026 * Testcase for the t3lib_utility_Mail class. 00027 * 00028 * @package TYPO3 00029 * @subpackage t3lib 00030 * 00031 * @author Oliver Klee <typo3-coding@oliverklee.de> 00032 */ 00033 class t3lib_utility_mailTest extends tx_phpunit_testcase { 00034 /** 00035 * backed-up TYPO3_CONF_VARS SC_OPTIONS 00036 * 00037 * @var array 00038 */ 00039 private $scOptionsBackup = array(); 00040 00041 /** 00042 * backed-up T3_VAR callUserFunction 00043 * 00044 * @var array 00045 */ 00046 private $callUserFunctionBackup = array(); 00047 00048 public function setUp() { 00049 $this->scOptionsBackup = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']; 00050 $this->callUserFunctionBackup = $GLOBALS['T3_VAR']['callUserFunction']; 00051 } 00052 00053 public function tearDown() { 00054 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'] = $this->scOptionsBackup; 00055 $GLOBALS['T3_VAR']['callUserFunction'] = $this->callUserFunctionBackup; 00056 } 00057 00058 00059 ////////////////////////// 00060 // Tests concerning mail 00061 ////////////////////////// 00062 00063 /** 00064 * @test 00065 */ 00066 public function mailCallsHook() { 00067 $to = 'john@example.com'; 00068 $subject = 'Good news everybody!'; 00069 $messageBody = 'The hooks works!'; 00070 $additionalHeaders = 'Reply-to: jane@example.com'; 00071 $additionalParameters = '-f postmaster@example.com'; 00072 00073 $mockMailer = $this->getMock('mockMailer', array('mail')); 00074 $mockMailer->expects($this->once())->method('mail') 00075 ->with( 00076 array( 00077 'to' => $to, 00078 'subject' => $subject, 00079 'messageBody' => $messageBody, 00080 'additionalHeaders' => $additionalHeaders, 00081 'additionalParameters' => $additionalParameters, 00082 ), 00083 FALSE 00084 ); 00085 $GLOBALS['T3_VAR']['callUserFunction']['mockMailer->mail'] 00086 = array('obj' => $mockMailer, 'method' => 'mail'); 00087 00088 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'] 00089 ['t3lib/utility/class.t3lib_utility_mail.php'] 00090 ['substituteMailDelivery'] = array('mockMailer->mail'); 00091 00092 t3lib_utility_Mail::mail( 00093 $to, $subject, $messageBody, $additionalHeaders, 00094 $additionalParameters 00095 ); 00096 } 00097 } 00098 ?>
1.8.0