PMCORE-959
This commit is contained in:
@@ -364,6 +364,46 @@ class EmailServerTest extends TestCase
|
||||
$emailServer->sendTestMail($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* It test the delete method
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\EmailServer::delete()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_the_delete_method()
|
||||
{
|
||||
$email = factory(EmailServerModel::class)->create();
|
||||
|
||||
$emailServer = new EmailServer();
|
||||
$res = $emailServer->delete($email['MESS_UID']);
|
||||
|
||||
$this->assertNull($res);
|
||||
|
||||
$this->expectExceptionMessage("**ID_EMAIL_SERVER_DOES_NOT_EXIST**");
|
||||
$emailServer->getEmailServer($email['MESS_UID']);
|
||||
}
|
||||
|
||||
/**
|
||||
* It test the delete method with an IMAP email server
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\EmailServer::delete()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_the_delete_method_with_imap()
|
||||
{
|
||||
$email = factory(EmailServerModel::class)->create([
|
||||
'MESS_ENGINE' => 'IMAP'
|
||||
]);
|
||||
|
||||
$emailServer = new EmailServer();
|
||||
$res = $emailServer->delete($email['MESS_UID']);
|
||||
|
||||
$this->assertNull($res);
|
||||
|
||||
$this->expectExceptionMessage("**ID_EMAIL_SERVER_DOES_NOT_EXIST**");
|
||||
$emailServer->getEmailServer($email['MESS_UID']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call the tearDown method
|
||||
*/
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
|
||||
|
||||
use EmailServer;
|
||||
use ProcessMaker\Model\Application;
|
||||
use ProcessMaker\Model\AbeConfiguration;
|
||||
use ProcessMaker\Model\AbeRequest;
|
||||
@@ -105,4 +106,82 @@ class AbeConfigurationTest extends TestCase
|
||||
//Asserts the result has one record
|
||||
$this->assertEmpty($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* It should test the updateReceiverUidToEmpty method
|
||||
*
|
||||
* @covers \ProcessMaker\Model\AbeConfiguration::updateReceiverUidToEmpty()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_the_update_abe_configuration_receiver_uid_method()
|
||||
{
|
||||
$emailServer = factory(EmailServerModel::class)->create();
|
||||
|
||||
$abeConfigurationFactory = factory(AbeConfiguration::class)->create([
|
||||
'ABE_EMAIL_SERVER_UID' => $emailServer['MESS_UID']
|
||||
]);
|
||||
|
||||
$abeConfiguration = new AbeConfiguration();
|
||||
$abeConfiguration->updateReceiverUidToEmpty($emailServer['MESS_UID']);
|
||||
|
||||
$query = AbeConfiguration::query()->select();
|
||||
$query->where('ABE_UID', $abeConfigurationFactory['ABE_UID']);
|
||||
$updatedAbe = $query->get()->values()->toArray();
|
||||
|
||||
$this->assertEquals($updatedAbe[0]['ABE_EMAIL_SERVER_RECEIVER_UID'], '');
|
||||
}
|
||||
|
||||
/**
|
||||
* It should test the updateEmailServerUidToDefaultOrEmpty method when there is not a default server
|
||||
*
|
||||
* @covers \ProcessMaker\Model\AbeConfiguration::updateEmailServerUidToDefaultOrEmpty()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_the_update_abe_configuration_email_server_uid_method_when_there_is_not_a_default_server()
|
||||
{
|
||||
EmailServerModel::query()->delete();
|
||||
$emailServer = factory(EmailServerModel::class)->create();
|
||||
|
||||
$abeConfigurationFactory = factory(AbeConfiguration::class)->create([
|
||||
'ABE_EMAIL_SERVER_UID' => $emailServer['MESS_UID']
|
||||
]);
|
||||
|
||||
$abeConfiguration = new AbeConfiguration();
|
||||
$abeConfiguration->updateEmailServerUidToDefaultOrEmpty($emailServer['MESS_UID']);
|
||||
|
||||
$query = AbeConfiguration::query()->select();
|
||||
$query->where('ABE_UID', $abeConfigurationFactory['ABE_UID']);
|
||||
$updatedAbe = $query->get()->values()->toArray();
|
||||
|
||||
$this->assertEquals($updatedAbe[0]['ABE_EMAIL_SERVER_UID'], '');
|
||||
}
|
||||
|
||||
/**
|
||||
* It should test the updateEmailServerUidToDefaultOrEmpty method when there is a default server
|
||||
*
|
||||
* @covers \ProcessMaker\Model\AbeConfiguration::updateEmailServerUidToDefaultOrEmpty()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_the_update_abe_configuration_email_server_uid_method_when_there_is_a_default_server()
|
||||
{
|
||||
EmailServerModel::query()->delete();
|
||||
$emailServer = factory(EmailServerModel::class)->create();
|
||||
|
||||
$defaultServer = factory(EmailServerModel::class)->create([
|
||||
'MESS_DEFAULT' => 1
|
||||
]);
|
||||
|
||||
$abeConfigurationFactory = factory(AbeConfiguration::class)->create([
|
||||
'ABE_EMAIL_SERVER_UID' => $emailServer['MESS_UID']
|
||||
]);
|
||||
|
||||
$abeConfiguration = new AbeConfiguration();
|
||||
$abeConfiguration->updateEmailServerUidToDefaultOrEmpty($emailServer['MESS_UID']);
|
||||
|
||||
$query = AbeConfiguration::query()->select();
|
||||
$query->where('ABE_UID', $abeConfigurationFactory['ABE_UID']);
|
||||
$updatedAbe = $query->get()->values()->toArray();
|
||||
|
||||
$this->assertEquals($updatedAbe[0]['ABE_EMAIL_SERVER_UID'], $defaultServer['MESS_UID']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
|
||||
|
||||
use ProcessMaker\Model\EmailEvent;
|
||||
use ProcessMaker\Model\EmailServerModel;
|
||||
use Tests\TestCase;
|
||||
|
||||
class EmailEventTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Call the setUp parent method
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp(); // TODO: Change the autogenerated stub
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the updateServerAndFromToDefaultOrEmpty method
|
||||
*
|
||||
* @covers \ProcessMaker\Model\EmailEvent::updateServerAndFromToDefaultOrEmpty()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_the_update_event_method()
|
||||
{
|
||||
EmailServerModel::query()->delete();
|
||||
$emailServer = factory(EmailServerModel::class)->create();
|
||||
$emailEventFactory = factory(EmailEvent::class)->create([
|
||||
'EMAIL_SERVER_UID' => $emailServer['MESS_UID']
|
||||
]);
|
||||
|
||||
$emailEvent = new EmailEvent();
|
||||
$emailEvent->updateServerAndFromToDefaultOrEmpty($emailServer['MESS_UID']);
|
||||
|
||||
$query = EmailEvent::query()->select();
|
||||
$query->where('EMAIL_EVENT_UID', $emailEventFactory['EMAIL_EVENT_UID']);
|
||||
$updatedEmailEvent = $query->get()->values()->toArray();
|
||||
|
||||
$this->assertEquals($updatedEmailEvent[0]['EMAIL_SERVER_UID'], '');
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the updateServerAndFromToDefaultOrEmpty method with a default email server
|
||||
*
|
||||
* @covers \ProcessMaker\Model\EmailEvent::updateServerAndFromToDefaultOrEmpty()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_the_update_event_method_with_a_default_email_server()
|
||||
{
|
||||
EmailServerModel::query()->delete();
|
||||
$emailServer = factory(EmailServerModel::class)->create();
|
||||
$emailServerDefault = factory(EmailServerModel::class)->create([
|
||||
'MESS_DEFAULT' => 1
|
||||
]);
|
||||
$emailEventFactory = factory(EmailEvent::class)->create([
|
||||
'EMAIL_SERVER_UID' => $emailServer['MESS_UID']
|
||||
]);
|
||||
|
||||
$emailEvent = new EmailEvent();
|
||||
$emailEvent->updateServerAndFromToDefaultOrEmpty($emailServer['MESS_UID']);
|
||||
|
||||
$query = EmailEvent::query()->select();
|
||||
$query->where('EMAIL_EVENT_UID', $emailEventFactory['EMAIL_EVENT_UID']);
|
||||
$updatedEmailEvent = $query->get()->values()->toArray();
|
||||
|
||||
$this->assertEquals($updatedEmailEvent[0]['EMAIL_SERVER_UID'], $emailServerDefault['MESS_UID']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call the tearDown parent method
|
||||
*/
|
||||
public function tearDown()
|
||||
{
|
||||
parent::tearDown(); // TODO: Change the autogenerated stub
|
||||
}
|
||||
}
|
||||
@@ -86,4 +86,38 @@ class EmailServerModelTest extends TestCase
|
||||
//Assert the result es not empty
|
||||
$this->assertNotEmpty($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the isImap method when there is an IMAP server
|
||||
*
|
||||
* @covers \ProcessMaker\Model\EmailServerModel::isImap()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_the_is_imap_method_when_there_is_an_imap_server()
|
||||
{
|
||||
EmailServerModel::query()->delete();
|
||||
$emailServer = factory(EmailServerModel::class)->create([
|
||||
'MESS_ENGINE' => 'IMAP'
|
||||
]);
|
||||
$emailServerModel = new EmailServerModel();
|
||||
$r = $emailServerModel->isImap($emailServer['MESS_UID']);
|
||||
|
||||
$this->assertTrue($r);
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the isImap method when there is not an IMAP server
|
||||
*
|
||||
* @covers \ProcessMaker\Model\EmailServerModel::isImap()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_the_is_imap_method_when_there_is_not_an_imap_server()
|
||||
{
|
||||
EmailServerModel::query()->delete();
|
||||
$emailServer = factory(EmailServerModel::class)->create();
|
||||
$emailServerModel = new EmailServerModel();
|
||||
$r = $emailServerModel->isImap($emailServer['MESS_UID']);
|
||||
|
||||
$this->assertFalse($r);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user