PMCORE-552
This commit is contained in:
committed by
Julio Cesar Laura Avendaño
parent
a1f447d8af
commit
ebfc73ca11
@@ -4,10 +4,15 @@ namespace ProcessMaker\BusinessModel;
|
||||
|
||||
use Exception;
|
||||
use G;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use ProcessMaker\BusinessModel\Cases;
|
||||
use ProcessMaker\Model\Application;
|
||||
use ProcessMaker\Model\Delegation;
|
||||
use ProcessMaker\Model\Documents;
|
||||
use ProcessMaker\Model\ListUnassigned;
|
||||
use ProcessMaker\Model\Task;
|
||||
use ProcessMaker\Model\Triggers;
|
||||
use ProcessMaker\Model\User;
|
||||
use RBAC;
|
||||
use Tests\TestCase;
|
||||
@@ -19,7 +24,6 @@ use Tests\TestCase;
|
||||
*/
|
||||
class CasesTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* Set up method.
|
||||
*/
|
||||
@@ -233,4 +237,82 @@ class CasesTest extends TestCase
|
||||
// Call the uploadFiles method
|
||||
$case->uploadFiles($user->USR_UID, $application->APP_UID, $varName, -1, null, $delegation->DEL_INDEX);
|
||||
}
|
||||
|
||||
/**
|
||||
* This test the execution of trigger from cases related to the self services timeout
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::executeSelfServiceTimeout()
|
||||
* @test
|
||||
*/
|
||||
public function it_execute_trigger_from_cases_with_self_service_timeout_every_time()
|
||||
{
|
||||
ListUnassigned::truncate();
|
||||
// Define the Execute Trigger = EVERY_TIME
|
||||
$application = factory(Application::class)->states('foreign_keys')->create();
|
||||
// Create a trigger
|
||||
$trigger = factory(Triggers::class)->create([
|
||||
'PRO_UID' => $application->PRO_UID,
|
||||
'TRI_WEBBOT' => 'echo(1);'
|
||||
]);
|
||||
// Create a task with the configuration trigger execution
|
||||
$task = factory(Task::class)->states('sef_service_timeout')->create([
|
||||
'PRO_UID' => $application->PRO_UID,
|
||||
'TAS_SELFSERVICE_EXECUTION' => 'EVERY_TIME',
|
||||
'TAS_SELFSERVICE_TRIGGER_UID' => $trigger->TRI_UID
|
||||
]);
|
||||
// Create a unassigned cases
|
||||
factory(ListUnassigned::class)->create([
|
||||
'TAS_UID' => $task->TAS_UID,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'APP_UID' => $application->APP_UID,
|
||||
'PRO_UID' => $application->PRO_UID
|
||||
]);
|
||||
// Define the session
|
||||
$_SESSION["PROCESS"] = $application->PRO_UID;
|
||||
|
||||
// todo: the function Cases::loadCase is using propel we need to change this
|
||||
DB::commit();
|
||||
$casesExecuted = Cases::executeSelfServiceTimeout();
|
||||
$this->assertTrue(is_array($casesExecuted));
|
||||
}
|
||||
|
||||
/**
|
||||
* This test the execution of trigger from cases related to the self services timeout
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::executeSelfServiceTimeout()
|
||||
* @test
|
||||
*/
|
||||
public function it_execute_trigger_from_cases_with_self_service_timeout_once()
|
||||
{
|
||||
ListUnassigned::truncate();
|
||||
// Define the Execute Trigger = ONCE
|
||||
$application = factory(Application::class)->states('foreign_keys')->create();
|
||||
// Create a trigger
|
||||
$trigger = factory(Triggers::class)->create([
|
||||
'PRO_UID' => $application->PRO_UID,
|
||||
'TRI_WEBBOT' => 'echo(1);'
|
||||
]);
|
||||
// Create a task with the configuration trigger execution
|
||||
$task = factory(Task::class)->states('sef_service_timeout')->create([
|
||||
'PRO_UID' => $application->PRO_UID,
|
||||
'TAS_SELFSERVICE_EXECUTION' => 'ONCE',
|
||||
'TAS_SELFSERVICE_TRIGGER_UID' => $trigger->TRI_UID
|
||||
]);
|
||||
// Create a unassigned cases
|
||||
factory(ListUnassigned::class)->create([
|
||||
'TAS_UID' => $task->TAS_UID,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'APP_UID' => $application->APP_UID,
|
||||
'PRO_UID' => $application->PRO_UID
|
||||
]);
|
||||
// Define the session
|
||||
$_SESSION["PROCESS"] = $application->PRO_UID;
|
||||
|
||||
// todo: the function Cases::loadCase is using propel we need to change this
|
||||
DB::commit();
|
||||
$casesExecuted = Cases::executeSelfServiceTimeout();
|
||||
$this->assertTrue(is_array($casesExecuted));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use ProcessMaker\Model\AppTimeoutAction;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class DelegationTest
|
||||
*
|
||||
* @coversDefaultClass \ProcessMaker\Model\AppTimeoutAction
|
||||
*/
|
||||
class AppTimeoutActionTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
/**
|
||||
* Test set and get the caseUid property
|
||||
*
|
||||
* @covers \ProcessMaker\Model\AppTimeoutAction::setCaseUid()
|
||||
* @covers \ProcessMaker\Model\AppTimeoutAction::getCaseUid()
|
||||
* @test
|
||||
*/
|
||||
public function it_set_get_case_uid()
|
||||
{
|
||||
factory(AppTimeoutAction::class)->create();
|
||||
$timeout = factory(AppTimeoutAction::class)->create();
|
||||
$timeout->setCaseUid($timeout->APP_UID);
|
||||
$this->assertEquals($timeout->getCaseUid(), $timeout->APP_UID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test set and get the index property
|
||||
*
|
||||
* @covers \ProcessMaker\Model\AppTimeoutAction::setIndex()
|
||||
* @covers \ProcessMaker\Model\AppTimeoutAction::getIndex()
|
||||
* @test
|
||||
*/
|
||||
public function it_set_get_index()
|
||||
{
|
||||
factory(AppTimeoutAction::class)->create();
|
||||
$timeout = factory(AppTimeoutAction::class)->create();
|
||||
$timeout->setIndex($timeout->DEL_INDEX);
|
||||
$this->assertEquals($timeout->getIndex(), $timeout->DEL_INDEX);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test a query to only include a specific case
|
||||
*
|
||||
* @covers \ProcessMaker\Model\AppTimeoutAction::scopeCase()
|
||||
* @test
|
||||
*/
|
||||
public function it_filter_a_specific_case()
|
||||
{
|
||||
factory(AppTimeoutAction::class)->create();
|
||||
$timeout = factory(AppTimeoutAction::class)->create();
|
||||
$this->assertCount(1, $timeout->case($timeout->APP_UID)->get());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test scope a query to only include a specific case
|
||||
*
|
||||
* @covers \ProcessMaker\Model\AppTimeoutAction::scopeIndex()
|
||||
* @test
|
||||
*/
|
||||
public function it_filter_a_specific_index()
|
||||
{
|
||||
factory(AppTimeoutAction::class)->create();
|
||||
$timeout = factory(AppTimeoutAction::class)->create();
|
||||
$this->assertCount(1, $timeout->case($timeout->APP_UID)->index($timeout->DEL_INDEX)->get());
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks it returns information about the self service timeout in a sequential thread
|
||||
*
|
||||
* @covers \ProcessMaker\Model\AppTimeoutAction::cases()
|
||||
* @test
|
||||
*/
|
||||
public function it_return_the_case_executed_once_one_thread()
|
||||
{
|
||||
$records = factory(AppTimeoutAction::class, 5)->create();
|
||||
foreach ($records as $row) {
|
||||
$appUid = $row->APP_UID;
|
||||
$delIndex = $row->DEL_INDEX;
|
||||
}
|
||||
|
||||
$appTimeout = new AppTimeoutAction();
|
||||
$appTimeout->setCaseUid($appUid);
|
||||
$appTimeout->setIndex($delIndex);
|
||||
$caseExecuted = $appTimeout->cases();
|
||||
$this->assertNotEmpty($caseExecuted);
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks it returns information about the self service timeout in a parallel thread
|
||||
*
|
||||
* @covers \ProcessMaker\Model\AppTimeoutAction::cases()
|
||||
* @test
|
||||
*/
|
||||
public function it_return_the_case_executed_once_more_than_one_thread()
|
||||
{
|
||||
$records = factory(AppTimeoutAction::class, 5)->create();
|
||||
foreach ($records as $row) {
|
||||
$appUid = $row->APP_UID;
|
||||
$delIndex = $row->DEL_INDEX;
|
||||
}
|
||||
// Create other thread in the same case
|
||||
factory(AppTimeoutAction::class)->create([
|
||||
'APP_UID' => $appUid,
|
||||
'DEL_INDEX' => $delIndex + 1,
|
||||
]);
|
||||
|
||||
$appTimeout = new AppTimeoutAction();
|
||||
$appTimeout->setCaseUid($appUid);
|
||||
$appTimeout->setIndex($delIndex);
|
||||
$caseExecuted = $appTimeout->cases();
|
||||
$this->assertNotEmpty($caseExecuted);
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,16 @@ use Tests\TestCase;
|
||||
*/
|
||||
class ListUnassignedTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* Set up function.
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
ListUnassigned::truncate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method set up.
|
||||
*/
|
||||
@@ -300,5 +310,25 @@ class ListUnassignedTest extends TestCase
|
||||
$result = ListUnassigned::loadList($user->USR_UID, $filters);
|
||||
$this->assertCount(2, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks the self-service timeout cases
|
||||
*
|
||||
* @covers \ProcessMaker\Model\ListUnassigned::selfServiceTimeout()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_return_cases_configured_self_service_timeout()
|
||||
{
|
||||
// Create some cases configured the self service timeout
|
||||
for ($x = 1; $x <= 5; $x++) {
|
||||
$task = factory(Task::class)->states('sef_service_timeout')->create();
|
||||
factory(ListUnassigned::class)->create([
|
||||
'TAS_UID' => $task->TAS_UID,
|
||||
'TAS_ID' => $task->TAS_ID
|
||||
]);
|
||||
}
|
||||
$results = ListUnassigned::selfServiceTimeout();
|
||||
$this->assertCount(5, $results);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,14 +2,40 @@
|
||||
|
||||
namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
|
||||
|
||||
use G;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use ProcessMaker\Model\Process;
|
||||
use ProcessMaker\Model\Triggers;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class DelegationTest
|
||||
*
|
||||
* @coversDefaultClass \ProcessMaker\Model\Triggers
|
||||
*/
|
||||
class TriggersTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
/**
|
||||
* Test set and get the trigger property
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Triggers::setTrigger()
|
||||
* @covers \ProcessMaker\Model\Triggers::getTrigger()
|
||||
* @test
|
||||
*/
|
||||
public function it_set_get_trigger()
|
||||
{
|
||||
factory(Triggers::class)->create();
|
||||
$trigger = factory(Triggers::class)->create();
|
||||
$trigger->setTrigger($trigger->TRI_UID);
|
||||
$this->assertEquals($trigger->getTrigger(), $trigger->TRI_UID);
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the process scope in the trigger model
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Triggers::scopeProcess()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_process_scope_in_trigger_model()
|
||||
@@ -74,4 +100,48 @@ class TriggersTest extends TestCase
|
||||
$this->assertEquals($process[2]['PRO_UID'], $result[0]['PRO_UID']);
|
||||
$this->assertEquals($process[2]['PRO_UID'], $result[1]['PRO_UID']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test scope a query to only include a specific case
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Triggers::scopeTrigger()
|
||||
* @test
|
||||
*/
|
||||
public function it_filter_specific_tasks()
|
||||
{
|
||||
factory(Triggers::class)->create();
|
||||
$trigger = factory(Triggers::class)->create();
|
||||
$this->assertCount(1, $trigger->trigger($trigger->TRI_UID)->get());
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks it returns information about the trigger
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Triggers::triggers()
|
||||
* @test
|
||||
*/
|
||||
public function it_return_specific_trigger_information()
|
||||
{
|
||||
$triggers = factory(Triggers::class, 5)->create();
|
||||
$trigger = new Triggers();
|
||||
$trigger->setTrigger($triggers[0]->TRI_UID);
|
||||
$triggersList = $trigger->triggers();
|
||||
$this->assertCount(1, $triggersList);
|
||||
$this->assertEquals($triggers[0]->TRI_TITLE , $triggersList[0]['TRI_TITLE']);
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks it returns empty when the trigger does not exist
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Triggers::triggers()
|
||||
* @test
|
||||
*/
|
||||
public function it_return_empty_when_the_trigger_not_exist()
|
||||
{
|
||||
factory(Triggers::class)->create();
|
||||
$trigger = new Triggers();
|
||||
$trigger->setTrigger(G::generateUniqueID());
|
||||
$triggersList = $trigger->triggers();
|
||||
$this->assertEmpty($triggersList);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\src\ProcessMaker\Util\Helpers;
|
||||
|
||||
use Tests\TestCase;
|
||||
|
||||
class CalculateDateTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* It tests the addition of days
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_test_adding_days()
|
||||
{
|
||||
$iniDate = '2019-10-04 12:07:40';
|
||||
$newDate = calculateDate($iniDate, 'DAYS', 1);
|
||||
$this->assertEquals('2019-10-05 12:07:40', $newDate);
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the addition of hours
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_test_adding_hours()
|
||||
{
|
||||
$iniDate = '2019-10-04 12:07:40';
|
||||
$newDate = calculateDate($iniDate, 'HOURS', 1);
|
||||
$this->assertEquals('2019-10-04 13:07:40', $newDate);
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the addition of minutes
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_test_adding_minutes()
|
||||
{
|
||||
$iniDate = '2019-10-04 12:07:40';
|
||||
$newDate = calculateDate($iniDate, 'MINUTES', 10);
|
||||
$this->assertEquals('2019-10-04 12:17:40', $newDate);
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ namespace Tests\unit\workflow\src\ProcessMaker\Util\Helpers;
|
||||
|
||||
use Tests\TestCase;
|
||||
|
||||
class ChangeAbbreviationOfDirectives extends TestCase
|
||||
class ChangeAbbreviationOfDirectivesTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Provider to define different types of configurations in the php.ini and the result expected
|
||||
Reference in New Issue
Block a user