Project

General

Profile

Feature #22212 » 13698_tests.diff

Administrator Admin, 2010-04-13 21:22

View differences:

tests/t3lib/utility/t3lib_utility_mail_testcase.php (revision 0)
<?php
/***************************************************************
* Copyright notice
*
* (c) 2010 Oliver Klee (typo3-coding@oliverklee.de)
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* Testcase for the t3lib_utility_Mail class.
*
* @package TYPO3
* @subpackage t3lib
*
* @author Oliver Klee <typo3-coding@oliverklee.de>
*/
class t3lib_utility_mail_testcase extends tx_phpunit_testcase {
/**
* backed-up TYPO3_CONF_VARS SC_OPTIONS
*
* @var array
*/
private $scOptionsBackup = array();
/**
* backed-up T3_VAR callUserFunction
*
* @var array
*/
private $callUserFunctionBackup = array();
public function setUp() {
$this->scOptionsBackup = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'];
$this->callUserFunctionBackup = $GLOBALS['T3_VAR']['callUserFunction'];
}
public function tearDown() {
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'] = $this->scOptionsBackup;
$GLOBALS['T3_VAR']['callUserFunction'] = $this->callUserFunctionBackup;
}
//////////////////////////
// Tests concerning mail
//////////////////////////
/**
* @test
*/
public function mailCallsHook() {
$to = 'john@example.com';
$subject = 'Good news everybody!';
$messageBody = 'The hooks works!';
$additionalHeaders = 'Reply-to: jane@example.com';
$additionalParameters = '-f postmaster@example.com';
$mockMailer = $this->getMock('mockMailer', array('mail'));
$mockMailer->expects($this->once())->method('mail')
->with(
array(
'to' => $to,
'subject' => $subject,
'messageBody' => $messageBody,
'additionalHeaders' => $additionalHeaders,
'additionalParameters' => $additionalParameters,
),
FALSE
);
$GLOBALS['T3_VAR']['callUserFunction']['mockMailer->mail']
= array('obj' => $mockMailer, 'method' => 'mail');
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']
['t3lib/utility/class.t3lib_utility_mail.php']
['substituteMailDelivery'] = array('mockMailer->mail');
t3lib_utility_Mail::mail(
$to, $subject, $messageBody, $additionalHeaders,
$additionalParameters
);
}
}
?>
(3-3/3)