Merged in bugfix/PMCORE-598 (pull request #7237)

PMCORE-598

Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
Andrea Adamczyk
2020-02-03 19:02:55 +00:00
committed by Julio Cesar Laura Avendaño
3 changed files with 99 additions and 2 deletions

View File

@@ -250,4 +250,101 @@ class EmailServerTest extends TestCase
$this->expectException(Exception::class);
$actual = $this->emailServer->getEmailServer($emailServerUid);
}
/**
* It tests the sendTestMail method with a successful result
*
* @covers \ProcessMaker\BusinessModel\EmailServer::sendTestMail()
* @test
*/
public function it_should_test_the_send_test_mail_method()
{
// The data that will be sent to the method
$data = [
"FROM_EMAIL" => "admin@processmaker.com",
"FROM_NAME" => "Administrator",
"MESS_ENGINE" => "MAIL",
"MESS_SERVER" => "localhost",
"MESS_PORT" => 25,
"MESS_ACCOUNT" => "admin@processmaker.com",
"MESS_PASSWORD" => "",
"TO" => "admin@processmaker.com",
"MESS_RAUTH" => true
];
// Create the EmailServer object
$emailServer = new EmailServer();
// Call the sendTestMail method
$result = $emailServer->sendTestMail($data);
// Assert the status is true
$this->assertTrue($result['status']);
// Assert the success is true
$this->assertTrue($result['success']);
// Assert the message of the result
$this->assertEquals('**ID_MAIL_TEST_SUCCESS**', $result['msg']);
}
/**
* It tests the sendTestMail method with a failed result
*
* @covers \ProcessMaker\BusinessModel\EmailServer::sendTestMail()
* @test
*/
public function it_should_test_the_send_test_mail_method_failure()
{
// The data that will be sent to the method
$data = [
"FROM_EMAIL" => "admin@processmaker.com",
"FROM_NAME" => "Administrator",
"MESS_ENGINE" => "PHPMAILER",
"MESS_SERVER" => "smtp.gmail.com",
"MESS_PORT" => 587,
"MESS_ACCOUNT" => "admin@processmaker.com",
"MESS_PASSWORD" => "",
"TO" => "admin@processmaker.com",
"MESS_RAUTH" => false,
];
// Create the EmailServer object
$emailServer = new EmailServer();
// Call the sendTestMail method
$result = $emailServer->sendTestMail($data);
// Assert the status is false
$this->assertFalse($result['status']);
// Assert the status is false
$this->assertFalse($result['success']);
// Assert the message of the result is empty
$this->assertEmpty($result['msg']);
}
/**
* It tests the sendTestMail method with an exception
*
* @covers \ProcessMaker\BusinessModel\EmailServer::sendTestMail()
* @test
*/
public function it_should_test_the_send_test_mail_method_exception()
{
// The data that will be sent to the method
$data = [];
// Create the EmailServer object
$emailServer = new EmailServer();
// This expects an exception message
$this->expectExceptionMessage("Undefined index: MESS_ENGINE");
// Call the sendTestMail method
$emailServer->sendTestMail($data);
}
/**
* Call the tearDown method
*/
public function tearDown()
{
parent::tearDown(); // TODO: Change the autogenerated stub
}
}

View File

@@ -195,7 +195,7 @@ class EmailServer
$bodyPre = new TemplatePower(PATH_TPL . "admin" . PATH_SEP . "email.tpl");
$bodyPre->prepare();
$bodyPre->assign("server", $_SERVER["SERVER_NAME"]);
$bodyPre->assign("server", System::getServerProtocol() . System::getServerHost());
$bodyPre->assign("date", date("H:i:s"));
$bodyPre->assign("ver", System::getVersion());
$bodyPre->assign("engine", $engine);

View File

@@ -2,7 +2,7 @@
<tbody>
<tr>
<td>
<img id='logo' src='http://{server}/images/processmaker.logo.jpg' />
<img id='logo' src='{server}/images/processmaker.logo.jpg' />
</td>
</tr>
<tr>