PMCORE-2091 PMFSendMessage sends 10 mails when deleting a case

This commit is contained in:
Roly Rudy Gutierrez Pinto
2020-09-09 19:32:41 -04:00
parent e31ad1f404
commit c0b94a7ccf
2 changed files with 55 additions and 0 deletions

View File

@@ -331,4 +331,56 @@ class SpoolRunTest extends TestCase
$this->assertTrue($expected);
}
/**
* This test updateSpoolStatus method.
* @test
* @covers \SpoolRun::__construct()
* @covers \SpoolRun::setData()
* @covers \SpoolRun::setConfig()
* @covers \SpoolRun::sendMail()
* @covers \SpoolRun::handleMail()
* @covers \SpoolRun::updateSpoolStatus()
*/
public function it_should_test_updateSpoolStatus_method()
{
$appMsgUid = G::generateUniqueID();
factory(AppMessage::class)->create([
'APP_MSG_UID' => $appMsgUid
]);
$emailServer = factory(EmailServerModel::class)->states('PHPMAILER')->make();
$config = $emailServer->toArray();
$config['SMTPSecure'] = 'ssl';
$faker = Factory::create();
$file1 = UploadedFile::fake()->image('avatar.jpg', 400, 300);
$file2 = UploadedFile::fake()->create('document.pdf', 200);
$files = [
$file1->path(),
$file2->path()
];
$spoolRun = new SpoolRun();
$spoolRun->setData(
$appMsgUid,
$faker->title,
$faker->companyEmail,
$faker->freeEmail,
$faker->text(),
$faker->dateTime()->format('Y-m-d H:i:s'),
$faker->companyEmail,
$faker->freeEmail,
'',
$files
);
$spoolRun->setConfig($config);
$expected = $spoolRun->sendMail();
$this->assertTrue($expected);
}
}

View File

@@ -336,6 +336,9 @@ class SpoolRun
private function updateSpoolStatus()
{
$oAppMessage = AppMessagePeer::retrieveByPK($this->spoolId);
if (empty($oAppMessage)) {
return;
}
if (is_array($this->fileData['attachments'])) {
$attachment = implode(",", $this->fileData['attachments']);
$oAppMessage->setappMsgAttach($attachment);