[TASK] Adapt unit-tests to new mail-adapter-hook
authorStefan Neufeind <typo3.neufeind@speedpartner.de>
Fri, 10 Feb 2012 18:21:29 +0000 (19:21 +0100)
committerSteffen Gebert <steffen.gebert@typo3.org>
Sat, 11 Feb 2012 16:34:58 +0000 (17:34 +0100)
 (for t3lib_utility_mail)

Adjust the unit-tests to the updated interface
instead of the deprecated one. The deprecated
interface was removed with 4.7
(commit 97a6f07f8fb990302ce3b05865aedcc77f220917).

Change-Id: I76f6bb24a58ab7f4d487e596e2abedb1da9767da
Resolves: #33850
Releases: 4.7
Reviewed-on: http://review.typo3.org/8973
Reviewed-by: Philipp Gampe
Tested-by: Philipp Gampe
Reviewed-by: Steffen Gebert
Tested-by: Steffen Gebert
tests/t3lib/utility/class.t3lib_utility_mailTest.php

index c80019f..cb0b1eb 100644 (file)
@@ -89,30 +89,29 @@ class t3lib_utility_MailTest extends tx_phpunit_testcase {
                $messageBody = 'The hooks works!';
                $additionalHeaders = 'Reply-to: jane@example.com';
                $additionalParameters = '-f postmaster@example.com';
+               $fakeThis = FALSE;
 
                $additionalHeadersExpected = $additionalHeaders;
                if ($fromAddress !== '' && $fromName !== '') {
                        $additionalHeadersExpected .= LF . sprintf('From: "%s" <%s>', $fromName, $fromAddress);
                }
 
-               $mockMailer = $this->getMock('mockMailer', array('mail'));
+               $mockMailer = $this->getMock('t3lib_mail_MailerAdapter', array('mail'));
+               $mockClassName = get_class($mockMailer);
+               t3lib_div::addInstance($mockClassName, $mockMailer);
                $mockMailer->expects($this->once())->method('mail')
                        ->with(
-                               array(
-                                       'to' => $to,
-                                       'subject' => $subject,
-                                       'messageBody' => $messageBody,
-                                       'additionalHeaders' => $additionalHeadersExpected,
-                                       'additionalParameters' => $additionalParameters,
-                               ),
-                               FALSE
+                               $to,
+                               $subject,
+                               $messageBody,
+                               $additionalHeadersExpected,
+                               $additionalParameters,
+                               $fakeThis
                        );
-               $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');
+                       ['substituteMailDelivery'] = array($mockClassName);
 
                t3lib_utility_Mail::mail(
                        $to, $subject, $messageBody, $additionalHeaders,