-
Notifications
You must be signed in to change notification settings - Fork 238
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 N°7916 SF#2274 EmailLaminas.php: Keep charset with part header in m…
…ultipart email (#672) * 🐛 N°2274 EmailLaminas.php: Keep charset with part header in multipart email * Add a unit test --------- Co-authored-by: Stephen Abello <[email protected]>
- Loading branch information
1 parent
0d5ff26
commit c70d62a
Showing
2 changed files
with
44 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,4 +45,43 @@ public function testCheckHeadersOnSendEmail(): void | |
$oConfig->Set('email_transport', $sCurrentEmailTransport); | ||
$oConfig->Set('email_asynchronous', $sCurrentEmailAsync); | ||
} | ||
|
||
/** | ||
* @return void | ||
* @throws \ConfigException | ||
* @throws \CoreException | ||
* @covers Email::SetBody() | ||
* @covers Email::Send() | ||
*/ | ||
public function testCheckPartsHeadersOnSendEmailWithAttachment(): void | ||
{ | ||
$oConfig = utils::GetConfig(); | ||
$sCurrentEmailTransport = $oConfig->Get('email_transport'); | ||
$sCurrentEmailAsync = $oConfig->Get('email_asynchronous'); | ||
|
||
// Set our email transport to file, so we can read it after | ||
$oConfig->Set('email_transport', 'LogFile'); | ||
$oConfig->Set('email_asynchronous', false); | ||
|
||
$oEmail = new Email(); | ||
$oEmail->SetRecipientTO('[email protected]'); | ||
$oEmail->SetRecipientFrom('[email protected]'); | ||
$oEmail->SetSubject('dummy subject'); | ||
$oEmail->SetBody('dummy body', 'text/plain'); | ||
$oEmail->AddAttachment('Dummy attachment', 'attachment.txt', 'text/plain'); | ||
|
||
// 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('Content-Type: text/plain; charset=UTF-8', $sEmailContent); | ||
|
||
// Set our previous email transport value back, so it doesn't affect other tests | ||
$oConfig->Set('email_transport', $sCurrentEmailTransport); | ||
$oConfig->Set('email_asynchronous', $sCurrentEmailAsync); | ||
} | ||
} |