diff --git a/tests/php-unit-tests/unitary-tests/core/EMailTest.php b/tests/php-unit-tests/unitary-tests/core/EMailTest.php new file mode 100644 index 000000000..037a02b11 --- /dev/null +++ b/tests/php-unit-tests/unitary-tests/core/EMailTest.php @@ -0,0 +1,44 @@ +Get('email_transport'); + // Set our email transport to file so we can read it after + $oConfig->Set('email_transport', 'LogFile'); + + $oEmail = new Email(); + $oEmail->SetRecipientTO('email@email.com'); + $oEmail->SetRecipientFrom('email2@email2.com'); + $oEmail->SetSubject('dummy subject'); + $oEmail->SetBody('dummy body'); + + // Send the mail and check if there's any issue + $aIssues = []; + $oEmail->Send($aIssues); + $this->assertEmpty($aIssues); + + // Check if our charset is correctly set + // We know this file may be used by other future test, but as we can't configure output filename, it is what it is + $sEmailContent = file_get_contents(APPROOT.'log/mail.log'); + $this->assertStringContainsString('charset="UTF-8"', $sEmailContent); + + // Set our previous email transport value back, so it doesn't affect other tests + $oConfig->Set('email_transport', $sCurrentEmailTransport); + } +} \ No newline at end of file