diff --git a/tests/unit/workflow/engine/methods/cases/CasesMenuHighlightTest.php b/tests/unit/workflow/engine/methods/cases/CasesMenuHighlightTest.php new file mode 100644 index 000000000..21333f1d1 --- /dev/null +++ b/tests/unit/workflow/engine/methods/cases/CasesMenuHighlightTest.php @@ -0,0 +1,104 @@ +settingUserLogged(); + } + + /** + * This starts a valid user in session with the appropriate permissions. + * + * @global object $RBAC + */ + private function settingUserLogged() + { + global $RBAC; + + $this->user = User::where('USR_ID', '=', 1)->get()->first(); + + $_SESSION['USER_LOGGED'] = $this->user['USR_UID']; + + $RBAC = RBAC::getSingleton(PATH_DATA, session_id()); + $RBAC->initRBAC(); + $RBAC->loadUserRolePermission('PROCESSMAKER', $_SESSION['USER_LOGGED']); + } + + /** + * Test if the file is returning a valid JSON object with the correct data for the current user + * + * @test + */ + public function it_should_test_the_response_of_the_cases_menu_highlight_file() + { + // Create process + $process = factory(Process::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 the current user in the task + factory(TaskUser::class)->create([ + 'TAS_UID' => $task->TAS_UID, + 'USR_UID' => $this->user->USR_UID, + 'TU_RELATION' => 1, //Related to the user + 'TU_TYPE' => 1 + ]); + + // Create records in delegation relate to self-service + factory(Delegation::class, 10)->create([ + 'TAS_ID' => $task->TAS_ID, + 'DEL_THREAD_STATUS' => 'OPEN', + 'USR_ID' => 0 + ]); + + // Turn on output buffering + ob_start(); + + // Call the tested file + require_once PATH_METHODS . 'cases/casesMenuHighlight.php'; + + // Return the contents of the output buffer + $outputBuffer = ob_get_contents(); + + // Clean the output buffer and turn off output buffering + ob_end_clean(); + + // Check if is a valid JSON + $this->assertJson($outputBuffer); + + // Parse JSON + $result = json_decode($outputBuffer, true); + + // Check if the object is valid + $this->assertNotEmpty($result); + $this->assertArrayHasKey('item', $result[0]); + $this->assertArrayHasKey('highlight', $result[0]); + $this->assertEquals('CASES_SELFSERVICE', $result[0]['item']); + $this->assertEquals(true, $result[0]['highlight']); + } +} diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Core/SystemTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Core/SystemTest.php index b1efad7bf..5065344e9 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Core/SystemTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Core/SystemTest.php @@ -76,6 +76,11 @@ class SystemTest extends TestCase $this->assertArrayHasKey('server_hostname_requests_frontend', $result); $this->assertArrayHasKey('disable_php_upload_execution', $result); $this->assertArrayHasKey('mobile_offline_tables_download_interval', $result); + + // Default values for highlight home folder feature + $this->assertArrayHasKey('highlight_home_folder_enable', $result); + $this->assertArrayHasKey('highlight_home_folder_refresh_time', $result); + $this->assertArrayHasKey('highlight_home_folder_scope', $result); } /** @@ -93,6 +98,11 @@ class SystemTest extends TestCase $this->assertArrayHasKey('server_hostname_requests_frontend', $result); $this->assertArrayHasKey('disable_php_upload_execution', $result); $this->assertArrayHasKey('mobile_offline_tables_download_interval', $result); + + // Default values for highlight home folder feature + $this->assertArrayHasKey('highlight_home_folder_enable', $result); + $this->assertArrayHasKey('highlight_home_folder_refresh_time', $result); + $this->assertArrayHasKey('highlight_home_folder_scope', $result); } /** @@ -171,4 +181,60 @@ class SystemTest extends TestCase $this->assertArrayHasKey("proxy_pass", $result); } + + /** + * It should return parameters defined inside env file for "highlight home folders" feature. + * @test + * @covers \ProcessMaker\Core\System::getSystemConfiguration() + */ + public function it_should_return_highlight_home_folders_params_defined_inside_env_file() + { + // Initializing variables to use + $oldContent = ""; + $path = PATH_CONFIG . "env.ini"; + $faker = $faker = Factory::create(); + + // Get content of env.ini file, if exists + if (file_exists($path)) { + $oldContent = file_get_contents($path); + } + + // Write correct values in env.ini file + $highlightEnable = 1; + $highlightRefreshTime = 5; + $highlightScope = "unassigned"; + $content = "highlight_home_folder_enable = $highlightEnable" . PHP_EOL; + $content .= "highlight_home_folder_refresh_time = $highlightRefreshTime" . PHP_EOL; + $content .= "highlight_home_folder_scope = \"$highlightScope\"" . PHP_EOL; + file_put_contents($path, $content); + + // Get configuration + $result = System::getSystemConfiguration(); + + // Check correct parameters, should be the same + $this->assertEquals($highlightEnable, $result["highlight_home_folder_enable"]); + $this->assertEquals($highlightRefreshTime, $result["highlight_home_folder_refresh_time"]); + $this->assertEquals($highlightScope, $result["highlight_home_folder_scope"]); + + // Write incorrect values in env.ini file + $highlightEnable = $faker->numberBetween(2, 100); + $highlightRefreshTime = $faker->word; + $highlightScope = $faker->word; + $content = "highlight_home_folder_enable = $highlightEnable" . PHP_EOL; + $content .= "highlight_home_folder_refresh_time = $highlightRefreshTime" . PHP_EOL; + $content .= "highlight_home_folder_scope = \"$highlightScope\"" . PHP_EOL; + file_put_contents($path, $content); + + // Get configuration + $result = System::getSystemConfiguration(); + + // Check incorrect parameters, should be return the default values, the default values are private, so for the current + // test has hardcoded values + $this->assertEquals(0, $result["highlight_home_folder_enable"]); + $this->assertEquals(10, $result["highlight_home_folder_refresh_time"]); + $this->assertEquals("unassigned", $result["highlight_home_folder_scope"]); + + // Restore content of th env.ini file + file_put_contents($path, $oldContent); + } } diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/DelegationTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/DelegationTest.php index ea443ec0d..a9314cd26 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Model/DelegationTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Model/DelegationTest.php @@ -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 * diff --git a/workflow/engine/methods/cases/main_init.php b/workflow/engine/methods/cases/main_init.php index f4d4b47ab..9cfb1796d 100644 --- a/workflow/engine/methods/cases/main_init.php +++ b/workflow/engine/methods/cases/main_init.php @@ -131,7 +131,6 @@ $oHeadPublisher->assign("FORMATS", $conf->getFormats()); if (HIGHLIGHT_HOME_FOLDER_ENABLE) { $oHeadPublisher->assign("highlightUrlProxy", "casesMenuHighlight?r="); $oHeadPublisher->assign("highlightRefreshTime", HIGHLIGHT_HOME_FOLDER_REFRESH_TIME); - $oHeadPublisher->assign("highlightScope", HIGHLIGHT_HOME_FOLDER_SCOPE); } /*----------------------------------********---------------------------------*/ diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Lists.php b/workflow/engine/src/ProcessMaker/BusinessModel/Lists.php index 60f2f4051..e40d8f7c5 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Lists.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Lists.php @@ -68,19 +68,20 @@ class Lists /*----------------------------------********---------------------------------*/ ]; + // If the feature for highlight the home folders is disabled, add self-service list to the map + if (!HIGHLIGHT_HOME_FOLDER_ENABLE) { + $this->mapList['ListSelfService'] = 'CASES_SELFSERVICE'; + } + $this->ListInbox = new \ListInbox(); $this->ListDraft = new \ListInbox(); $this->ListCanceled = new \ListCanceled(); $this->ListParticipated = new \ListParticipatedLast(); $this->ListPaused = new \ListPaused(); $this->ListCompleted = new \ListCompleted(); + $this->ListSelfService = new \ListUnassigned(); /*----------------------------------********---------------------------------*/ $this->ListConsolidated = new Consolidated(); - // If the feature for highlight the home folders is disabled, add/initialize properties related to self-service list - if (!HIGHLIGHT_HOME_FOLDER_ENABLE) { - $this->mapList['ListSelfService'] = 'CASES_SELFSERVICE'; - $this->ListSelfService = new \ListUnassigned(); - } /*----------------------------------********---------------------------------*/ } @@ -153,11 +154,8 @@ class Lists $listpeer = 'ListMyInboxPeer'; break; case 'unassigned': - // If the feature for highlight the home folders is disabled, initialize the variables for unassigned list - if (!HIGHLIGHT_HOME_FOLDER_ENABLE) { - $list = new \ListUnassigned(); - $listpeer = 'ListUnassignedPeer'; - } + $list = new \ListUnassigned(); + $listpeer = 'ListUnassignedPeer'; break; }