[BUGFIX] Fix the unit tests to work with PHPUnit 3.6
authorOliver Klee <typo3-coding@oliverklee.de>
Fri, 6 Apr 2012 23:54:46 +0000 (01:54 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Thu, 12 Apr 2012 16:47:39 +0000 (18:47 +0200)
Phpunit 3.6 is no longer able to test for a generic Exception
class. The main part of this patch changes generic Exceptions to
better detailed subclasses to give more information on the error.

Change-Id: I286ae33bfaffec3e347fbb1a67910aeb3afa623e
Fixes: #35202
Releases: 6.0, 4.7, 4.6, 4.5
Reviewed-on: http://review.typo3.org/10352
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
t3lib/config_default.php
t3lib/mail/class.t3lib_mail_mboxtransport.php
t3lib/mail/class.t3lib_mail_rfc822addressesparser.php
t3lib/tree/pagetree/class.t3lib_tree_pagetree_commands.php
tests/t3lib/utility/t3lib_utility_mailTest.php
typo3/sysext/em/classes/connection/class.tx_em_connection_soap.php
typo3/sysext/scheduler/class.tx_scheduler_croncmd_normalize.php

index b16fe4a..24c2839 100644 (file)
@@ -704,7 +704,7 @@ define('TYPO3_URL_DONATE', 'http://typo3.org/donate/');
 
        // Include localconf.php. Use this file to configure TYPO3 for your needs and database
 if (!@is_file(PATH_typo3conf . 'localconf.php')) {
-       throw new Exception('localconf.php is not found!');
+       throw new RuntimeException('localconf.php is not found!', 1333754332);
 }
 require(PATH_typo3conf.'localconf.php');
 
index f5d87e4..0344f44 100644 (file)
@@ -77,7 +77,7 @@ class t3lib_mail_MboxTransport implements Swift_Transport {
         * @param Swift_Mime_Message $message The message to send
         * @param string[] &$failedRecipients To collect failures by-reference, nothing will fail in our debugging case
         * @return int
-        * @throws Exception
+        * @throws RuntimeException
         */
        public function send(Swift_Mime_Message $message, &$failedRecipients = null) {
                $message->generateId();
index 5978598..83c8549 100644 (file)
@@ -172,7 +172,7 @@ class t3lib_mail_Rfc822AddressesParser {
                while ($this->address = $this->_splitAddresses($this->address));
 
                if ($this->address === false || isset($this->error)) {
-                       throw new Exception($this->error, 1294681466);
+                       throw new InvalidArgumentException($this->error, 1294681466);
                }
 
                // Validate each address individually.  If we encounter an invalid
@@ -181,7 +181,7 @@ class t3lib_mail_Rfc822AddressesParser {
                        $valid = $this->_validateAddress($address);
 
                        if ($valid === false || isset($this->error)) {
-                               throw new Exception($this->error, 1294681467);
+                               throw new InvalidArgumentException($this->error, 1294681467);
                        }
 
                        $this->structure = array_merge($this->structure, $valid);
@@ -842,4 +842,4 @@ class t3lib_mail_Rfc822AddressesParser {
        }
 }
 
-?>
+?>
\ No newline at end of file
index 38cc37d..5e7456a 100644 (file)
@@ -171,7 +171,7 @@ final class t3lib_tree_pagetree_Commands {
         *
         * @param array $cmd
         * @param array $data
-        * @throws Exception if an error happened while the TCE processing
+        * @throws RuntimeException if an error happened while the TCE processing
         * @return array
         */
        protected static function processTceCmdAndDataMap(array $cmd, array $data = array()) {
@@ -191,7 +191,7 @@ final class t3lib_tree_pagetree_Commands {
 
                        // check errors
                if (count($tce->errorLog)) {
-                       throw new Exception(implode(chr(10), $tce->errorLog));
+                       throw new RuntimeException(implode(chr(10), $tce->errorLog), 1333754629);
                }
 
                return $returnValues;
index 2f6ca2c..041d125 100644 (file)
@@ -51,6 +51,7 @@ class t3lib_utility_mailTest extends tx_phpunit_testcase {
        }
 
        public function tearDown() {
+               t3lib_div::purgeInstances();
                $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'] = $this->scOptionsBackup;
                $GLOBALS['T3_VAR']['callUserFunction'] = $this->callUserFunctionBackup;
        }
index a2b6c79..409e49b 100644 (file)
@@ -89,7 +89,7 @@ class tx_em_Connection_Soap {
                        $this->client = new SoapClient($options['wsdl'], (array) $options['soapoptions']);
                } else {
                        $this->client = FALSE;
-                       throw new Exception('PHP soap extension not available');
+                       throw new RuntimeException('PHP soap extension not available', 1333754714);
                }
        }
 
index 32b907d..4832107 100644 (file)
@@ -309,7 +309,7 @@ final class tx_scheduler_CronCmd_Normalize {
         *      1-5/2 -> 1,3,5
         *      2-10/3 -> 2,5,8
         *
-        * @throws Exception if step value is invalid or if resulting list is empty
+        * @throws InvalidArgumentException if step value is invalid or if resulting list is empty
         * @param string #stepExpression stepvalue expression
         * @return string Comma separated list of valid values
         */
@@ -458,4 +458,4 @@ final class tx_scheduler_CronCmd_Normalize {
                return $normalizedWeekday;
        }
 }
-?>
+?>
\ No newline at end of file