PMCORE-514

This commit is contained in:
Paula Quispe
2021-08-02 13:06:17 -04:00
parent f6770eff24
commit 2077edb64b
11 changed files with 393 additions and 279 deletions

View File

@@ -354,6 +354,7 @@ class DraftTest extends TestCase
* It tests the getCountersByProcesses() method with the category filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getCountersByProcesses()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getCountersByProcesses()
* @test
*/
public function it_should_test_get_counters_by_processes_method_category()
@@ -643,6 +644,7 @@ class DraftTest extends TestCase
* It tests the getCountersByRange() method
*
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getCountersByRange()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getCountersByProcesses()
* @test
*/
public function it_should_test_get_counters_by_range_method()

View File

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

View File

@@ -5,6 +5,7 @@ namespace ProcessMaker\BusinessModel;
use Exception;
use G;
use Illuminate\Support\Facades\DB;
use ProcessMaker\Model\AppDelay;
use ProcessMaker\Model\Application;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\Documents;
@@ -380,4 +381,45 @@ class CasesTest extends TestCase
// Get DynaForms assigned as steps for the second task when the application status is COMPLETED
self::assertCount(1, Cases::dynaFormsByApplication($application->APP_UID, $task2->TAS_UID, '', 'COMPLETED'));
}
/**
* It test the case info used in the PMFCaseLink
*
* @covers \ProcessMaker\BusinessModel\Cases::getStatusInfo()
* @covers \ProcessMaker\Model\AppDelay::getPaused()
* @test
*/
public function it_should_test_case_status_info()
{
// Get status info when the case is PAUSED
$table = factory(AppDelay::class)->states('paused_foreign_keys')->create();
$cases = new Cases();
$result = $cases->getStatusInfo($table->APP_UID, $table->APP_DEL_INDEX, $table->APP_DELEGATION_USER);
$this->assertNotEmpty($result);
$this->assertArrayHasKey('APP_STATUS', $result);
$this->assertArrayHasKey('DEL_INDEX', $result);
$this->assertArrayHasKey('PRO_UID', $result);
// Get status info when the case is UNASSIGNED
// Get status info when the case is TO_DO
$table = factory(Delegation::class)->states('foreign_keys')->create();
$cases = new Cases();
$result = $cases->getStatusInfo($table->APP_UID, $table->DEL_INDEX, $table->USR_UID);
$this->assertNotEmpty($result);
$this->assertArrayHasKey('APP_STATUS', $result);
$this->assertArrayHasKey('DEL_INDEX', $result);
$this->assertArrayHasKey('PRO_UID', $result);
// Get status info when the case is COMPLETED
$table = factory(Application::class)->states('completed')->create();
$table = factory(Delegation::class)->states('foreign_keys')->create([
'APP_NUMBER' => $table->APP_NUMBER,
'APP_UID' => $table->APP_UID,
]);
$cases = new Cases();
$result = $cases->getStatusInfo($table->APP_UID, $table->DEL_INDEX, $table->USR_UID);
$this->assertNotEmpty($result);
$this->assertArrayHasKey('APP_STATUS', $result);
$this->assertArrayHasKey('DEL_INDEX', $result);
$this->assertArrayHasKey('PRO_UID', $result);
}
}

View File

@@ -0,0 +1,102 @@
<?php
namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use ProcessMaker\Model\AppDelay;
use Tests\TestCase;
/**
* Class AppDelayTest
*
* @coversDefaultClass \ProcessMaker\Model\AppDelay
*/
class AppDelayTest extends TestCase
{
use DatabaseTransactions;
/**
* Set up function.
*/
public function setUp()
{
parent::setUp();
AppDelay::truncate();
}
/**
* This test scopeType
*
* @covers \ProcessMaker\Model\AppDelay::scopeType()
* @test
*/
public function it_return_scope_type()
{
$table = factory(AppDelay::class)->states('paused_foreign_keys')->create();
$this->assertCount(1, $table->type('PAUSE')->get());
}
/**
* This test scopeNotDisabled
*
* @covers \ProcessMaker\Model\AppDelay::scopeNotDisabled()
* @test
*/
public function it_return_scope_not_action_disable()
{
$table = factory(AppDelay::class)->states('paused_foreign_keys')->create();
$this->assertCount(1, $table->notDisabled()->get());
}
/**
* This test scopeCase
*
* @covers \ProcessMaker\Model\AppDelay::scopeCase()
* @test
*/
public function it_return_scope_case()
{
$table = factory(AppDelay::class)->states('paused_foreign_keys')->create();
$this->assertCount(1, $table->case($table->APP_NUMBER)->get());
}
/**
* This test scopeIndex
*
* @covers \ProcessMaker\Model\AppDelay::scopeIndex()
* @test
*/
public function it_return_scope_index()
{
$table = factory(AppDelay::class)->states('paused_foreign_keys')->create();
$this->assertCount(1, $table->index($table->APP_DEL_INDEX)->get());
}
/**
* This test scopeDelegateUser
*
* @covers \ProcessMaker\Model\AppDelay::scopeDelegateUser()
* @test
*/
public function it_return_scope_delegate_user()
{
$table = factory(AppDelay::class)->states('paused_foreign_keys')->create();
$this->assertCount(1, $table->delegateUser($table->APP_DELEGATION_USER)->get());
}
/**
* This test getPaused
*
* @covers \ProcessMaker\Model\AppDelay::getPaused()
* @covers \ProcessMaker\Model\AppDelay::scopeCase()
* @covers \ProcessMaker\Model\AppDelay::scopeIndex()
* @covers \ProcessMaker\Model\AppDelay::scopeDelegateUser()
* @test
*/
public function it_return_paused_threads()
{
$table = factory(AppDelay::class)->states('paused_foreign_keys')->create();
$result = AppDelay::getPaused($table->APP_NUMBER, $table->APP_DEL_INDEX, $table->APP_DELEGATION_USER);
$this->assertNotEmpty($result);
}
}

View File

@@ -170,7 +170,7 @@ class DelegationTest extends TestCase
*/
public function it_return_scope_case_started()
{
$table = factory(Delegation::class)->states('foreign_keys')->create();
$table = factory(Delegation::class)->states('first_thread')->create();
$this->assertCount(1, $table->caseStarted($table->DEL_INDEX)->get());
}
@@ -532,7 +532,7 @@ class DelegationTest extends TestCase
{
$table = factory(Delegation::class)->states('foreign_keys')->create();
$cases = [$table->APP_NUMBER];
$rangeCases = [$table->APP_NUMBER.'-'.$table->APP_NUMBER];
$rangeCases = [$table->APP_NUMBER . '-' . $table->APP_NUMBER];
$this->assertCount(1, $table->casesOrRangeOfCases($cases, $rangeCases)->get());
}
@@ -2150,6 +2150,8 @@ class DelegationTest extends TestCase
//Review the self-service records
$result = Delegation::getSelfService($user->USR_UID);
$this->assertEquals(25, count($result));
$result = Delegation::getSelfService($user->USR_UID, ['APP_DELEGATION.APP_NUMBER', 'APP_DELEGATION.DEL_INDEX'], null, null,null, null, null, 0, 15);
$this->assertEquals(15, count($result));
}
/**
@@ -3369,7 +3371,7 @@ class DelegationTest extends TestCase
*/
public function it_get_cases_started_by_specific_user()
{
$delegation = factory(Delegation::class)->states('foreign_keys')->create();
$delegation = factory(Delegation::class)->states('first_thread')->create();
$result = Delegation::casesStartedBy($delegation->USR_ID);
$this->assertNotEmpty($result);
}