conflicts: merge develop
This commit is contained in:
@@ -28,6 +28,7 @@ class DraftTest extends TestCase
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
Delegation::truncate();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -881,4 +882,18 @@ class DraftTest extends TestCase
|
||||
$res = $draft->getCasesRisk($process->PRO_ID, null, null, 'OVERDUE');
|
||||
$this->assertCount(1, $res);
|
||||
}
|
||||
|
||||
/**
|
||||
* This tests the getCounterMetrics() method
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getCounterMetrics()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_get_counter_metrics()
|
||||
{
|
||||
$this->createDraft();
|
||||
$draft = new Draft();
|
||||
$result = $draft->getCounterMetrics();
|
||||
$this->assertTrue($result > 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,14 @@ class InboxTest extends TestCase
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
Delegation::truncate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method tearDown
|
||||
*/
|
||||
public function tearDown() {
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -272,9 +280,14 @@ class InboxTest extends TestCase
|
||||
public function it_filter_by_thread_title()
|
||||
{
|
||||
// Create factories related to the to_do cases
|
||||
$cases = $this->createInbox();
|
||||
$usrId = $cases->USR_ID;
|
||||
$title = $cases->DEL_TITLE;
|
||||
$delegation = factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'DEL_PREVIOUS' => 1,
|
||||
'DEL_INDEX' => 2,
|
||||
'DEL_TITLE' => 'Test',
|
||||
]);
|
||||
$usrId = $delegation->USR_ID;
|
||||
$title = 'Test';
|
||||
// We need to commit the records inserted because is needed for the "fulltext" index
|
||||
DB::commit();
|
||||
// Create new Inbox object
|
||||
@@ -830,4 +843,18 @@ class InboxTest extends TestCase
|
||||
$res = $inbox->getCasesRisk($process->PRO_ID, null, null, "OVERDUE");
|
||||
$this->assertCount(1, $res);
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the getCounterMetrics method
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getCounterMetrics()
|
||||
* @test
|
||||
*/
|
||||
public function it_tests_get_counter_metrics()
|
||||
{
|
||||
$this->createInbox();
|
||||
$inbox = new Inbox();
|
||||
$res = $inbox->getCounterMetrics();
|
||||
$this->assertTrue($res > 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ class PausedTest extends TestCase
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
Delegation::truncate();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -911,4 +912,19 @@ class PausedTest extends TestCase
|
||||
$res = $paused->getCasesRisk($process1->PRO_ID, null, null, 'OVERDUE');
|
||||
$this->assertCount(1, $res);
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the getCounterMetrics() method
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getCounterMetrics()
|
||||
* @test
|
||||
*/
|
||||
public function it_tests_get_counter_metrics()
|
||||
{
|
||||
$this->createMultiplePaused(3);
|
||||
$paused = new Paused();
|
||||
|
||||
$res = $paused->getCounterMetrics();
|
||||
$this->assertTrue($res > 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ class UnassignedTest extends TestCase
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
Delegation::truncate();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -951,4 +952,18 @@ class UnassignedTest extends TestCase
|
||||
$res = $unassigned->getCasesRisk($process1->PRO_ID, null, null, 'OVERDUE');
|
||||
$this->assertCount(1, $res);
|
||||
}
|
||||
|
||||
/**
|
||||
* This the getCounterMetrics method
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getCounterMetrics()
|
||||
* @test
|
||||
*/
|
||||
public function it_tests_get_counter_metrics()
|
||||
{
|
||||
$this->createSelfServiceUserOrGroup();
|
||||
$unassigned = new Unassigned;
|
||||
$result = $unassigned->getCounterMetrics();
|
||||
$this->assertTrue($result > 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1154,7 +1154,11 @@ class DelegationTest extends TestCase
|
||||
*/
|
||||
public function it_should_search_and_filter_by_app_title()
|
||||
{
|
||||
$delegations = factory(Delegation::class, 1)->states('foreign_keys')->create();
|
||||
$delegations = factory(Delegation::class, 1)->states('foreign_keys')->create([
|
||||
'APP_NUMBER' => function () {
|
||||
return factory(Application::class)->create()->APP_NUMBER;
|
||||
}
|
||||
]);
|
||||
$title = $delegations->last()->DEL_TITLE;
|
||||
// We need to commit the records inserted because is needed for the "fulltext" index
|
||||
DB::commit();
|
||||
@@ -3596,4 +3600,83 @@ class DelegationTest extends TestCase
|
||||
$res = $table->joinApplication()->participatedUser($table->USR_ID)->get();
|
||||
$this->assertCount(1, $res);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the scopeInboxMetrics
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Delegation::scopeInboxMetrics()
|
||||
* @test
|
||||
*/
|
||||
public function it_tests_scope_inbox_metrics()
|
||||
{
|
||||
$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,
|
||||
]);
|
||||
$res = $table->inboxMetrics()->get();
|
||||
$this->assertCount(1, $res);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the scopeDraftMetrics
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Delegation::scopeDraftMetrics()
|
||||
* @test
|
||||
*/
|
||||
public function it_tests_scope_draft_metrics()
|
||||
{
|
||||
$application = factory(Application::class)->states('draft')->create();
|
||||
$table = factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'APP_UID' => $application->APP_UID,
|
||||
]);
|
||||
$res = $table->draftMetrics()->get();
|
||||
$this->assertCount(1, $res);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the scopePausedMetrics
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Delegation::scopePausedMetrics()
|
||||
* @test
|
||||
*/
|
||||
public function it_tests_scope_paused_metrics()
|
||||
{
|
||||
$application = factory(Application::class)->states('paused')->create();
|
||||
$appDelay = factory(AppDelay::class)->states('paused_foreign_keys')->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'APP_UID' => $application->APP_UID,
|
||||
]);
|
||||
$table = factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'APP_UID' => $application->APP_UID,
|
||||
'DEL_INDEX' => $appDelay->APP_DEL_INDEX,
|
||||
]);
|
||||
$res = $table->pausedMetrics()->get();
|
||||
$this->assertCount(1, $res);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the scopeSelfServiceMetrics
|
||||
*
|
||||
* @covers \ProcessMaker\Model\Delegation::scopeSelfServiceMetrics()
|
||||
* @test
|
||||
*/
|
||||
public function it_tests_scope_self_service_metrics()
|
||||
{
|
||||
$application = factory(Application::class)->states('paused')->create();
|
||||
$task = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
|
||||
]);
|
||||
$delegation = factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'APP_UID' => $application->APP_UID,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_ID' => 0,
|
||||
]);
|
||||
$res = $delegation->selfServiceMetrics()->get();
|
||||
$this->assertCount(1, $res);
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,13 @@ use Luracast\Restler\Defaults;
|
||||
use Luracast\Restler\HumanReadableCache;
|
||||
use Maveriks\Extension\Restler;
|
||||
use ProcessMaker\BusinessModel\Cases\Unassigned;
|
||||
use ProcessMaker\Model\AppDelay;
|
||||
use ProcessMaker\Model\Application as ApplicationModel;
|
||||
use ProcessMaker\Model\Delegation;
|
||||
use ProcessMaker\Model\Process;
|
||||
use ProcessMaker\Model\Task;
|
||||
use ProcessMaker\Model\TaskUser;
|
||||
use ProcessMaker\Model\User;
|
||||
use ProcessMaker\Services\Api\Metrics;
|
||||
use ReflectionClass;
|
||||
use Tests\TestCase;
|
||||
@@ -31,6 +38,7 @@ class MetricsTest extends TestCase
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
Delegation::truncate();
|
||||
}
|
||||
/**
|
||||
* Initialize Rest API.
|
||||
@@ -80,6 +88,8 @@ class MetricsTest extends TestCase
|
||||
*/
|
||||
public function it_tests_get_counters_list_method_empty_lists()
|
||||
{
|
||||
ApplicationModel::truncate();
|
||||
|
||||
$user = factory(\ProcessMaker\Model\User::class)->create();
|
||||
$this->initializeRestApi($user->USR_UID);
|
||||
|
||||
@@ -154,4 +164,560 @@ class MetricsTest extends TestCase
|
||||
$res = $metrics->getCountersList();
|
||||
$this->assertNotEmpty($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the getProcessTotalCases method with inbox
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_tests_get_process_total_cases_inbox()
|
||||
{
|
||||
factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'DEL_PREVIOUS' => 1,
|
||||
'DEL_INDEX' => 2,
|
||||
]);
|
||||
$metrics = new Metrics();
|
||||
$res = $metrics->getProcessTotalCases('inbox');
|
||||
$this->assertNotEmpty($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the getProcessTotalCases method with draft
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_tests_get_process_total_cases_draft()
|
||||
{
|
||||
$application = factory(ApplicationModel::class)->states('draft')->create();
|
||||
factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'DEL_INDEX' => 1,
|
||||
'USR_UID' => $application->APP_INIT_USER,
|
||||
'USR_ID' => $application->APP_INIT_USER_ID,
|
||||
'APP_UID' => $application->APP_UID,
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
]);
|
||||
$metrics = new Metrics();
|
||||
$res = $metrics->getProcessTotalCases('draft');
|
||||
$this->assertNotEmpty($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the getProcessTotalCases method with paused
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_tests_get_process_total_cases_paused()
|
||||
{
|
||||
$process1 = factory(Process::class)->create(
|
||||
['PRO_CATEGORY' => '1']
|
||||
);
|
||||
$process2 = factory(Process::class)->create(
|
||||
['PRO_CATEGORY' => '2']
|
||||
);
|
||||
$user = factory(User::class)->create();
|
||||
$task = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => '',
|
||||
'TAS_GROUP_VARIABLE' => '',
|
||||
'PRO_UID' => $process1->PRO_UID,
|
||||
'TAS_TYPE' => 'NORMAL'
|
||||
]);
|
||||
$application1 = factory(ApplicationModel::class)->create();
|
||||
$application2 = factory(ApplicationModel::class)->create();
|
||||
factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application1->APP_NUMBER,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'CLOSED',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process1->PRO_ID,
|
||||
'PRO_UID' => $process1->PRO_UID,
|
||||
'DEL_PREVIOUS' => 0,
|
||||
'DEL_INDEX' => 1
|
||||
]);
|
||||
$delegation1 = factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application1->APP_NUMBER,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'CLOSED',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process1->PRO_ID,
|
||||
'PRO_UID' => $process1->PRO_UID,
|
||||
'DEL_PREVIOUS' => 1,
|
||||
'DEL_INDEX' => 2
|
||||
]);
|
||||
factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application2->APP_NUMBER,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process2->PRO_ID,
|
||||
'PRO_UID' => $process2->PRO_UID,
|
||||
'DEL_PREVIOUS' => 0,
|
||||
'DEL_INDEX' => 1
|
||||
]);
|
||||
$delegation2 = factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application2->APP_NUMBER,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process2->PRO_ID,
|
||||
'PRO_UID' => $process2->PRO_UID,
|
||||
'DEL_PREVIOUS' => 1,
|
||||
'DEL_INDEX' => 2
|
||||
]);
|
||||
factory(AppDelay::class, 5)->create([
|
||||
'APP_DELEGATION_USER' => $user->USR_UID,
|
||||
'PRO_UID' => $process2->PRO_UID,
|
||||
'APP_NUMBER' => $delegation1->APP_NUMBER,
|
||||
'APP_DEL_INDEX' => $delegation1->DEL_INDEX,
|
||||
'APP_DISABLE_ACTION_USER' => 0,
|
||||
'APP_TYPE' => 'PAUSE'
|
||||
]);
|
||||
factory(AppDelay::class, 5)->create([
|
||||
'APP_DELEGATION_USER' => $user->USR_UID,
|
||||
'PRO_UID' => $process2->PRO_UID,
|
||||
'APP_NUMBER' => $delegation2->APP_NUMBER,
|
||||
'APP_DEL_INDEX' => $delegation2->DEL_INDEX,
|
||||
'APP_DISABLE_ACTION_USER' => 0,
|
||||
'APP_TYPE' => 'PAUSE'
|
||||
]);
|
||||
$metrics = new Metrics();
|
||||
$res = $metrics->getProcessTotalCases('paused');
|
||||
$this->assertNotEmpty($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the getProcessTotalCases method with unassigned
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_tests_get_process_total_cases_unassigned()
|
||||
{
|
||||
$user = factory(\ProcessMaker\Model\User::class)->create();
|
||||
$process = factory(Process::class)->create();
|
||||
$application = factory(ApplicationModel::class)->create([
|
||||
'APP_STATUS_ID' => 2
|
||||
]);
|
||||
$task = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
|
||||
'TAS_GROUP_VARIABLE' => '',
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'PRO_ID' => $process->PRO_ID,
|
||||
]);
|
||||
factory(TaskUser::class)->create([
|
||||
'TAS_UID' => $task->TAS_UID,
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'TU_RELATION' => 1,
|
||||
'TU_TYPE' => 1
|
||||
]);
|
||||
factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'PRO_ID' => $process->PRO_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_ID' => 0,
|
||||
'DEL_DELEGATE_DATE' => date('Y-m-d H:i:s', strtotime("-1 year"))
|
||||
]);
|
||||
$metrics = new Metrics();
|
||||
$res = $metrics->getProcessTotalCases('unassigned');
|
||||
$this->assertNotEmpty($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the getTotalCasesByRange method with inbox
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_tests_get_total_cases_by_range_inbox()
|
||||
{
|
||||
factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'DEL_PREVIOUS' => 1,
|
||||
'DEL_INDEX' => 2,
|
||||
]);
|
||||
$metrics = new Metrics();
|
||||
$res = $metrics->getTotalCasesByRange('inbox');
|
||||
$this->assertNotEmpty($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the getTotalCasesByRange method with draft
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_tests_get_total_cases_by_range_draft()
|
||||
{
|
||||
$application = factory(ApplicationModel::class)->states('draft')->create();
|
||||
factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'DEL_INDEX' => 1,
|
||||
'USR_UID' => $application->APP_INIT_USER,
|
||||
'USR_ID' => $application->APP_INIT_USER_ID,
|
||||
'APP_UID' => $application->APP_UID,
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
]);
|
||||
$metrics = new Metrics();
|
||||
$res = $metrics->getTotalCasesByRange('draft');
|
||||
$this->assertNotEmpty($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the getTotalCasesByRange method with paused
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_tests_get_total_cases_by_range_paused()
|
||||
{
|
||||
$process1 = factory(Process::class)->create(
|
||||
['PRO_CATEGORY' => '1']
|
||||
);
|
||||
$process2 = factory(Process::class)->create(
|
||||
['PRO_CATEGORY' => '2']
|
||||
);
|
||||
$user = factory(User::class)->create();
|
||||
$task = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => '',
|
||||
'TAS_GROUP_VARIABLE' => '',
|
||||
'PRO_UID' => $process1->PRO_UID,
|
||||
'TAS_TYPE' => 'NORMAL'
|
||||
]);
|
||||
$application1 = factory(ApplicationModel::class)->create();
|
||||
$application2 = factory(ApplicationModel::class)->create();
|
||||
factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application1->APP_NUMBER,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'CLOSED',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process1->PRO_ID,
|
||||
'PRO_UID' => $process1->PRO_UID,
|
||||
'DEL_PREVIOUS' => 0,
|
||||
'DEL_INDEX' => 1
|
||||
]);
|
||||
$delegation1 = factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application1->APP_NUMBER,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'CLOSED',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process1->PRO_ID,
|
||||
'PRO_UID' => $process1->PRO_UID,
|
||||
'DEL_PREVIOUS' => 1,
|
||||
'DEL_INDEX' => 2
|
||||
]);
|
||||
factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application2->APP_NUMBER,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process2->PRO_ID,
|
||||
'PRO_UID' => $process2->PRO_UID,
|
||||
'DEL_PREVIOUS' => 0,
|
||||
'DEL_INDEX' => 1
|
||||
]);
|
||||
$delegation2 = factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application2->APP_NUMBER,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process2->PRO_ID,
|
||||
'PRO_UID' => $process2->PRO_UID,
|
||||
'DEL_PREVIOUS' => 1,
|
||||
'DEL_INDEX' => 2
|
||||
]);
|
||||
factory(AppDelay::class, 5)->create([
|
||||
'APP_DELEGATION_USER' => $user->USR_UID,
|
||||
'PRO_UID' => $process2->PRO_UID,
|
||||
'APP_NUMBER' => $delegation1->APP_NUMBER,
|
||||
'APP_DEL_INDEX' => $delegation1->DEL_INDEX,
|
||||
'APP_DISABLE_ACTION_USER' => 0,
|
||||
'APP_TYPE' => 'PAUSE'
|
||||
]);
|
||||
factory(AppDelay::class, 5)->create([
|
||||
'APP_DELEGATION_USER' => $user->USR_UID,
|
||||
'PRO_UID' => $process2->PRO_UID,
|
||||
'APP_NUMBER' => $delegation2->APP_NUMBER,
|
||||
'APP_DEL_INDEX' => $delegation2->DEL_INDEX,
|
||||
'APP_DISABLE_ACTION_USER' => 0,
|
||||
'APP_TYPE' => 'PAUSE'
|
||||
]);
|
||||
$metrics = new Metrics();
|
||||
$res = $metrics->getTotalCasesByRange('paused');
|
||||
$this->assertNotEmpty($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the getTotalCasesByRange method with unassigned
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_tests_get_total_cases_by_range_unassigned()
|
||||
{
|
||||
$user = factory(\ProcessMaker\Model\User::class)->create();
|
||||
$process = factory(Process::class)->create();
|
||||
$application = factory(ApplicationModel::class)->create([
|
||||
'APP_STATUS_ID' => 2
|
||||
]);
|
||||
$task = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
|
||||
'TAS_GROUP_VARIABLE' => '',
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'PRO_ID' => $process->PRO_ID,
|
||||
]);
|
||||
factory(TaskUser::class)->create([
|
||||
'TAS_UID' => $task->TAS_UID,
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'TU_RELATION' => 1,
|
||||
'TU_TYPE' => 1
|
||||
]);
|
||||
factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'PRO_ID' => $process->PRO_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_ID' => 0,
|
||||
'DEL_DELEGATE_DATE' => date('Y-m-d H:i:s', strtotime("-1 year"))
|
||||
]);
|
||||
$metrics = new Metrics();
|
||||
$res = $metrics->getTotalCasesByRange('unassigned');
|
||||
$this->assertNotEmpty($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the getCasesRiskByProcess method with inbox
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_tests_get_cases_risk_by_process_inbox()
|
||||
{
|
||||
$process = factory(Process::class)->create();
|
||||
$delegation = factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'DEL_PREVIOUS' => 1,
|
||||
'DEL_INDEX' => 2,
|
||||
'PRO_ID' => $process->PRO_ID,
|
||||
'DEL_RISK_DATE' => date('Y-m-d H:i:s'),
|
||||
'DEL_TASK_DUE_DATE' => date('Y-m-d H:i:s', strtotime("+1 hour"))
|
||||
]);
|
||||
$metrics = new Metrics();
|
||||
$res = $metrics->getCasesRiskByProcess('inbox', $delegation->PRO_ID, null, null, 'AT_RISK');
|
||||
$this->assertNotEmpty($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the getCasesRiskByProcess method with draft
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_tests_get_cases_risk_by_process_draft()
|
||||
{
|
||||
$process = factory(Process::class)->create();
|
||||
$application = factory(ApplicationModel::class)->states('draft')->create();
|
||||
$delegation = factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'DEL_INDEX' => 1,
|
||||
'USR_UID' => $application->APP_INIT_USER,
|
||||
'USR_ID' => $application->APP_INIT_USER_ID,
|
||||
'APP_UID' => $application->APP_UID,
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'PRO_ID' => $process->PRO_ID,
|
||||
'DEL_RISK_DATE' => date('Y-m-d H:i:s'),
|
||||
'DEL_TASK_DUE_DATE' => date('Y-m-d H:i:s', strtotime("+1 hour"))
|
||||
]);
|
||||
$metrics = new Metrics();
|
||||
$res = $metrics->getCasesRiskByProcess('draft', $delegation->PRO_ID, null, null, 'AT_RISK');
|
||||
$this->assertNotEmpty($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the getCasesRiskByProcess method with paused
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_tests_get_cases_risk_by_process_paused()
|
||||
{
|
||||
$process1 = factory(Process::class)->create(
|
||||
['PRO_CATEGORY' => '1']
|
||||
);
|
||||
$process2 = factory(Process::class)->create(
|
||||
['PRO_CATEGORY' => '2']
|
||||
);
|
||||
$user = factory(User::class)->create();
|
||||
$task = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => '',
|
||||
'TAS_GROUP_VARIABLE' => '',
|
||||
'PRO_UID' => $process1->PRO_UID,
|
||||
'TAS_TYPE' => 'NORMAL'
|
||||
]);
|
||||
$application1 = factory(ApplicationModel::class)->create();
|
||||
$application2 = factory(ApplicationModel::class)->create();
|
||||
factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application1->APP_NUMBER,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'CLOSED',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process1->PRO_ID,
|
||||
'PRO_UID' => $process1->PRO_UID,
|
||||
'DEL_PREVIOUS' => 0,
|
||||
'DEL_INDEX' => 1,
|
||||
'DEL_RISK_DATE' => date('Y-m-d H:i:s'),
|
||||
'DEL_TASK_DUE_DATE' => date('Y-m-d H:i:s', strtotime("+1 hour"))
|
||||
]);
|
||||
$delegation1 = factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application1->APP_NUMBER,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'CLOSED',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process1->PRO_ID,
|
||||
'PRO_UID' => $process1->PRO_UID,
|
||||
'DEL_PREVIOUS' => 1,
|
||||
'DEL_INDEX' => 2,
|
||||
'DEL_RISK_DATE' => date('Y-m-d H:i:s'),
|
||||
'DEL_TASK_DUE_DATE' => date('Y-m-d H:i:s', strtotime("+1 hour"))
|
||||
]);
|
||||
factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application2->APP_NUMBER,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process2->PRO_ID,
|
||||
'PRO_UID' => $process2->PRO_UID,
|
||||
'DEL_PREVIOUS' => 0,
|
||||
'DEL_INDEX' => 1,
|
||||
'DEL_RISK_DATE' => date('Y-m-d H:i:s'),
|
||||
'DEL_TASK_DUE_DATE' => date('Y-m-d H:i:s', strtotime("+1 hour"))
|
||||
]);
|
||||
$delegation2 = factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application2->APP_NUMBER,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process2->PRO_ID,
|
||||
'PRO_UID' => $process2->PRO_UID,
|
||||
'DEL_PREVIOUS' => 1,
|
||||
'DEL_INDEX' => 2,
|
||||
'DEL_RISK_DATE' => date('Y-m-d H:i:s'),
|
||||
'DEL_TASK_DUE_DATE' => date('Y-m-d H:i:s', strtotime("+1 hour"))
|
||||
]);
|
||||
factory(AppDelay::class, 5)->create([
|
||||
'APP_DELEGATION_USER' => $user->USR_UID,
|
||||
'PRO_UID' => $process2->PRO_UID,
|
||||
'APP_NUMBER' => $delegation1->APP_NUMBER,
|
||||
'APP_DEL_INDEX' => $delegation1->DEL_INDEX,
|
||||
'APP_DISABLE_ACTION_USER' => 0,
|
||||
'APP_TYPE' => 'PAUSE'
|
||||
]);
|
||||
factory(AppDelay::class, 5)->create([
|
||||
'APP_DELEGATION_USER' => $user->USR_UID,
|
||||
'PRO_UID' => $process2->PRO_UID,
|
||||
'APP_NUMBER' => $delegation2->APP_NUMBER,
|
||||
'APP_DEL_INDEX' => $delegation2->DEL_INDEX,
|
||||
'APP_DISABLE_ACTION_USER' => 0,
|
||||
'APP_TYPE' => 'PAUSE'
|
||||
]);
|
||||
$metrics = new Metrics();
|
||||
$res = $metrics->getCasesRiskByProcess('paused', $delegation1->PRO_ID, null, null, 'AT_RISK');
|
||||
$this->assertNotEmpty($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the getCasesRiskByProcess method with unassigned
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_tests_get_cases_risk_by_process_unassigned()
|
||||
{
|
||||
$user = factory(\ProcessMaker\Model\User::class)->create();
|
||||
$process = factory(Process::class)->create();
|
||||
$application = factory(ApplicationModel::class)->create([
|
||||
'APP_STATUS_ID' => 2
|
||||
]);
|
||||
$task = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
|
||||
'TAS_GROUP_VARIABLE' => '',
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'PRO_ID' => $process->PRO_ID,
|
||||
]);
|
||||
factory(TaskUser::class)->create([
|
||||
'TAS_UID' => $task->TAS_UID,
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'TU_RELATION' => 1,
|
||||
'TU_TYPE' => 1
|
||||
]);
|
||||
$delegation = factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'PRO_ID' => $process->PRO_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_ID' => 0,
|
||||
'DEL_DELEGATE_DATE' => date('Y-m-d H:i:s', strtotime("-1 year")),
|
||||
'DEL_RISK_DATE' => date('Y-m-d H:i:s'),
|
||||
'DEL_TASK_DUE_DATE' => date('Y-m-d H:i:s', strtotime("+1 hour"))
|
||||
]);
|
||||
unset($RBAC);
|
||||
$metrics = new Metrics();
|
||||
$res = $metrics->getCasesRiskByProcess('unassigned', $delegation->PRO_ID, null, null, 'AT_RISK');
|
||||
$this->assertNotEmpty($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the getProcessTotalCases method with exception
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_tests_get_process_total_cases_exception()
|
||||
{
|
||||
factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'DEL_PREVIOUS' => 1,
|
||||
'DEL_INDEX' => 2,
|
||||
]);
|
||||
$metrics = new Metrics();
|
||||
$this->expectExceptionMessage("Undefined variable: list");
|
||||
$metrics->getProcessTotalCases(12, 123, "asda");
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the getTotalCasesByRange method with exception
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_tests_get_total_cases_by_range_exception()
|
||||
{
|
||||
factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'DEL_PREVIOUS' => 1,
|
||||
'DEL_INDEX' => 2,
|
||||
]);
|
||||
$metrics = new Metrics();
|
||||
$this->expectExceptionMessage("Undefined variable: list");
|
||||
$metrics->getTotalCasesByRange(12, 123, "asda");
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the getCasesRiskByProcess method with exception
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_tests_get_counters_list_exception()
|
||||
{
|
||||
factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'DEL_PREVIOUS' => 1,
|
||||
'DEL_INDEX' => 2,
|
||||
]);
|
||||
$metrics = new Metrics();
|
||||
$this->expectExceptionMessage("Undefined variable: list");
|
||||
$metrics->getCasesRiskByProcess(12, 123, "asda");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user