From c41243e3819fe8555bb9a4dcb96f303b9f92d19c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Nitzsche?= Date: Sun, 26 Jun 2022 21:50:34 +0200 Subject: [PATCH 1/4] Some refactoring for current rn_base support --- .github/workflows/phpci.yml | 1 - .gitignore | 1 + .php-cs-fixer.php | 20 +++++ .../Frontend/Action/SendMails.php | 24 +++--- .../Mail/Attachment.php | 25 +++--- .../Mail/Factory.php | 55 ++++++------ .../Mail/IAttachment.php | 17 ++-- .../Mail/IMailAddress.php | 11 +-- .../Mail/MailAddress.php | 17 ++-- .../Model/Log.php | 14 ++-- .../Model/Queue.php | 47 +++++------ .../Model/Template.php | 84 ++++++++----------- Migrations/Code/ClassAliasMap.php | 16 ++++ Migrations/Code/LegacyClassesForIde.php | 43 ++++++++++ composer.json | 14 +++- 15 files changed, 223 insertions(+), 166 deletions(-) create mode 100644 .php-cs-fixer.php rename actions/class.tx_mkmailer_actions_SendMails.php => Classes/Frontend/Action/SendMails.php (70%) rename mail/class.tx_mkmailer_mail_Attachment.php => Classes/Mail/Attachment.php (80%) rename mail/class.tx_mkmailer_mail_Factory.php => Classes/Mail/Factory.php (81%) rename mail/class.tx_mkmailer_mail_IAttachment.php => Classes/Mail/IAttachment.php (79%) rename mail/class.tx_mkmailer_mail_IAddress.php => Classes/Mail/IMailAddress.php (78%) rename mail/class.tx_mkmailer_mail_Address.php => Classes/Mail/MailAddress.php (78%) rename models/class.tx_mkmailer_models_Log.php => Classes/Model/Log.php (75%) rename models/class.tx_mkmailer_models_Queue.php => Classes/Model/Queue.php (73%) rename models/class.tx_mkmailer_models_Template.php => Classes/Model/Template.php (66%) create mode 100644 Migrations/Code/ClassAliasMap.php create mode 100644 Migrations/Code/LegacyClassesForIde.php diff --git a/.github/workflows/phpci.yml b/.github/workflows/phpci.yml index ae76d45..81f225e 100644 --- a/.github/workflows/phpci.yml +++ b/.github/workflows/phpci.yml @@ -19,7 +19,6 @@ jobs: strategy: matrix: php-version: - - "7.0" - "7.1" - "7.2" - "7.3" diff --git a/.gitignore b/.gitignore index 3601939..364ce79 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ /var composer.lock .php_cs.cache +.php-cs-fixer.cache ### eclipse files /.buildpath diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php new file mode 100644 index 0000000..92a07d1 --- /dev/null +++ b/.php-cs-fixer.php @@ -0,0 +1,20 @@ +exclude('Resources') + ->exclude('Documentation') + ->exclude('phpmailer') + ->in(__DIR__) +; + +$config = new PhpCsFixer\Config(); +return $config->setFinder($finder) + ->setRules([ + '@Symfony' => true, + 'phpdoc_align' => false, + 'no_superfluous_phpdoc_tags' => false, + 'fully_qualified_strict_types' => false, + 'php_unit_method_casing' => false, + ]) + ->setLineEnding("\n") +; diff --git a/actions/class.tx_mkmailer_actions_SendMails.php b/Classes/Frontend/Action/SendMails.php similarity index 70% rename from actions/class.tx_mkmailer_actions_SendMails.php rename to Classes/Frontend/Action/SendMails.php index 769737f..04ad029 100644 --- a/actions/class.tx_mkmailer_actions_SendMails.php +++ b/Classes/Frontend/Action/SendMails.php @@ -1,4 +1,10 @@ getConfId(); - $mailSrv = tx_mkmailer_util_ServiceRegistry::getMailService(); + $mailSrv = \tx_mkmailer_util_ServiceRegistry::getMailService(); return $mailSrv->executeQueue($configurations, $this->getConfId()); } @@ -51,7 +55,7 @@ protected function handleRequest(&$parameters, &$configurations, &$viewdata) /** * (non-PHPdoc). * - * @see tx_rnbase_action_BaseIOC::getTemplateName() + * @see AbstractAction::getTemplateName() */ protected function getTemplateName() { @@ -61,14 +65,10 @@ protected function getTemplateName() /** * (non-PHPdoc). * - * @see tx_rnbase_action_BaseIOC::getViewClassName() + * @see AbstractAction::getViewClassName() */ protected function getViewClassName() { return ''; } } - -if (defined('TYPO3_MODE') && $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/mkmailer/actions/class.tx_mkmailer_actions_SendMails.php']) { - include_once $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/mkmailer/actions/class.tx_mkmailer_actions_SendMails.php']; -} diff --git a/mail/class.tx_mkmailer_mail_Attachment.php b/Classes/Mail/Attachment.php similarity index 80% rename from mail/class.tx_mkmailer_mail_Attachment.php rename to Classes/Mail/Attachment.php index 16a530e..7eaab7b 100644 --- a/mail/class.tx_mkmailer_mail_Attachment.php +++ b/Classes/Mail/Attachment.php @@ -1,4 +1,7 @@ type = $type; } } - -if (defined('TYPO3_MODE') && $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/mkmailer/mail/class.tx_mkmailer_mail_Attachment.php']) { - include_once $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/mkmailer/mail/class.tx_mkmailer_mail_Attachment.php']; -} diff --git a/mail/class.tx_mkmailer_mail_Factory.php b/Classes/Mail/Factory.php similarity index 81% rename from mail/class.tx_mkmailer_mail_Factory.php rename to Classes/Mail/Factory.php index 5406a24..3ac55d2 100644 --- a/mail/class.tx_mkmailer_mail_Factory.php +++ b/Classes/Mail/Factory.php @@ -1,4 +1,13 @@ file($absPathOrContent); @@ -117,9 +122,9 @@ protected static function getFileInfoMimeType($absPathOrContent) */ public static function makeAbsPath($path) { - if (!tx_rnbase_util_Files::isAbsPath($path)) { - $path = tx_rnbase_util_Files::getFileAbsFileName( - Tx_Rnbase_Utility_T3General::fixWindowsFilePath($path) + if (!Files::isAbsPath($path)) { + $path = Files::getFileAbsFileName( + T3General::fixWindowsFilePath($path) ); } @@ -134,7 +139,7 @@ public static function makeAbsPath($path) * @param string $encoding * @param string $mimeType * - * @return tx_mkmailer_mail_IAttachment + * @return IAttachment */ public static function createStringAttachment( $content, @@ -143,7 +148,7 @@ public static function createStringAttachment( $mimeType = false ) { return self::createAttachmentInstance( - tx_mkmailer_mail_IAttachment::TYPE_ATTACHMENT, + IAttachment::TYPE_ATTACHMENT, $content, $name, '', @@ -163,7 +168,7 @@ public static function createStringAttachment( * @param string $encoding * @param string $mimeType * - * @return tx_mkmailer_mail_IAttachment + * @return IAttachment */ public static function createEmbeddedAttachment( $path, @@ -173,7 +178,7 @@ public static function createEmbeddedAttachment( $mimeType = false ) { return self::createAttachmentInstance( - tx_mkmailer_mail_IAttachment::TYPE_ATTACHMENT, + IAttachment::TYPE_ATTACHMENT, self::makeAbsPath($path), $name, $embedId, @@ -192,7 +197,7 @@ public static function createEmbeddedAttachment( * @param string $encoding * @param string $mimeType * - * @return tx_mkmailer_mail_Attachment + * @return Attachment */ private static function createAttachmentInstance( $type, @@ -202,9 +207,9 @@ private static function createAttachmentInstance( $encoding = 'base64', $mimeType = false ) { - /* @var $attachment tx_mkmailer_mail_Attachment */ + /* @var $attachment Attachment */ $attachment = tx_rnbase::makeInstance( - 'tx_mkmailer_mail_Attachment', + Attachment::class, $type ); @@ -227,14 +232,14 @@ private static function createAttachmentInstance( * @param string $address * @param string $name * - * @return tx_mkmailer_mail_Address + * @return MailAddress */ public static function createAddressInstance( $address, $name = '' ) { return tx_rnbase::makeInstance( - 'tx_mkmailer_mail_Address', + MailAddress::class, $address, $name ); diff --git a/mail/class.tx_mkmailer_mail_IAttachment.php b/Classes/Mail/IAttachment.php similarity index 79% rename from mail/class.tx_mkmailer_mail_IAttachment.php rename to Classes/Mail/IAttachment.php index c0d4a19..e542b38 100644 --- a/mail/class.tx_mkmailer_mail_IAttachment.php +++ b/Classes/Mail/IAttachment.php @@ -1,4 +1,7 @@ * @license http://www.gnu.org/licenses/lgpl.html * GNU Lesser General Public License, version 3 or later */ -class tx_mkmailer_mail_Address implements tx_mkmailer_mail_IAddress +class MailAddress implements IMailAddress { /** * @param string $address @@ -54,7 +53,7 @@ public function setAddress($address) /** * (non-PHPdoc). * - * @see tx_mkmailer_mail_IAddress::getAddress() + * @see IMailAddress::getAddress() */ public function getAddress() { @@ -72,14 +71,10 @@ public function setName($name) /** * (non-PHPdoc). * - * @see tx_mkmailer_mail_IAddress::getName() + * @see IMailAddress::getName() */ public function getName() { return $this->name; } } - -if (defined('TYPO3_MODE') && $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/mkmailer/mail/class.tx_mkmailer_mail_Address.php']) { - include_once $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/mkmailer/mail/class.tx_mkmailer_mail_Address.php']; -} diff --git a/models/class.tx_mkmailer_models_Log.php b/Classes/Model/Log.php similarity index 75% rename from models/class.tx_mkmailer_models_Log.php rename to Classes/Model/Log.php index 0071de8..82ad89c 100644 --- a/models/class.tx_mkmailer_models_Log.php +++ b/Classes/Model/Log.php @@ -1,4 +1,9 @@ record['subject']; + return $this->getProperty('subject'); } /** @@ -62,7 +67,7 @@ public function getSubject() */ public function getContentText() { - return $this->record['contenttext']; + return $this->getProperty('contenttext'); } /** @@ -72,7 +77,7 @@ public function getContentText() */ public function getContentHtml() { - return $this->record['contenthtml']; + return $this->getProperty('contenthtml'); } /** @@ -89,14 +94,12 @@ public function getUploads() } // Hier muss geprüft werden ob serialisierte Daten vorliegen. if ($attachments && 'a' === $attachments[0] && ':' === $attachments[1]) { - tx_rnbase::load('tx_mkmailer_mail_Attachment'); $ret = unserialize($attachments); } else { // Alle Strings zu Attachments umformen - tx_rnbase::load('tx_mkmailer_mail_Factory'); - $files = tx_rnbase_util_Strings::trimExplode(',', $attachments); + $files = Strings::trimExplode(',', $attachments); foreach ($files as $file) { - $ret[] = tx_mkmailer_mail_Factory::createAttachment($file); + $ret[] = Factory::createAttachment($file); } } @@ -108,7 +111,7 @@ public function getUploads() */ public function getMailCount() { - return intval($this->record['mailcount']); + return (int) $this->getProperty('mailcount'); } /** @@ -116,7 +119,7 @@ public function getMailCount() */ public function getCc() { - return $this->record['mail_cc']; + return $this->getProperty('mail_cc'); } /** @@ -124,7 +127,7 @@ public function getCc() */ public function getBcc() { - return $this->record['mail_bcc']; + return $this->getProperty('mail_bcc'); } /** @@ -132,7 +135,7 @@ public function getBcc() */ public function getFrom() { - return $this->record['mail_from']; + return $this->getProperty('mail_from'); } /** @@ -140,7 +143,7 @@ public function getFrom() */ public function getFromName() { - return $this->record['mail_fromName']; + return $this->getProperty('mail_fromName'); } /** @@ -150,7 +153,7 @@ public function getFromName() */ public function isPrefer() { - return intval($this->record['prefer']) > 0; + return intval($this->getProperty('prefer')) > 0; } /** @@ -160,7 +163,7 @@ public function isPrefer() */ public function getCreationDate() { - return $this->record['cr_date']; + return $this->getProperty('cr_date'); } /** @@ -170,7 +173,7 @@ public function getCreationDate() */ public function getLastUpdate() { - return $this->record['lastupdate']; + return $this->getProperty('lastupdate'); } /** @@ -180,12 +183,8 @@ public function getLastUpdate() */ public function getReceivers() { - $mailServ = tx_mkmailer_util_ServiceRegistry::getMailService(); + $mailServ = \tx_mkmailer_util_ServiceRegistry::getMailService(); return $mailServ->getMailReceivers($this); } } - -if (defined('TYPO3_MODE') && $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/mkmailer/models/class.tx_mkmailer_models_Queue.php']) { - include_once $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/mkmailer/models/class.tx_mkmailer_models_Queue.php']; -} diff --git a/models/class.tx_mkmailer_models_Template.php b/Classes/Model/Template.php similarity index 66% rename from models/class.tx_mkmailer_models_Template.php rename to Classes/Model/Template.php index e8bddd7..362846e 100644 --- a/models/class.tx_mkmailer_models_Template.php +++ b/Classes/Model/Template.php @@ -1,4 +1,15 @@ record['contenttext']; + return $this->getProperty('contenttext'); } /** @@ -64,11 +70,10 @@ public function getContentText() public function getContentHtml($plain = false) { if ($plain) { - return $this->record['contenthtml']; + return $this->getProperty('contenthtml'); } - tx_rnbase::load('tx_mkmailer_util_Misc'); - $ret = tx_mkmailer_util_Misc::getRTEText($this->record['contenthtml']); + $ret = Misc::getRTEText($this->getProperty('contenthtml')); return $ret; } @@ -76,7 +81,7 @@ public function getContentHtml($plain = false) /** * Liefert die BCCs als Adress-Array. * - * @return array[tx_mkmailer_mail_IAddress] + * @return IMailAddress[] */ public function getBccAddress() { @@ -86,7 +91,7 @@ public function getBccAddress() /** * @param string $addrStr * - * @return multitype:|multitype:tx_mkmailer_mail_Address + * @return multitype:|multitype:MailAddress */ private function getAddresses($addrStr) { @@ -94,9 +99,9 @@ private function getAddresses($addrStr) if (!strlen(trim($addrStr))) { return $ret; } - $addrArr = tx_rnbase_util_Strings::trimExplode(',', $addrStr); + $addrArr = Strings::trimExplode(',', $addrStr); foreach ($addrArr as $addr) { - $ret[] = new tx_mkmailer_mail_Address($addr); + $ret[] = new MailAddress($addr); } return $ret; @@ -107,13 +112,13 @@ private function getAddresses($addrStr) */ public function getBcc() { - return $this->record['mail_bcc']; + return $this->getProperty('mail_bcc'); } /** * Liefert die CCs als Adress-Array. * - * @return array[tx_mkmailer_mail_IAddress] + * @return IMailAddress[] */ public function getCcAddress() { @@ -125,17 +130,17 @@ public function getCcAddress() */ public function getCc() { - return $this->record['mail_cc']; + return $this->getProperty('mail_cc'); } /** * Liefert den Absender als Adresse. * - * @return tx_mkmailer_mail_IAddress + * @return \tx_mkmailer_mail_IAddress */ public function getFromAddress() { - return new tx_mkmailer_mail_Address($this->record['mail_from'], $this->record['mail_fromName']); + return new MailAddress($this->getProperty('mail_from'), $this->getProperty('mail_fromName')); } /** @@ -145,7 +150,7 @@ public function getFromAddress() */ public function getFrom() { - return $this->record['mail_from']; + return $this->getProperty('mail_from'); } /** @@ -155,7 +160,7 @@ public function getFrom() */ public function getFromName() { - return $this->record['mail_fromName']; + return $this->getProperty('mail_fromName'); } /** @@ -165,22 +170,7 @@ public function getFromName() */ public function getSubject() { - return $this->record['subject']; - } - - /** - * Liefert die DAM-Attachments. - * - * @return array - */ - private function getDamAttachmentPaths() - { - if (!$this->isPersisted() || !tx_rnbase_util_Extensions::isLoaded('dam')) { - return []; - } - $dam = tx_rnbase_util_TSDAM::getReferences($this->getTableName(), $this->getUid(), 'attachments'); - - return empty($dam['files']) ? [] : array_values($dam['files']); + return $this->getProperty('subject'); } /** @@ -193,10 +183,8 @@ private function getDamAttachmentPaths() private function getFalAttachmentPaths() { $attachmentPaths = []; - tx_rnbase::load('tx_rnbase_util_TYPO3'); - if ($this->isPersisted() && tx_rnbase_util_TYPO3::isTYPO60OrHigher()) { - tx_rnbase::load('tx_rnbase_util_TSFAL'); - $falFiles = tx_rnbase_util_TSFAL::getReferences( + if ($this->isPersisted()) { + $falFiles = TSFAL::getReferences( $this->getTableName(), $this->getUid(), 'attachments' @@ -230,7 +218,7 @@ private function getT3AttachmentUploadFolder() */ private function getT3AttachmentPaths() { - $files = tx_rnbase_util_Strings::trimExplode(',', $this->record['attachmentst3'], true); + $files = Strings::trimExplode(',', $this->getProperty('attachmentst3'), true); if (empty($files)) { return $files; } @@ -252,7 +240,6 @@ protected function getAttachmentPaths() { return array_merge( $this->getFalAttachmentPaths(), - $this->getDamAttachmentPaths(), $this->getT3AttachmentPaths() ); } @@ -260,7 +247,7 @@ protected function getAttachmentPaths() /** * Liefert die Attachments. * - * @return array[tx_mkmailer_mail_IAttachment] + * @return \tx_mkmailer_mail_IAttachment[] */ public function getAttachments() { @@ -268,15 +255,10 @@ public function getAttachments() if (empty($files)) { return $files; } - tx_rnbase::load('tx_mkmailer_mail_Factory'); foreach ($files as &$file) { - $file = tx_mkmailer_mail_Factory::createAttachment($file); + $file = \tx_mkmailer_mail_Factory::createAttachment($file); } return $files; } } - -if (defined('TYPO3_MODE') && $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/mkmailer/models/class.tx_mkmailer_models_Template.php']) { - include_once $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/mkmailer/models/class.tx_mkmailer_models_Template.php']; -} diff --git a/Migrations/Code/ClassAliasMap.php b/Migrations/Code/ClassAliasMap.php new file mode 100644 index 0000000..fe8dcb0 --- /dev/null +++ b/Migrations/Code/ClassAliasMap.php @@ -0,0 +1,16 @@ + \DMK\MkMailer\Frontend\Action\SendMails::class, + 'tx_mkmailer_mail_IAddress' => \DMK\MkMailer\Mail\IMailAddress::class, + 'tx_mkmailer_mail_IAttachment' => \DMK\MkMailer\Mail\IAttachment::class, + 'tx_mkmailer_mail_Address' => \DMK\MkMailer\Mail\MailAddress::class, + 'tx_mkmailer_mail_Attachment' => \DMK\MkMailer\Mail\Attachment::class, + 'tx_mkmailer_mail_Factory' => \DMK\MkMailer\Mail\Factory::class, + + 'tx_mkmailer_models_Log' => \DMK\MkMailer\Model\Log::class, + 'tx_mkmailer_models_Queue' => \DMK\MkMailer\Model\Queue::class, + 'tx_mkmailer_models_Template' => \DMK\MkMailer\Model\Template::class, +]; diff --git a/Migrations/Code/LegacyClassesForIde.php b/Migrations/Code/LegacyClassesForIde.php new file mode 100644 index 0000000..f1c641e --- /dev/null +++ b/Migrations/Code/LegacyClassesForIde.php @@ -0,0 +1,43 @@ + Date: Sun, 26 Jun 2022 21:55:31 +0200 Subject: [PATCH 2/4] Fix linter --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index f4f703d..4d7e394 100644 --- a/composer.json +++ b/composer.json @@ -75,7 +75,7 @@ ], "lint:php": [ "[ -e .Build/bin/parallel-lint ] || composer update", - ".Build/bin/parallel-lint ./scheduler ./actions ./exceptions ./mail ./mod1 ./models ./phpmailer ./receiver ./services ./tests ./util ./*.php" + ".Build/bin/parallel-lint ./scheduler ./exceptions ./mail ./mod1 ./phpmailer ./receiver ./services ./tests ./util ./*.php" ], "lint": [ "@lint:php" From 1b6eb931358f189795e91fb98a0aded681b5c89a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Nitzsche?= Date: Sun, 26 Jun 2022 22:03:17 +0200 Subject: [PATCH 3/4] Fix unit test --- Classes/Model/Queue.php | 2 +- ...ass.tx_mkmailer_tests_mail_FactoryTest.php | 16 +++++++------- ...ass.tx_mkmailer_tests_models_QueueTest.php | 21 +++++++++---------- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/Classes/Model/Queue.php b/Classes/Model/Queue.php index a6f1c6a..997104e 100644 --- a/Classes/Model/Queue.php +++ b/Classes/Model/Queue.php @@ -88,7 +88,7 @@ public function getContentHtml() public function getUploads() { $ret = []; - $attachments = $this->record['attachments']; + $attachments = $this->getProperty('attachments'); if (!$attachments) { return $ret; } diff --git a/tests/mail/class.tx_mkmailer_tests_mail_FactoryTest.php b/tests/mail/class.tx_mkmailer_tests_mail_FactoryTest.php index aafed66..c5df07f 100644 --- a/tests/mail/class.tx_mkmailer_tests_mail_FactoryTest.php +++ b/tests/mail/class.tx_mkmailer_tests_mail_FactoryTest.php @@ -1,4 +1,8 @@ 123, 'attachments' => '/uploadfolder/myfile.jpg, /uploadfolder/yourfile.jpg']); + $queue = tx_rnbase::makeInstance(Queue::class, ['uid' => 123, 'attachments' => '/uploadfolder/myfile.jpg, /uploadfolder/yourfile.jpg']); $attachments = $queue->getUploads(); $this->assertEquals(2, count($attachments), 'Wrong size of attachments'); - $this->assertTrue($attachments[0] instanceof tx_mkmailer_mail_IAttachment, 'Interface not implemented.'); + $this->assertTrue($attachments[0] instanceof IAttachment, 'Interface not implemented.'); $this->assertEquals('/uploadfolder/myfile.jpg', $attachments[0]->getPathOrContent(), 'File is wrong.'); } @@ -48,14 +51,10 @@ public function tesstAttachmentWithSerializedObjects() // geht leider nicht. Deserialisierung klappt nicht. $serData = 'a:2:{i:0;O:27:"tx_mkmailer_mail_Attachment":6:{s:33:"tx_mkmailer_mail_Attachmenttype";i:0;s:42:"tx_mkmailer_mail_AttachmentpathOrContent";s:24:"/uploadfolder/myfile.jpg";s:33:"tx_mkmailer_mail_Attachmentname";s:0:"";s:36:"tx_mkmailer_mail_AttachmentembedId";N;s:37:"tx_mkmailer_mail_AttachmentmimeType";s:24:"application/octet-stream";s:37:"tx_mkmailer_mail_Attachmentencoding";s:6:"base64";}i:1;O:27:"tx_mkmailer_mail_Attachment":6:{s:33:"tx_mkmailer_mail_Attachmenttype";i:0;s:42:"tx_mkmailer_mail_AttachmentpathOrContent";s:26:"/uploadfolder/yourfile.jpg";s:33:"tx_mkmailer_mail_Attachmentname";s:0:"";s:36:"tx_mkmailer_mail_AttachmentembedId";N;s:37:"tx_mkmailer_mail_AttachmentmimeType";s:24:"application/octet-stream";s:37:"tx_mkmailer_mail_Attachmentencoding";s:6:"base64";}}'; - $queue = tx_rnbase::makeInstance('tx_mkmailer_models_Queue', ['uid' => 123, 'attachments' => $serData]); + $queue = tx_rnbase::makeInstance(Queue::class, ['uid' => 123, 'attachments' => $serData]); $attachments = $queue->getUploads(); $this->assertEquals(2, count($attachments), 'Wrong size of attachments'); - $this->assertTrue($attachments[0] instanceof tx_mkmailer_mail_IAttachment, 'Interface not implemented.'); + $this->assertTrue($attachments[0] instanceof IAttachment, 'Interface not implemented.'); $this->assertEquals('/uploadfolder/myfile.jpg', $attachments[0]->getPathOrContent(), 'File is wrong.'); } } - -if (defined('TYPO3_MODE') && $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/mkmailer/tests/models/class.tx_mkmailer_tests_models_Queue_testcase.php']) { - include_once $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/mkmailer/tests/models/class.tx_mkmailer_tests_models_Queue_testcase.php']; -} From b76eb61027a6706137c782a346081d25749ad8c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Nitzsche?= Date: Sun, 26 Jun 2022 22:05:34 +0200 Subject: [PATCH 4/4] Fix unit test --- tests/mail/class.tx_mkmailer_tests_mail_FactoryTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/mail/class.tx_mkmailer_tests_mail_FactoryTest.php b/tests/mail/class.tx_mkmailer_tests_mail_FactoryTest.php index c5df07f..b4d667f 100644 --- a/tests/mail/class.tx_mkmailer_tests_mail_FactoryTest.php +++ b/tests/mail/class.tx_mkmailer_tests_mail_FactoryTest.php @@ -26,7 +26,6 @@ * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ - /** * Mail factory Tests. *