PMCORE-1124

This commit is contained in:
Julio Cesar Laura Avendaño
2020-02-06 16:30:46 -04:00
parent 3c6faec73f
commit 627ecded7f
5 changed files with 1044 additions and 11 deletions

View File

@@ -846,6 +846,872 @@ class DelegationTest extends TestCase
$this->assertEmpty($results);
}
/**
* This checks if get the query is working properly in self-service user assigned
*
* @covers \ProcessMaker\Model\Delegation::getSelfServiceQuery()
* @test
*/
public function it_should_get_query_cases_by_user_with_self_service_user_assigned()
{
//Create process
$process = factory(Process::class)->create();
//Create user
$user = factory(User::class)->create();
//Create a task self service
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $task->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
factory(Delegation::class, 25)->create([
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the self-service query
$result = Delegation::getSelfServiceQuery($user->USR_UID);
$this->assertTrue(is_string($result));
}
/**
* This checks if get the query is working properly in self-service-value-based when the variable has a value related
* with the USR_UID When the value assigned in the variable @@ARRAY_OF_USERS = [USR_UID]
*
* @covers \ProcessMaker\Model\Delegation::getSelfServiceQuery()
* @test
*/
public function it_should_get_query_cases_by_user_with_self_service_value_based_usr_uid()
{
//Create process
$process = factory(Process::class)->create();
//Create a case
$application = factory(Application::class)->create();
//Create user
$user = factory(User::class)->create();
//Create a task self service value based
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
'PRO_UID' => $process->PRO_UID
]);
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => 2,
'TAS_ID' => $task->TAS_ID
]);
factory(AppAssignSelfServiceValueGroup::class)->create([
'ID' => $appSelfValue->ID,
'GRP_UID' => $user->USR_UID,
'ASSIGNEE_ID' => $user->USR_ID, //The usrId or grpId
'ASSIGNEE_TYPE' => 1 //Related to the user=1 related to the group=2
]);
//Create the register in self-service
factory(Delegation::class, 25)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => $appSelfValue->DEL_INDEX,
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the self-service query
$result = Delegation::getSelfServiceQuery($user->USR_UID);
$this->assertInstanceOf(\Illuminate\Database\Eloquent\Builder::class, $result);
}
/**
* This checks if get the query is working properly in self-service group assigned
*
* @covers \ProcessMaker\Model\Delegation::getSelfServiceQuery()
* @test
*/
public function it_should_get_query_cases_by_user_with_self_service_group_assigned()
{
//Create process
$process = factory(Process::class)->create();
//Create group
$group = factory(Groupwf::class)->create();
//Create user
$user = factory(User::class)->create();
//Assign a user in the group
factory(GroupUser::class)->create([
'GRP_UID' => $group->GRP_UID,
'GRP_ID' => $group->GRP_ID,
'USR_UID' => $user->USR_UID
]);
//Create a task self service
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 2, //Related to the group
'TU_TYPE' => 1
]);
//Create the register in self-service
factory(Delegation::class, 25)->create([
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the self-service query
$result = Delegation::getSelfServiceQuery($user->USR_UID);
$this->assertTrue(is_string($result));
}
/**
* This checks if get the query is working properly in self-service-value-based when the variable has a value related
* with the GRP_UID When the value assigned in the variable @@ARRAY_OF_USERS = [GRP_UID]
*
* @covers \ProcessMaker\Model\Delegation::getSelfServiceQuery()
* @test
*/
public function it_should_get_query_cases_by_user_with_self_service_value_based_grp_uid()
{
//Create process
$process = factory(Process::class)->create();
//Create a task self service value based
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
'PRO_UID' => $process->PRO_UID
]);
//Create a case
$application = factory(Application::class)->create();
//Create group
$group = factory(Groupwf::class)->create();
//Create user
$user = factory(User::class)->create([
'USR_USERNAME' => 'gary',
'USR_LASTNAME' => 'Gary',
'USR_FIRSTNAME' => 'Bailey',
]);
//Assign a user in the group
factory(GroupUser::class)->create([
'GRP_UID' => $group->GRP_UID,
'GRP_ID' => $group->GRP_ID,
'USR_UID' => $user->USR_UID,
]);
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'APP_UID' => $application->APP_UID,
'DEL_INDEX' => 2,
'TAS_ID' => $task->TAS_ID
]);
factory(AppAssignSelfServiceValueGroup::class)->create([
'ID' => $appSelfValue->ID,
'GRP_UID' => $group->GRP_UID,
'ASSIGNEE_ID' => $group->GRP_ID, //The usrId or grpId
'ASSIGNEE_TYPE' => 2 //Related to the user=1 related to the group=2
]);
//Create the register in self-service
factory(Delegation::class, 25)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => 2,
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the self-service query
$result = Delegation::getSelfServiceQuery($user->USR_UID);
$this->assertInstanceOf(\Illuminate\Database\Eloquent\Builder::class, $result);
}
/**
* This checks if get the query is working properly with self-service and self-service-value-based
*
* @covers \ProcessMaker\Model\Delegation::getSelfServiceQuery()
* @test
*/
public function it_should_get_query_cases_by_user_with_self_service_and_self_service_value_based()
{
//Create process
$process = factory(Process::class)->create();
//Create group
$group = factory(Groupwf::class)->create();
//Create user
$user = factory(User::class)->create();
//Assign a user in the group
factory(GroupUser::class)->create([
'GRP_UID' => $group->GRP_UID,
'GRP_ID' => $group->GRP_ID,
'USR_UID' => $user->USR_UID
]);
//Create a task self service
$taskSelfService = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $taskSelfService->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create the register in self service
factory(Delegation::class)->create([
'TAS_ID' => $taskSelfService->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Create a task self service value based
$taskSelfServiceByVariable = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $taskSelfServiceByVariable->TAS_UID,
'USR_UID' => $group->GRP_UID,
'TU_RELATION' => 2, //Related to the group
'TU_TYPE' => 1
]);
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
$appAssignSelfService = factory(AppAssignSelfServiceValue::class)->create([
'TAS_ID' => $taskSelfServiceByVariable->TAS_ID
]);
factory(AppAssignSelfServiceValueGroup::class)->create([
'ID' => $appAssignSelfService->ID,
'GRP_UID' => $group->GRP_UID,
'ASSIGNEE_ID' => $group->GRP_ID, //The usrId or grpId
'ASSIGNEE_TYPE' => 2 //Related to the user=1 related to the group=2
]);
//Create the register in self service value based
factory(Delegation::class)->create([
'APP_NUMBER' => $appAssignSelfService->APP_NUMBER,
'DEL_INDEX' => $appAssignSelfService->DEL_INDEX,
'TAS_ID' => $taskSelfServiceByVariable->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the self-service query
$result = Delegation::getSelfServiceQuery($user->USR_UID);
$this->assertTrue(is_string($result));
}
/**
* This checks if get the query is working properly in self-service user and group assigned in parallel task
*
* @covers \ProcessMaker\Model\Delegation::getSelfServiceQuery()
* @test
*/
public function it_should_get_query_cases_by_user_with_self_service_user_and_group_assigned_parallel_task()
{
//Create process
$process = factory(Process::class)->create();
//Create group
$group = factory(Groupwf::class)->create();
//Create user
$user = factory(User::class)->create();
//Assign a user in the group
factory(GroupUser::class)->create([
'GRP_UID' => $group->GRP_UID,
'GRP_ID' => $group->GRP_ID,
'USR_UID' => $user->USR_UID
]);
//Create a task self service
$task1 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task1
factory(TaskUser::class)->create([
'TAS_UID' => $task1->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create a task self service
$task2 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task2
factory(TaskUser::class)->create([
'TAS_UID' => $task2->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create a task self service
$task3 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $task3->TAS_UID,
'USR_UID' => $group->GRP_UID,
'TU_RELATION' => 2, //Related to the group
'TU_TYPE' => 1
]);
//Create a task self service
$task4 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $task4->TAS_UID,
'USR_UID' => $group->GRP_UID,
'TU_RELATION' => 2, //Related to the group
'TU_TYPE' => 1
]);
//Create the register in self-service related to the task1
factory(Delegation::class, 10)->create([
'TAS_ID' => $task1->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Create the register in self-service related to the task2
factory(Delegation::class, 10)->create([
'TAS_ID' => $task2->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Create the register in self-service related to the task3
factory(Delegation::class, 10)->create([
'TAS_ID' => $task3->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Create the register in self-service related to the task4
factory(Delegation::class, 10)->create([
'TAS_ID' => $task4->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the self-service query
$result = Delegation::getSelfServiceQuery($user->USR_UID);
$this->assertTrue(is_string($result));
}
/**
* This checks if get the query is working properly in self-service-value-based with GRP_UID and USR_UID in parallel
* task When the value assigned in the variable @@ARRAY_OF_USERS = [GRP_UID, USR_UID]
*
* @covers \ProcessMaker\Model\Delegation::getSelfServiceQuery()
* @test
*/
public function it_should_get_query_cases_by_user_with_self_service_value_based_usr_uid_and_grp_uid()
{
//Create process
$process = factory(Process::class)->create();
//Create a case
$application = factory(Application::class)->create();
//Create user
$user = factory(User::class)->create();
//Create a task1 self service value based
$task1 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
'PRO_UID' => $process->PRO_UID
]);
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'TAS_ID' => $task1->TAS_ID
]);
factory(AppAssignSelfServiceValueGroup::class)->create([
'ID' => $appSelfValue->ID,
'GRP_UID' => $user->USR_UID,
'ASSIGNEE_ID' => $user->USR_ID, //The usrId or grpId
'ASSIGNEE_TYPE' => 1 //Related to the user=1 related to the group=2
]);
//Create the register in self-service
factory(Delegation::class, 10)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => $appSelfValue->DEL_INDEX,
'TAS_ID' => $task1->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Create a task2 self service value based
$task2 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
'PRO_UID' => $process->PRO_UID
]);
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'TAS_ID' => $task2->TAS_ID
]);
factory(AppAssignSelfServiceValueGroup::class)->create([
'ID' => $appSelfValue->ID,
'GRP_UID' => $user->USR_UID,
'ASSIGNEE_ID' => $user->USR_ID, //The usrId or grpId
'ASSIGNEE_TYPE' => 1 //Related to the user=1 related to the group=2
]);
//Create the register in self-service
factory(Delegation::class, 15)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => $appSelfValue->DEL_INDEX,
'TAS_ID' => $task2->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the self-service query
$result = Delegation::getSelfServiceQuery($user->USR_UID);
$this->assertInstanceOf(\Illuminate\Database\Eloquent\Builder::class, $result);
}
/**
* This checks if get the records is working properly in self-service user assigned
*
* @covers \ProcessMaker\Model\Delegation::getSelfService()
* @test
*/
public function it_should_get_cases_by_user_with_self_service_user_assigned()
{
//Create process
$process = factory(Process::class)->create();
//Create user
$user = factory(User::class)->create();
//Create a task self service
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $task->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
factory(Delegation::class, 25)->create([
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the self-service records
$result = Delegation::getSelfService($user->USR_UID);
$this->assertEquals(25, count($result));
}
/**
* This checks if get the records is working properly in self-service-value-based when the variable has a value related
* with the USR_UID When the value assigned in the variable @@ARRAY_OF_USERS = [USR_UID]
*
* @covers \ProcessMaker\Model\Delegation::getSelfService()
* @test
*/
public function it_should_get_cases_by_user_with_self_service_value_based_usr_uid()
{
//Create process
$process = factory(Process::class)->create();
//Create a case
$application = factory(Application::class)->create();
//Create user
$user = factory(User::class)->create();
//Create a task self service value based
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
'PRO_UID' => $process->PRO_UID
]);
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => 2,
'TAS_ID' => $task->TAS_ID
]);
factory(AppAssignSelfServiceValueGroup::class)->create([
'ID' => $appSelfValue->ID,
'GRP_UID' => $user->USR_UID,
'ASSIGNEE_ID' => $user->USR_ID, //The usrId or grpId
'ASSIGNEE_TYPE' => 1 //Related to the user=1 related to the group=2
]);
//Create the register in self-service
factory(Delegation::class, 25)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => $appSelfValue->DEL_INDEX,
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the self-service records
$result = Delegation::getSelfService($user->USR_UID);
$this->assertEquals(25, count($result));
}
/**
* This checks if get the records is working properly in self-service group assigned
*
* @covers \ProcessMaker\Model\Delegation::getSelfService()
* @test
*/
public function it_should_get_cases_by_user_with_self_service_group_assigned()
{
//Create process
$process = factory(Process::class)->create();
//Create group
$group = factory(Groupwf::class)->create();
//Create user
$user = factory(User::class)->create();
//Assign a user in the group
factory(GroupUser::class)->create([
'GRP_UID' => $group->GRP_UID,
'GRP_ID' => $group->GRP_ID,
'USR_UID' => $user->USR_UID
]);
//Create a task self service
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 2, //Related to the group
'TU_TYPE' => 1
]);
//Create the register in self-service
factory(Delegation::class, 25)->create([
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the self-service records
$result = Delegation::getSelfService($user->USR_UID);
$this->assertEquals(25, count($result));
}
/**
* This checks if get the records is working properly in self-service-value-based when the variable has a value related
* with the GRP_UID When the value assigned in the variable @@ARRAY_OF_USERS = [GRP_UID]
*
* @covers \ProcessMaker\Model\Delegation::getSelfService()
* @test
*/
public function it_should_get_cases_by_user_with_self_service_value_based_grp_uid()
{
//Create process
$process = factory(Process::class)->create();
//Create a task self service value based
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
'PRO_UID' => $process->PRO_UID
]);
//Create a case
$application = factory(Application::class)->create();
//Create group
$group = factory(Groupwf::class)->create();
//Create user
$user = factory(User::class)->create([
'USR_USERNAME' => 'gary',
'USR_LASTNAME' => 'Gary',
'USR_FIRSTNAME' => 'Bailey',
]);
//Assign a user in the group
factory(GroupUser::class)->create([
'GRP_UID' => $group->GRP_UID,
'GRP_ID' => $group->GRP_ID,
'USR_UID' => $user->USR_UID,
]);
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'APP_UID' => $application->APP_UID,
'DEL_INDEX' => 2,
'TAS_ID' => $task->TAS_ID
]);
factory(AppAssignSelfServiceValueGroup::class)->create([
'ID' => $appSelfValue->ID,
'GRP_UID' => $group->GRP_UID,
'ASSIGNEE_ID' => $group->GRP_ID, //The usrId or grpId
'ASSIGNEE_TYPE' => 2 //Related to the user=1 related to the group=2
]);
//Create the register in self-service
factory(Delegation::class, 25)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => 2,
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the self-service records
$result = Delegation::getSelfService($user->USR_UID);
$this->assertEquals(25, count($result));
}
/**
* This checks if get the records is working properly with self-service and self-service-value-based
*
* @covers \ProcessMaker\Model\Delegation::getSelfService()
* @test
*/
public function it_should_get_cases_by_user_with_self_service_and_self_service_value_based()
{
//Create process
$process = factory(Process::class)->create();
//Create group
$group = factory(Groupwf::class)->create();
//Create user
$user = factory(User::class)->create();
//Assign a user in the group
factory(GroupUser::class)->create([
'GRP_UID' => $group->GRP_UID,
'GRP_ID' => $group->GRP_ID,
'USR_UID' => $user->USR_UID
]);
//Create a task self service
$taskSelfService = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $taskSelfService->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create the register in self service
factory(Delegation::class)->create([
'TAS_ID' => $taskSelfService->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Create a task self service value based
$taskSelfServiceByVariable = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $taskSelfServiceByVariable->TAS_UID,
'USR_UID' => $group->GRP_UID,
'TU_RELATION' => 2, //Related to the group
'TU_TYPE' => 1
]);
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
$appAssignSelfService = factory(AppAssignSelfServiceValue::class)->create([
'TAS_ID' => $taskSelfServiceByVariable->TAS_ID
]);
factory(AppAssignSelfServiceValueGroup::class)->create([
'ID' => $appAssignSelfService->ID,
'GRP_UID' => $group->GRP_UID,
'ASSIGNEE_ID' => $group->GRP_ID, //The usrId or grpId
'ASSIGNEE_TYPE' => 2 //Related to the user=1 related to the group=2
]);
//Create the register in self service value based
factory(Delegation::class)->create([
'APP_NUMBER' => $appAssignSelfService->APP_NUMBER,
'DEL_INDEX' => $appAssignSelfService->DEL_INDEX,
'TAS_ID' => $taskSelfServiceByVariable->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the self-service records
$result = Delegation::getSelfService($user->USR_UID);
$this->assertEquals(2, count($result));
}
/**
* This checks if get the records is working properly in self-service user and group assigned in parallel task
*
* @covers \ProcessMaker\Model\Delegation::getSelfService()
* @test
*/
public function it_should_get_cases_by_user_with_self_service_user_and_group_assigned_parallel_task()
{
//Create process
$process = factory(Process::class)->create();
//Create group
$group = factory(Groupwf::class)->create();
//Create user
$user = factory(User::class)->create();
//Assign a user in the group
factory(GroupUser::class)->create([
'GRP_UID' => $group->GRP_UID,
'GRP_ID' => $group->GRP_ID,
'USR_UID' => $user->USR_UID
]);
//Create a task self service
$task1 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task1
factory(TaskUser::class)->create([
'TAS_UID' => $task1->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create a task self service
$task2 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task2
factory(TaskUser::class)->create([
'TAS_UID' => $task2->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create a task self service
$task3 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $task3->TAS_UID,
'USR_UID' => $group->GRP_UID,
'TU_RELATION' => 2, //Related to the group
'TU_TYPE' => 1
]);
//Create a task self service
$task4 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $task4->TAS_UID,
'USR_UID' => $group->GRP_UID,
'TU_RELATION' => 2, //Related to the group
'TU_TYPE' => 1
]);
//Create the register in self-service related to the task1
factory(Delegation::class, 10)->create([
'TAS_ID' => $task1->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Create the register in self-service related to the task2
factory(Delegation::class, 10)->create([
'TAS_ID' => $task2->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Create the register in self-service related to the task3
factory(Delegation::class, 10)->create([
'TAS_ID' => $task3->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Create the register in self-service related to the task4
factory(Delegation::class, 10)->create([
'TAS_ID' => $task4->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the self-service records
$result = Delegation::getSelfService($user->USR_UID);
$this->assertEquals(40, count($result));
}
/**
* This checks if get the records is working properly in self-service-value-based with GRP_UID and USR_UID in parallel
* task When the value assigned in the variable @@ARRAY_OF_USERS = [GRP_UID, USR_UID]
*
* @covers \ProcessMaker\Model\Delegation::getSelfService()
* @test
*/
public function it_should_get_cases_by_user_with_self_service_value_based_usr_uid_and_grp_uid()
{
//Create process
$process = factory(Process::class)->create();
//Create a case
$application = factory(Application::class)->create();
//Create user
$user = factory(User::class)->create();
//Create a task1 self service value based
$task1 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
'PRO_UID' => $process->PRO_UID
]);
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'TAS_ID' => $task1->TAS_ID
]);
factory(AppAssignSelfServiceValueGroup::class)->create([
'ID' => $appSelfValue->ID,
'GRP_UID' => $user->USR_UID,
'ASSIGNEE_ID' => $user->USR_ID, //The usrId or grpId
'ASSIGNEE_TYPE' => 1 //Related to the user=1 related to the group=2
]);
//Create the register in self-service
factory(Delegation::class, 10)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => $appSelfValue->DEL_INDEX,
'TAS_ID' => $task1->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Create a task2 self service value based
$task2 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
'PRO_UID' => $process->PRO_UID
]);
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'TAS_ID' => $task2->TAS_ID
]);
factory(AppAssignSelfServiceValueGroup::class)->create([
'ID' => $appSelfValue->ID,
'GRP_UID' => $user->USR_UID,
'ASSIGNEE_ID' => $user->USR_ID, //The usrId or grpId
'ASSIGNEE_TYPE' => 1 //Related to the user=1 related to the group=2
]);
//Create the register in self-service
factory(Delegation::class, 15)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => $appSelfValue->DEL_INDEX,
'TAS_ID' => $task2->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the self-service records
$result = Delegation::getSelfService($user->USR_UID);
$this->assertEquals(25, count($result));
}
/**
* This checks the counters is working properly in self-service user assigned
*