[TASK] Removes eval() in core mailer unit test 48/40448/3
authorPierrick Caillon <pierrick.caillon@plan-net.fr>
Thu, 18 Jun 2015 13:26:53 +0000 (15:26 +0200)
committerMarkus Klein <markus.klein@typo3.org>
Thu, 18 Jun 2015 21:06:02 +0000 (23:06 +0200)
Adds fixture for FakeTransport and removes the ugly usage of
eval() from MailerTest in unit tests.

Resolves: #67604
Related: #67468
Releases: master
Change-Id: I37011a5eaadc0abac38e1c53bcd20bbe3e62f4fd
Reviewed-on: http://review.typo3.org/40448
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
typo3/sysext/core/Tests/Unit/Mail/Fixtures/FakeTransportFixture.php [new file with mode: 0644]
typo3/sysext/core/Tests/Unit/Mail/MailerTest.php

diff --git a/typo3/sysext/core/Tests/Unit/Mail/Fixtures/FakeTransportFixture.php b/typo3/sysext/core/Tests/Unit/Mail/Fixtures/FakeTransportFixture.php
new file mode 100644 (file)
index 0000000..3748bb1
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+namespace TYPO3\CMS\Core\Tests\Unit\Mail\Fixtures;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use TYPO3\CMS\Core\Mail\MboxTransport;
+
+/**
+ * Fixture fake transport
+ */
+class FakeTransportFixture extends MboxTransport {
+
+       /**
+        * Constructor
+        *
+        * @param string $settings
+        */
+       public function __construct($settings) {
+       }
+}
index 0c3cdc3..58d93f1 100644 (file)
@@ -13,6 +13,7 @@ namespace TYPO3\CMS\Core\Tests\Unit\Mail;
  *
  * The TYPO3 project - inspiring people to share!
  */
+use TYPO3\CMS\Core\Tests\Unit\Mail\Fixtures\FakeTransportFixture;
 
 /**
  * Testcase for the TYPO3\CMS\Core\Mail\Mailer class.
@@ -82,13 +83,7 @@ class MailerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @test
         */
        public function providingCorrectClassnameDoesNotThrowException() {
-               if (!class_exists('t3lib_mail_SwiftMailerFakeTransport')) {
-                               // Create fake custom transport class
-                       eval('class t3lib_mail_SwiftMailerFakeTransport extends \\TYPO3\\CMS\\Core\\Mail\\MboxTransport {
-                               public function __construct($settings) {}
-                       }');
-               }
-               $this->subject->injectMailSettings(array('transport' => 't3lib_mail_SwiftMailerFakeTransport'));
+               $this->subject->injectMailSettings(array('transport' => FakeTransportFixture::class));
                $this->subject->__construct();
        }