2019-08-08 09:51:39 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
use App\Jobs\EmailEvent;
|
|
|
|
|
use Faker\Factory;
|
|
|
|
|
use Illuminate\Support\Facades\Queue;
|
|
|
|
|
use ProcessMaker\Model\Application;
|
2022-02-16 11:20:13 -04:00
|
|
|
use ProcessMaker\Model\AppDelay;
|
2019-09-10 15:29:00 -04:00
|
|
|
use ProcessMaker\Model\AppThread;
|
|
|
|
|
use ProcessMaker\Model\Delegation;
|
2019-09-10 15:11:18 -04:00
|
|
|
use ProcessMaker\Model\EmailServerModel;
|
2019-08-08 09:51:39 -04:00
|
|
|
use ProcessMaker\Model\Process;
|
|
|
|
|
use ProcessMaker\Model\Task;
|
2021-04-30 09:17:09 -04:00
|
|
|
use ProcessMaker\Model\TaskUser;
|
2019-08-08 09:51:39 -04:00
|
|
|
use ProcessMaker\Model\User;
|
2020-02-14 15:33:28 -04:00
|
|
|
use ProcessMaker\Model\UserReporting;
|
2019-08-08 09:51:39 -04:00
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
2020-02-03 16:25:37 -04:00
|
|
|
/**
|
2020-02-14 15:33:28 -04:00
|
|
|
* Class WsBaseTest
|
2020-02-03 16:25:37 -04:00
|
|
|
*
|
|
|
|
|
* @coversDefaultClass WsBase
|
|
|
|
|
*/
|
2019-08-08 09:51:39 -04:00
|
|
|
class WsBaseTest extends TestCase
|
|
|
|
|
{
|
|
|
|
|
/**
|
2019-08-23 11:51:51 -04:00
|
|
|
* Constructor of the class.
|
|
|
|
|
*
|
|
|
|
|
* @param string $name
|
|
|
|
|
* @param array $data
|
|
|
|
|
* @param string $dataName
|
2019-08-08 09:51:39 -04:00
|
|
|
*/
|
|
|
|
|
public function __construct($name = null, array $data = [], $dataName = '')
|
|
|
|
|
{
|
|
|
|
|
parent::__construct($name, $data, $dataName);
|
2019-09-10 15:29:00 -04:00
|
|
|
Application::query()->truncate();
|
|
|
|
|
AppThread::query()->truncate();
|
|
|
|
|
Delegation::query()->truncate();
|
2019-08-08 09:51:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Tears down the fixture, for example, closes a network connection.
|
|
|
|
|
* This method is called after a test is executed.
|
|
|
|
|
*/
|
2022-06-09 11:43:56 -04:00
|
|
|
public function tearDown(): void
|
2019-08-08 09:51:39 -04:00
|
|
|
{
|
|
|
|
|
parent::tearDown();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create an application.
|
|
|
|
|
*
|
|
|
|
|
* @param int $applicationNumber
|
|
|
|
|
* @return \stdClass
|
|
|
|
|
*/
|
|
|
|
|
private function createNewCase($applicationNumber = null)
|
|
|
|
|
{
|
2020-06-09 12:50:12 -04:00
|
|
|
$userUid = G::generateUniqueID();
|
|
|
|
|
$processUid = G::generateUniqueID();
|
|
|
|
|
$applicationUid = G::generateUniqueID();
|
2019-08-08 09:51:39 -04:00
|
|
|
if (empty($applicationNumber)) {
|
|
|
|
|
$faker = Factory::create();
|
|
|
|
|
$applicationNumber = $faker->unique()->numberBetween(1, 10000000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$appData = [
|
|
|
|
|
'SYS_LANG' => 'en',
|
|
|
|
|
'SYS_SKIN' => 'neoclassic',
|
|
|
|
|
'SYS_SYS' => 'workflow',
|
2020-06-09 12:50:12 -04:00
|
|
|
'APPLICATION' => $applicationUid,
|
|
|
|
|
'PROCESS' => $processUid,
|
2019-08-08 09:51:39 -04:00
|
|
|
'TASK' => '',
|
|
|
|
|
'INDEX' => 2,
|
|
|
|
|
'USER_LOGGED' => $userUid,
|
|
|
|
|
'USR_USERNAME' => 'admin',
|
|
|
|
|
'APP_NUMBER' => $applicationNumber,
|
|
|
|
|
'PIN' => '97ZN'
|
|
|
|
|
];
|
|
|
|
|
|
2022-07-21 00:04:21 -04:00
|
|
|
$user = User::factory()->create([
|
2019-08-08 09:51:39 -04:00
|
|
|
'USR_UID' => $userUid
|
|
|
|
|
]);
|
|
|
|
|
|
2022-07-21 00:04:21 -04:00
|
|
|
$process = Process::factory()->create([
|
2019-08-08 09:51:39 -04:00
|
|
|
'PRO_UID' => $processUid
|
|
|
|
|
]);
|
|
|
|
|
|
2022-07-21 00:04:21 -04:00
|
|
|
$task = Task::factory()->create([
|
2019-08-08 09:51:39 -04:00
|
|
|
'PRO_UID' => $process->PRO_UID
|
|
|
|
|
]);
|
|
|
|
|
|
2022-07-21 00:04:21 -04:00
|
|
|
$application = Application::factory()->create([
|
2019-08-08 09:51:39 -04:00
|
|
|
'PRO_UID' => $process->PRO_UID,
|
|
|
|
|
'APP_UID' => $applicationUid,
|
|
|
|
|
'APP_NUMBER' => $applicationNumber,
|
|
|
|
|
'APP_DATA' => serialize($appData)
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$result = new stdClass();
|
2020-06-09 12:50:12 -04:00
|
|
|
$result->application = $application;
|
2019-08-08 09:51:39 -04:00
|
|
|
$result->user = $user;
|
|
|
|
|
$result->process = $process;
|
|
|
|
|
return $result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create a email server configuration.
|
|
|
|
|
*
|
2019-09-10 15:11:18 -04:00
|
|
|
* @return ProcessMaker\Model\EmailServerModel;
|
2019-08-08 09:51:39 -04:00
|
|
|
*/
|
|
|
|
|
private function createEmailServer()
|
|
|
|
|
{
|
|
|
|
|
$passwordEnv = env('emailAccountPassword');
|
|
|
|
|
$password = G::encrypt("hash:" . $passwordEnv, 'EMAILENCRYPT');
|
2022-07-21 00:04:21 -04:00
|
|
|
$emailServer = EmailServerModel::factory()->create([
|
2019-08-08 09:51:39 -04:00
|
|
|
'MESS_ENGINE' => env('emailEngine'),
|
|
|
|
|
'MESS_SERVER' => env('emailServer'),
|
|
|
|
|
'MESS_PORT' => env('emailPort'),
|
|
|
|
|
'MESS_INCOMING_SERVER' => '',
|
|
|
|
|
'MESS_INCOMING_PORT' => 0,
|
|
|
|
|
'MESS_RAUTH' => 1,
|
|
|
|
|
'MESS_ACCOUNT' => env('emailAccount'),
|
|
|
|
|
'MESS_PASSWORD' => $password,
|
|
|
|
|
'MESS_FROM_MAIL' => env('emailAccount'),
|
|
|
|
|
'MESS_FROM_NAME' => '',
|
|
|
|
|
'SMTPSECURE' => 'ssl',
|
|
|
|
|
'MESS_TRY_SEND_INMEDIATLY' => 1,
|
|
|
|
|
'MAIL_TO' => $password,
|
|
|
|
|
'MESS_DEFAULT' => 1,
|
|
|
|
|
]);
|
|
|
|
|
return $emailServer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create a new template for send email.
|
|
|
|
|
*
|
|
|
|
|
* @param string $proUid
|
|
|
|
|
* @param string $usrUid
|
|
|
|
|
* @return \ProcessMaker\Model\ProcessFiles
|
|
|
|
|
*/
|
|
|
|
|
private function createTemplate($proUid, $usrUid)
|
|
|
|
|
{
|
2022-02-09 10:38:04 -04:00
|
|
|
if (!file_exists(PATH_DB)) {
|
|
|
|
|
mkdir(PATH_DB);
|
|
|
|
|
}
|
|
|
|
|
if (!file_exists(PATH_DATA_SITE)) {
|
|
|
|
|
mkdir(PATH_DATA_SITE);
|
|
|
|
|
}
|
|
|
|
|
$data = file_get_contents(PATH_TRUNK . 'tests/resources/template.html');
|
|
|
|
|
if (!file_exists(PATH_DATA_SITE . 'mailTemplates')) {
|
|
|
|
|
mkdir(PATH_DATA_SITE . 'mailTemplates');
|
|
|
|
|
}
|
|
|
|
|
file_put_contents(PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . 'template.html', $data);
|
|
|
|
|
if (!file_exists(PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . $proUid)) {
|
|
|
|
|
mkdir(PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . $proUid);
|
|
|
|
|
}
|
|
|
|
|
file_put_contents(PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . $proUid . PATH_SEP . 'template.html', $data);
|
2022-07-21 00:04:21 -04:00
|
|
|
$template = \ProcessMaker\Model\ProcessFiles::factory()->create([
|
2019-08-08 09:51:39 -04:00
|
|
|
'PRO_UID' => $proUid,
|
|
|
|
|
'USR_UID' => $usrUid,
|
2022-02-09 10:38:04 -04:00
|
|
|
'PRF_PATH' => 'template.html'
|
2019-08-08 09:51:39 -04:00
|
|
|
]);
|
|
|
|
|
return $template;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create empty html.
|
|
|
|
|
*
|
|
|
|
|
* @param string $content
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
private function createDefaultHtmlContent($content = '')
|
|
|
|
|
{
|
|
|
|
|
$string = ''
|
2021-04-30 09:17:09 -04:00
|
|
|
. '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
|
|
|
|
|
. '<html>'
|
|
|
|
|
. '<head>'
|
|
|
|
|
. '</head>'
|
|
|
|
|
. '<body>'
|
|
|
|
|
. $content
|
|
|
|
|
. '</body>'
|
|
|
|
|
. '</html>';
|
2019-08-08 09:51:39 -04:00
|
|
|
return $string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This represents a collection of "messageType" for queue elements.
|
|
|
|
|
*/
|
|
|
|
|
public function messageTypesWithQueue()
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
[WsBase::MESSAGE_TYPE_EMAIL_EVENT],
|
|
|
|
|
[WsBase::MESSAGE_TYPE_PM_FUNCTION],
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This represents a collection of "messageType" for no queueable elements.
|
|
|
|
|
*/
|
|
|
|
|
public function messageTypesWithoutQueue()
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
[WsBase::MESSAGE_TYPE_ACTIONS_BY_EMAIL],
|
|
|
|
|
[WsBase::MESSAGE_TYPE_CASE_NOTE],
|
|
|
|
|
[WsBase::MESSAGE_TYPE_EXTERNAL_REGISTRATION],
|
|
|
|
|
[WsBase::MESSAGE_TYPE_RETRIEVE_PASSWORD],
|
|
|
|
|
[WsBase::MESSAGE_TYPE_SOAP],
|
|
|
|
|
[WsBase::MESSAGE_TYPE_TASK_NOTIFICATION],
|
|
|
|
|
[WsBase::MESSAGE_TYPE_TEST_EMAIL],
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This should send an email of types elements to the work queue jobs.
|
|
|
|
|
* Queue-fake has been used, see more at: https://laravel.com/docs/5.7/mocking#queue-fake
|
2020-02-03 16:25:37 -04:00
|
|
|
*
|
2019-08-08 09:51:39 -04:00
|
|
|
* @test
|
|
|
|
|
* @dataProvider messageTypesWithQueue
|
2020-02-03 16:25:37 -04:00
|
|
|
* @covers WsBase::sendMessage()
|
2019-08-08 09:51:39 -04:00
|
|
|
*/
|
|
|
|
|
public function it_should_send_an_sendMessage_with_queue_jobs($messageType)
|
|
|
|
|
{
|
|
|
|
|
//data
|
|
|
|
|
$emailServer = $this->createEmailServer();
|
|
|
|
|
$case = $this->createNewCase();
|
|
|
|
|
$template = $this->createTemplate($case->process->PRO_UID, $case->user->USR_UID);
|
|
|
|
|
|
|
|
|
|
//parameters
|
2020-06-09 12:50:12 -04:00
|
|
|
$appUid = $case->application->APP_UID;
|
2019-08-08 09:51:39 -04:00
|
|
|
$from = $emailServer->MESS_ACCOUNT;
|
|
|
|
|
$to = $emailServer->MESS_ACCOUNT;
|
|
|
|
|
$cc = "";
|
|
|
|
|
$bcc = "";
|
|
|
|
|
$subject = "test";
|
|
|
|
|
$templateName = basename($template->PRF_PATH);
|
|
|
|
|
$appFields = [];
|
|
|
|
|
$attachment = [];
|
|
|
|
|
$showMessage = true;
|
|
|
|
|
$delIndex = 0;
|
|
|
|
|
$config = $emailServer->toArray();
|
|
|
|
|
$gmail = 0;
|
|
|
|
|
$appMsgType = $messageType;
|
|
|
|
|
|
|
|
|
|
//assertions
|
|
|
|
|
Queue::fake();
|
|
|
|
|
Queue::assertNothingPushed();
|
|
|
|
|
|
|
|
|
|
$wsBase = new WsBase();
|
|
|
|
|
$wsBase->sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $templateName, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType);
|
|
|
|
|
Queue::assertPushed(EmailEvent::class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This should send an email of types elements without work queue jobs.
|
|
|
|
|
* Queue-fake has been used, see more at: https://laravel.com/docs/5.7/mocking#queue-fake
|
2020-02-03 16:25:37 -04:00
|
|
|
*
|
2019-08-08 09:51:39 -04:00
|
|
|
* @test
|
|
|
|
|
* @dataProvider messageTypesWithoutQueue
|
2020-02-03 16:25:37 -04:00
|
|
|
* @covers WsBase::sendMessage()
|
2019-08-08 09:51:39 -04:00
|
|
|
*/
|
|
|
|
|
public function it_should_execute_an_sendMessage_without_queue_jobs($messageTypes)
|
|
|
|
|
{
|
|
|
|
|
//data
|
|
|
|
|
$emailServer = $this->createEmailServer();
|
|
|
|
|
$case = $this->createNewCase();
|
|
|
|
|
$template = $this->createTemplate($case->process->PRO_UID, $case->user->USR_UID);
|
|
|
|
|
|
|
|
|
|
//parameters
|
2020-06-09 12:50:12 -04:00
|
|
|
$appUid = $case->application->APP_UID;
|
2019-08-08 09:51:39 -04:00
|
|
|
$from = $emailServer->MESS_ACCOUNT;
|
|
|
|
|
$to = "";
|
|
|
|
|
$cc = "";
|
|
|
|
|
$bcc = "";
|
|
|
|
|
$subject = "test";
|
|
|
|
|
$templateName = basename($template->PRF_PATH);
|
|
|
|
|
$appFields = [];
|
|
|
|
|
$attachment = [];
|
|
|
|
|
$showMessage = true;
|
|
|
|
|
$delIndex = 0;
|
|
|
|
|
$config = $emailServer->toArray();
|
|
|
|
|
$gmail = 0;
|
|
|
|
|
$appMsgType = $messageTypes;
|
|
|
|
|
|
|
|
|
|
//assertions
|
|
|
|
|
Queue::fake();
|
|
|
|
|
Queue::assertNothingPushed();
|
|
|
|
|
|
|
|
|
|
$wsBase = new WsBase();
|
|
|
|
|
$wsBase->sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $templateName, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType);
|
|
|
|
|
Queue::assertNotPushed(EmailEvent::class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* It should send an sendMessage with queue jobs and empty config parameter.
|
2020-02-03 16:25:37 -04:00
|
|
|
*
|
2019-08-08 09:51:39 -04:00
|
|
|
* @test
|
|
|
|
|
* @dataProvider messageTypesWithQueue
|
2020-02-03 16:25:37 -04:00
|
|
|
* @covers WsBase::sendMessage()
|
2019-08-08 09:51:39 -04:00
|
|
|
*/
|
|
|
|
|
public function it_should_send_an_sendMessage_with_queue_jobs_and_empty_config_parameter($messageTypes)
|
|
|
|
|
{
|
|
|
|
|
//data
|
|
|
|
|
$emailServer = $this->createEmailServer();
|
|
|
|
|
$case = $this->createNewCase();
|
|
|
|
|
$template = $this->createTemplate($case->process->PRO_UID, $case->user->USR_UID);
|
|
|
|
|
|
|
|
|
|
//parameters
|
2020-06-09 12:50:12 -04:00
|
|
|
$appUid = $case->application->APP_UID;
|
2019-08-08 09:51:39 -04:00
|
|
|
$from = $emailServer->MESS_ACCOUNT;
|
|
|
|
|
$to = $emailServer->MESS_ACCOUNT;
|
|
|
|
|
$cc = "";
|
|
|
|
|
$bcc = "";
|
|
|
|
|
$subject = "test";
|
|
|
|
|
$templateName = basename($template->PRF_PATH);
|
|
|
|
|
$appFields = [];
|
|
|
|
|
$attachment = [];
|
|
|
|
|
$showMessage = true;
|
|
|
|
|
$delIndex = 0;
|
|
|
|
|
$config = []; //with empty configuration
|
|
|
|
|
$gmail = 0;
|
|
|
|
|
$appMsgType = $messageTypes;
|
|
|
|
|
|
|
|
|
|
//assertions
|
|
|
|
|
Queue::fake();
|
|
|
|
|
Queue::assertNothingPushed();
|
|
|
|
|
|
|
|
|
|
$wsBase = new WsBase();
|
|
|
|
|
$wsBase->sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $templateName, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType);
|
|
|
|
|
Queue::assertPushed(EmailEvent::class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* It should send an sendMessage without queue jobs and empty config parameter.
|
2020-02-03 16:25:37 -04:00
|
|
|
*
|
2019-08-08 09:51:39 -04:00
|
|
|
* @test
|
|
|
|
|
* @dataProvider messageTypesWithoutQueue
|
2020-02-03 16:25:37 -04:00
|
|
|
* @covers WsBase::sendMessage()
|
2019-08-08 09:51:39 -04:00
|
|
|
*/
|
|
|
|
|
public function it_should_send_an_sendMessage_without_queue_jobs_and_empty_config_parameter($messageTypes)
|
|
|
|
|
{
|
|
|
|
|
//data
|
|
|
|
|
$emailServer = $this->createEmailServer();
|
|
|
|
|
$case = $this->createNewCase();
|
|
|
|
|
$template = $this->createTemplate($case->process->PRO_UID, $case->user->USR_UID);
|
|
|
|
|
|
|
|
|
|
//parameters
|
2020-06-09 12:50:12 -04:00
|
|
|
$appUid = $case->application->APP_UID;
|
2019-08-08 09:51:39 -04:00
|
|
|
$from = $emailServer->MESS_ACCOUNT;
|
|
|
|
|
$to = "";
|
|
|
|
|
$cc = "";
|
|
|
|
|
$bcc = "";
|
|
|
|
|
$subject = "test";
|
|
|
|
|
$templateName = basename($template->PRF_PATH);
|
|
|
|
|
$appFields = [];
|
|
|
|
|
$attachment = [];
|
|
|
|
|
$showMessage = true;
|
|
|
|
|
$delIndex = 0;
|
|
|
|
|
$config = []; //with empty configuration
|
|
|
|
|
$gmail = 0;
|
|
|
|
|
$appMsgType = $messageTypes;
|
|
|
|
|
|
|
|
|
|
//assertions
|
|
|
|
|
Queue::fake();
|
|
|
|
|
Queue::assertNothingPushed();
|
|
|
|
|
|
|
|
|
|
$wsBase = new WsBase();
|
|
|
|
|
$wsBase->sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $templateName, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType);
|
|
|
|
|
Queue::assertNotPushed(EmailEvent::class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* It should send an sendMessage with queue jobs and config parameter like id.
|
2020-02-03 16:25:37 -04:00
|
|
|
*
|
2019-08-08 09:51:39 -04:00
|
|
|
* @test
|
|
|
|
|
* @dataProvider messageTypesWithQueue
|
2020-02-03 16:25:37 -04:00
|
|
|
* @covers WsBase::sendMessage()
|
2019-08-08 09:51:39 -04:00
|
|
|
*/
|
|
|
|
|
public function it_should_send_an_sendMessage_with_queue_jobs_and_config_parameter_like_id($messageTypes)
|
|
|
|
|
{
|
|
|
|
|
//data
|
|
|
|
|
$emailServer = $this->createEmailServer();
|
|
|
|
|
$case = $this->createNewCase();
|
|
|
|
|
$template = $this->createTemplate($case->process->PRO_UID, $case->user->USR_UID);
|
|
|
|
|
|
|
|
|
|
//parameters
|
2020-06-09 12:50:12 -04:00
|
|
|
$appUid = $case->application->APP_UID;
|
2019-08-08 09:51:39 -04:00
|
|
|
$from = $emailServer->MESS_ACCOUNT;
|
|
|
|
|
$to = $emailServer->MESS_ACCOUNT;
|
|
|
|
|
$cc = "";
|
|
|
|
|
$bcc = "";
|
|
|
|
|
$subject = "test";
|
|
|
|
|
$templateName = basename($template->PRF_PATH);
|
|
|
|
|
$appFields = [];
|
|
|
|
|
$attachment = [];
|
|
|
|
|
$showMessage = true;
|
|
|
|
|
$delIndex = 0;
|
|
|
|
|
$config = $emailServer->MESS_UID; //With a valid Email Server Uid
|
|
|
|
|
$gmail = 0;
|
|
|
|
|
$appMsgType = $messageTypes;
|
|
|
|
|
|
|
|
|
|
//assertions
|
|
|
|
|
Queue::fake();
|
|
|
|
|
Queue::assertNothingPushed();
|
|
|
|
|
|
|
|
|
|
$wsBase = new WsBase();
|
|
|
|
|
$wsBase->sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $templateName, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType);
|
|
|
|
|
Queue::assertPushed(EmailEvent::class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* It should send an sendMessage without queue jobs and config parameter like id.
|
2020-02-03 16:25:37 -04:00
|
|
|
*
|
2019-08-08 09:51:39 -04:00
|
|
|
* @test
|
|
|
|
|
* @dataProvider messageTypesWithoutQueue
|
2020-02-03 16:25:37 -04:00
|
|
|
* @covers WsBase::sendMessage()
|
2019-08-08 09:51:39 -04:00
|
|
|
*/
|
|
|
|
|
public function it_should_send_an_sendMessage_without_queue_jobs_and_config_parameter_like_id($messageTypes)
|
|
|
|
|
{
|
|
|
|
|
//data
|
|
|
|
|
$emailServer = $this->createEmailServer();
|
|
|
|
|
$case = $this->createNewCase();
|
|
|
|
|
$template = $this->createTemplate($case->process->PRO_UID, $case->user->USR_UID);
|
|
|
|
|
|
|
|
|
|
//parameters
|
2020-06-09 12:50:12 -04:00
|
|
|
$appUid = $case->application->APP_UID;
|
2019-08-08 09:51:39 -04:00
|
|
|
$from = $emailServer->MESS_ACCOUNT;
|
|
|
|
|
$to = "";
|
|
|
|
|
$cc = "";
|
|
|
|
|
$bcc = "";
|
|
|
|
|
$subject = "test";
|
|
|
|
|
$templateName = basename($template->PRF_PATH);
|
|
|
|
|
$appFields = [];
|
|
|
|
|
$attachment = [];
|
|
|
|
|
$showMessage = true;
|
|
|
|
|
$delIndex = 0;
|
|
|
|
|
$config = $emailServer->MESS_UID; //With a valid Email Server Uid
|
|
|
|
|
$gmail = 0;
|
|
|
|
|
$appMsgType = $messageTypes;
|
|
|
|
|
|
|
|
|
|
//assertions
|
|
|
|
|
Queue::fake();
|
|
|
|
|
Queue::assertNothingPushed();
|
|
|
|
|
|
|
|
|
|
$wsBase = new WsBase();
|
|
|
|
|
$wsBase->sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $templateName, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType);
|
|
|
|
|
Queue::assertNotPushed(EmailEvent::class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* It should send an sendMessage without queue jobs and gmail parameter like one.
|
2020-02-03 16:25:37 -04:00
|
|
|
*
|
2019-08-08 09:51:39 -04:00
|
|
|
* @test
|
|
|
|
|
* @dataProvider messageTypesWithoutQueue
|
2020-02-03 16:25:37 -04:00
|
|
|
* @covers WsBase::sendMessage()
|
2019-08-08 09:51:39 -04:00
|
|
|
*/
|
|
|
|
|
public function it_should_send_an_sendMessage_without_queue_jobs_and_gmail_parameter_like_one($messageTypes)
|
|
|
|
|
{
|
|
|
|
|
//data
|
|
|
|
|
$emailServer = $this->createEmailServer();
|
|
|
|
|
$case = $this->createNewCase();
|
|
|
|
|
$template = $this->createTemplate($case->process->PRO_UID, $case->user->USR_UID);
|
|
|
|
|
|
|
|
|
|
//parameters
|
2020-06-09 12:50:12 -04:00
|
|
|
$appUid = $case->application->APP_UID;
|
2019-08-08 09:51:39 -04:00
|
|
|
$from = $emailServer->MESS_ACCOUNT;
|
|
|
|
|
$to = "";
|
|
|
|
|
$cc = "";
|
|
|
|
|
$bcc = "";
|
|
|
|
|
$subject = "test";
|
|
|
|
|
$templateName = basename($template->PRF_PATH);
|
|
|
|
|
$appFields = [];
|
|
|
|
|
$attachment = [];
|
|
|
|
|
$showMessage = true;
|
|
|
|
|
$delIndex = 0;
|
|
|
|
|
$config = $emailServer->MESS_UID;
|
|
|
|
|
$gmail = 1; //GMail flag enabled
|
|
|
|
|
$appMsgType = $messageTypes;
|
|
|
|
|
|
|
|
|
|
//assertions
|
|
|
|
|
Queue::fake();
|
|
|
|
|
Queue::assertNothingPushed();
|
|
|
|
|
|
|
|
|
|
$wsBase = new WsBase();
|
|
|
|
|
$wsBase->sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $templateName, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType);
|
|
|
|
|
Queue::assertNotPushed(EmailEvent::class);
|
|
|
|
|
}
|
2019-09-10 15:29:00 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Test that the casesList method returns the case title value
|
|
|
|
|
*
|
|
|
|
|
* @test
|
2020-02-03 16:25:37 -04:00
|
|
|
* @covers WsBase::caseList()
|
2019-09-10 15:29:00 -04:00
|
|
|
*/
|
|
|
|
|
public function it_should_test_that_the_cases_list_method_returns_the_case_title()
|
|
|
|
|
{
|
|
|
|
|
//Create the user factory
|
2022-07-21 00:04:21 -04:00
|
|
|
$user = User::factory()->create();
|
2019-09-10 15:29:00 -04:00
|
|
|
|
|
|
|
|
//Create the application factory
|
2022-07-21 00:04:21 -04:00
|
|
|
$application1 = Application::factory()->create(
|
2021-04-30 09:17:09 -04:00
|
|
|
[
|
|
|
|
|
'APP_STATUS' => 'TO_DO',
|
|
|
|
|
'APP_TITLE' => 'Title1'
|
|
|
|
|
]
|
2019-09-10 15:29:00 -04:00
|
|
|
);
|
2022-07-21 00:04:21 -04:00
|
|
|
$application2 = Application::factory()->create(
|
2021-04-30 09:17:09 -04:00
|
|
|
[
|
|
|
|
|
'APP_STATUS' => 'DRAFT',
|
|
|
|
|
'APP_TITLE' => 'Title2'
|
|
|
|
|
]
|
2019-09-10 15:29:00 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
//Create the delegation factory
|
2022-07-21 00:04:21 -04:00
|
|
|
$delegation1 = Delegation::factory()->create(
|
2021-04-30 09:17:09 -04:00
|
|
|
[
|
|
|
|
|
'USR_UID' => $user->USR_UID,
|
|
|
|
|
'DEL_THREAD_STATUS' => 'OPEN',
|
|
|
|
|
'DEL_FINISH_DATE' => null,
|
|
|
|
|
'APP_NUMBER' => $application1->APP_NUMBER
|
|
|
|
|
]
|
2019-09-10 15:29:00 -04:00
|
|
|
);
|
2022-07-21 00:04:21 -04:00
|
|
|
$delegation2 = Delegation::factory()->create(
|
2021-04-30 09:17:09 -04:00
|
|
|
[
|
|
|
|
|
'USR_UID' => $user->USR_UID,
|
|
|
|
|
'DEL_THREAD_STATUS' => 'OPEN',
|
|
|
|
|
'DEL_FINISH_DATE' => null,
|
|
|
|
|
'APP_NUMBER' => $application2->APP_NUMBER
|
|
|
|
|
]
|
2019-09-10 15:29:00 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
//Create app thread factory
|
2022-07-21 00:04:21 -04:00
|
|
|
AppThread::factory()->create(
|
2021-04-30 09:17:09 -04:00
|
|
|
[
|
|
|
|
|
'APP_THREAD_STATUS' => 'OPEN',
|
|
|
|
|
'APP_UID' => $delegation1->APP_UID
|
|
|
|
|
]
|
2019-09-10 15:29:00 -04:00
|
|
|
);
|
2022-07-21 00:04:21 -04:00
|
|
|
AppThread::factory()->create(
|
2021-04-30 09:17:09 -04:00
|
|
|
[
|
|
|
|
|
'APP_THREAD_STATUS' => 'OPEN',
|
|
|
|
|
'APP_UID' => $delegation2->APP_UID
|
|
|
|
|
]
|
2019-09-10 15:29:00 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
//Instance the object
|
|
|
|
|
$wsBase = new WsBase();
|
|
|
|
|
//Call the caseList method
|
|
|
|
|
$res = $wsBase->caseList($user->USR_UID);
|
|
|
|
|
|
|
|
|
|
//Assert the result has 2 rows
|
|
|
|
|
$this->assertCount(2, $res);
|
|
|
|
|
|
|
|
|
|
//Assert the status of the case
|
|
|
|
|
$this->assertTrue('TO_DO' || 'DRAFT' == $res[0]['status']);
|
|
|
|
|
$this->assertTrue('TO_DO' || 'DRAFT' == $res[1]['status']);
|
|
|
|
|
|
|
|
|
|
//Assert the case title is returned
|
|
|
|
|
$this->assertTrue($application1->APP_TITLE || $application2->APP_TITLE == $res[0]['name']);
|
|
|
|
|
$this->assertTrue($application1->APP_TITLE || $application2->APP_TITLE == $res[1]['name']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Test the casesList method when the result is empty
|
|
|
|
|
*
|
|
|
|
|
* @test
|
2020-02-03 16:25:37 -04:00
|
|
|
* @covers WsBase::caseList()
|
2019-09-10 15:29:00 -04:00
|
|
|
*/
|
|
|
|
|
public function it_should_test_the_cases_list_method_when_there_are_no_results()
|
|
|
|
|
{
|
|
|
|
|
//Create the user factory
|
2022-07-21 00:04:21 -04:00
|
|
|
$user1 = User::factory()->create();
|
|
|
|
|
$user2 = User::factory()->create();
|
2019-09-10 15:29:00 -04:00
|
|
|
|
|
|
|
|
//Create the application factory
|
2022-07-21 00:04:21 -04:00
|
|
|
$application1 = Application::factory()->create(
|
2021-04-30 09:17:09 -04:00
|
|
|
[
|
|
|
|
|
'APP_STATUS' => 'TO_DO',
|
|
|
|
|
'APP_TITLE' => 'Title1'
|
|
|
|
|
]
|
2019-09-10 15:29:00 -04:00
|
|
|
);
|
2022-07-21 00:04:21 -04:00
|
|
|
$application2 = Application::factory()->create(
|
2021-04-30 09:17:09 -04:00
|
|
|
[
|
|
|
|
|
'APP_STATUS' => 'DRAFT',
|
|
|
|
|
'APP_TITLE' => 'Title2'
|
|
|
|
|
]
|
2019-09-10 15:29:00 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
//Create the delegation factory
|
2022-07-21 00:04:21 -04:00
|
|
|
$delegation1 = Delegation::factory()->create(
|
2021-04-30 09:17:09 -04:00
|
|
|
[
|
|
|
|
|
'USR_UID' => $user1->USR_UID,
|
|
|
|
|
'DEL_THREAD_STATUS' => 'OPEN',
|
|
|
|
|
'DEL_FINISH_DATE' => null,
|
|
|
|
|
'APP_NUMBER' => $application1->APP_NUMBER
|
|
|
|
|
]
|
2019-09-10 15:29:00 -04:00
|
|
|
);
|
2022-07-21 00:04:21 -04:00
|
|
|
$delegation2 = Delegation::factory()->create(
|
2021-04-30 09:17:09 -04:00
|
|
|
[
|
|
|
|
|
'USR_UID' => $user1->USR_UID,
|
|
|
|
|
'DEL_THREAD_STATUS' => 'OPEN',
|
|
|
|
|
'DEL_FINISH_DATE' => null,
|
|
|
|
|
'APP_NUMBER' => $application2->APP_NUMBER
|
|
|
|
|
]
|
2019-09-10 15:29:00 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
//Create app thread factory
|
2022-07-21 00:04:21 -04:00
|
|
|
AppThread::factory()->create(
|
2021-04-30 09:17:09 -04:00
|
|
|
[
|
|
|
|
|
'APP_THREAD_STATUS' => 'OPEN',
|
|
|
|
|
'APP_UID' => $delegation1->APP_UID
|
|
|
|
|
]
|
2019-09-10 15:29:00 -04:00
|
|
|
);
|
2022-07-21 00:04:21 -04:00
|
|
|
AppThread::factory()->create(
|
2021-04-30 09:17:09 -04:00
|
|
|
[
|
|
|
|
|
'APP_THREAD_STATUS' => 'OPEN',
|
|
|
|
|
'APP_UID' => $delegation2->APP_UID
|
|
|
|
|
]
|
2019-09-10 15:29:00 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
//Instance the object
|
|
|
|
|
$wsBase = new WsBase();
|
|
|
|
|
|
|
|
|
|
//Call the caseList method
|
|
|
|
|
$res = $wsBase->caseList($user2->USR_UID);
|
|
|
|
|
|
|
|
|
|
//Assert the result his empty
|
|
|
|
|
$this->assertEmpty($res);
|
|
|
|
|
}
|
2019-12-12 11:32:20 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This test ensures obtaining the email configuration with all fields.
|
|
|
|
|
* @test
|
2020-02-03 16:25:37 -04:00
|
|
|
* @covers WsBase::sendMessage()
|
2019-12-12 11:32:20 -04:00
|
|
|
*/
|
|
|
|
|
public function it_should_get_email_configuration()
|
|
|
|
|
{
|
|
|
|
|
$faker = Factory::create();
|
|
|
|
|
|
|
|
|
|
//data
|
|
|
|
|
$case = $this->createNewCase();
|
|
|
|
|
$template = $this->createTemplate($case->process->PRO_UID, $case->user->USR_UID);
|
|
|
|
|
|
|
|
|
|
//parameters
|
2020-06-09 12:50:12 -04:00
|
|
|
$appUid = $case->application->APP_UID;
|
2019-12-12 11:32:20 -04:00
|
|
|
$from = $faker->email;
|
|
|
|
|
$to = "";
|
|
|
|
|
$cc = "";
|
|
|
|
|
$bcc = "";
|
|
|
|
|
$subject = $faker->title;
|
|
|
|
|
$templateName = basename($template->PRF_PATH);
|
|
|
|
|
$appFields = [
|
|
|
|
|
'var1' => $faker->numberBetween(1, 100)
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
$wsBase = new WsBase();
|
|
|
|
|
$result = $wsBase->sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $templateName, $appFields);
|
|
|
|
|
|
|
|
|
|
//assertions
|
2020-06-09 12:50:12 -04:00
|
|
|
$this->assertInstanceOf(WsResponse::class, $result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This test ensures the response when the default configuration does not exist.
|
|
|
|
|
* @test
|
|
|
|
|
* @covers WsBase::sendMessage
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_test_an_send_message_without_default_configuration()
|
|
|
|
|
{
|
|
|
|
|
//data
|
|
|
|
|
$emailServer = $this->createEmailServer();
|
|
|
|
|
$case = $this->createNewCase();
|
|
|
|
|
$template = $this->createTemplate($case->process->PRO_UID, $case->user->USR_UID);
|
|
|
|
|
|
|
|
|
|
//parameters
|
|
|
|
|
$appUid = $case->application->APP_UID;
|
|
|
|
|
$from = $emailServer->MESS_ACCOUNT;
|
|
|
|
|
$to = $emailServer->MESS_ACCOUNT;
|
|
|
|
|
$cc = "";
|
|
|
|
|
$bcc = "";
|
|
|
|
|
$subject = "test";
|
|
|
|
|
$templateName = basename($template->PRF_PATH);
|
|
|
|
|
$appFields = [];
|
|
|
|
|
$attachment = [];
|
|
|
|
|
$showMessage = true;
|
|
|
|
|
$delIndex = 0;
|
|
|
|
|
$config = [];
|
|
|
|
|
$gmail = 0;
|
|
|
|
|
$appMsgType = '';
|
|
|
|
|
|
|
|
|
|
//for empty configuration
|
|
|
|
|
EmailServerModel::truncate();
|
|
|
|
|
|
|
|
|
|
$wsBase = new WsBase();
|
|
|
|
|
$result = $wsBase->sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $templateName, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType);
|
|
|
|
|
|
|
|
|
|
//assertions
|
|
|
|
|
$this->assertObjectHasAttribute('status_code', $result);
|
|
|
|
|
$this->assertObjectHasAttribute('message', $result);
|
|
|
|
|
$this->assertObjectHasAttribute('timestamp', $result);
|
|
|
|
|
$this->assertObjectHasAttribute('extraParams', $result);
|
|
|
|
|
$this->assertEquals(29, $result->status_code);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This test ensures the response when the template is not found.
|
|
|
|
|
* @test
|
|
|
|
|
* @covers WsBase::sendMessage
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_test_an_send_message_missing_template()
|
|
|
|
|
{
|
|
|
|
|
//data
|
|
|
|
|
$emailServer = $this->createEmailServer();
|
|
|
|
|
$case = $this->createNewCase();
|
|
|
|
|
$template = $this->createTemplate($case->process->PRO_UID, $case->user->USR_UID);
|
|
|
|
|
|
|
|
|
|
//parameters
|
|
|
|
|
$appUid = $case->application->APP_UID;
|
|
|
|
|
$from = $emailServer->MESS_ACCOUNT;
|
|
|
|
|
$to = $emailServer->MESS_ACCOUNT;
|
|
|
|
|
$cc = "";
|
|
|
|
|
$bcc = "";
|
|
|
|
|
$subject = "test";
|
|
|
|
|
$templateName = basename($template->PRF_PATH);
|
|
|
|
|
$appFields = [];
|
|
|
|
|
$attachment = [];
|
|
|
|
|
$showMessage = true;
|
|
|
|
|
$delIndex = 0;
|
|
|
|
|
$config = $emailServer->toArray();
|
|
|
|
|
$gmail = 0;
|
|
|
|
|
$appMsgType = '';
|
|
|
|
|
|
|
|
|
|
//for a missing template
|
|
|
|
|
$templateName = 'MissingFile';
|
|
|
|
|
G::rm_dir(PATH_DATA_SITE . 'mailTemplates');
|
|
|
|
|
|
|
|
|
|
$wsBase = new WsBase();
|
|
|
|
|
$result = $wsBase->sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $templateName, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType);
|
|
|
|
|
|
|
|
|
|
//assertions
|
|
|
|
|
$this->assertObjectHasAttribute('status_code', $result);
|
|
|
|
|
$this->assertObjectHasAttribute('message', $result);
|
|
|
|
|
$this->assertObjectHasAttribute('timestamp', $result);
|
|
|
|
|
$this->assertObjectHasAttribute('extraParams', $result);
|
|
|
|
|
$this->assertEquals(28, $result->status_code);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This test ensures the response when there is an exception.
|
|
|
|
|
* @test
|
|
|
|
|
* @covers WsBase::sendMessage
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_test_an_send_message_when_appears_an_exception()
|
|
|
|
|
{
|
|
|
|
|
//data
|
|
|
|
|
$emailServer = $this->createEmailServer();
|
|
|
|
|
$case = $this->createNewCase();
|
|
|
|
|
$template = $this->createTemplate($case->process->PRO_UID, $case->user->USR_UID);
|
|
|
|
|
|
|
|
|
|
//parameters
|
|
|
|
|
$appUid = null;
|
|
|
|
|
$from = $emailServer->MESS_ACCOUNT;
|
|
|
|
|
$to = $emailServer->MESS_ACCOUNT;
|
|
|
|
|
$cc = "";
|
|
|
|
|
$bcc = "";
|
|
|
|
|
$subject = "test";
|
|
|
|
|
$templateName = basename($template->PRF_PATH);
|
|
|
|
|
$appFields = [];
|
|
|
|
|
$attachment = [];
|
|
|
|
|
$showMessage = true;
|
|
|
|
|
$delIndex = 0;
|
|
|
|
|
$config = $emailServer->toArray();
|
|
|
|
|
$gmail = 0;
|
|
|
|
|
$appMsgType = '';
|
|
|
|
|
|
|
|
|
|
$wsBase = new WsBase();
|
|
|
|
|
$result = $wsBase->sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $templateName, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType);
|
|
|
|
|
|
|
|
|
|
//assertions
|
|
|
|
|
$this->assertObjectHasAttribute('status_code', $result);
|
|
|
|
|
$this->assertObjectHasAttribute('message', $result);
|
|
|
|
|
$this->assertObjectHasAttribute('timestamp', $result);
|
|
|
|
|
$this->assertObjectHasAttribute('extraParams', $result);
|
|
|
|
|
$this->assertEquals(100, $result->status_code);
|
2019-12-12 11:32:20 -04:00
|
|
|
}
|
2020-02-03 16:25:37 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Review if the flag is true when the cancel case is related to the same case in SESSION
|
|
|
|
|
*
|
|
|
|
|
* @covers WsBase::cancelCase()
|
|
|
|
|
* @test
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_set_flag_when_is_same_case()
|
|
|
|
|
{
|
2022-07-21 00:04:21 -04:00
|
|
|
$application = Application::factory()->create([
|
2020-02-03 16:25:37 -04:00
|
|
|
'APP_STATUS_ID' => 2,
|
|
|
|
|
'APP_STATUS' => 'TO_DO'
|
|
|
|
|
]);
|
2022-07-21 00:04:21 -04:00
|
|
|
$delegation = Delegation::factory()->foreign_keys()->create([
|
2020-02-03 16:25:37 -04:00
|
|
|
'APP_NUMBER' => $application->APP_NUMBER,
|
|
|
|
|
'APP_UID' => $application->APP_UID,
|
|
|
|
|
]);
|
|
|
|
|
$_SESSION["APPLICATION"] = $delegation->APP_UID;
|
|
|
|
|
$ws = new WsBase();
|
2020-06-09 12:50:12 -04:00
|
|
|
$response = (object) $ws->cancelCase($delegation->APP_UID, $delegation->DEL_INDEX, $delegation->APP_UID);
|
2020-02-03 16:25:37 -04:00
|
|
|
$this->assertEquals($ws->getFlagSameCase(), true);
|
|
|
|
|
$this->assertNotEmpty($response);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Review the required field caseUid
|
|
|
|
|
*
|
|
|
|
|
* @covers WsBase::cancelCase()
|
|
|
|
|
* @test
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_validate_required_app_uid()
|
|
|
|
|
{
|
2022-07-21 00:04:21 -04:00
|
|
|
$delegation = Delegation::factory()->foreign_keys()->create();
|
2020-02-03 16:25:37 -04:00
|
|
|
$ws = new WsBase();
|
2020-06-09 12:50:12 -04:00
|
|
|
$response = (object) $ws->cancelCase('', $delegation->DE_INDEX, $delegation->URS_UID);
|
2020-02-03 16:25:37 -04:00
|
|
|
$this->assertEquals($response->status_code, 100);
|
|
|
|
|
$this->assertEquals($response->message, G::LoadTranslation("ID_REQUIRED_FIELD") . ' caseUid');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Review the required field status = TO_DO
|
|
|
|
|
*
|
|
|
|
|
* @covers WsBase::cancelCase()
|
|
|
|
|
* @test
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_validate_required_status_todo()
|
|
|
|
|
{
|
|
|
|
|
// Create a case in DRAFT status
|
2022-07-21 00:04:21 -04:00
|
|
|
$application = Application::factory()->create([
|
2020-02-03 16:25:37 -04:00
|
|
|
'APP_STATUS_ID' => 1,
|
|
|
|
|
'APP_STATUS' => 'DRAFT'
|
|
|
|
|
]);
|
2022-07-21 00:04:21 -04:00
|
|
|
$delegation = Delegation::factory()->foreign_keys()->create([
|
2020-02-03 16:25:37 -04:00
|
|
|
'APP_NUMBER' => $application->APP_NUMBER,
|
|
|
|
|
'APP_UID' => $application->APP_UID,
|
|
|
|
|
]);
|
|
|
|
|
$ws = new WsBase();
|
2020-06-09 12:50:12 -04:00
|
|
|
$response = (object) $ws->cancelCase($delegation->APP_UID, $delegation->DE_INDEX, $delegation->URS_UID);
|
2020-02-03 16:25:37 -04:00
|
|
|
$this->assertEquals($response->status_code, 100);
|
|
|
|
|
$this->assertEquals($response->message, G::LoadTranslation("ID_CASE_IN_STATUS") . ' DRAFT');
|
|
|
|
|
|
|
|
|
|
// Create a case in COMPLETED status
|
2022-07-21 00:04:21 -04:00
|
|
|
$application = Application::factory()->create([
|
2020-02-03 16:25:37 -04:00
|
|
|
'APP_STATUS_ID' => 3,
|
|
|
|
|
'APP_STATUS' => 'COMPLETED'
|
|
|
|
|
]);
|
2022-07-21 00:04:21 -04:00
|
|
|
$delegation = Delegation::factory()->foreign_keys()->create([
|
2020-02-03 16:25:37 -04:00
|
|
|
'APP_NUMBER' => $application->APP_NUMBER,
|
|
|
|
|
'APP_UID' => $application->APP_UID,
|
|
|
|
|
]);
|
|
|
|
|
$ws = new WsBase();
|
2020-06-09 12:50:12 -04:00
|
|
|
$response = (object) $ws->cancelCase($delegation->APP_UID, $delegation->DE_INDEX, $delegation->URS_UID);
|
2020-02-03 16:25:37 -04:00
|
|
|
$this->assertEquals($response->status_code, 100);
|
|
|
|
|
$this->assertEquals($response->message, G::LoadTranslation("ID_CASE_IN_STATUS") . ' COMPLETED');
|
|
|
|
|
|
|
|
|
|
// Create a case in CANCELLED status
|
2022-07-21 00:04:21 -04:00
|
|
|
$application = Application::factory()->create([
|
2020-02-03 16:25:37 -04:00
|
|
|
'APP_STATUS_ID' => 4,
|
|
|
|
|
'APP_STATUS' => 'CANCELLED'
|
|
|
|
|
]);
|
2022-07-21 00:04:21 -04:00
|
|
|
$delegation = Delegation::factory()->foreign_keys()->create([
|
2020-02-03 16:25:37 -04:00
|
|
|
'APP_NUMBER' => $application->APP_NUMBER,
|
|
|
|
|
'APP_UID' => $application->APP_UID,
|
|
|
|
|
]);
|
|
|
|
|
$ws = new WsBase();
|
2020-06-09 12:50:12 -04:00
|
|
|
$response = (object) $ws->cancelCase($delegation->APP_UID, $delegation->DE_INDEX, $delegation->URS_UID);
|
2020-02-03 16:25:37 -04:00
|
|
|
$this->assertEquals($response->status_code, 100);
|
|
|
|
|
$this->assertEquals($response->message, G::LoadTranslation("ID_CASE_IN_STATUS") . ' CANCELLED');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Review the required field delIndex
|
|
|
|
|
*
|
|
|
|
|
* @covers WsBase::cancelCase()
|
|
|
|
|
* @test
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_validate_required_del_index()
|
|
|
|
|
{
|
2022-07-21 00:04:21 -04:00
|
|
|
$application = Application::factory()->create([
|
2020-02-03 16:25:37 -04:00
|
|
|
'APP_STATUS_ID' => 2,
|
|
|
|
|
'APP_STATUS' => 'TO_DO'
|
|
|
|
|
]);
|
2022-07-21 00:04:21 -04:00
|
|
|
$delegation = Delegation::factory()->foreign_keys()->create([
|
2020-02-03 16:25:37 -04:00
|
|
|
'APP_NUMBER' => $application->APP_NUMBER,
|
|
|
|
|
'APP_UID' => $application->APP_UID,
|
|
|
|
|
]);
|
|
|
|
|
$ws = new WsBase();
|
2020-06-09 12:50:12 -04:00
|
|
|
$response = (object) $ws->cancelCase($delegation->APP_UID, '', $delegation->USR_UID);
|
2020-02-03 16:25:37 -04:00
|
|
|
$this->assertEquals($response->status_code, 100);
|
|
|
|
|
$this->assertEquals($response->message, G::LoadTranslation("ID_REQUIRED_FIELD") . ' delIndex');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Review the required field open thread
|
|
|
|
|
*
|
|
|
|
|
* @covers WsBase::cancelCase()
|
|
|
|
|
* @test
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_validate_required_open_thread()
|
|
|
|
|
{
|
2022-07-21 00:04:21 -04:00
|
|
|
$application = Application::factory()->create([
|
2020-02-03 16:25:37 -04:00
|
|
|
'APP_STATUS_ID' => 2,
|
|
|
|
|
'APP_STATUS' => 'TO_DO'
|
|
|
|
|
]);
|
2022-07-21 00:04:21 -04:00
|
|
|
$delegation = Delegation::factory()->foreign_keys()->create([
|
2020-02-03 16:25:37 -04:00
|
|
|
'APP_NUMBER' => $application->APP_NUMBER,
|
|
|
|
|
'APP_UID' => $application->APP_UID,
|
|
|
|
|
'DEL_THREAD_STATUS' => 'CLOSED'
|
|
|
|
|
]);
|
|
|
|
|
$ws = new WsBase();
|
2020-06-09 12:50:12 -04:00
|
|
|
$response = (object) $ws->cancelCase($delegation->APP_UID, $delegation->DEL_INDEX, '');
|
2020-02-03 16:25:37 -04:00
|
|
|
$this->assertEquals($response->status_code, 100);
|
|
|
|
|
$this->assertEquals($response->message, G::LoadTranslation("ID_CASE_DELEGATION_ALREADY_CLOSED"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Review the required field userUid
|
|
|
|
|
*
|
|
|
|
|
* @covers WsBase::cancelCase()
|
|
|
|
|
* @test
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_validate_required_usr_uid()
|
|
|
|
|
{
|
2022-07-21 00:04:21 -04:00
|
|
|
$application = Application::factory()->create([
|
2020-02-03 16:25:37 -04:00
|
|
|
'APP_STATUS_ID' => 2,
|
|
|
|
|
'APP_STATUS' => 'TO_DO'
|
|
|
|
|
]);
|
2022-07-21 00:04:21 -04:00
|
|
|
$delegation = Delegation::factory()->foreign_keys()->create([
|
2020-02-03 16:25:37 -04:00
|
|
|
'APP_NUMBER' => $application->APP_NUMBER,
|
|
|
|
|
'APP_UID' => $application->APP_UID,
|
|
|
|
|
]);
|
|
|
|
|
$ws = new WsBase();
|
2020-06-09 12:50:12 -04:00
|
|
|
$response = (object) $ws->cancelCase($delegation->APP_UID, $delegation->DEL_INDEX, '');
|
2020-02-03 16:25:37 -04:00
|
|
|
$this->assertEquals($response->status_code, 100);
|
|
|
|
|
$this->assertEquals($response->message, G::LoadTranslation("ID_REQUIRED_FIELD") . ' userUid');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Review cancel case with parallel threads
|
|
|
|
|
*
|
|
|
|
|
* @covers WsBase::cancelCase()
|
|
|
|
|
* @test
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_validate_only_one_thread_opened()
|
|
|
|
|
{
|
2022-07-21 00:04:21 -04:00
|
|
|
$application = Application::factory()->create([
|
2020-02-03 16:25:37 -04:00
|
|
|
'APP_STATUS_ID' => 2,
|
|
|
|
|
'APP_STATUS' => 'TO_DO'
|
|
|
|
|
]);
|
2022-07-21 00:04:21 -04:00
|
|
|
AppThread::factory()->create([
|
2020-02-03 16:25:37 -04:00
|
|
|
'APP_UID' => $application->APP_UID,
|
|
|
|
|
'APP_THREAD_INDEX' => 1,
|
|
|
|
|
'APP_THREAD_PARENT' => 1,
|
|
|
|
|
'APP_THREAD_STATUS' => 'OPEN',
|
|
|
|
|
'DEL_INDEX' => 1
|
|
|
|
|
]);
|
2022-07-21 00:04:21 -04:00
|
|
|
Delegation::factory()->foreign_keys()->create([
|
2020-02-03 16:25:37 -04:00
|
|
|
'APP_NUMBER' => $application->APP_NUMBER,
|
|
|
|
|
'APP_UID' => $application->APP_UID,
|
|
|
|
|
'DEL_THREAD_STATUS' => 'OPEN'
|
|
|
|
|
]);
|
2022-07-21 00:04:21 -04:00
|
|
|
AppThread::factory()->create([
|
2020-02-03 16:25:37 -04:00
|
|
|
'APP_UID' => $application->APP_UID,
|
|
|
|
|
'APP_THREAD_INDEX' => 2,
|
|
|
|
|
'APP_THREAD_PARENT' => 1,
|
|
|
|
|
'APP_THREAD_STATUS' => 'OPEN',
|
|
|
|
|
'DEL_INDEX' => 2
|
|
|
|
|
]);
|
2022-07-21 00:04:21 -04:00
|
|
|
$delegation = Delegation::factory()->foreign_keys()->create([
|
2020-02-03 16:25:37 -04:00
|
|
|
'APP_NUMBER' => $application->APP_NUMBER,
|
|
|
|
|
'APP_UID' => $application->APP_UID,
|
|
|
|
|
'DEL_THREAD_STATUS' => 'OPEN',
|
|
|
|
|
'DEL_INDEX' => 2,
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$ws = new WsBase();
|
2020-06-09 12:50:12 -04:00
|
|
|
$response = (object) $ws->cancelCase($delegation->APP_UID, $delegation->DEL_INDEX, $delegation->USR_UID);
|
2020-02-03 16:25:37 -04:00
|
|
|
$this->assertEquals($response->status_code, 100);
|
|
|
|
|
$this->assertEquals($response->message, G::LoadTranslation("ID_CASE_CANCELLED_PARALLEL"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-02-14 15:33:28 -04:00
|
|
|
* Review the cancel case with one thread open was executed successfully
|
2020-02-03 16:25:37 -04:00
|
|
|
*
|
|
|
|
|
* @covers WsBase::cancelCase()
|
|
|
|
|
* @test
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_cancel_case()
|
|
|
|
|
{
|
2020-02-14 15:33:28 -04:00
|
|
|
// Definition for avoid the error: Trying to get property 'aUserInfo' of non-object in the action buildAppDelayRow()
|
|
|
|
|
global $RBAC;
|
2022-08-26 12:42:07 -04:00
|
|
|
$user = User::where('USR_ID', '=', 1)->first();
|
2020-02-14 15:33:28 -04:00
|
|
|
$_SESSION['USER_LOGGED'] = $user['USR_UID'];
|
|
|
|
|
$RBAC = RBAC::getSingleton(PATH_DATA, session_id());
|
|
|
|
|
$RBAC->initRBAC();
|
|
|
|
|
$RBAC->loadUserRolePermission('PROCESSMAKER', $_SESSION['USER_LOGGED']);
|
|
|
|
|
|
|
|
|
|
// Create the data related to the cancel a case
|
2022-07-21 00:04:21 -04:00
|
|
|
$process = Process::factory()->create([
|
2022-02-09 10:38:04 -04:00
|
|
|
'PRO_CREATE_USER' => $user->USR_UID
|
|
|
|
|
]);
|
2022-07-21 00:04:21 -04:00
|
|
|
$task = Task::factory()->create([
|
2022-02-09 10:38:04 -04:00
|
|
|
'PRO_UID' => $process->PRO_UID,
|
|
|
|
|
'TAS_USER' => $user->USR_UID
|
|
|
|
|
]);
|
2022-07-21 00:04:21 -04:00
|
|
|
TaskUser::factory()->create([
|
2022-02-09 10:38:04 -04:00
|
|
|
'TAS_UID' => $task->TAS_UID,
|
|
|
|
|
'USR_UID' => $user->USR_UID
|
|
|
|
|
]);
|
2022-07-21 00:04:21 -04:00
|
|
|
UserReporting::factory()->create([
|
2020-02-14 15:33:28 -04:00
|
|
|
'TAS_UID' => $task->TAS_UID
|
|
|
|
|
]);
|
2022-07-21 00:04:21 -04:00
|
|
|
$application = Application::factory()->foreign_keys()->create([
|
2022-02-09 10:38:04 -04:00
|
|
|
'PRO_UID' => $process->PRO_UID,
|
|
|
|
|
'APP_INIT_USER' => $user->USR_UID,
|
|
|
|
|
'APP_CUR_USER' => $user->USR_UID,
|
2020-02-03 16:25:37 -04:00
|
|
|
'APP_STATUS_ID' => 2,
|
|
|
|
|
'APP_STATUS' => 'TO_DO'
|
|
|
|
|
]);
|
2022-07-21 00:04:21 -04:00
|
|
|
AppThread::factory()->create([
|
2020-02-03 16:25:37 -04:00
|
|
|
'APP_UID' => $application->APP_UID,
|
|
|
|
|
'APP_THREAD_INDEX' => 1,
|
|
|
|
|
'APP_THREAD_PARENT' => 1,
|
|
|
|
|
'APP_THREAD_STATUS' => 'OPEN',
|
|
|
|
|
'DEL_INDEX' => 2
|
|
|
|
|
]);
|
2022-07-21 00:04:21 -04:00
|
|
|
$delegation = Delegation::factory()->foreign_keys()->create([
|
2020-02-14 15:33:28 -04:00
|
|
|
'TAS_UID' => $task->TAS_UID,
|
|
|
|
|
'PRO_UID' => $application->PRO_UID,
|
2020-02-03 16:25:37 -04:00
|
|
|
'APP_NUMBER' => $application->APP_NUMBER,
|
|
|
|
|
'APP_UID' => $application->APP_UID,
|
|
|
|
|
'DEL_THREAD_STATUS' => 'OPEN',
|
|
|
|
|
'DEL_INDEX' => 2,
|
2022-02-09 10:38:04 -04:00
|
|
|
'DEL_PREVIOUS' => 2
|
2020-02-03 16:25:37 -04:00
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$ws = new WsBase();
|
2020-06-09 12:50:12 -04:00
|
|
|
$response = (object) $ws->cancelCase($delegation->APP_UID, $delegation->DEL_INDEX, $delegation->USR_UID);
|
2020-02-03 16:25:37 -04:00
|
|
|
$this->assertNotEmpty($response);
|
2020-02-14 15:33:28 -04:00
|
|
|
$this->assertObjectHasAttribute('status_code', $response);
|
|
|
|
|
$this->assertEquals($response->message, G::LoadTranslation("ID_COMMAND_EXECUTED_SUCCESSFULLY"));
|
2020-02-03 16:25:37 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2020-02-14 15:33:28 -04:00
|
|
|
* Review the cancel case with parallel threads was executed successfully
|
2020-02-03 16:25:37 -04:00
|
|
|
*
|
|
|
|
|
* @covers WsBase::cancelCase()
|
|
|
|
|
* @test
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_cancel_case_parallel()
|
|
|
|
|
{
|
2020-02-14 15:33:28 -04:00
|
|
|
// Definition for avoid the error: Trying to get property 'aUserInfo' of non-object in the action buildAppDelayRow()
|
|
|
|
|
global $RBAC;
|
2022-08-26 12:42:07 -04:00
|
|
|
$user = User::where('USR_ID', '=', 1)->first();
|
2020-02-14 15:33:28 -04:00
|
|
|
$_SESSION['USER_LOGGED'] = $user['USR_UID'];
|
|
|
|
|
$RBAC = RBAC::getSingleton(PATH_DATA, session_id());
|
|
|
|
|
$RBAC->initRBAC();
|
|
|
|
|
$RBAC->loadUserRolePermission('PROCESSMAKER', $_SESSION['USER_LOGGED']);
|
|
|
|
|
|
|
|
|
|
// Create the data related to the cancel a case
|
2022-07-21 00:04:21 -04:00
|
|
|
$task = Task::factory()->create();
|
|
|
|
|
UserReporting::factory()->create([
|
2020-02-14 15:33:28 -04:00
|
|
|
'TAS_UID' => $task->TAS_UID
|
|
|
|
|
]);
|
2022-07-21 00:04:21 -04:00
|
|
|
$application = Application::factory()->foreign_keys()->create([
|
2020-02-03 16:25:37 -04:00
|
|
|
'APP_STATUS_ID' => 2,
|
2022-02-09 10:38:04 -04:00
|
|
|
'APP_INIT_USER' => $user->USR_UID,
|
|
|
|
|
'APP_CUR_USER' => $user->USR_UID,
|
2020-02-03 16:25:37 -04:00
|
|
|
'APP_STATUS' => 'TO_DO'
|
|
|
|
|
]);
|
2020-02-14 15:33:28 -04:00
|
|
|
// Create the first thread
|
2022-07-21 00:04:21 -04:00
|
|
|
AppThread::factory()->create([
|
2020-02-03 16:25:37 -04:00
|
|
|
'APP_UID' => $application->APP_UID,
|
2020-02-14 15:33:28 -04:00
|
|
|
'APP_THREAD_INDEX' => 2,
|
2020-02-03 16:25:37 -04:00
|
|
|
'APP_THREAD_PARENT' => 1,
|
|
|
|
|
'APP_THREAD_STATUS' => 'OPEN',
|
2020-02-14 15:33:28 -04:00
|
|
|
'DEL_INDEX' => 2
|
2020-02-03 16:25:37 -04:00
|
|
|
]);
|
2022-07-21 00:04:21 -04:00
|
|
|
Delegation::factory()->foreign_keys()->create([
|
2020-02-14 15:33:28 -04:00
|
|
|
'TAS_UID' => $task->TAS_UID,
|
|
|
|
|
'PRO_UID' => $application->PRO_UID,
|
2020-02-03 16:25:37 -04:00
|
|
|
'APP_NUMBER' => $application->APP_NUMBER,
|
|
|
|
|
'APP_UID' => $application->APP_UID,
|
2020-02-14 15:33:28 -04:00
|
|
|
'DEL_THREAD_STATUS' => 'OPEN',
|
|
|
|
|
'DEL_INDEX' => 2,
|
2022-02-09 10:38:04 -04:00
|
|
|
'DEL_PREVIOUS' => 2,
|
2020-02-03 16:25:37 -04:00
|
|
|
]);
|
2020-02-14 15:33:28 -04:00
|
|
|
// Create the second thread
|
2022-07-21 00:04:21 -04:00
|
|
|
AppThread::factory()->create([
|
2020-02-03 16:25:37 -04:00
|
|
|
'APP_UID' => $application->APP_UID,
|
2020-02-14 15:33:28 -04:00
|
|
|
'APP_THREAD_INDEX' => 3,
|
2020-02-03 16:25:37 -04:00
|
|
|
'APP_THREAD_PARENT' => 1,
|
|
|
|
|
'APP_THREAD_STATUS' => 'OPEN',
|
2020-02-14 15:33:28 -04:00
|
|
|
'DEL_INDEX' => 3
|
2020-02-03 16:25:37 -04:00
|
|
|
]);
|
2022-07-21 00:04:21 -04:00
|
|
|
$delegation = Delegation::factory()->foreign_keys()->create([
|
2020-02-14 15:33:28 -04:00
|
|
|
'TAS_UID' => $task->TAS_UID,
|
|
|
|
|
'PRO_UID' => $application->PRO_UID,
|
2022-02-09 10:38:04 -04:00
|
|
|
'USR_UID' => $user->USR_UID,
|
2020-02-03 16:25:37 -04:00
|
|
|
'APP_NUMBER' => $application->APP_NUMBER,
|
|
|
|
|
'APP_UID' => $application->APP_UID,
|
|
|
|
|
'DEL_THREAD_STATUS' => 'OPEN',
|
2020-02-14 15:33:28 -04:00
|
|
|
'DEL_INDEX' => 3,
|
2022-02-09 10:38:04 -04:00
|
|
|
'DEL_PREVIOUS' => 3,
|
2020-02-03 16:25:37 -04:00
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$ws = new WsBase();
|
2020-06-09 12:50:12 -04:00
|
|
|
$response = (object) $ws->cancelCase($delegation->APP_UID, null, null);
|
2020-02-03 16:25:37 -04:00
|
|
|
$this->assertNotEmpty($response);
|
2020-02-14 15:33:28 -04:00
|
|
|
$this->assertObjectHasAttribute('status_code', $response);
|
|
|
|
|
$this->assertEquals($response->message, G::LoadTranslation("ID_COMMAND_EXECUTED_SUCCESSFULLY"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Review the cancel case when the applications does not exist
|
|
|
|
|
*
|
|
|
|
|
* @covers WsBase::cancelCase()
|
|
|
|
|
* @test
|
|
|
|
|
*/
|
|
|
|
|
public function it_tried_cancel_an_undefined_case()
|
|
|
|
|
{
|
|
|
|
|
$fakeApp = G::generateUniqueID();
|
2022-07-21 00:04:21 -04:00
|
|
|
$application = Application::factory()->create([
|
2020-02-14 15:33:28 -04:00
|
|
|
'APP_STATUS_ID' => 2,
|
|
|
|
|
'APP_STATUS' => 'TO_DO'
|
|
|
|
|
]);
|
2022-07-21 00:04:21 -04:00
|
|
|
AppThread::factory()->create([
|
2020-02-14 15:33:28 -04:00
|
|
|
'APP_UID' => $application->APP_UID,
|
|
|
|
|
'APP_THREAD_INDEX' => 1,
|
|
|
|
|
'APP_THREAD_PARENT' => 1,
|
|
|
|
|
'APP_THREAD_STATUS' => 'OPEN',
|
|
|
|
|
'DEL_INDEX' => 2
|
|
|
|
|
]);
|
2022-07-21 00:04:21 -04:00
|
|
|
$delegation = Delegation::factory()->foreign_keys()->create([
|
2020-02-14 15:33:28 -04:00
|
|
|
'APP_NUMBER' => $application->APP_NUMBER,
|
|
|
|
|
'APP_UID' => $application->APP_UID,
|
|
|
|
|
'DEL_THREAD_STATUS' => 'OPEN',
|
|
|
|
|
'DEL_INDEX' => 2,
|
|
|
|
|
]);
|
|
|
|
|
$ws = new WsBase();
|
2020-06-09 12:50:12 -04:00
|
|
|
$response = (object) $ws->cancelCase($fakeApp, $delegation->DEL_INDEX, $delegation->USR_UID);
|
2020-02-14 15:33:28 -04:00
|
|
|
$this->assertEquals($response->status_code, 100);
|
2022-07-21 00:04:21 -04:00
|
|
|
$this->assertStringContainsString($fakeApp, $response->message);
|
2020-02-03 16:25:37 -04:00
|
|
|
}
|
2021-04-30 09:17:09 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Test the unassigned case list method with unassigned cases
|
|
|
|
|
*
|
|
|
|
|
* @test
|
|
|
|
|
* @covers WsBase::unassignedCaseList()
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_test_the_unassigned_case_list_method_with_unassigned_cases()
|
|
|
|
|
{
|
|
|
|
|
//Create process
|
2022-07-21 00:04:21 -04:00
|
|
|
$process1 = Process::factory()->create([
|
2021-04-30 09:17:09 -04:00
|
|
|
'PRO_TITLE' => 'China Supplier Payment Proposal'
|
|
|
|
|
]);
|
2022-07-21 00:04:21 -04:00
|
|
|
$process2 = Process::factory()->create([
|
2021-04-30 09:17:09 -04:00
|
|
|
'PRO_TITLE' => 'Egypt Supplier Payment Proposal'
|
|
|
|
|
]);
|
|
|
|
|
//Create application
|
2022-07-21 00:04:21 -04:00
|
|
|
$application1 = Application::factory()->create([
|
2021-04-30 09:17:09 -04:00
|
|
|
'APP_STATUS_ID' => 2
|
|
|
|
|
]);
|
|
|
|
|
//Create user
|
2022-07-21 00:04:21 -04:00
|
|
|
$user = User::factory()->create();
|
2021-04-30 09:17:09 -04:00
|
|
|
//Create a task self service
|
2022-07-21 00:04:21 -04:00
|
|
|
$task1 = Task::factory()->create([
|
2021-04-30 09:17:09 -04:00
|
|
|
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
|
|
|
|
|
'TAS_GROUP_VARIABLE' => '',
|
|
|
|
|
'PRO_UID' => $process1->PRO_UID
|
|
|
|
|
]);
|
2022-07-21 00:04:21 -04:00
|
|
|
$task2 = Task::factory()->create([
|
2021-04-30 09:17:09 -04:00
|
|
|
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
|
|
|
|
|
'TAS_GROUP_VARIABLE' => '',
|
|
|
|
|
'PRO_UID' => $process1->PRO_UID
|
|
|
|
|
]);
|
|
|
|
|
//Assign a user in the task
|
2022-07-21 00:04:21 -04:00
|
|
|
TaskUser::factory()->create([
|
2021-04-30 09:17:09 -04:00
|
|
|
'TAS_UID' => $task1->TAS_UID,
|
|
|
|
|
'USR_UID' => $user->USR_UID,
|
|
|
|
|
'TU_RELATION' => 1, //Related to the user
|
|
|
|
|
'TU_TYPE' => 1
|
|
|
|
|
]);
|
2022-07-21 00:04:21 -04:00
|
|
|
TaskUser::factory()->create([
|
2021-04-30 09:17:09 -04:00
|
|
|
'TAS_UID' => $task2->TAS_UID,
|
|
|
|
|
'USR_UID' => $user->USR_UID,
|
|
|
|
|
'TU_RELATION' => 1, //Related to the user
|
|
|
|
|
'TU_TYPE' => 1
|
|
|
|
|
]);
|
|
|
|
|
//Create the register in delegation relate to self-service
|
2022-07-21 00:04:21 -04:00
|
|
|
Delegation::factory(2)->create([
|
2021-04-30 09:17:09 -04:00
|
|
|
'APP_NUMBER' => $application1->APP_NUMBER,
|
|
|
|
|
'TAS_ID' => $task1->TAS_ID,
|
|
|
|
|
'PRO_ID' => $process1->id,
|
|
|
|
|
'DEL_THREAD_STATUS' => 'OPEN',
|
|
|
|
|
'USR_ID' => 0,
|
|
|
|
|
]);
|
2022-07-21 00:04:21 -04:00
|
|
|
Delegation::factory(2)->create([
|
2021-04-30 09:17:09 -04:00
|
|
|
'APP_NUMBER' => $application1->APP_NUMBER,
|
|
|
|
|
'TAS_ID' => $task2->TAS_ID,
|
|
|
|
|
'PRO_ID' => $process2->id,
|
|
|
|
|
'DEL_THREAD_STATUS' => 'OPEN',
|
|
|
|
|
'USR_ID' => 0,
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$wsBase = new WsBase();
|
|
|
|
|
$res = $wsBase->unassignedCaseList($user->USR_UID);
|
|
|
|
|
//Assert the expected number of unassigned cases
|
|
|
|
|
$this->assertCount(4, $res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Test the unassigned case list method without unassigned cases
|
|
|
|
|
*
|
|
|
|
|
* @test
|
|
|
|
|
* @covers WsBase::unassignedCaseList()
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_test_the_unassigned_case_list_method_without_unassigned_cases()
|
|
|
|
|
{
|
|
|
|
|
//Create process
|
2022-07-21 00:04:21 -04:00
|
|
|
$process1 = Process::factory()->create([
|
2021-04-30 09:17:09 -04:00
|
|
|
'PRO_TITLE' => 'China Supplier Payment Proposal'
|
|
|
|
|
]);
|
2022-07-21 00:04:21 -04:00
|
|
|
$process2 = Process::factory()->create([
|
2021-04-30 09:17:09 -04:00
|
|
|
'PRO_TITLE' => 'Egypt Supplier Payment Proposal'
|
|
|
|
|
]);
|
|
|
|
|
//Create application
|
2022-07-21 00:04:21 -04:00
|
|
|
$application1 = Application::factory()->create([
|
2021-04-30 09:17:09 -04:00
|
|
|
'APP_STATUS_ID' => 2
|
|
|
|
|
]);
|
|
|
|
|
//Create user
|
2022-07-21 00:04:21 -04:00
|
|
|
$user = User::factory()->create();
|
2021-04-30 09:17:09 -04:00
|
|
|
//Create a task self service
|
2022-07-21 00:04:21 -04:00
|
|
|
$task1 = Task::factory()->create([
|
2021-04-30 09:17:09 -04:00
|
|
|
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
|
|
|
|
|
'TAS_GROUP_VARIABLE' => '',
|
|
|
|
|
'PRO_UID' => $process1->PRO_UID
|
|
|
|
|
]);
|
2022-07-21 00:04:21 -04:00
|
|
|
$task2 = Task::factory()->create([
|
2021-04-30 09:17:09 -04:00
|
|
|
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
|
|
|
|
|
'TAS_GROUP_VARIABLE' => '',
|
|
|
|
|
'PRO_UID' => $process1->PRO_UID
|
|
|
|
|
]);
|
|
|
|
|
//Assign a user in the task
|
2022-07-21 00:04:21 -04:00
|
|
|
TaskUser::factory()->create([
|
2021-04-30 09:17:09 -04:00
|
|
|
'TAS_UID' => $task1->TAS_UID,
|
|
|
|
|
'USR_UID' => $user->USR_UID,
|
|
|
|
|
'TU_RELATION' => 1, //Related to the user
|
|
|
|
|
'TU_TYPE' => 1
|
|
|
|
|
]);
|
|
|
|
|
//Assign a user in the task
|
2022-07-21 00:04:21 -04:00
|
|
|
TaskUser::factory()->create([
|
2021-04-30 09:17:09 -04:00
|
|
|
'TAS_UID' => $task2->TAS_UID,
|
|
|
|
|
'USR_UID' => $user->USR_UID,
|
|
|
|
|
'TU_RELATION' => 1, //Related to the user
|
|
|
|
|
'TU_TYPE' => 1
|
|
|
|
|
]);
|
|
|
|
|
//Create the register in delegation relate to self-service
|
2022-07-21 00:04:21 -04:00
|
|
|
Delegation::factory(2)->create([
|
2021-04-30 09:17:09 -04:00
|
|
|
'APP_NUMBER' => $application1->APP_NUMBER,
|
|
|
|
|
'TAS_ID' => $task1->TAS_ID,
|
|
|
|
|
'PRO_ID' => $process1->id,
|
|
|
|
|
'DEL_THREAD_STATUS' => 'OPEN',
|
|
|
|
|
'USR_ID' => 5,
|
|
|
|
|
]);
|
2022-07-21 00:04:21 -04:00
|
|
|
Delegation::factory(2)->create([
|
2021-04-30 09:17:09 -04:00
|
|
|
'APP_NUMBER' => $application1->APP_NUMBER,
|
|
|
|
|
'TAS_ID' => $task2->TAS_ID,
|
|
|
|
|
'PRO_ID' => $process2->id,
|
|
|
|
|
'DEL_THREAD_STATUS' => 'OPEN',
|
|
|
|
|
'USR_ID' => 3,
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$wsBase = new WsBase();
|
|
|
|
|
$res = $wsBase->unassignedCaseList($user->USR_UID);
|
|
|
|
|
|
|
|
|
|
//Assert the expected number of unassigned cases
|
|
|
|
|
$this->assertCount(0, $res);
|
|
|
|
|
}
|
2022-02-16 11:20:13 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Review the required fields in pause case
|
|
|
|
|
*
|
|
|
|
|
* @covers WsBase::pauseCase()
|
|
|
|
|
* @test
|
|
|
|
|
*/
|
|
|
|
|
public function it_review_fields_to_pause_case()
|
|
|
|
|
{
|
|
|
|
|
// Validate the appUid
|
|
|
|
|
$ws = new WsBase();
|
|
|
|
|
$response = (object) $ws->pauseCase('', 0, '');
|
|
|
|
|
$this->assertEquals($response->status_code, 100);
|
|
|
|
|
// Validate the status
|
2022-07-21 00:04:21 -04:00
|
|
|
$application = Application::factory()->draft()->create();
|
2022-02-16 11:20:13 -04:00
|
|
|
$ws = new WsBase();
|
|
|
|
|
$response = (object) $ws->pauseCase($application->APP_UID, 0, '');
|
|
|
|
|
$this->assertEquals($response->status_code, 100);
|
|
|
|
|
// Validate the index
|
2022-07-21 00:04:21 -04:00
|
|
|
$application = Application::factory()->todo()->create();
|
2022-02-16 11:20:13 -04:00
|
|
|
$ws = new WsBase();
|
|
|
|
|
$response = (object) $ws->pauseCase($application->APP_UID, '', '');
|
|
|
|
|
$this->assertEquals($response->status_code, 100);
|
|
|
|
|
// Validate the user
|
2022-07-21 00:04:21 -04:00
|
|
|
$application = Application::factory()->todo()->create();
|
|
|
|
|
$delegation = Delegation::factory()->foreign_keys()->create([
|
2022-02-16 11:20:13 -04:00
|
|
|
'APP_NUMBER' => $application->APP_NUMBER,
|
|
|
|
|
'APP_UID' => $application->APP_UID,
|
|
|
|
|
]);
|
|
|
|
|
$ws = new WsBase();
|
|
|
|
|
$response = (object) $ws->pauseCase($application->APP_UID, $delegation->DEL_INDEX, '');
|
|
|
|
|
$this->assertEquals($response->status_code, 100);
|
|
|
|
|
// If needs to validate the current user
|
2022-07-21 00:04:21 -04:00
|
|
|
$user = User::factory()->create();
|
2022-02-16 11:20:13 -04:00
|
|
|
$response = (object) $ws->pauseCase($application->APP_UID, $delegation->DEL_INDEX, $user->USR_UID, null, true);
|
|
|
|
|
$this->assertEquals($response->status_code, 100);
|
|
|
|
|
// Validate if status is closed
|
2022-07-21 00:04:21 -04:00
|
|
|
$application = Application::factory()->todo()->create();
|
|
|
|
|
$delegation = Delegation::factory()->foreign_keys()->create([
|
2022-02-16 11:20:13 -04:00
|
|
|
'APP_NUMBER' => $application->APP_NUMBER,
|
|
|
|
|
'APP_UID' => $application->APP_UID,
|
|
|
|
|
'DEL_THREAD_STATUS' => 'CLOSED',
|
|
|
|
|
'DEL_INDEX' => 2,
|
|
|
|
|
]);
|
|
|
|
|
$ws = new WsBase();
|
|
|
|
|
$response = (object) $ws->pauseCase($application->APP_UID, $delegation->DEL_INDEX, $delegation->USR_UID, null);
|
|
|
|
|
$this->assertEquals($response->status_code, 100);
|
|
|
|
|
// Validate if the case is paused
|
2022-07-21 00:04:21 -04:00
|
|
|
$application = Application::factory()->todo()->create();
|
|
|
|
|
$delegation = Delegation::factory()->foreign_keys()->create([
|
2022-02-16 11:20:13 -04:00
|
|
|
'APP_NUMBER' => $application->APP_NUMBER,
|
|
|
|
|
'APP_UID' => $application->APP_UID,
|
|
|
|
|
]);
|
2022-07-21 00:04:21 -04:00
|
|
|
AppDelay::factory()->create([
|
2022-02-16 11:20:13 -04:00
|
|
|
'APP_DELEGATION_USER' => $delegation->USR_UID,
|
|
|
|
|
'PRO_UID' => $delegation->PRO_UID,
|
|
|
|
|
'APP_NUMBER' => $delegation->APP_NUMBER,
|
|
|
|
|
'APP_DEL_INDEX' => $delegation->DEL_INDEX,
|
|
|
|
|
'APP_DISABLE_ACTION_USER' => 0,
|
|
|
|
|
'APP_TYPE' => 'PAUSE'
|
|
|
|
|
]);
|
2022-07-21 00:04:21 -04:00
|
|
|
AppThread::factory()->create([
|
2022-02-16 11:20:13 -04:00
|
|
|
'APP_UID' => $delegation->APP_UID,
|
|
|
|
|
'APP_THREAD_INDEX' => 1,
|
|
|
|
|
'APP_THREAD_PARENT' => 0,
|
|
|
|
|
'APP_THREAD_STATUS' => 'OPEN',
|
|
|
|
|
'DEL_INDEX' => $delegation->DEL_INDEX
|
|
|
|
|
]);
|
|
|
|
|
$ws = new WsBase();
|
|
|
|
|
$response = (object) $ws->pauseCase($application->APP_UID, $delegation->DEL_INDEX, $delegation->USR_UID, null);
|
|
|
|
|
// Review the unpaused date
|
2022-07-21 00:04:21 -04:00
|
|
|
$application = Application::factory()->todo()->create();
|
|
|
|
|
$delegation = Delegation::factory()->foreign_keys()->create([
|
2022-02-16 11:20:13 -04:00
|
|
|
'APP_NUMBER' => $application->APP_NUMBER,
|
|
|
|
|
'APP_UID' => $application->APP_UID,
|
|
|
|
|
]);
|
|
|
|
|
$ws = new WsBase();
|
|
|
|
|
$response = (object) $ws->pauseCase($delegation->APP_UID, $delegation->DEL_INDEX, $delegation->USR_UID, '06/13/2019 5:35 PM');
|
|
|
|
|
$this->assertEquals($response->status_code, 100);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Review the required fields in pause case
|
|
|
|
|
*
|
|
|
|
|
* @covers WsBase::pauseCase()
|
|
|
|
|
* @test
|
|
|
|
|
*/
|
|
|
|
|
public function it_pause_case()
|
|
|
|
|
{
|
2022-07-21 00:04:21 -04:00
|
|
|
$application = Application::factory()->todo()->create();
|
|
|
|
|
$delegation = Delegation::factory()->foreign_keys()->create([
|
2022-02-16 11:20:13 -04:00
|
|
|
'APP_NUMBER' => $application->APP_NUMBER,
|
|
|
|
|
'APP_UID' => $application->APP_UID,
|
|
|
|
|
'DEL_THREAD_STATUS' => 'OPEN',
|
|
|
|
|
'DEL_INDEX' => 2,
|
|
|
|
|
]);
|
2022-07-21 00:04:21 -04:00
|
|
|
AppDelay::factory()->create([
|
2022-02-16 11:20:13 -04:00
|
|
|
'APP_DELEGATION_USER' => $delegation->USR_UID,
|
|
|
|
|
'PRO_UID' => $delegation->PRO_UID,
|
|
|
|
|
'APP_NUMBER' => $delegation->APP_NUMBER,
|
|
|
|
|
'APP_DEL_INDEX' => $delegation->DEL_INDEX,
|
|
|
|
|
'APP_DISABLE_ACTION_USER' => 0,
|
|
|
|
|
'APP_TYPE' => 'PAUSE'
|
|
|
|
|
]);
|
2022-07-21 00:04:21 -04:00
|
|
|
AppThread::factory()->create([
|
2022-02-16 11:20:13 -04:00
|
|
|
'APP_UID' => $delegation->APP_UID,
|
|
|
|
|
'APP_THREAD_INDEX' => 1,
|
|
|
|
|
'APP_THREAD_PARENT' => 0,
|
|
|
|
|
'APP_THREAD_STATUS' => 'OPEN',
|
|
|
|
|
'DEL_INDEX' => $delegation->DEL_INDEX
|
|
|
|
|
]);
|
|
|
|
|
$ws = new WsBase();
|
|
|
|
|
$response = (object) $ws->pauseCase($delegation->APP_UID, $delegation->DEL_INDEX, $delegation->USR_UID);
|
2022-07-21 00:04:21 -04:00
|
|
|
$this->assertEquals(0, $response->status_code);
|
2022-02-16 11:20:13 -04:00
|
|
|
}
|
2019-08-08 09:51:39 -04:00
|
|
|
}
|