Merged in bugfix/PMCORE-1220 (pull request #7900)

PMCORE-1220

Approved-by: Julio Cesar Laura Avendaño
This commit is contained in:
Paula Quispe
2021-05-11 22:21:13 +00:00
committed by Julio Cesar Laura Avendaño
22 changed files with 1081 additions and 117 deletions

View File

@@ -0,0 +1,59 @@
<?php
namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use ProcessMaker\BusinessModel\Cases\BatchRouting;
use ProcessMaker\Model\Consolidated;
use ProcessMaker\Model\Delegation;
use Tests\TestCase;
/**
* @coversDefaultClass \ProcessMaker\BusinessModel\Cases\BatchRouting
*/
class BatchRoutingTest extends TestCase
{
use DatabaseTransactions;
/**
* Method set up.
*/
public function setUp()
{
parent::setUp();
}
/**
* Create consolidated cases factories
*
* @return array
*/
public function createConsolidated()
{
$consolidated = factory(Consolidated::class)->states('foreign_keys')->create();
$delegation = factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'TAS_UID' => $consolidated->TAS_UID,
]);
return $delegation;
}
/**
* This checks the counters is working properly in batch routing
*
* @covers \ProcessMaker\BusinessModel\Cases\BatchRouting::getCounter()
* @test
*/
public function it_should_count_cases_consolidated()
{
// Create factories related to the consolidated cases
$cases = $this->createConsolidated();
// Create new Draft object
$consolidated = new BatchRouting();
$consolidated->setUserId($cases['USR_ID']);
$consolidated->setUserUid($cases['USR_UID']);
$result = $consolidated->getCounter();
$this->assertTrue($result > 0);
}
}

View File

@@ -0,0 +1,62 @@
<?php
namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use ProcessMaker\BusinessModel\Cases\Canceled;
use ProcessMaker\Model\Application;
use ProcessMaker\Model\Delegation;
use Tests\TestCase;
/**
* @coversDefaultClass \ProcessMaker\BusinessModel\Cases\Canceled
*/
class CanceledTest extends TestCase
{
use DatabaseTransactions;
/**
* Method set up.
*/
public function setUp()
{
parent::setUp();
}
/**
* Create inbox cases factories
*
* @return array
*/
public function createCanceled()
{
$application = factory(Application::class)->states('canceled')->create();
$delegation = factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'CLOSED',
'DEL_INDEX' => 1,
'USR_UID' => $application->APP_INIT_USER,
'APP_UID' => $application->APP_UID,
'APP_NUMBER' => $application->APP_NUMBER,
]);
return $delegation;
}
/**
* This checks the counters is working properly in canceled
*
* @covers \ProcessMaker\BusinessModel\Cases\Canceled::getCounter()
* @test
*/
public function it_should_count_cases_completed()
{
// Create factories related to the canceled cases
$cases = $this->createCanceled();
// Create new Canceled object
$canceled = new Canceled();
$canceled->setUserId($cases['USR_ID']);
$canceled->setUserUid($cases['USR_UID']);
$result = $canceled->getCounter();
$this->assertTrue($result > 0);
}
}

View File

@@ -0,0 +1,60 @@
<?php
namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use ProcessMaker\BusinessModel\Cases\CasesList;
use ProcessMaker\Model\Application;
use ProcessMaker\Model\Delegation;
use Tests\TestCase;
/**
* @coversDefaultClass \ProcessMaker\BusinessModel\Cases\CasesList
*/
class CasesListTest extends TestCase
{
use DatabaseTransactions;
/**
* Method set up.
*/
public function setUp()
{
parent::setUp();
}
/**
* Create cases factories
*
* @return array
*/
public function createCases()
{
$application = factory(Application::class)->states('completed')->create();
$delegation = factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'CLOSED',
'DEL_INDEX' => 1,
'USR_UID' => $application->APP_INIT_USER,
'APP_UID' => $application->APP_UID,
'APP_NUMBER' => $application->APP_NUMBER,
]);
return $delegation;
}
/**
* This test getAllCounters
*
* @covers \ProcessMaker\BusinessModel\Cases\CasesList::getAllCounters()
* @test
*/
public function it_return_all_counters()
{
$delegation = factory(Delegation::class)->states('foreign_keys')->create();
$count = new CasesList();
$result = $count->getAllCounters($delegation->USR_UID);
$this->assertNotEmpty($result);
$this->assertArrayHasKey('CASES_INBOX', $result);
$this->assertArrayHasKey('CASES_DRAFT', $result);
}
}

View File

@@ -0,0 +1,62 @@
<?php
namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use ProcessMaker\BusinessModel\Cases\Completed;
use ProcessMaker\Model\Application;
use ProcessMaker\Model\Delegation;
use Tests\TestCase;
/**
* @coversDefaultClass \ProcessMaker\BusinessModel\Cases\Completed
*/
class CompletedTest extends TestCase
{
use DatabaseTransactions;
/**
* Method set up.
*/
public function setUp()
{
parent::setUp();
}
/**
* Create complete cases factories
*
* @return array
*/
public function createCompleted()
{
$application = factory(Application::class)->states('completed')->create();
$delegation = factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'CLOSED',
'DEL_INDEX' => 1,
'USR_UID' => $application->APP_INIT_USER,
'APP_UID' => $application->APP_UID,
'APP_NUMBER' => $application->APP_NUMBER,
]);
return $delegation;
}
/**
* This checks the counters is working properly in completed
*
* @covers \ProcessMaker\BusinessModel\Cases\Completed::getCounter()
* @test
*/
public function it_should_count_cases_completed()
{
// Create factories related to the completed cases
$cases = $this->createCompleted();
// Create new Completed object
$completed = new Completed();
$completed->setUserId($cases['USR_ID']);
$completed->setUserUid($cases['USR_UID']);
$result = $completed->getCounter();
$this->assertTrue($result > 0);
}
}

View File

@@ -98,6 +98,7 @@ class DraftTest extends TestCase
*
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getColumnsView()
* @covers \ProcessMaker\Model\Delegation::scopeDraft()
* @test
*/
public function it_get_result_without_filters()

View File

@@ -89,6 +89,7 @@ class InboxTest extends TestCase
*
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getColumnsView()
* @covers \ProcessMaker\Model\Delegation::scopeInbox()
* @test
*/
public function it_get_result_without_filters()

View File

@@ -89,6 +89,7 @@ class ParticipatedTest extends TestCase
*
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getColumnsView()
* @covers \ProcessMaker\Model\Delegation::scopeParticipated()
* @test
*/
public function it_get_result_without_filters()

View File

@@ -196,6 +196,7 @@ class PausedTest extends TestCase
*
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\Model\Delegation::scopePaused()
* @test
*/
public function it_get_result_without_filters()

View File

@@ -319,6 +319,7 @@ class UnassignedTest extends TestCase
* This ensures get data from self-service-user-assigned without filters
*
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getData()
* @covers \ProcessMaker\Model\Delegation::scopeSelfService()
* @test
*/
public function it_test_unassigned_by_user_without_filters()

View File

@@ -0,0 +1,72 @@
<?php
namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use ProcessMaker\Model\Consolidated;
use ProcessMaker\Model\Delegation;
use Tests\TestCase;
/**
* @coversDefaultClass \ProcessMaker\Model\Consolidated
*/
class ConsolidatedTest extends TestCase
{
use DatabaseTransactions;
/**
* Method set up.
*/
public function setUp()
{
parent::setUp();
}
/**
* Create consolidated cases factories
*
* @return array
*/
public function createConsolidated()
{
$consolidated = factory(Consolidated::class)->states('foreign_keys')->create();
$delegation = factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'TAS_UID' => $consolidated->TAS_UID,
]);
return $delegation;
}
/**
* This checks the counters is working properly in draft
*
* @covers \ProcessMaker\Model\Consolidated::getCounterActive()
* @test
*/
public function it_should_count_cases_consolidated()
{
// Create factories related to the consolidated
$cases = $this->createConsolidated();
// Create new Consolidated object
$consolidated = new Consolidated();
$result = $consolidated->getCounterActive();
$this->assertTrue($result > 0);
}
/**
* This checks the counters is working properly in consolidated
*
* @covers \ProcessMaker\Model\Consolidated::getCounterActive()
* @test
*/
public function it_should_count_cases()
{
// Create factories related to the consolidated
$cases = $this->createConsolidated();
// Create new Consolidated object
$consolidated = new Consolidated();
$result = $consolidated->getConsolidated();
$this->assertTrue($result > 0);
}
}

View File

@@ -7,6 +7,7 @@ use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\Model\AppAssignSelfServiceValue;
use ProcessMaker\Model\AppAssignSelfServiceValueGroup;
use ProcessMaker\Model\AppDelay;
use ProcessMaker\Model\Application;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\GroupUser;
@@ -218,6 +219,22 @@ class DelegationTest extends TestCase
$this->assertCount(1, $table->joinApplication()->caseCompleted()->get());
}
/**
* This test scopeCaseCanceled
*
* @covers \ProcessMaker\Model\Delegation::scopeCaseCanceled()
* @test
*/
public function it_return_scope_case_canceled()
{
$application = factory(Application::class)->states('canceled')->create();
$table = factory(Delegation::class)->states('foreign_keys')->create([
'APP_NUMBER' => $application->APP_NUMBER,
'APP_UID' => $application->APP_UID,
]);
$this->assertCount(1, $table->joinApplication()->caseCanceled()->get());
}
/**
* This test scopeStatus
*
@@ -250,6 +267,70 @@ class DelegationTest extends TestCase
$this->assertCount(1, $table->joinApplication()->statusIds([$application->APP_STATUS_ID])->get());
}
/**
* This test scopeStartDateFrom
*
* @covers \ProcessMaker\Model\Delegation::scopeStartDateFrom()
* @test
*/
public function it_return_scope_start_date_from()
{
$application = factory(Application::class)->states('todo')->create();
$table = factory(Delegation::class)->states('foreign_keys')->create([
'APP_NUMBER' => $application->APP_NUMBER,
'APP_UID' => $application->APP_UID,
]);
$this->assertCount(1, $table->joinApplication()->startDateFrom($application->APP_CREATE_DATE->format("Y-m-d H:i:s"))->get());
}
/**
* This test scopeStartDateTo
*
* @covers \ProcessMaker\Model\Delegation::scopeStartDateTo()
* @test
*/
public function it_return_scope_start_date_to()
{
$application = factory(Application::class)->states('todo')->create();
$table = factory(Delegation::class)->states('foreign_keys')->create([
'APP_NUMBER' => $application->APP_NUMBER,
'APP_UID' => $application->APP_UID,
]);
$this->assertCount(1, $table->joinApplication()->startDateto($application->APP_CREATE_DATE->format("Y-m-d H:i:s"))->get());
}
/**
* This test scopeFinishCaseFrom
*
* @covers \ProcessMaker\Model\Delegation::scopeFinishCaseFrom()
* @test
*/
public function it_return_scope_finish_case_date_from()
{
$application = factory(Application::class)->states('todo')->create();
$table = factory(Delegation::class)->states('foreign_keys')->create([
'APP_NUMBER' => $application->APP_NUMBER,
'APP_UID' => $application->APP_UID,
]);
$this->assertCount(1, $table->joinApplication()->finishCaseFrom($application->APP_FINISH_DATE->format("Y-m-d H:i:s"))->get());
}
/**
* This test scopeFinishCaseTo
*
* @covers \ProcessMaker\Model\Delegation::scopeFinishCaseTo()
* @test
*/
public function it_return_scope_finish_case_date_to()
{
$application = factory(Application::class)->states('todo')->create();
$table = factory(Delegation::class)->states('foreign_keys')->create([
'APP_NUMBER' => $application->APP_NUMBER,
'APP_UID' => $application->APP_UID,
]);
$this->assertCount(1, $table->joinApplication()->finishCaseTo($application->APP_FINISH_DATE->format("Y-m-d H:i:s"))->get());
}
/**
* This test scopeDelegateDateFrom
*
@@ -513,7 +594,7 @@ class DelegationTest extends TestCase
public function it_return_scope_exclude_tas_types()
{
$table = factory(Delegation::class)->states('foreign_keys')->create();
$this->assertCount(0, $table->excludeTaskTypes(['NORMAL'])->get());
$this->assertNotEmpty($table->excludeTaskTypes(['ADHOC'])->get());
}
/**
@@ -546,6 +627,137 @@ class DelegationTest extends TestCase
$this->assertCount(1, $table->appStatusId()->get());
}
/**
* This test scopeProcessInList
*
* @covers \ProcessMaker\Model\Delegation::scopeProcessInList()
* @test
*/
public function it_return_scope_process_in_list()
{
$table = factory(Delegation::class)->states('foreign_keys')->create();
$this->assertCount(1, $table->processInList([$table->PRO_ID])->get());
}
/**
* This test scopeJoinCategoryProcess
*
* @covers \ProcessMaker\Model\Delegation::scopeJoinCategoryProcess()
* @test
*/
public function it_return_scope_join_category_process()
{
$category = factory(ProcessCategory::class)->create();
$process = factory(Process::class)->create([
'PRO_CATEGORY' => $category->CATEGORY_UID
]);
$table = factory(Delegation::class)->states('foreign_keys')->create([
'PRO_ID' => $process->PRO_ID
]);
$this->assertCount(1, $table->joinCategoryProcess($category->CATEGORY_UID)->get());
}
/**
* This test scopeJoinPreviousIndex
*
* @covers \ProcessMaker\Model\Delegation::scopeJoinPreviousIndex()
* @test
*/
public function it_return_scope_join_previous_index()
{
$previous = factory(Delegation::class)->states('foreign_keys')->create();
$table = factory(Delegation::class)->states('foreign_keys')->create([
'APP_NUMBER' => $previous->APP_NUMBER,
'DEL_INDEX' => $previous->DEL_INDEX+1,
'DEL_PREVIOUS' => $previous->DEL_INDEX
]);
$this->assertNotEmpty($table->joinPreviousIndex()->get());
}
/**
* This test scopeJoinProcess
*
* @covers \ProcessMaker\Model\Delegation::scopeJoinProcess()
* @test
*/
public function it_return_scope_join_process()
{
$process = factory(Process::class)->create();
$table = factory(Delegation::class)->states('foreign_keys')->create([
'PRO_ID' => $process->PRO_ID
]);
$this->assertCount(1, $table->joinProcess()->get());
}
/**
* This test scopeJoinTask
*
* @covers \ProcessMaker\Model\Delegation::scopeJoinTask()
* @test
*/
public function it_return_scope_join_task()
{
$task = factory(Task::class)->create();
$table = factory(Delegation::class)->states('foreign_keys')->create([
'TAS_ID' => $task->TAS_ID
]);
$this->assertCount(1, $table->joinTask()->get());
}
/**
* This test scopeJoinUser
*
* @covers \ProcessMaker\Model\Delegation::scopeJoinUser()
* @test
*/
public function it_return_scope_join_user()
{
$user = factory(User::class)->create();
$table = factory(Delegation::class)->states('foreign_keys')->create([
'USR_ID' => $user->USR_ID
]);
$this->assertCount(1, $table->joinUser()->get());
}
/**
* This test scopeJoinApplication
*
* @covers \ProcessMaker\Model\Delegation::scopeJoinApplication()
* @test
*/
public function it_return_scope_join_application()
{
$application = factory(Application::class)->create();
$table = factory(Delegation::class)->states('foreign_keys')->create([
'APP_NUMBER' => $application->APP_NUMBER
]);
$this->assertCount(1, $table->joinApplication()->get());
}
/**
* This test scopeJoinAppDelay
*
* @covers \ProcessMaker\Model\Delegation::scopeJoinAppDelay()
* @covers \ProcessMaker\Model\Delegation::scopeJoinAppDelayUsers()
* @test
*/
public function it_return_scope_join_app_delay_pause()
{
$user = factory(User::class)->create();
$delay = factory(AppDelay::class)->create([
'APP_TYPE' => 'PAUSE',
'APP_DISABLE_ACTION_USER' => '0',
'APP_DELEGATION_USER' => $user->USR_UID,
]);
$table = factory(Delegation::class)->states('foreign_keys')->create([
'USR_ID' => $user->USR_ID,
'USR_UID' => $user->USR_UID,
'APP_NUMBER' => $delay->APP_NUMBER,
'DEL_INDEX' => $delay->APP_DEL_INDEX
]);
$this->assertCount(1, $table->joinAppDelay('PAUSE')->joinAppDelayUsers($user->USR_ID)->get());
}
/**
* This checks to make sure pagination is working properly
*
@@ -2892,6 +3104,58 @@ class DelegationTest extends TestCase
$this->assertNotEmpty($result);
}
/**
* This check the return of thread info
*
* @covers \ProcessMaker\Model\Delegation::getThreadInfo()
* @test
*/
public function it_get_thread_info()
{
$delegation = factory(Delegation::class)->states('foreign_keys')->create();
$result = Delegation::getThreadInfo($delegation->APP_NUMBER, $delegation->DEL_INDEX);
$this->assertNotEmpty($result);
}
/**
* This check the return of pending threads
*
* @covers \ProcessMaker\Model\Delegation::getPendingThreads()
* @test
*/
public function it_get_threads_pending()
{
$delegation = factory(Delegation::class)->states('foreign_keys')->create();
$result = Delegation::getPendingThreads($delegation->APP_NUMBER);
$this->assertNotEmpty($result);
}
/**
* This check the return of pending task
*
* @covers \ProcessMaker\Model\Delegation::getPendingTask()
* @test
*/
public function it_get_task_pending()
{
$delegation = factory(Delegation::class)->states('foreign_keys')->create();
$result = Delegation::getPendingTask($delegation->APP_NUMBER);
$this->assertNotEmpty($result);
}
/**
* This check the return of last thread
*
* @covers \ProcessMaker\Model\Delegation::getLastThread()
* @test
*/
public function it_get_last_thread()
{
$delegation = factory(Delegation::class)->states('foreign_keys')->create();
$result = Delegation::getLastThread($delegation->APP_NUMBER);
$this->assertNotEmpty($result);
}
/**
* This tests the getDeltitle() method
*