From 1a48d77c96dcda8b79f180dc88fab807400a82b2 Mon Sep 17 00:00:00 2001 From: Paula Quispe Date: Fri, 3 Dec 2021 18:37:03 -0400 Subject: [PATCH] PMCORE-3553 --- database/factories/TaskFactory.php | 2 ++ .../src/ProcessMaker/Model/DelegationTest.php | 15 ++++++++++++++- .../BusinessModel/Cases/Participated.php | 2 +- .../BusinessModel/Cases/Supervising.php | 2 +- .../engine/src/ProcessMaker/Model/Delegation.php | 6 +----- 5 files changed, 19 insertions(+), 8 deletions(-) diff --git a/database/factories/TaskFactory.php b/database/factories/TaskFactory.php index 25584e9a9..caef8aba7 100644 --- a/database/factories/TaskFactory.php +++ b/database/factories/TaskFactory.php @@ -17,6 +17,7 @@ $factory->define(\ProcessMaker\Model\Task::class, function(Faker $faker) { 'TAS_DURATION' => 1, 'TAS_ASSIGN_TYPE' => 'BALANCED', 'TAS_DEF_TITLE' => $faker->sentence(2), + 'TAS_DEF_DESCRIPTION' => $faker->sentence(2), 'TAS_ASSIGN_VARIABLE' => '@@SYS_NEXT_USER_TO_BE_ASSIGNED', 'TAS_MI_INSTANCE_VARIABLE' => '@@SYS_VAR_TOTAL_INSTANCE', 'TAS_MI_COMPLETE_VARIABLE' => '@@SYS_VAR_TOTAL_INSTANCES_COMPLETE', @@ -47,6 +48,7 @@ $factory->state(\ProcessMaker\Model\Task::class, 'foreign_keys', function (Faker 'TAS_DURATION' => 1, 'TAS_ASSIGN_TYPE' => 'BALANCED', 'TAS_DEF_TITLE' => $faker->sentence(2), + 'TAS_DEF_DESCRIPTION' => $faker->sentence(2), 'TAS_ASSIGN_VARIABLE' => '@@SYS_NEXT_USER_TO_BE_ASSIGNED', 'TAS_MI_INSTANCE_VARIABLE' => '@@SYS_VAR_TOTAL_INSTANCE', 'TAS_MI_COMPLETE_VARIABLE' => '@@SYS_VAR_TOTAL_INSTANCES_COMPLETE', diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/DelegationTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/DelegationTest.php index be1fd91f6..375975266 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Model/DelegationTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Model/DelegationTest.php @@ -3425,7 +3425,7 @@ class DelegationTest extends TestCase public function it_get_thread_title() { $delegation = factory(Delegation::class)->states('foreign_keys')->create(); - $result = Delegation::getThreadTitle($delegation->TAS_UID, $delegation->APP_NUMBER, $delegation->DEL_INDEX, []); + $result = Delegation::getThreadTitle($delegation->TAS_UID, $delegation->APP_NUMBER, $delegation->DEL_PREVIOUS, []); $this->assertNotEmpty($result); } @@ -3584,6 +3584,19 @@ class DelegationTest extends TestCase $this->assertNotEmpty($result); } + /** + * This check the return cases thread title + * + * @covers \ProcessMaker\Model\Delegation::casesThreadTitle() + * @test + */ + public function it_get_cases_thread_title() + { + $delegation = factory(Delegation::class)->states('foreign_keys')->create(); + $result = Delegation::casesThreadTitle($delegation->DEL_TITLE); + $this->assertNotEmpty($result); + } + /** * Test the scopeParticipatedUser * diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Participated.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Participated.php index 54cb1650a..e1c680914 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Participated.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Participated.php @@ -68,7 +68,7 @@ class Participated extends AbstractCases // Specific case title if (!empty($this->getCaseTitle())) { // Get the result - $result = Delegation::casesThreadTitle($this->getCaseTitle(), $this->getOffset(), $this->getLimit()); + $result = Delegation::casesThreadTitle($this->getCaseTitle()); // Add the filter $query->specificCases($result); } diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Supervising.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Supervising.php index bb4c61d67..5179c45ba 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Supervising.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/Supervising.php @@ -66,7 +66,7 @@ class Supervising extends AbstractCases // Specific case title if (!empty($this->getCaseTitle())) { // Get the result - $result = Delegation::casesThreadTitle($this->getCaseTitle(), $this->getOffset(), $this->getLimit()); + $result = Delegation::casesThreadTitle($this->getCaseTitle()); // Add the filter $query->specificCases($result); } diff --git a/workflow/engine/src/ProcessMaker/Model/Delegation.php b/workflow/engine/src/ProcessMaker/Model/Delegation.php index 904af8e9d..56fcb2fd6 100644 --- a/workflow/engine/src/ProcessMaker/Model/Delegation.php +++ b/workflow/engine/src/ProcessMaker/Model/Delegation.php @@ -2181,12 +2181,10 @@ class Delegation extends Model * Get cases filter by thread title * * @param string $search - * @param int $offset - * @param int $limit * * @return array */ - public static function casesThreadTitle(string $search, int $offset = 0, int $limit = 15) + public static function casesThreadTitle(string $search) { // Get the case numbers related to this filter $query = Delegation::query()->select(['APP_NUMBER']); @@ -2194,8 +2192,6 @@ class Delegation extends Model $query->title($search); // Group by $query->groupBy('APP_NUMBER'); - // Apply the limit - $query->offset($offset)->limit($limit); // Get the result $results = $query->get();