PMCORE-764 No "test mail" is registered in "Logs" in the "Emails" option

This commit is contained in:
Roly Rudy Gutierrez Pinto
2020-01-28 17:23:33 -04:00
parent ba92704775
commit 54e5b60ba0
4 changed files with 136 additions and 6 deletions

View File

@@ -210,6 +210,10 @@ class GmailOAuthTest extends TestCase
$gmailOauth->setSendTestMail(0);
$result = $gmailOauth->sendTestEmailWithGoogleServiceGmail();
$this->assertTrue($result instanceof Google_Service_Gmail_Message);
$this->expectException(Exception::class);
$gmailOauth->setSendTestMail(1);
$result = $gmailOauth->sendTestEmailWithGoogleServiceGmail();
}
/**
@@ -249,6 +253,12 @@ class GmailOAuthTest extends TestCase
$gmailOauth->setSendTestMail(0);
$result = $gmailOauth->sendTestMailWithPHPMailerOAuth();
$this->assertTrue($result instanceof PHPMailerOAuth);
$this->expectException(Exception::class);
$gmailOauth->setSenderEmail("");
$gmailOauth->setMailTo($faker->email);
$gmailOauth->setSendTestMail(1);
$result = $gmailOauth->sendTestMailWithPHPMailerOAuth();
}
/**
@@ -262,4 +272,62 @@ class GmailOAuthTest extends TestCase
$result = $gmailOauth->getMessageBody();
$this->assertTrue(is_string($result));
}
/**
* This ensures that it is saved in the APP_MESSAGE table.
* @test
* @covers \ProcessMaker\GmailOAuth\GmailOAuth::saveIntoAppMessage()
*/
public function it_should_save_into_app_message_table()
{
$faker = $this->faker;
$gmailOauth = new GmailOAuth();
$gmailOauth->setFromAccount($faker->email);
$gmailOauth->setSenderEmail($faker->email);
$gmailOauth->setMailTo($faker->email);
try {
$gmailOauth->saveIntoAppMessage("pending");
} catch (Exception $e) {
$this->fail($e->getMessage());
}
$this->assertTrue(true);
try {
$gmailOauth->saveIntoAppMessage("sent");
} catch (Exception $e) {
$this->fail($e->getMessage());
}
$this->assertTrue(true);
}
/**
* This ensures that it is saved in the Standard Log table.
* @test
* @covers \ProcessMaker\GmailOAuth\GmailOAuth::saveIntoStandardLogs()
*/
public function it_should_save_into_standard_log()
{
$faker = $this->faker;
$gmailOauth = new GmailOAuth();
$gmailOauth->setFromAccount($faker->email);
$gmailOauth->setSenderEmail($faker->email);
$gmailOauth->setMailTo($faker->email);
try {
$gmailOauth->saveIntoStandardLogs("pending");
} catch (Exception $e) {
$this->fail($e->getMessage());
}
$this->assertTrue(true);
try {
$gmailOauth->saveIntoStandardLogs("sent");
} catch (Exception $e) {
$this->fail($e->getMessage());
}
$this->assertTrue(true);
}
}