PMCORE-598

This commit is contained in:
Andrea Adamczyk
2020-02-03 11:41:58 -04:00
parent 76f2eaf619
commit ebef7b41cd
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
}
}