From 6712fa8404bc2be4adee1eacd57de62a8319833d Mon Sep 17 00:00:00 2001 From: Paula Quispe Date: Wed, 22 Dec 2021 16:54:04 -0400 Subject: [PATCH] PMCORE-3610 --- .../BusinessModel/Cases/AbstractCasesTest.php | 2 + .../BusinessModel/Cases/BatchRoutingTest.php | 5 +- .../BusinessModel/Cases/CanceledTest.php | 10 +- .../BusinessModel/Cases/CasesListTest.php | 2 + .../BusinessModel/Cases/CompletedTest.php | 10 +- .../BusinessModel/Cases/DraftTest.php | 22 +++ .../BusinessModel/Cases/HomeTest.php | 2 + .../BusinessModel/Cases/InboxTest.php | 23 +++ .../BusinessModel/Cases/ParticipatedTest.php | 172 +++++++++++++++++- .../BusinessModel/Cases/PausedTest.php | 25 +++ .../BusinessModel/Cases/SearchTest.php | 2 +- .../BusinessModel/Cases/SupervisingTest.php | 30 +++ .../BusinessModel/Cases/UnassignedTest.php | 63 ++++++- .../BusinessModel/Cases/BatchRouting.php | 8 +- .../BusinessModel/Cases/Canceled.php | 7 +- .../BusinessModel/Cases/Completed.php | 7 +- 16 files changed, 373 insertions(+), 17 deletions(-) diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/AbstractCasesTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/AbstractCasesTest.php index 239caaeaf..eac1d5506 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/AbstractCasesTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/AbstractCasesTest.php @@ -18,6 +18,8 @@ use ProcessMaker\Model\User; use Tests\TestCase; /** + * Class AbstractCasesTest + * * @coversDefaultClass \ProcessMaker\BusinessModel\Cases\AbstractCases */ class AbstractCasesTest extends TestCase diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/BatchRoutingTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/BatchRoutingTest.php index 0d0b420ff..8d7e55ab1 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/BatchRoutingTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/BatchRoutingTest.php @@ -9,6 +9,8 @@ use ProcessMaker\Model\Delegation; use Tests\TestCase; /** + * Class BatchRoutingTest + * * @coversDefaultClass \ProcessMaker\BusinessModel\Cases\BatchRouting */ class BatchRoutingTest extends TestCase @@ -44,6 +46,7 @@ class BatchRoutingTest extends TestCase * * @covers \ProcessMaker\BusinessModel\Cases\BatchRouting::getColumnsView() * @covers \ProcessMaker\BusinessModel\Cases\BatchRouting::getData() + * @covers \ProcessMaker\BusinessModel\Cases\BatchRouting::filters() * @test */ public function it_test_extended_methods() @@ -51,7 +54,7 @@ class BatchRoutingTest extends TestCase // Create new BatchRouting object $consolidated = new BatchRouting(); $result = $consolidated->getColumnsView(); - $this->assertEmpty($result); + $this->assertNotEmpty($result); $result = $consolidated->getData(); $this->assertEmpty($result); } diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/CanceledTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/CanceledTest.php index 6d58ddf5e..143721296 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/CanceledTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/CanceledTest.php @@ -9,6 +9,8 @@ use ProcessMaker\Model\Delegation; use Tests\TestCase; /** + * Class CanceledTest + * * @coversDefaultClass \ProcessMaker\BusinessModel\Cases\Canceled */ class CanceledTest extends TestCase @@ -52,10 +54,10 @@ class CanceledTest extends TestCase public function it_test_extended_methods() { // Create new batch Canceled object - $consolidated = new Canceled(); - $result = $consolidated->getColumnsView(); - $this->assertEmpty($result); - $result = $consolidated->getData(); + $canceled = new Canceled(); + $result = $canceled->getColumnsView(); + $this->assertNotEmpty($result); + $result = $canceled->getData(); $this->assertEmpty($result); } diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/CasesListTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/CasesListTest.php index 961c455bd..1e8ccc7c9 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/CasesListTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/CasesListTest.php @@ -9,6 +9,8 @@ use ProcessMaker\Model\Delegation; use Tests\TestCase; /** + * Class CasesListTest + * * @coversDefaultClass \ProcessMaker\BusinessModel\Cases\CasesList */ class CasesListTest extends TestCase diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/CompletedTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/CompletedTest.php index 6746cc585..e2f502dea 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/CompletedTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/CompletedTest.php @@ -9,6 +9,8 @@ use ProcessMaker\Model\Delegation; use Tests\TestCase; /** + * Class CompletedTest + * * @coversDefaultClass \ProcessMaker\BusinessModel\Cases\Completed */ class CompletedTest extends TestCase @@ -52,10 +54,10 @@ class CompletedTest extends TestCase public function it_test_extended_methods() { // Create new batch Completed object - $consolidated = new Completed(); - $result = $consolidated->getColumnsView(); - $this->assertEmpty($result); - $result = $consolidated->getData(); + $completed = new Completed(); + $result = $completed->getColumnsView(); + $this->assertNotEmpty($result); + $result = $completed->getData(); $this->assertEmpty($result); } diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/DraftTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/DraftTest.php index 13d43a431..87f4f25eb 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/DraftTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/DraftTest.php @@ -16,6 +16,8 @@ use ProcessMaker\Model\User; use Tests\TestCase; /** + * Class DraftTest + * * @coversDefaultClass \ProcessMaker\BusinessModel\Cases\Draft */ class DraftTest extends TestCase @@ -121,6 +123,26 @@ class DraftTest extends TestCase $this->assertNotEmpty($res); } + /** + * It tests the getData method with categoryId filter + * + * @covers \ProcessMaker\BusinessModel\Cases\Draft::getData() + * @covers \ProcessMaker\BusinessModel\Cases\Draft::getColumnsView() + * @covers \ProcessMaker\BusinessModel\Cases\Draft::filters() + * @test + */ + public function it_filter_by_category() + { + // Create factories related to the draft cases + $cases = $this->createDraft(); + // Create new Draft object + $draft = new Draft(); + $draft->setUserId($cases['USR_ID']); + $draft->setCategoryId(2000); + $res = $draft->getData(); + $this->assertEmpty($res); + } + /** * It tests the getData method with processId filter * diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/HomeTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/HomeTest.php index 212198cf1..09a0a724b 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/HomeTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/HomeTest.php @@ -19,6 +19,8 @@ use ProcessMaker\Model\TaskUser; use Tests\TestCase; /** + * Class HomeTest + * * @coversDefaultClass \ProcessMaker\BusinessModel\Cases\Home */ class HomeTest extends TestCase diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InboxTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InboxTest.php index 647bbd117..d3c9869a1 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InboxTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InboxTest.php @@ -121,6 +121,29 @@ class InboxTest extends TestCase $this->assertNotEmpty($res); } + /** + * It tests the getData method with categoryId filter + * + * @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData() + * @covers \ProcessMaker\BusinessModel\Cases\Inbox::getColumnsView() + * @covers \ProcessMaker\BusinessModel\Cases\Inbox::filters() + * @covers \ProcessMaker\BusinessModel\Cases\Inbox::setCategoryId() + * @test + */ + public function it_filter_by_category() + { + // Create factories related to the to_do cases + $cases = $this->createInbox(); + // Create new Inbox object + $inbox = new Inbox(); + // Apply filters + $inbox->setUserId($cases->USR_ID); + $inbox->setCategoryId(2000); + // Call to getData method + $res = $inbox->getData(); + $this->assertEmpty($res); + } + /** * It tests the getData method with processId filter * diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/ParticipatedTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/ParticipatedTest.php index a4f00b49c..60f4b3e5b 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/ParticipatedTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/ParticipatedTest.php @@ -10,7 +10,7 @@ use ProcessMaker\Model\Delegation; use Tests\TestCase; /** - * Class InboxTest + * Class ParticipatedTest * * @coversDefaultClass \ProcessMaker\BusinessModel\Cases\Participated */ @@ -61,6 +61,27 @@ class ParticipatedTest extends TestCase * * @return array */ + public function createParticipatedDraft() + { + $application = factory(Application::class)->states('draft')->create(); + $delegation = factory(Delegation::class)->states('foreign_keys')->create([ + 'APP_NUMBER' => $application->APP_NUMBER, + 'APP_UID' => $application->APP_UID, + 'DEL_THREAD_STATUS' => 'OPEN', + 'DEL_INDEX' => 1, + 'DEL_LAST_INDEX' => 1, + ]); + + return $delegation; + } + + /** + * Create participated cases factories when the case is CANCELED + * + * @param string + * + * @return array + */ public function createParticipatedCompleted() { $application = factory(Application::class)->states('completed')->create(); @@ -207,6 +228,38 @@ class ParticipatedTest extends TestCase $this->assertNotEmpty($result); } + /** + * It tests the getData the specific filter setCategoryId + * + * @covers \ProcessMaker\BusinessModel\Cases\Participated::getData() + * @covers \ProcessMaker\BusinessModel\Cases\Participated::getColumnsView() + * @covers \ProcessMaker\BusinessModel\Cases\Participated::filters() + * @covers \ProcessMaker\BusinessModel\Cases\Participated::setFilterCases() + * @covers \ProcessMaker\BusinessModel\Cases\Participated::setUserUid() + * @covers \ProcessMaker\BusinessModel\Cases\Participated::setUserId() + * @covers \ProcessMaker\BusinessModel\Cases\Participated::setCategoryId() + * @test + */ + public function it_filter_by_category() + { + // Create factories related to the participated cases + $cases = $this->createParticipated(); + // Create new Participated object + $participated = new Participated(); + // Set the filter + $participated->setFilterCases('STARTED'); + // Set the user UID + $participated->setUserUid($cases['USR_UID']); + // Set the user ID + $participated->setUserId($cases['USR_ID']); + // Set the category + $participated->setCategoryId(3000); + // Get the data + $result = $participated->getData(); + // Asserts with the result + $this->assertEmpty($result); + } + /** * It tests the getData the specific filter setProcessId * @@ -239,6 +292,67 @@ class ParticipatedTest extends TestCase $this->assertNotEmpty($result); } + /** + * It tests the getData the specific filter setTaskId + * + * @covers \ProcessMaker\BusinessModel\Cases\Participated::getData() + * @covers \ProcessMaker\BusinessModel\Cases\Participated::getColumnsView() + * @covers \ProcessMaker\BusinessModel\Cases\Participated::filters() + * @covers \ProcessMaker\BusinessModel\Cases\Participated::setFilterCases() + * @covers \ProcessMaker\BusinessModel\Cases\Participated::setUserUid() + * @covers \ProcessMaker\BusinessModel\Cases\Participated::setUserId() + * @covers \ProcessMaker\BusinessModel\Cases\Participated::setProcessId() + * @test + */ + public function it_filter_by_task() + { + // Create factories related to the participated cases + $cases = $this->createParticipated(); + // Create new Participated object + $participated = new Participated(); + // Set the filter + $participated->setFilterCases('STARTED'); + // Set the user UID + $participated->setUserUid($cases['USR_UID']); + // Set the user ID + $participated->setUserId($cases['USR_ID']); + // Set the task + $participated->setTaskId($cases['TAS_ID']); + // Get the data + $result = $participated->getData(); + // Asserts with the result + $this->assertNotEmpty($result); + } + + /** + * It tests the getData the specific filter setCaseNumber + * + * @covers \ProcessMaker\BusinessModel\Cases\Participated::getData() + * @covers \ProcessMaker\BusinessModel\Cases\Participated::getColumnsView() + * @covers \ProcessMaker\BusinessModel\Cases\Participated::filters() + * @covers \ProcessMaker\BusinessModel\Cases\Participated::setCaseNumber() + * @test + */ + public function it_filter_by_specific_case() + { + // Create factories related to the participated cases + $cases = $this->createParticipated(); + // Create new Participated object + $participated = new Participated(); + // Set the filter + $participated->setFilterCases('STARTED'); + // Set the user UID + $participated->setUserUid($cases['USR_UID']); + // Set the user ID + $participated->setUserId($cases['USR_ID']); + // Set the case numbers + $participated->setCaseNumber($cases['APP_NUMBER']); + // Get the data + $result = $participated->getData(); + // Asserts with the result + $this->assertNotEmpty($result); + } + /** * It tests the getData method with case number filter * @@ -443,7 +557,7 @@ class ParticipatedTest extends TestCase * @covers \ProcessMaker\BusinessModel\Cases\Participated::setParticipatedStatus() * @test */ - public function it_get_status_in_progress() + public function it_get_status_in_progress_todo() { // Create factories related to the participated cases $cases = $this->createParticipated(); @@ -461,6 +575,60 @@ class ParticipatedTest extends TestCase $this->assertNotEmpty($result); } + /** + * It tests the specific filter setParticipatedStatus = IN_PROGRESS + * + * @covers \ProcessMaker\BusinessModel\Cases\Participated::getData() + * @covers \ProcessMaker\BusinessModel\Cases\Participated::getColumnsView() + * @covers \ProcessMaker\BusinessModel\Cases\Participated::filters() + * @covers \ProcessMaker\BusinessModel\Cases\Participated::setParticipatedStatus() + * @test + */ + public function it_get_status_in_started_and_completed() + { + // Create factories related to the participated cases + $cases = $this->createParticipatedCompleted(); + // Create new Participated object + $participated = new Participated(); + // Set the user UID + $participated->setUserUid($cases->USR_UID); + // Set the user ID + $participated->setUserId($cases->USR_ID); + // Set participated status + $participated->setParticipatedStatus('STARTED'); + // Get the data + $result = $participated->getData(); + // Asserts with the result + $this->assertNotEmpty($result); + } + + /** + * It tests the specific filter setParticipatedStatus = IN_PROGRESS + * + * @covers \ProcessMaker\BusinessModel\Cases\Participated::getData() + * @covers \ProcessMaker\BusinessModel\Cases\Participated::getColumnsView() + * @covers \ProcessMaker\BusinessModel\Cases\Participated::filters() + * @covers \ProcessMaker\BusinessModel\Cases\Participated::setParticipatedStatus() + * @test + */ + public function it_get_status_started_and_draft() + { + // Create factories related to the participated cases + $cases = $this->createParticipatedDraft(); + // Create new Participated object + $participated = new Participated(); + // Set the user UID + $participated->setUserUid($cases->USR_UID); + // Set the user ID + $participated->setUserId($cases->USR_ID); + // Set participated status + $participated->setParticipatedStatus('STARTED'); + // Get the data + $result = $participated->getData(); + // Asserts with the result + $this->assertNotEmpty($result); + } + /** * It tests the specific filter setParticipatedStatus = STARTED * diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/PausedTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/PausedTest.php index c384325e8..8ba31b48f 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/PausedTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/PausedTest.php @@ -300,6 +300,31 @@ class PausedTest extends TestCase $this->assertNotEmpty($res); } + /** + * It tests the getData method with categoryId filter + * + * @covers \ProcessMaker\BusinessModel\Cases\Paused::getData() + * @covers \ProcessMaker\BusinessModel\Cases\Paused::getColumnsView() + * @covers \ProcessMaker\BusinessModel\Cases\Paused::filters() + * @test + */ + public function it_filter_by_category() + { + // Create factories related to the paused cases + $cases = $this->createPaused(); + // Create new Paused object + $paused = new Paused(); + // Set the user UID + $paused->setUserUid($cases->USR_UID); + // Set the user ID + $paused->setUserId($cases->USR_ID); + $paused->setCategoryId(2000); + // Get the data + $res = $paused->getData(); + // Asserts + $this->assertEmpty($res); + } + /** * It tests the getData method with processId filter * diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/SearchTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/SearchTest.php index 010ddebef..8ababa0be 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/SearchTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/SearchTest.php @@ -10,7 +10,7 @@ use ProcessMaker\Model\Delegation; use Tests\TestCase; /** - * Class InboxTest + * Class SearchTest * * @coversDefaultClass \ProcessMaker\BusinessModel\Cases\Search */ diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/SupervisingTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/SupervisingTest.php index 250f9570b..dca0559c3 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/SupervisingTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/SupervisingTest.php @@ -15,6 +15,8 @@ use ProcessMaker\Model\User; use Tests\TestCase; /** + * Class SupervisingTest + * * @coversDefaultClass \ProcessMaker\BusinessModel\Cases\Supervising */ class SupervisingTest extends TestCase @@ -405,6 +407,34 @@ class SupervisingTest extends TestCase $this->assertNotEmpty($result); } + /** + * Tests the specific filter category + * + * @covers \ProcessMaker\BusinessModel\Cases\Supervising::getData() + * @covers \ProcessMaker\BusinessModel\Cases\Supervising::getColumnsView() + * @covers \ProcessMaker\BusinessModel\Cases\Supervising::filters() + * @covers \ProcessMaker\BusinessModel\Cases\Supervising::setUserUid() + * @covers \ProcessMaker\BusinessModel\Cases\Supervising::setUserId() + * @covers \ProcessMaker\BusinessModel\Cases\Supervising::setCategoryId() + * @test + */ + public function it_filter_by_category() + { + $cases = $this->createSupervising(); + // Instance the Supervising object + $supervising = new Supervising(); + // Set the user UID + $supervising->setUserUid($cases['USR_UID']); + // Set the user ID + $supervising->setUserId($cases['USR_ID']); + // Set the process + $supervising->setCategoryId(2000); + // Get the data + $result = $supervising->getData(); + // Asserts with the result + $this->assertEmpty($result); + } + /** * Tests the specific filter process * diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/UnassignedTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/UnassignedTest.php index e36231d13..20e0b011f 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/UnassignedTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/UnassignedTest.php @@ -22,6 +22,8 @@ use ProcessMaker\Model\User; use Tests\TestCase; /** + * Class UnassignedTest + * * @coversDefaultClass \ProcessMaker\BusinessModel\Cases\Unassigned */ class UnassignedTest extends TestCase @@ -79,6 +81,13 @@ class UnassignedTest extends TestCase 'TU_RELATION' => $relation, //Related to the user 'TU_TYPE' => 1 ]); + //Create the previous delegation before self-service + $delegation = factory(Delegation::class)->create([ + 'APP_NUMBER' => $application->APP_NUMBER, + 'PRO_ID' => $process->PRO_ID, + 'DEL_THREAD_STATUS' => 'CLOSED', + 'DEL_DELEGATE_DATE' => date('Y-m-d H:i:s', strtotime("-$i year")) + ]); //Create the register in delegation relate to self-service $delegation = factory(Delegation::class)->create([ 'APP_NUMBER' => $application->APP_NUMBER, @@ -86,6 +95,7 @@ class UnassignedTest extends TestCase 'PRO_ID' => $process->PRO_ID, 'DEL_THREAD_STATUS' => 'OPEN', 'USR_ID' => 0, + 'DEL_PREVIOUS' => $delegation->DEL_INDEX, 'DEL_DELEGATE_DATE' => date('Y-m-d H:i:s', strtotime("-$i year")) ]); } @@ -143,6 +153,13 @@ class UnassignedTest extends TestCase 'ASSIGNEE_ID' => ($userAssignee) ? $user->USR_ID : $group->GRP_ID, 'ASSIGNEE_TYPE' => $relation ]); + //Create the previous delegation before self-service + $delegation = factory(Delegation::class)->create([ + 'APP_NUMBER' => $application->APP_NUMBER, + 'PRO_ID' => $process->PRO_ID, + 'DEL_THREAD_STATUS' => 'CLOSED', + 'DEL_DELEGATE_DATE' => date('Y-m-d H:i:s', strtotime("-$i year")) + ]); //Create the register in delegation relate to self-service $delegation = factory(Delegation::class)->create([ 'APP_NUMBER' => $application->APP_NUMBER, @@ -151,6 +168,7 @@ class UnassignedTest extends TestCase 'PRO_ID' => $process->PRO_ID, 'DEL_THREAD_STATUS' => 'OPEN', 'USR_ID' => 0, + 'DEL_PREVIOUS' => $delegation->DEL_INDEX, 'DEL_DELEGATE_DATE' => date('Y-m-d H:i:s', strtotime("-$i year")) ]); } @@ -378,7 +396,30 @@ class UnassignedTest extends TestCase } /** - * This ensures get data from self-service-user-assigned with filter setRangeCasesFromTo + * This ensures get data from self-service-user-assigned with filter setCategoryId + * + * @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getData() + * @covers \ProcessMaker\BusinessModel\Cases\Unassigned::filters() + * @test + */ + public function it_filter_by_category() + { + // Create factories related to the unassigned cases + $cases = $this->createSelfServiceUserOrGroup(); + // Create new object + $unassigned = new Unassigned(); + // Apply filters + $unassigned->setUserUid($cases['taskUser']->USR_UID); + $unassigned->setUserId($cases['delegation']->USR_ID); + $unassigned->setCategoryId(2000); + // Call to getData method + $res = $unassigned->getData(); + // This assert that the expected numbers of results are returned + $this->assertEmpty($res); + } + + /** + * This ensures get data from self-service-user-assigned with filter setRangeCasesFromTo, setCasesNumbers, setCaseUid * * @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getData() * @covers \ProcessMaker\BusinessModel\Cases\Unassigned::filters() @@ -390,11 +431,29 @@ class UnassignedTest extends TestCase $cases = $this->createSelfServiceUserOrGroup(); // Create new object $unassigned = new Unassigned(); - // Apply filters + $unassigned->setUserUid($cases['taskUser']->USR_UID); + $unassigned->setUserId($cases['delegation']->USR_ID); + $unassigned->setCasesNumbers([$cases['delegation']->APP_NUMBER]); + $unassigned->setRangeCasesFromTo([]); + // Create new object + $unassigned = new Unassigned(); + $unassigned->setUserUid($cases['taskUser']->USR_UID); + $unassigned->setUserId($cases['delegation']->USR_ID); + $rangeOfCases = $cases['delegation']->APP_NUMBER . "-" . $cases['delegation']->APP_NUMBER; + $unassigned->setCasesNumbers([]); + $unassigned->setRangeCasesFromTo([$rangeOfCases]); + // Create new object + $unassigned = new Unassigned(); $unassigned->setUserUid($cases['taskUser']->USR_UID); $unassigned->setUserId($cases['delegation']->USR_ID); $rangeOfCases = $cases['delegation']->APP_NUMBER . "-" . $cases['delegation']->APP_NUMBER; $unassigned->setRangeCasesFromTo([$rangeOfCases]); + $unassigned->setCasesNumbers([$cases['delegation']->APP_NUMBER]); + // Create new object + $unassigned = new Unassigned(); + $unassigned->setUserUid($cases['taskUser']->USR_UID); + $unassigned->setUserId($cases['delegation']->USR_ID); + $unassigned->setCaseUid($cases['delegation']->APP_UID); // Call to getData method $res = $unassigned->getData(); // This assert that the expected numbers of results are returned diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/BatchRouting.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/BatchRouting.php index 449accfbd..8c8bf8e4c 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/BatchRouting.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/BatchRouting.php @@ -3,11 +3,15 @@ namespace ProcessMaker\BusinessModel\Cases; use ProcessMaker\Model\Consolidated; +use ProcessMaker\Model\Delegation; class BatchRouting extends AbstractCases { // Columns to see in the cases list - public $columnsView = []; + public $columnsView = [ + // Columns view in the cases list + 'APP_DELEGATION.APP_NUMBER', // Case # + ]; /** * Get the columns related to the cases list @@ -37,6 +41,8 @@ class BatchRouting extends AbstractCases */ public function getData() { + $query = Delegation::query()->select($this->getColumnsView()); + $this->filters($query); // todo, the list for consolidated cases was not defined for the new HOME return []; } diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Canceled.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Canceled.php index 2fba4fe06..f8ea15d4b 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Canceled.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Canceled.php @@ -7,7 +7,10 @@ use ProcessMaker\Model\Delegation; class Canceled extends AbstractCases { // Columns to see in the cases list - public $columnsView = []; + public $columnsView = [ + // Columns view in the cases list + 'APP_DELEGATION.APP_NUMBER', // Case # + ]; /** * Get the columns related to the cases list @@ -37,6 +40,8 @@ class Canceled extends AbstractCases */ public function getData() { + $query = Delegation::query()->select($this->getColumnsView()); + $this->filters($query); // todo, the list for canceled cases was not defined return []; } diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Completed.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Completed.php index 896817b90..6122df51b 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Completed.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Completed.php @@ -7,7 +7,10 @@ use ProcessMaker\Model\Delegation; class Completed extends AbstractCases { // Columns to see in the cases list - public $columnsView = []; + public $columnsView = [ + // Columns view in the cases list + 'APP_DELEGATION.APP_NUMBER', // Case # + ]; /** * Get the columns related to the cases list @@ -37,6 +40,8 @@ class Completed extends AbstractCases */ public function getData() { + $query = Delegation::query()->select($this->getColumnsView()); + $this->filters($query); // todo, the list for completed cases was defined in participated return []; }