Merged in feature/PMCORE-3049 (pull request #7964)

PMCORE-3049 PRD

Approved-by: Henry Jonathan Quispe Quispe
Approved-by: Julio Cesar Laura Avendaño
This commit is contained in:
Paula Quispe
2021-09-06 20:40:34 +00:00
committed by Julio Cesar Laura Avendaño
214 changed files with 29643 additions and 4643 deletions

View File

@@ -630,7 +630,6 @@ class CasesTest extends TestCase
// Asserts the emails of both users are contained in the result
$this->assertRegExp("/{$user->USR_EMAIL}/", $result["to"]);
$this->assertRegExp("/{$user2->USR_EMAIL}/", $result["to"]);
}
/**
@@ -735,7 +734,6 @@ class CasesTest extends TestCase
// Asserts the emails of both users are contained in the result
$this->assertRegExp("/{$user->USR_EMAIL}/", $result["to"]);
$this->assertRegExp("/{$user2->USR_EMAIL}/", $result["to"]);
}
/**

View File

@@ -90,6 +90,7 @@ class ExecuteQueryTest extends TestCase
*/
public function it_should_insert_a_record_in_the_category_table_using_the_execute_query_method()
{
$this->expectException(SQLException::class);
$database = env('DB_DATABASE');
$faker = Factory::create();
$uid = G::generateUniqueID();
@@ -132,6 +133,7 @@ class ExecuteQueryTest extends TestCase
*/
public function it_should_replace_a_record_in_the_category_table_using_the_execute_query_method()
{
$this->expectException(SQLException::class);
$database = env('DB_DATABASE');
$faker = Factory::create();
$id = $faker->unique()->numberBetween(1, 10000000);
@@ -168,6 +170,7 @@ class ExecuteQueryTest extends TestCase
*/
public function it_should_update_a_record_in_the_category_table_using_the_execute_query_method()
{
$this->expectException(SQLException::class);
$database = env('DB_DATABASE');
$faker = Factory::create();
$id = $faker->unique()->numberBetween(1, 10000000);
@@ -200,7 +203,7 @@ class ExecuteQueryTest extends TestCase
*/
public function it_should_delete_a_record_in_the_category_table_using_the_execute_query_method()
{
$this->expectException(SQLException::class);
$database = env('DB_DATABASE');
$category = factory(ProcessCategory::class)->create();

View File

@@ -96,9 +96,9 @@ class CasesMenuHighlightTest extends TestCase
// Check if the object is valid
$this->assertNotEmpty($result);
$this->assertArrayHasKey('item', $result[0]);
$this->assertArrayHasKey('highlight', $result[0]);
$this->assertEquals('CASES_SELFSERVICE', $result[0]['item']);
$this->assertEquals(true, $result[0]['highlight']);
$this->assertArrayHasKey('item', $result[7]);
$this->assertArrayHasKey('highlight', $result[7]);
$this->assertEquals('CASES_SELFSERVICE', $result[7]['item']);
$this->assertEquals(true, $result[7]['highlight']);
}
}

View File

@@ -90,7 +90,7 @@ class EmailServerAjaxTest extends TestCase
$content = $this->requireOnceForEmailServerAjax();
$data = json_decode($content, JSON_OBJECT_AS_ARRAY);
$this->assertContains(200, $data);
$this->assertContains(500, $data);
}
/**

View File

@@ -2,10 +2,12 @@
namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases;
use Exception;
use G;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use ProcessMaker\BusinessModel\Cases\AbstractCases;
use ProcessMaker\Model\Application;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\Process;
use ProcessMaker\Model\ProcessCategory;
use ProcessMaker\Model\Task;
@@ -19,6 +21,22 @@ class AbstractCasesTest extends TestCase
{
use DatabaseTransactions;
/**
* This check the getter and setter related to the category
*
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCategoryId()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getCategoryId()
* @test
*/
public function it_return_set_get_category()
{
$category = factory(ProcessCategory::class)->create();
$absCases = new AbstractCases();
$absCases->setCategoryId($category->CATEGORY_ID);
$actual = $absCases->getCategoryId();
$this->assertEquals($category->CATEGORY_ID, $actual);
}
/**
* This check the getter and setter related to the category
*
@@ -26,7 +44,7 @@ class AbstractCasesTest extends TestCase
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getCategoryUid()
* @test
*/
public function it_return_set_get_category()
public function it_return_set_get_category_uid()
{
$category = factory(ProcessCategory::class)->create();
$absCases = new AbstractCases();
@@ -93,6 +111,38 @@ class AbstractCasesTest extends TestCase
$this->assertEquals($users->USR_ID, $actual);
}
/**
* This check the getter and setter related to the user completed
*
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setUserCompletedId()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getUserCompletedId()
* @test
*/
public function it_return_set_get_user_completed()
{
$users = factory(User::class)->create();
$absCases = new AbstractCases();
$absCases->setUserCompletedId($users->USR_ID);
$actual = $absCases->getUserCompletedId();
$this->assertEquals($users->USR_ID, $actual);
}
/**
* This check the getter and setter related to the user started
*
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setUserStartedId()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getUserStartedId()
* @test
*/
public function it_return_set_get_user_started()
{
$users = factory(User::class)->create();
$absCases = new AbstractCases();
$absCases->setUserStartedId($users->USR_ID);
$actual = $absCases->getUserStartedId();
$this->assertEquals($users->USR_ID, $actual);
}
/**
* This check the getter and setter related to the priority
*
@@ -131,6 +181,19 @@ class AbstractCasesTest extends TestCase
$this->assertNotEmpty($actual);
}
/**
* This test the exception setPriorities
*
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setPriorities()
* @test
*/
public function it_return_exception_priorities()
{
$this->expectException(Exception::class);
$absCases = new AbstractCases();
$absCases->setPriorities(['INVALID_VALUE']);
}
/**
* This check the getter and setter related to the case number
*
@@ -208,6 +271,19 @@ class AbstractCasesTest extends TestCase
}
}
/**
* This test the exception setInboxStatus
*
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setInboxStatus()
* @test
*/
public function it_return_exception_inbox_status()
{
$this->expectException(Exception::class);
$absCases = new AbstractCases();
$absCases->setInboxStatus('INVALID_VALUE');
}
/**
* This check the getter and setter related to the participated status
*
@@ -225,6 +301,19 @@ class AbstractCasesTest extends TestCase
$this->assertEquals($arguments[$index], $actual);
}
/**
* This test the exception setParticipatedStatus
*
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setParticipatedStatus()
* @test
*/
public function it_return_exception_participated_status()
{
$this->expectException(Exception::class);
$absCases = new AbstractCases();
$absCases->setParticipatedStatus('INVALID_VALUE');
}
/**
* This check the getter and setter related to the risk status
*
@@ -242,6 +331,19 @@ class AbstractCasesTest extends TestCase
$this->assertEquals($arguments[$index], $actual);
}
/**
* This test the exception setRiskStatus
*
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setRiskStatus()
* @test
*/
public function it_return_exception_risk_status()
{
$this->expectException(Exception::class);
$absCases = new AbstractCases();
$absCases->setRiskStatus('INVALID_VALUE');
}
/**
* This check the getter and setter related to the case status
*
@@ -258,9 +360,22 @@ class AbstractCasesTest extends TestCase
$actual = $absCases->getCaseStatus();
$this->assertEquals($index, $actual);
// Incorrect canceled status
$absCases->setCaseStatuses(['CANCELLED']);
$actual = $absCases->getCaseStatuses();
$this->assertEquals([4], $actual);
$absCases->setCaseStatus('CANCELLED');
$actual = $absCases->getCaseStatus();
$this->assertEquals(4, $actual);
}
/**
* This test the exception setCaseStatus
*
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCaseStatus()
* @test
*/
public function it_return_exception_case_status()
{
$this->expectException(Exception::class);
$absCases = new AbstractCases();
$absCases->setCaseStatus('INVALID_VALUE');
}
/**
@@ -284,6 +399,19 @@ class AbstractCasesTest extends TestCase
$this->assertNotEmpty($actual);
}
/**
* This test the exception setCaseStatuses
*
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCaseStatuses()
* @test
*/
public function it_return_exception_case_statuses()
{
$this->expectException(Exception::class);
$absCases = new AbstractCases();
$absCases->setCaseStatuses(['INVALID_VALUE']);
}
/**
* This check the getter and setter related to the case
*
@@ -500,7 +628,7 @@ class AbstractCasesTest extends TestCase
}
/**
* This check the getter and setter related to the oldest than date
* This check the getter and setter related to the order by column
*
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setOrderByColumn()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getOrderByColumn()
@@ -513,6 +641,20 @@ class AbstractCasesTest extends TestCase
$absCases->setOrderByColumn($text);
$actual = $absCases->getOrderByColumn();
$this->assertEquals($text, $actual);
}
/**
* This test the exception setOrderByColumn
*
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setOrderByColumn()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getOrderByColumn()
* @test
*/
public function it_return_exception_order_by_column()
{
$this->expectException(Exception::class);
$absCases = new AbstractCases();
$absCases->setOrderByColumn('INVALID');
}
/**
@@ -532,6 +674,19 @@ class AbstractCasesTest extends TestCase
$this->assertEquals($arguments[$index], $actual);
}
/**
* This test the exception setOrderDirection
*
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setOrderDirection()
* @test
*/
public function it_return_exception_order_direction()
{
$this->expectException(Exception::class);
$absCases = new AbstractCases();
$absCases->setOrderDirection('INVALID_VALUE');
}
/**
* This check the getter and setter related to the paged, offset and limit
*
@@ -618,39 +773,8 @@ class AbstractCasesTest extends TestCase
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setUserId()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCaseNumber()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCaseTitle()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getProcessId()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getTaskId()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getUserId()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getCaseNumber()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getCaseTitle()
*
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setParticipatedStatus()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCaseStatus()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setStartCaseFrom()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setStartCaseTo()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setFinishCaseFrom()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setFinishCaseTo()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getParticipatedStatus()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getCaseStatus()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getStartCaseFrom()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getStartCaseTo()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getFinishCaseFrom()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getFinishCaseTo()
*
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setFilterCases()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCaseStatuses()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setProperties()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setDelegateFrom()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setDelegateTo()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setDueFrom()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setDueTo()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getFilterCases()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getCaseStatuses()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getDelegateFrom()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getDelegateTo()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getDueFrom()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getDueTo()
*
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCasesNumbers()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setRangeCasesFromTo()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCaseUid()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCasesUids()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setOrderByColumn()
@@ -658,6 +782,14 @@ class AbstractCasesTest extends TestCase
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setPaged()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setOffset()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setLimit()
*
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getProcessId()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getTaskId()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getUserId()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getCaseNumber()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getCaseTitle()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getCasesNumbers()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getRangeCasesFromTo()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getCaseUid()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getCasesUids()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getOrderByColumn()
@@ -671,23 +803,13 @@ class AbstractCasesTest extends TestCase
{
$absCases = new AbstractCases();
$properties = [
// Tasks - Cases
// Filters that works for all list
'process' => rand(),
'task' => rand(),
'user' => rand(),
'caseNumber' => rand(),
'caseTitle' => G::generateUniqueID(),
// Home - Search
'caseStatuses' => ['TO_DO','DRAFT'],
'filterCases'=> '1,3-5,8,10-15',
// Home - My cases
'filter'=> 'STARTED',
'caseStatus' => 'TO_DO',
'startCaseFrom' => date('Y-m-d'),
'startCaseTo' => date('Y-m-d'),
'finishCaseFrom' => date('Y-m-d'),
'finishCaseTo' => date('Y-m-d'),
// Other
'caseLink' => G::generateUniqueID(),
'appUidCheck' => [G::generateUniqueID()],
'sort' => 'APP_NUMBER',
@@ -708,37 +830,10 @@ class AbstractCasesTest extends TestCase
$this->assertEquals($properties['caseNumber'], $actual);
$actual = $absCases->getCaseTitle();
$this->assertEquals($properties['caseTitle'], $actual);
// Home - Search
$actual = $absCases->getCaseStatuses();
$this->assertNotEmpty($actual);
$actual = $absCases->getFilterCases();
$this->assertEmpty($actual);
$actual = $absCases->getCasesNumbers();
$this->assertEmpty($actual);
$this->assertNotEmpty($actual);
$actual = $absCases->getRangeCasesFromTo();
$this->assertEmpty($actual);
$actual = $absCases->getStartCaseFrom();
$this->assertEmpty($actual);
$actual = $absCases->getStartCaseTo();
$this->assertEmpty($actual);
$actual = $absCases->getFinishCaseFrom();
$this->assertEmpty($actual);
$actual = $absCases->getFinishCaseTo();
$this->assertEmpty($actual);
// Home - My cases
$actual = $absCases->getParticipatedStatus();
$this->assertEmpty($actual);
$actual = $absCases->getCaseStatus();
$this->assertEmpty($actual);
$actual = $absCases->getStartCaseFrom();
$this->assertEmpty($actual);
$actual = $absCases->getStartCaseTo();
$this->assertEmpty($actual);
$actual = $absCases->getFinishCaseFrom();
$this->assertEmpty($actual);
$actual = $absCases->getFinishCaseTo();
$this->assertEmpty($actual);
// Other
$this->assertNotEmpty($actual);
$actual = $absCases->getCaseUid();
$this->assertEquals($properties['caseLink'], $actual);
$actual = $absCases->getCasesUids();
@@ -765,8 +860,15 @@ class AbstractCasesTest extends TestCase
{
$absCases = new AbstractCases();
$dueDate = date('Y-m-d');
// Review overdue
$result = $absCases->getTaskColor($dueDate);
$this->assertNotEmpty($result);
$absCases = new AbstractCases();
$dueDate = date('Y-m-d');
// Review on-time
$result = $absCases->getTaskColor($dueDate,'' ,'2000-01-01');
$this->assertNotEmpty($result);
}
/**
@@ -783,7 +885,29 @@ class AbstractCasesTest extends TestCase
{"tas_id":'.$task[0]->TAS_ID.', "user_id":1, "due_date":"2020-12-04 19:11:14"},
{"tas_id":'.$task[1]->TAS_ID.', "user_id":2, "due_date":"2020-12-04 19:12:45"}
]';
// Default values
$result = $absCases->prepareTaskPending($pending);
$this->assertNotEmpty($result);
// Thread users
$result = $absCases->prepareTaskPending($pending, false);
$this->assertNotEmpty($result);
}
/**
* This get thread information
*
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::threadInformation()
* @test
*/
public function it_return_thread_information()
{
$delegation = factory(Delegation::class)->states('foreign_keys')->create();
$taskPending = Delegation::getLastThread($delegation->APP_NUMBER);
$absCases = new AbstractCases();
foreach ($taskPending as $thread) {
$thread['APP_STATUS'] = 'TO_DO';
$result = $absCases->threadInformation($thread, true, true);
$this->assertNotEmpty($result);
}
}
}

View File

@@ -39,6 +39,23 @@ class BatchRoutingTest extends TestCase
return $delegation;
}
/**
* This test the extended function, currently are not implemented
*
* @covers \ProcessMaker\BusinessModel\Cases\BatchRouting::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\BatchRouting::getData()
* @test
*/
public function it_test_extended_methods()
{
// Create new BatchRouting object
$consolidated = new BatchRouting();
$result = $consolidated->getColumnsView();
$this->assertEmpty($result);
$result = $consolidated->getData();
$this->assertEmpty($result);
}
/**
* This checks the counters is working properly in batch routing
*
@@ -49,7 +66,7 @@ class BatchRoutingTest extends TestCase
{
// Create factories related to the consolidated cases
$cases = $this->createConsolidated();
// Create new Draft object
// Create new batch routing object
$consolidated = new BatchRouting();
$consolidated->setUserId($cases['USR_ID']);
$consolidated->setUserUid($cases['USR_UID']);

View File

@@ -42,6 +42,23 @@ class CanceledTest extends TestCase
return $delegation;
}
/**
* This test the extended function, currently are not implemented
*
* @covers \ProcessMaker\BusinessModel\Cases\Canceled::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Canceled::getData()
* @test
*/
public function it_test_extended_methods()
{
// Create new batch Canceled object
$consolidated = new Canceled();
$result = $consolidated->getColumnsView();
$this->assertEmpty($result);
$result = $consolidated->getData();
$this->assertEmpty($result);
}
/**
* This checks the counters is working properly in canceled
*

View File

@@ -42,6 +42,18 @@ class CasesListTest extends TestCase
return $delegation;
}
/**
* This test construct
*
* @covers \ProcessMaker\BusinessModel\Cases\CasesList::__construct()
* @test
*/
public function it_test_construct()
{
$casesList = new CasesList();
$this->assertInstanceOf(CasesList::class, $casesList);
}
/**
* This test getAllCounters
*
@@ -57,4 +69,29 @@ class CasesListTest extends TestCase
$this->assertArrayHasKey('CASES_INBOX', $result);
$this->assertArrayHasKey('CASES_DRAFT', $result);
}
/**
* This test getAllCounters
*
* @covers \ProcessMaker\BusinessModel\Cases\CasesList::atLeastOne()
* @covers \ProcessMaker\BusinessModel\Cases\BatchRouting::atLeastOne()
* @covers \ProcessMaker\BusinessModel\Cases\Canceled::atLeastOne()
* @covers \ProcessMaker\BusinessModel\Cases\Completed::atLeastOne()
* @covers \ProcessMaker\BusinessModel\Cases\Draft::atLeastOne()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::atLeastOne()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::atLeastOne()
* @covers \ProcessMaker\BusinessModel\Cases\Paused::atLeastOne()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::atLeastOne()
* @test
*/
public function it_return_at_least_one()
{
$delegation = factory(Delegation::class)->states('foreign_keys')->create();
$count = new CasesList();
$result = $count->atLeastOne($delegation->USR_UID);
$this->assertNotEmpty($result);
$firstItem = head($result);
$this->assertArrayHasKey('item', $firstItem);
$this->assertArrayHasKey('highlight', $firstItem);
}
}

View File

@@ -42,6 +42,23 @@ class CompletedTest extends TestCase
return $delegation;
}
/**
* This test the extended function, currently are not implemented
*
* @covers \ProcessMaker\BusinessModel\Cases\Completed::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Completed::getData()
* @test
*/
public function it_test_extended_methods()
{
// Create new batch Completed object
$consolidated = new Completed();
$result = $consolidated->getColumnsView();
$this->assertEmpty($result);
$result = $consolidated->getData();
$this->assertEmpty($result);
}
/**
* This checks the counters is working properly in completed
*

View File

@@ -1,12 +1,17 @@
<?php
namespace Tests\unit\workflow\src\ProcessMaker\BusinessModel\Cases;
namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases;
use DateInterval;
use Datetime;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\BusinessModel\Cases\Draft;
use ProcessMaker\Model\AdditionalTables;
use ProcessMaker\Model\Application;
use ProcessMaker\Model\CaseList;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\Process;
use ProcessMaker\Model\User;
use Tests\TestCase;
@@ -156,6 +161,49 @@ class DraftTest extends TestCase
$this->assertNotEmpty($res);
}
/**
* It tests the getData method with case number 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_specific_cases()
{
// Create factories related to the draft cases
$cases = $this->createDraft();
// Create new Draft object
$draft = new Draft();
$draft->setUserId($cases['USR_ID']);
$draft->setCasesNumbers([$cases['APP_NUMBER']]);
$draft->setOrderByColumn('APP_NUMBER');
$res = $draft->getData();
$this->assertNotEmpty($res);
}
/**
* It tests the getData method with case number 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_range_cases()
{
// Create factories related to the draft cases
$cases = $this->createDraft();
// Create new Draft object
$draft = new Draft();
$draft->setUserId($cases['USR_ID']);
$rangeOfCases = $cases['APP_NUMBER'] . "-" . $cases['APP_NUMBER'];
$draft->setRangeCasesFromTo([$rangeOfCases]);
$draft->setOrderByColumn('APP_NUMBER');
$res = $draft->getData();
$this->assertNotEmpty($res);
}
/**
* It tests the getData method with taskId filter
*
@@ -219,9 +267,6 @@ class DraftTest extends TestCase
'APP_NUMBER',
'DEL_TITLE',
'PRO_TITLE',
'TAS_TITLE',
'DEL_TASK_DUE_DATE',
'DEL_DELEGATE_DATE'
];
$index = array_rand($columnsView);
// Create new Inbox object
@@ -262,4 +307,577 @@ class DraftTest extends TestCase
$this->assertEquals(1, $res);
}
/**
* It tests the getCountersByProcesses() method without filters
*
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getCountersByProcesses()
* @test
*/
public function it_should_test_get_counters_by_processes_method_no_filter()
{
$process = factory(Process::class)->create();
$process2 = factory(Process::class)->create();
$user = factory(User::class)->create();
$application1 = factory(Application::class)->states('draft')->create([
'APP_INIT_USER' => $user->USR_UID,
'APP_CUR_USER' => $user->USR_UID,
]);
$application2 = factory(Application::class)->states('draft')->create([
'APP_INIT_USER' => $user->USR_UID,
'APP_CUR_USER' => $user->USR_UID,
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 1,
'USR_UID' => $application1->APP_INIT_USER,
'USR_ID' => $user->USR_ID,
'APP_UID' => $application1->APP_UID,
'APP_NUMBER' => $application1->APP_NUMBER,
'PRO_ID' => $process->PRO_ID,
'PRO_UID' => $process->PRO_UID
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 1,
'USR_UID' => $application2->APP_INIT_USER,
'USR_ID' => $user->USR_ID,
'APP_UID' => $application2->APP_UID,
'APP_NUMBER' => $application2->APP_NUMBER,
'PRO_ID' => $process2->PRO_ID,
'PRO_UID' => $process2->PRO_UID
]);
$draft = new Draft();
$draft->setUserId($user->USR_ID);
$draft->setUserUid($user->USR_ID);
$res = $draft->getCountersByProcesses();
$this->assertCount(2, $res);
}
/**
* 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()
{
$process = factory(Process::class)->create([
'CATEGORY_ID' => 1
]);
$process2 = factory(Process::class)->create([
'CATEGORY_ID' => 2
]);
$user = factory(User::class)->create();
$application = factory(Application::class, 5)->states('draft')->create([
'APP_INIT_USER' => $user->USR_UID,
'APP_CUR_USER' => $user->USR_UID,
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 1,
'USR_UID' => $application[0]->APP_INIT_USER,
'USR_ID' => $user->USR_ID,
'APP_UID' => $application[0]->APP_UID,
'APP_NUMBER' => $application[0]->APP_NUMBER,
'PRO_ID' => $process->PRO_ID,
'PRO_UID' => $process->PRO_UID
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 1,
'USR_UID' => $application[1]->APP_INIT_USER,
'USR_ID' => $user->USR_ID,
'APP_UID' => $application[1]->APP_UID,
'APP_NUMBER' => $application[1]->APP_NUMBER,
'PRO_ID' => $process->PRO_ID,
'PRO_UID' => $process->PRO_UID
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 1,
'USR_UID' => $application[2]->APP_INIT_USER,
'USR_ID' => $user->USR_ID,
'APP_UID' => $application[2]->APP_UID,
'APP_NUMBER' => $application[2]->APP_NUMBER,
'PRO_ID' => $process->PRO_ID,
'PRO_UID' => $process->PRO_UID
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 1,
'USR_UID' => $application[3]->APP_INIT_USER,
'USR_ID' => $user->USR_ID,
'APP_UID' => $application[3]->APP_UID,
'APP_NUMBER' => $application[3]->APP_NUMBER,
'PRO_ID' => $process2->PRO_ID,
'PRO_UID' => $process2->PRO_UID
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 1,
'USR_UID' => $application[4]->APP_INIT_USER,
'USR_ID' => $user->USR_ID,
'APP_UID' => $application[4]->APP_UID,
'APP_NUMBER' => $application[4]->APP_NUMBER,
'PRO_ID' => $process2->PRO_ID,
'PRO_UID' => $process2->PRO_UID
]);
$draft = new Draft();
$draft->setUserId($user->USR_ID);
$draft->setUserUid($user->USR_ID);
$res = $draft->getCountersByProcesses(2);
$this->assertCount(1, $res);
}
/**
* It tests the getCountersByProcesses() method with the top ten filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getCountersByProcesses()
* @test
*/
public function it_should_test_get_counters_by_processes_method_top_ten()
{
$process1 = factory(Process::class)->create();
$process2 = factory(Process::class)->create();
$process3 = factory(Process::class)->create();
$process4 = factory(Process::class)->create();
$process5 = factory(Process::class)->create();
$process6 = factory(Process::class)->create();
$process7 = factory(Process::class)->create();
$process8 = factory(Process::class)->create();
$process9 = factory(Process::class)->create();
$process10 = factory(Process::class)->create();
$process11 = factory(Process::class)->create();
$user = factory(User::class)->create();
$application = factory(Application::class, 14)->states('draft')->create([
'APP_INIT_USER' => $user->USR_UID,
'APP_CUR_USER' => $user->USR_UID,
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 1,
'USR_UID' => $application[0]->APP_INIT_USER,
'USR_ID' => $user->USR_ID,
'APP_UID' => $application[0]->APP_UID,
'APP_NUMBER' => $application[0]->APP_NUMBER,
'PRO_ID' => $process1->PRO_ID,
'PRO_UID' => $process1->PRO_UID
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 1,
'USR_UID' => $application[1]->APP_INIT_USER,
'USR_ID' => $user->USR_ID,
'APP_UID' => $application[1]->APP_UID,
'APP_NUMBER' => $application[1]->APP_NUMBER,
'PRO_ID' => $process1->PRO_ID,
'PRO_UID' => $process1->PRO_UID
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 1,
'USR_UID' => $application[2]->APP_INIT_USER,
'USR_ID' => $user->USR_ID,
'APP_UID' => $application[2]->APP_UID,
'APP_NUMBER' => $application[2]->APP_NUMBER,
'PRO_ID' => $process1->PRO_ID,
'PRO_UID' => $process1->PRO_UID
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 1,
'USR_UID' => $application[3]->APP_INIT_USER,
'USR_ID' => $user->USR_ID,
'APP_UID' => $application[3]->APP_UID,
'APP_NUMBER' => $application[3]->APP_NUMBER,
'PRO_ID' => $process2->PRO_ID,
'PRO_UID' => $process2->PRO_UID
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 1,
'USR_UID' => $application[4]->APP_INIT_USER,
'USR_ID' => $user->USR_ID,
'APP_UID' => $application[4]->APP_UID,
'APP_NUMBER' => $application[4]->APP_NUMBER,
'PRO_ID' => $process2->PRO_ID,
'PRO_UID' => $process2->PRO_UID
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 1,
'USR_UID' => $application[5]->APP_INIT_USER,
'USR_ID' => $user->USR_ID,
'APP_UID' => $application[5]->APP_UID,
'APP_NUMBER' => $application[5]->APP_NUMBER,
'PRO_ID' => $process3->PRO_ID,
'PRO_UID' => $process3->PRO_UID
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 1,
'USR_UID' => $application[6]->APP_INIT_USER,
'USR_ID' => $user->USR_ID,
'APP_UID' => $application[6]->APP_UID,
'APP_NUMBER' => $application[6]->APP_NUMBER,
'PRO_ID' => $process4->PRO_ID,
'PRO_UID' => $process4->PRO_UID
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 1,
'USR_UID' => $application[7]->APP_INIT_USER,
'USR_ID' => $user->USR_ID,
'APP_UID' => $application[7]->APP_UID,
'APP_NUMBER' => $application[7]->APP_NUMBER,
'PRO_ID' => $process5->PRO_ID,
'PRO_UID' => $process5->PRO_UID
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 1,
'USR_UID' => $application[8]->APP_INIT_USER,
'USR_ID' => $user->USR_ID,
'APP_UID' => $application[8]->APP_UID,
'APP_NUMBER' => $application[8]->APP_NUMBER,
'PRO_ID' => $process6->PRO_ID,
'PRO_UID' => $process6->PRO_UID
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 1,
'USR_UID' => $application[9]->APP_INIT_USER,
'USR_ID' => $user->USR_ID,
'APP_UID' => $application[9]->APP_UID,
'APP_NUMBER' => $application[9]->APP_NUMBER,
'PRO_ID' => $process7->PRO_ID,
'PRO_UID' => $process7->PRO_UID
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 1,
'USR_UID' => $application[10]->APP_INIT_USER,
'USR_ID' => $user->USR_ID,
'APP_UID' => $application[10]->APP_UID,
'APP_NUMBER' => $application[10]->APP_NUMBER,
'PRO_ID' => $process8->PRO_ID,
'PRO_UID' => $process8->PRO_UID
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 1,
'USR_UID' => $application[11]->APP_INIT_USER,
'USR_ID' => $user->USR_ID,
'APP_UID' => $application[11]->APP_UID,
'APP_NUMBER' => $application[11]->APP_NUMBER,
'PRO_ID' => $process9->PRO_ID,
'PRO_UID' => $process9->PRO_UID
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 1,
'USR_UID' => $application[12]->APP_INIT_USER,
'USR_ID' => $user->USR_ID,
'APP_UID' => $application[12]->APP_UID,
'APP_NUMBER' => $application[12]->APP_NUMBER,
'PRO_ID' => $process10->PRO_ID,
'PRO_UID' => $process10->PRO_UID
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 1,
'USR_UID' => $application[13]->APP_INIT_USER,
'USR_ID' => $user->USR_ID,
'APP_UID' => $application[13]->APP_UID,
'APP_NUMBER' => $application[13]->APP_NUMBER,
'PRO_ID' => $process11->PRO_ID,
'PRO_UID' => $process11->PRO_UID
]);
$draft = new Draft();
$draft->setUserId($user->USR_ID);
$draft->setUserUid($user->USR_ID);
$res = $draft->getCountersByProcesses(null, true);
$this->assertCount(10, $res);
}
/**
* It tests the getCountersByProcesses() method with the processes filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getCountersByProcesses()
* @test
*/
public function it_should_test_get_counters_by_processes_method_processes()
{
$process = factory(Process::class)->create();
$process2 = factory(Process::class)->create();
$user = factory(User::class)->create();
$application = factory(Application::class, 14)->states('draft')->create([
'APP_INIT_USER' => $user->USR_UID,
'APP_CUR_USER' => $user->USR_UID,
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 1,
'USR_UID' => $application[0]->APP_INIT_USER,
'USR_ID' => $user->USR_ID,
'APP_UID' => $application[0]->APP_UID,
'APP_NUMBER' => $application[0]->APP_NUMBER,
'PRO_ID' => $process->PRO_ID,
'PRO_UID' => $process->PRO_UID
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 1,
'USR_UID' => $application[1]->APP_INIT_USER,
'USR_ID' => $user->USR_ID,
'APP_UID' => $application[1]->APP_UID,
'APP_NUMBER' => $application[1]->APP_NUMBER,
'PRO_ID' => $process2->PRO_ID,
'PRO_UID' => $process2->PRO_UID
]);
$draft = new Draft();
$draft->setUserId($user->USR_ID);
$draft->setUserUid($user->USR_ID);
$res = $draft->getCountersByProcesses(null, false, [$process->PRO_ID]);
$this->assertCount(1, $res);
}
/**
* 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()
{
$process1 = factory(Process::class)->create();
$process2 = factory(Process::class)->create();
$user = factory(User::class)->create();
$application = factory(Application::class, 4)->states('draft')->create([
'APP_INIT_USER' => $user->USR_UID,
'APP_CUR_USER' => $user->USR_UID,
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 1,
'USR_UID' => $application[0]->APP_INIT_USER,
'USR_ID' => $user->USR_ID,
'APP_UID' => $application[0]->APP_UID,
'APP_NUMBER' => $application[0]->APP_NUMBER,
'PRO_ID' => $process1->PRO_ID,
'PRO_UID' => $process1->PRO_UID,
'DEL_DELEGATE_DATE' => '2021-05-20 09:52:32'
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 1,
'USR_UID' => $application[1]->APP_INIT_USER,
'USR_ID' => $user->USR_ID,
'APP_UID' => $application[1]->APP_UID,
'APP_NUMBER' => $application[1]->APP_NUMBER,
'PRO_ID' => $process1->PRO_ID,
'PRO_UID' => $process1->PRO_UID,
'DEL_DELEGATE_DATE' => '2021-05-21 09:52:32'
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 1,
'USR_UID' => $application[2]->APP_INIT_USER,
'USR_ID' => $user->USR_ID,
'APP_UID' => $application[2]->APP_UID,
'APP_NUMBER' => $application[2]->APP_NUMBER,
'PRO_ID' => $process1->PRO_ID,
'PRO_UID' => $process1->PRO_UID,
'DEL_DELEGATE_DATE' => '2021-05-22 00:00:00'
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 1,
'USR_UID' => $application[3]->APP_INIT_USER,
'USR_ID' => $user->USR_ID,
'APP_UID' => $application[3]->APP_UID,
'APP_NUMBER' => $application[3]->APP_NUMBER,
'PRO_ID' => $process2->PRO_ID,
'PRO_UID' => $process2->PRO_UID,
'DEL_DELEGATE_DATE' => '2021-05-23 09:52:32'
]);
$draft = new Draft();
$draft->setUserId($user->USR_ID);
$draft->setUserUid($user->USR_ID);
$res = $draft->getCountersByRange();
$this->assertCount(4, $res);
$res = $draft->getCountersByRange(null, null, null, 'month');
$this->assertCount(1, $res);
$res = $draft->getCountersByRange(null, null, null, 'year');
$this->assertCount(1, $res);
$res = $draft->getCountersByRange($process2->PRO_ID);
$this->assertCount(1, $res);
$res = $draft->getCountersByRange(null, '2021-05-20', '2021-05-22');
$this->assertCount(3, $res);
}
/**
* This tests the getCustomListCount() method.
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getCustomListCount()
* @test
*/
public function it_should_test_getCustomListCount_method()
{
$cases = $this->createManyDraft(3);
$additionalTables = factory(AdditionalTables::class)->create();
$query = ""
. "CREATE TABLE IF NOT EXISTS `{$additionalTables->ADD_TAB_NAME}` ("
. "`APP_UID` varchar(32) NOT NULL,"
. "`APP_NUMBER` int(11) NOT NULL,"
. "`APP_STATUS` varchar(10) NOT NULL,"
. "`VAR1` varchar(255) DEFAULT NULL,"
. "`VAR2` varchar(255) DEFAULT NULL,"
. "`VAR3` varchar(255) DEFAULT NULL,"
. "PRIMARY KEY (`APP_UID`),"
. "KEY `indexTable` (`APP_UID`))";
DB::statement($query);
$caseList = factory(CaseList::class)->create([
'CAL_TYPE' => 'draft',
'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID,
'USR_ID' => $cases->USR_ID
]);
$draft = new Draft();
$draft->setUserId($cases->USR_ID);
$draft->setUserUid($cases->USR_UID);
$res = $draft->getCustomListCount($caseList->CAL_ID, 'draft');
//assertions
$this->assertArrayHasKey('label', $res);
$this->assertArrayHasKey('name', $res);
$this->assertArrayHasKey('description', $res);
$this->assertArrayHasKey('tableName', $res);
$this->assertArrayHasKey('total', $res);
$this->assertEquals($additionalTables->ADD_TAB_NAME, $res['tableName']);
$this->assertEquals(3, $res['total']);
}
/**
* This tests the getCasesRisk() method with on time filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getCasesRisk()
* @test
*/
public function it_tests_get_cases_risk_on_time()
{
$date = new DateTime('now');
$currentDate = $date->format('Y-m-d H:i:s');
$diff1Day = new DateInterval('P1D');
$diff2Days = new DateInterval('P2D');
$process = factory(Process::class)->create();
$user = factory(User::class)->create();
$application = factory(Application::class, 14)->states('draft')->create([
'APP_INIT_USER' => $user->USR_UID,
'APP_CUR_USER' => $user->USR_UID,
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 1,
'USR_UID' => $application[0]->APP_INIT_USER,
'USR_ID' => $user->USR_ID,
'APP_UID' => $application[0]->APP_UID,
'APP_NUMBER' => $application[0]->APP_NUMBER,
'PRO_ID' => $process->PRO_ID,
'PRO_UID' => $process->PRO_UID,
'DEL_DELEGATE_DATE' => $currentDate,
'DEL_RISK_DATE' => $date->add($diff1Day),
'DEL_TASK_DUE_DATE' => $date->add($diff2Days)
]);
$draft = new Draft();
$draft->setUserId($user->USR_ID);
$draft->setUserUid($user->USR_ID);
$res = $draft->getCasesRisk($process->PRO_ID);
$this->assertCount(1, $res);
}
/**
* This tests the getCasesRisk() method with at risk filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getCasesRisk()
* @test
*/
public function it_tests_get_cases_risk_at_risk()
{
$date = new DateTime('now');
$currentDate = $date->format('Y-m-d H:i:s');
$diff2Days = new DateInterval('P2D');
$process = factory(Process::class)->create();
$user = factory(User::class)->create();
$application = factory(Application::class, 14)->states('draft')->create([
'APP_INIT_USER' => $user->USR_UID,
'APP_CUR_USER' => $user->USR_UID,
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 1,
'USR_UID' => $application[0]->APP_INIT_USER,
'USR_ID' => $user->USR_ID,
'APP_UID' => $application[0]->APP_UID,
'APP_NUMBER' => $application[0]->APP_NUMBER,
'PRO_ID' => $process->PRO_ID,
'PRO_UID' => $process->PRO_UID,
'DEL_DELEGATE_DATE' => $currentDate,
'DEL_RISK_DATE' => $currentDate,
'DEL_TASK_DUE_DATE' => $date->add($diff2Days)
]);
$draft = new Draft();
$draft->setUserId($user->USR_ID);
$draft->setUserUid($user->USR_ID);
$res = $draft->getCasesRisk($process->PRO_ID, null, null, 'AT_RISK');
$this->assertCount(1, $res);
}
/**
* This tests the getCasesRisk() method with overdue filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getCasesRisk()
* @test
*/
public function it_tests_get_cases_risk_overdue()
{
$date = new DateTime('now');
$currentDate = $date->format('Y-m-d H:i:s');
$diff2Days = new DateInterval('P2D');
$process = factory(Process::class)->create();
$user = factory(User::class)->create();
$application = factory(Application::class, 14)->states('draft')->create([
'APP_INIT_USER' => $user->USR_UID,
'APP_CUR_USER' => $user->USR_UID,
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 1,
'USR_UID' => $application[0]->APP_INIT_USER,
'USR_ID' => $user->USR_ID,
'APP_UID' => $application[0]->APP_UID,
'APP_NUMBER' => $application[0]->APP_NUMBER,
'PRO_ID' => $process->PRO_ID,
'PRO_UID' => $process->PRO_UID,
'DEL_DELEGATE_DATE' => $currentDate,
'DEL_RISK_DATE' => $currentDate,
'DEL_TASK_DUE_DATE' => $date->sub($diff2Days)
]);
$draft = new Draft();
$draft->setUserId($user->USR_ID);
$draft->setUserUid($user->USR_ID);
$res = $draft->getCasesRisk($process->PRO_ID, null, null, 'OVERDUE');
$this->assertCount(1, $res);
}
}

View File

@@ -0,0 +1,534 @@
<?php
namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases;
use Illuminate\Support\Facades\DB;
use ProcessMaker\BusinessModel\Cases\Home;
use ProcessMaker\Model\AdditionalTables;
use ProcessMaker\Model\AppDelay;
use ProcessMaker\Model\Application;
use ProcessMaker\Model\CaseList;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\Fields;
use ProcessMaker\Model\GroupUser;
use ProcessMaker\Model\Groupwf;
use ProcessMaker\Model\Process;
use ProcessMaker\Model\User;
use ProcessMaker\Model\Task;
use ProcessMaker\Model\TaskUser;
use Tests\TestCase;
/**
* @coversDefaultClass \ProcessMaker\BusinessModel\Cases\Home
*/
class HomeTest extends TestCase
{
/**
* setUp method.
*/
public function setUp()
{
parent::setUp();
}
/**
* tearDown method.
*/
public function tearDown()
{
parent::tearDown();
}
/**
* This test the getDraft method.
* @test
* @covers \ProcessMaker\BusinessModel\Cases\Home::getDraft()
*/
public function it_should_test_getDraft()
{
$application = factory(Application::class)->states('draft')->create();
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 1,
'USR_UID' => $application->APP_INIT_USER,
'APP_UID' => $application->APP_UID,
'APP_NUMBER' => $application->APP_NUMBER,
]);
$home = new Home($application->APP_INIT_USER);
$result = $home->getDraft();
$this->assertArrayHasKey('data', $result);
$this->assertArrayHasKey('total', $result);
}
/**
* This test the getInbox method.
* @test
* @covers \ProcessMaker\BusinessModel\Cases\Home::getInbox()
*/
public function it_should_test_getInbox()
{
$application = factory(Application::class)->states('todo')->create();
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 2
]);
$home = new Home($application->APP_INIT_USER);
$result = $home->getInbox();
$this->assertArrayHasKey('data', $result);
$this->assertArrayHasKey('total', $result);
}
/**
* This test the getUnassigned method.
* @test
* @covers \ProcessMaker\BusinessModel\Cases\Home::getUnassigned()
*/
public function it_should_test_getUnassigned()
{
$user = factory(User::class)->create();
$group = factory(Groupwf::class)->create();
factory(GroupUser::class)->create([
'GRP_UID' => $group->GRP_UID,
'GRP_ID' => $group->GRP_ID,
'USR_UID' => $user->USR_UID,
]);
$process = factory(Process::class)->create();
$application = factory(Application::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:m:s', strtotime("-1 year"))
]);
$home = new Home($user->USR_UID);
$result = $home->getUnassigned();
$this->assertArrayHasKey('data', $result);
$this->assertArrayHasKey('total', $result);
}
/**
* This test the getPaused method.
* @test
* @covers \ProcessMaker\BusinessModel\Cases\Home::getPaused()
*/
public function it_should_test_getPaused()
{
$user = factory(User::class)->create();
$process1 = factory(Process::class)->create();
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => '',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process1->PRO_UID,
'TAS_TYPE' => 'NORMAL'
]);
$application1 = factory(Application::class)->create();
$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
]);
$process2 = factory(Process::class)->create();
$application2 = factory(Application::class)->create();
$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'
]);
$home = new Home($user->USR_UID);
$result = $home->getPaused();
$this->assertArrayHasKey('data', $result);
$this->assertArrayHasKey('total', $result);
}
/**
* This test the buildCustomCaseList method.
* @test
* @covers \ProcessMaker\BusinessModel\Cases\Home::buildCustomCaseList()
*/
public function it_should_test_buildCustomCaseList()
{
$user = factory(User::class)->create();
$additionalTables = factory(AdditionalTables::class)->create();
$query = ""
. "CREATE TABLE IF NOT EXISTS `{$additionalTables->ADD_TAB_NAME}` ("
. "`APP_UID` varchar(32) NOT NULL,"
. "`APP_NUMBER` int(11) NOT NULL,"
. "`APP_STATUS` varchar(10) NOT NULL,"
. "`VAR1` varchar(255) DEFAULT NULL,"
. "`VAR2` varchar(255) DEFAULT NULL,"
. "`VAR3` varchar(255) DEFAULT NULL,"
. "PRIMARY KEY (`APP_UID`),"
. "KEY `indexTable` (`APP_UID`))";
DB::statement($query);
factory(Fields::class)->create([
'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID,
'FLD_NAME' => 'VAR1'
]);
factory(Fields::class)->create([
'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID,
'FLD_NAME' => 'VAR2'
]);
factory(Fields::class)->create([
'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID,
'FLD_NAME' => 'VAR3'
]);
//for inbox
$type = 'inbox';
$caseList = factory(CaseList::class)->create([
'CAL_TYPE' => $type,
'CAL_COLUMNS' => '[{"field":"case_number","enableFilter":false,"set":true},{"field":"case_title","enableFilter":false,"set":true},{"field":"process_name","enableFilter":false,"set":true},{"field":"task","enableFilter":false,"set":true},{"field":"send_by","enableFilter":false,"set":true},{"field":"due_date","enableFilter":false,"set":true},{"field":"delegation_date","enableFilter":false,"set":true},{"field":"priority","enableFilter":false,"set":true},{"field":"VAR1","enableFilter":false,"set":true},{"field":"VAR2","enableFilter":false,"set":true},{"field":"VAR3","enableFilter":false,"set":false}]',
'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID,
'USR_ID' => $user->USR_ID
]);
$arguments = [$caseList->CAL_ID, 0, 0, 0, 15, 0, '', '', 'APP_NUMBER,DESC'];
$defaultColumns = CaseList::formattingColumns($type, '', []);
$home = new Home($user->USR_UID);
$home->buildCustomCaseList($type, $caseList->CAL_ID, $arguments, $defaultColumns);
$this->assertTrue(is_callable(array_pop($arguments)));
}
/**
* This test the getCustomDraft method.
* @test
* @covers \ProcessMaker\BusinessModel\Cases\Home::getCustomDraft()
*/
public function it_should_test_getCustomDraft()
{
$additionalTables = factory(AdditionalTables::class)->create();
$query = ""
. "CREATE TABLE IF NOT EXISTS `{$additionalTables->ADD_TAB_NAME}` ("
. "`APP_UID` varchar(32) NOT NULL,"
. "`APP_NUMBER` int(11) NOT NULL,"
. "`APP_STATUS` varchar(10) NOT NULL,"
. "`VAR1` varchar(255) DEFAULT NULL,"
. "`VAR2` varchar(255) DEFAULT NULL,"
. "`VAR3` varchar(255) DEFAULT NULL,"
. "PRIMARY KEY (`APP_UID`),"
. "KEY `indexTable` (`APP_UID`))";
DB::statement($query);
factory(Fields::class)->create([
'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID,
'FLD_NAME' => 'VAR1'
]);
factory(Fields::class)->create([
'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID,
'FLD_NAME' => 'VAR2'
]);
factory(Fields::class)->create([
'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID,
'FLD_NAME' => 'VAR3'
]);
$application = factory(Application::class)->states('draft')->create();
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 1,
'USR_UID' => $application->APP_INIT_USER,
'APP_UID' => $application->APP_UID,
'APP_NUMBER' => $application->APP_NUMBER,
]);
$caseList = factory(CaseList::class)->create([
'CAL_TYPE' => 'draft',
'CAL_COLUMNS' => '[{"field":"case_number","enableFilter":false,"set":true},{"field":"case_title","enableFilter":false,"set":true},{"field":"process_name","enableFilter":false,"set":true},{"field":"task","enableFilter":false,"set":true},{"field":"send_by","enableFilter":false,"set":true},{"field":"due_date","enableFilter":false,"set":true},{"field":"delegation_date","enableFilter":false,"set":true},{"field":"priority","enableFilter":false,"set":true},{"field":"VAR1","enableFilter":false,"set":true},{"field":"VAR2","enableFilter":false,"set":true},{"field":"VAR3","enableFilter":false,"set":false}]',
'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID
]);
$arguments = [$caseList->CAL_ID, 0, 0, 0, 15, 0, '', '', 'APP_NUMBER,DESC'];
$home = new Home($application->APP_INIT_USER);
$result = $home->getCustomDraft(...$arguments);
$this->assertArrayHasKey('data', $result);
$this->assertArrayHasKey('total', $result);
$this->assertArrayHasKey('columns', $result);
}
/**
* This test the getCustomInbox method.
* @test
* @covers \ProcessMaker\BusinessModel\Cases\Home::getCustomInbox()
*/
public function it_should_test_getCustomInbox()
{
$additionalTables = factory(AdditionalTables::class)->create();
$query = ""
. "CREATE TABLE IF NOT EXISTS `{$additionalTables->ADD_TAB_NAME}` ("
. "`APP_UID` varchar(32) NOT NULL,"
. "`APP_NUMBER` int(11) NOT NULL,"
. "`APP_STATUS` varchar(10) NOT NULL,"
. "`VAR1` varchar(255) DEFAULT NULL,"
. "`VAR2` varchar(255) DEFAULT NULL,"
. "`VAR3` varchar(255) DEFAULT NULL,"
. "PRIMARY KEY (`APP_UID`),"
. "KEY `indexTable` (`APP_UID`))";
DB::statement($query);
factory(Fields::class)->create([
'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID,
'FLD_NAME' => 'VAR1'
]);
factory(Fields::class)->create([
'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID,
'FLD_NAME' => 'VAR2'
]);
factory(Fields::class)->create([
'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID,
'FLD_NAME' => 'VAR3'
]);
$application = factory(Application::class)->states('todo')->create();
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 2
]);
$caseList = factory(CaseList::class)->create([
'CAL_TYPE' => 'inbox',
'CAL_COLUMNS' => '[{"field":"case_number","enableFilter":false,"set":true},{"field":"case_title","enableFilter":false,"set":true},{"field":"process_name","enableFilter":false,"set":true},{"field":"task","enableFilter":false,"set":true},{"field":"send_by","enableFilter":false,"set":true},{"field":"due_date","enableFilter":false,"set":true},{"field":"delegation_date","enableFilter":false,"set":true},{"field":"priority","enableFilter":false,"set":true},{"field":"VAR1","enableFilter":false,"set":true},{"field":"VAR2","enableFilter":false,"set":true},{"field":"VAR3","enableFilter":false,"set":false}]',
'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID
]);
$arguments = [$caseList->CAL_ID, 0, 0, 0, 15, 0, '', '', 'APP_NUMBER,DESC'];
$home = new Home($application->APP_INIT_USER);
$result = $home->getCustomDraft(...$arguments);
$this->assertArrayHasKey('data', $result);
$this->assertArrayHasKey('total', $result);
$this->assertArrayHasKey('columns', $result);
}
/**
* This test the getCustomUnassigned method.
* @test
* @covers \ProcessMaker\BusinessModel\Cases\Home::getCustomUnassigned()
*/
public function it_should_test_getCustomUnassignedt()
{
$additionalTables = factory(AdditionalTables::class)->create();
$query = ""
. "CREATE TABLE IF NOT EXISTS `{$additionalTables->ADD_TAB_NAME}` ("
. "`APP_UID` varchar(32) NOT NULL,"
. "`APP_NUMBER` int(11) NOT NULL,"
. "`APP_STATUS` varchar(10) NOT NULL,"
. "`VAR1` varchar(255) DEFAULT NULL,"
. "`VAR2` varchar(255) DEFAULT NULL,"
. "`VAR3` varchar(255) DEFAULT NULL,"
. "PRIMARY KEY (`APP_UID`),"
. "KEY `indexTable` (`APP_UID`))";
DB::statement($query);
factory(Fields::class)->create([
'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID,
'FLD_NAME' => 'VAR1'
]);
factory(Fields::class)->create([
'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID,
'FLD_NAME' => 'VAR2'
]);
factory(Fields::class)->create([
'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID,
'FLD_NAME' => 'VAR3'
]);
$user = factory(User::class)->create();
$group = factory(Groupwf::class)->create();
factory(GroupUser::class)->create([
'GRP_UID' => $group->GRP_UID,
'GRP_ID' => $group->GRP_ID,
'USR_UID' => $user->USR_UID,
]);
$process = factory(Process::class)->create();
$application = factory(Application::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:m:s', strtotime("-1 year"))
]);
$caseList = factory(CaseList::class)->create([
'CAL_TYPE' => 'unassigned',
'CAL_COLUMNS' => '[{"field":"case_number","enableFilter":false,"set":true},{"field":"case_title","enableFilter":false,"set":true},{"field":"process_name","enableFilter":false,"set":true},{"field":"task","enableFilter":false,"set":true},{"field":"send_by","enableFilter":false,"set":true},{"field":"due_date","enableFilter":false,"set":true},{"field":"delegation_date","enableFilter":false,"set":true},{"field":"priority","enableFilter":false,"set":true},{"field":"VAR1","enableFilter":false,"set":true},{"field":"VAR2","enableFilter":false,"set":true},{"field":"VAR3","enableFilter":false,"set":false}]',
'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID
]);
$arguments = [$caseList->CAL_ID, 0, 0, 0, 15, 0, '', '', 'APP_NUMBER,DESC'];
$home = new Home($application->APP_INIT_USER);
$result = $home->getCustomDraft(...$arguments);
$this->assertArrayHasKey('data', $result);
$this->assertArrayHasKey('total', $result);
$this->assertArrayHasKey('columns', $result);
}
/**
* This test the getCustomPaused method.
* @test
* @covers \ProcessMaker\BusinessModel\Cases\Home::getCustomPaused()
*/
public function it_should_test_getCustomPaused()
{
$additionalTables = factory(AdditionalTables::class)->create();
$query = ""
. "CREATE TABLE IF NOT EXISTS `{$additionalTables->ADD_TAB_NAME}` ("
. "`APP_UID` varchar(32) NOT NULL,"
. "`APP_NUMBER` int(11) NOT NULL,"
. "`APP_STATUS` varchar(10) NOT NULL,"
. "`VAR1` varchar(255) DEFAULT NULL,"
. "`VAR2` varchar(255) DEFAULT NULL,"
. "`VAR3` varchar(255) DEFAULT NULL,"
. "PRIMARY KEY (`APP_UID`),"
. "KEY `indexTable` (`APP_UID`))";
DB::statement($query);
factory(Fields::class)->create([
'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID,
'FLD_NAME' => 'VAR1'
]);
factory(Fields::class)->create([
'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID,
'FLD_NAME' => 'VAR2'
]);
factory(Fields::class)->create([
'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID,
'FLD_NAME' => 'VAR3'
]);
$user = factory(User::class)->create();
$process1 = factory(Process::class)->create();
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => '',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process1->PRO_UID,
'TAS_TYPE' => 'NORMAL'
]);
$application1 = factory(Application::class)->create();
$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
]);
$process2 = factory(Process::class)->create();
$application2 = factory(Application::class)->create();
$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'
]);
$caseList = factory(CaseList::class)->create([
'CAL_TYPE' => 'paused',
'CAL_COLUMNS' => '[{"field":"case_number","enableFilter":false,"set":true},{"field":"case_title","enableFilter":false,"set":true},{"field":"process_name","enableFilter":false,"set":true},{"field":"task","enableFilter":false,"set":true},{"field":"send_by","enableFilter":false,"set":true},{"field":"due_date","enableFilter":false,"set":true},{"field":"delegation_date","enableFilter":false,"set":true},{"field":"priority","enableFilter":false,"set":true},{"field":"VAR1","enableFilter":false,"set":true},{"field":"VAR2","enableFilter":false,"set":true},{"field":"VAR3","enableFilter":false,"set":false}]',
'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID
]);
$arguments = [$caseList->CAL_ID, 0, 0, 0, 15, 0, '', '', 'APP_NUMBER,DESC'];
$home = new Home($application1->APP_INIT_USER);
$result = $home->getCustomDraft(...$arguments);
$this->assertArrayHasKey('data', $result);
$this->assertArrayHasKey('total', $result);
$this->assertArrayHasKey('columns', $result);
}
}

View File

@@ -2,10 +2,14 @@
namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases;
use DateInterval;
use Datetime;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\BusinessModel\Cases\Inbox;
use ProcessMaker\Model\AdditionalTables;
use ProcessMaker\Model\Application;
use ProcessMaker\Model\CaseList;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\Process;
use ProcessMaker\Model\Task;
@@ -55,7 +59,7 @@ class InboxTest extends TestCase
public function createMultipleInbox($cases)
{
$user = factory(\ProcessMaker\Model\User::class)->create();
for ($i = 0; $i < $cases; $i = $i + 1) {
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
@@ -150,12 +154,56 @@ class InboxTest extends TestCase
$this->assertNotEmpty($res);
}
/**
* It tests the getData method with case number filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::filters()
* @test
*/
public function it_filter_by_specific_cases()
{
// Create factories related to the to_do cases
$cases = $this->createInbox();
// Create new Inbox object
$inbox = new Inbox();
$inbox->setUserId($cases->USR_ID);
$inbox->setCasesNumbers([$cases->APP_NUMBER]);
$inbox->setOrderByColumn('APP_NUMBER');
$res = $inbox->getData();
$this->assertNotEmpty($res);
}
/**
* It tests the getData method with case number filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::filters()
* @test
*/
public function it_filter_by_range_cases()
{
// Create factories related to the to_do cases
$cases = $this->createInbox();
// Create new Inbox object
$inbox = new Inbox();
$inbox->setUserId($cases->USR_ID);
$rangeOfCases = $cases->APP_NUMBER . "-" . $cases->APP_NUMBER;
$inbox->setRangeCasesFromTo([$rangeOfCases]);
$inbox->setOrderByColumn('APP_NUMBER');
$res = $inbox->getData();
$this->assertNotEmpty($res);
}
/**
* It tests the getData method with taskId filter
*
* @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()
@@ -168,7 +216,6 @@ class InboxTest extends TestCase
$inbox->setTaskId($cases->TAS_ID);
$res = $inbox->getData();
$this->assertNotEmpty($res);
}
/**
@@ -214,9 +261,6 @@ class InboxTest extends TestCase
'APP_NUMBER',
'DEL_TITLE',
'PRO_TITLE',
'TAS_TITLE',
'DEL_TASK_DUE_DATE',
'DEL_DELEGATE_DATE'
];
$index = array_rand($columnsView);
// Create new Inbox object
@@ -255,4 +299,460 @@ class InboxTest extends TestCase
$res = $inbox->getPagingCounters();
$this->assertEquals(1, $res);
}
}
/**
* It tests the getCountersByProcesses() method without filters
*
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getCountersByProcesses()
* @test
*/
public function it_should_test_get_counters_by_processes_method_no_filter()
{
$user = factory(User::class)->create();
$process = factory(Process::class)->create();
$process2 = factory(Process::class)->create();
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 2,
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process->PRO_ID,
'PRO_UID' => $process->PRO_UID
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 2,
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process2->PRO_ID,
'PRO_UID' => $process2->PRO_UID
]);
$inbox = new Inbox();
$inbox->setUserId($user->USR_ID);
$inbox->setUserUid($user->USR_UID);
$res = $inbox->getCountersByProcesses();
$this->assertCount(2, $res);
}
/**
* It tests the getCountersByProcesses() method with the category filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getCountersByProcesses()
* @test
*/
public function it_should_test_get_counters_by_processes_method_category()
{
$user = factory(User::class)->create();
$process = factory(Process::class)->create([
'CATEGORY_ID' => 1
]);
$process2 = factory(Process::class)->create([
'CATEGORY_ID' => 2
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 2,
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process->PRO_ID,
'PRO_UID' => $process->PRO_UID
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 2,
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process->PRO_ID,
'PRO_UID' => $process->PRO_UID
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 2,
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process->PRO_ID,
'PRO_UID' => $process->PRO_UID
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 2,
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process2->PRO_ID,
'PRO_UID' => $process2->PRO_UID
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 2,
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process2->PRO_ID,
'PRO_UID' => $process2->PRO_UID
]);
$inbox = new Inbox();
$inbox->setUserId($user->USR_ID);
$inbox->setUserUid($user->USR_UID);
$res = $inbox->getCountersByProcesses(2);
$this->assertCount(1, $res);
}
/**
* It tests the getCountersByProcesses() method with the top ten filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getCountersByProcesses()
* @test
*/
public function it_should_test_get_counters_by_processes_method_top_ten()
{
$user = factory(User::class)->create();
$process1 = factory(Process::class)->create();
$process2 = factory(Process::class)->create();
$process3 = factory(Process::class)->create();
$process4 = factory(Process::class)->create();
$process5 = factory(Process::class)->create();
$process6 = factory(Process::class)->create();
$process7 = factory(Process::class)->create();
$process8 = factory(Process::class)->create();
$process9 = factory(Process::class)->create();
$process10 = factory(Process::class)->create();
$process11 = factory(Process::class)->create();
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 2,
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process1->PRO_ID,
'PRO_UID' => $process1->PRO_UID
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 2,
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process1->PRO_ID,
'PRO_UID' => $process1->PRO_UID
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 2,
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process1->PRO_ID,
'PRO_UID' => $process1->PRO_UID
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 2,
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process2->PRO_ID,
'PRO_UID' => $process2->PRO_UID
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 2,
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process2->PRO_ID,
'PRO_UID' => $process2->PRO_UID
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 2,
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process3->PRO_ID,
'PRO_UID' => $process3->PRO_UID
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 2,
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process4->PRO_ID,
'PRO_UID' => $process4->PRO_UID
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 2,
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process5->PRO_ID,
'PRO_UID' => $process5->PRO_UID
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 2,
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process6->PRO_ID,
'PRO_UID' => $process6->PRO_UID
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 2,
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process7->PRO_ID,
'PRO_UID' => $process7->PRO_UID
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 2,
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process8->PRO_ID,
'PRO_UID' => $process8->PRO_UID
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 2,
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process9->PRO_ID,
'PRO_UID' => $process9->PRO_UID
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 2,
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process10->PRO_ID,
'PRO_UID' => $process10->PRO_UID
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 2,
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process11->PRO_ID,
'PRO_UID' => $process11->PRO_UID
]);
$inbox = new Inbox();
$inbox->setUserId($user->USR_ID);
$inbox->setUserUid($user->USR_UID);
$res = $inbox->getCountersByProcesses(null, true);
$this->assertCount(10, $res);
}
/**
* It tests the getCountersByProcesses() method with the processes filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getCountersByProcesses()
* @test
*/
public function it_should_test_get_counters_by_processes_method_processes()
{
$user = factory(User::class)->create();
$process = factory(Process::class)->create();
$process2 = factory(Process::class)->create();
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 2,
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process->PRO_ID,
'PRO_UID' => $process->PRO_UID
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 2,
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process2->PRO_ID,
'PRO_UID' => $process2->PRO_UID
]);
$inbox = new Inbox();
$inbox->setUserId($user->USR_ID);
$inbox->setUserUid($user->USR_UID);
$res = $inbox->getCountersByProcesses(null, false, [$process->PRO_ID]);
$this->assertCount(1, $res);
}
/**
* It tests the getCountersByRange() method
*
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getCountersByRange()
* @test
*/
public function it_should_test_get_counters_by_range_method()
{
$user = factory(User::class)->create();
$process = factory(Process::class)->create();
$process2 = factory(Process::class)->create();
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 2,
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process->PRO_ID,
'PRO_UID' => $process->PRO_UID,
'DEL_DELEGATE_DATE' => '2021-05-20 09:52:32'
]);
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 2,
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process2->PRO_ID,
'PRO_UID' => $process2->PRO_UID,
'DEL_DELEGATE_DATE' => '2021-05-25 09:52:32'
]);
$inbox = new Inbox();
$inbox->setUserId($user->USR_ID);
$inbox->setUserUid($user->USR_UID);
$res = $inbox->getCountersByRange();
$this->assertCount(2, $res);
$res = $inbox->getCountersByRange(null, null, null, 'month');
$this->assertCount(1, $res);
$res = $inbox->getCountersByRange(null, null, null, 'year');
$this->assertCount(1, $res);
$res = $inbox->getCountersByRange($process2->PRO_ID);
$this->assertCount(1, $res);
$res = $inbox->getCountersByRange(null, '2021-05-20', '2021-05-23');
$this->assertCount(1, $res);
}
/**
* This tests the getCustomListCount() method.
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getCustomListCount()
* @test
*/
public function it_should_test_getCustomListCounts_method()
{
$cases = $this->createMultipleInbox(3);
$additionalTables = factory(AdditionalTables::class)->create();
$query = ""
. "CREATE TABLE IF NOT EXISTS `{$additionalTables->ADD_TAB_NAME}` ("
. "`APP_UID` varchar(32) NOT NULL,"
. "`APP_NUMBER` int(11) NOT NULL,"
. "`APP_STATUS` varchar(10) NOT NULL,"
. "`VAR1` varchar(255) DEFAULT NULL,"
. "`VAR2` varchar(255) DEFAULT NULL,"
. "`VAR3` varchar(255) DEFAULT NULL,"
. "PRIMARY KEY (`APP_UID`),"
. "KEY `indexTable` (`APP_UID`))";
DB::statement($query);
$caseList = factory(CaseList::class)->create([
'CAL_TYPE' => 'inbox',
'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID,
'USR_ID' => $cases->USR_ID
]);
$inbox = new Inbox();
$inbox->setUserId($cases->USR_ID);
$inbox->setUserUid($cases->USR_UID);
$res = $inbox->getCustomListCount($caseList->CAL_ID, 'inbox');
//assertions
$this->assertArrayHasKey('label', $res);
$this->assertArrayHasKey('name', $res);
$this->assertArrayHasKey('description', $res);
$this->assertArrayHasKey('tableName', $res);
$this->assertArrayHasKey('total', $res);
$this->assertEquals($additionalTables->ADD_TAB_NAME, $res['tableName']);
$this->assertEquals(3, $res['total']);
}
/**
* This tests the getCasesRisk() method with on time filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getCasesRisk()
* @test
*/
public function it_tests_get_cases_risk_on_time()
{
$date = new DateTime('now');
$currentDate = $date->format('Y-m-d H:i:s');
$diff1Day = new DateInterval('P1D');
$diff2Days = new DateInterval('P2D');
$user = factory(User::class)->create();
$process = factory(Process::class)->create();
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 2,
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process->PRO_ID,
'PRO_UID' => $process->PRO_UID,
'DEL_DELEGATE_DATE' => $currentDate,
'DEL_RISK_DATE' => $date->add($diff1Day),
'DEL_TASK_DUE_DATE' => $date->add($diff2Days)
]);
$inbox = new Inbox();
$inbox->setUserId($user->USR_ID);
$inbox->setUserUid($user->USR_UID);
$res = $inbox->getCasesRisk($process->PRO_ID);
$this->assertCount(1, $res);
}
/**
* This tests the getCasesRisk() method with at risk filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getCasesRisk()
* @test
*/
public function it_tests_get_cases_risk_at_risk()
{
$date = new DateTime('now');
$currentDate = $date->format('Y-m-d H:i:s');
$diff2Days = new DateInterval('P2D');
$user = factory(User::class)->create();
$process = factory(Process::class)->create();
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 2,
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process->PRO_ID,
'PRO_UID' => $process->PRO_UID,
'DEL_DELEGATE_DATE' => $currentDate,
'DEL_RISK_DATE' => $currentDate,
'DEL_TASK_DUE_DATE' => $date->add($diff2Days)
]);
$inbox = new Inbox();
$inbox->setUserId($user->USR_ID);
$inbox->setUserUid($user->USR_UID);
$res = $inbox->getCasesRisk($process->PRO_ID, null, null, "AT_RISK");
$this->assertCount(1, $res);
}
/**
* This tests the getCasesRisk() method with overdue filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getCasesRisk()
* @test
*/
public function it_tests_get_cases_risk_overdue()
{
$date = new DateTime('now');
$currentDate = $date->format('Y-m-d H:i:s');
$diff2Days = new DateInterval('P2D');
$user = factory(User::class)->create();
$process = factory(Process::class)->create();
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 2,
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process->PRO_ID,
'PRO_UID' => $process->PRO_UID,
'DEL_DELEGATE_DATE' => $currentDate,
'DEL_RISK_DATE' => $currentDate,
'DEL_TASK_DUE_DATE' => $date->sub($diff2Days)
]);
$inbox = new Inbox();
$inbox->setUserId($user->USR_ID);
$inbox->setUserUid($user->USR_UID);
$res = $inbox->getCasesRisk($process->PRO_ID, null, null, "OVERDUE");
$this->assertCount(1, $res);
}
}

View File

@@ -7,7 +7,6 @@ use Illuminate\Support\Facades\DB;
use ProcessMaker\BusinessModel\Cases\Participated;
use ProcessMaker\Model\Application;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\Process;
use Tests\TestCase;
/**
@@ -28,7 +27,7 @@ class ParticipatedTest extends TestCase
}
/**
* Create participated cases factories
* Create participated cases factories when the case is TO_DO
*
* @param string
*
@@ -39,8 +38,9 @@ class ParticipatedTest extends TestCase
$delegation = factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'CLOSED',
'DEL_INDEX' => 1,
'DEL_LAST_INDEX' => 0,
]);
$delegation2 = factory(Delegation::class)->states('last_thread')->create([
$delegation = factory(Delegation::class)->states('last_thread')->create([
'APP_NUMBER' => $delegation->APP_NUMBER,
'TAS_ID' => $delegation->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
@@ -48,9 +48,41 @@ class ParticipatedTest extends TestCase
'USR_ID' => $delegation->USR_ID,
'PRO_ID' => $delegation->PRO_ID,
'DEL_INDEX' => 2,
'DEL_LAST_INDEX' => 1,
]);
return $delegation2;
return $delegation;
}
/**
* Create participated cases factories when the case is COMPLETED
*
* @param string
*
* @return array
*/
public function createParticipatedCompleted()
{
$application = factory(Application::class)->states('completed')->create();
$delegation = factory(Delegation::class)->states('first_thread')->create([
'APP_NUMBER' => $application->APP_NUMBER,
'APP_UID' => $application->APP_UID,
'DEL_THREAD_STATUS' => 'CLOSED',
'DEL_INDEX' => 1,
'DEL_LAST_INDEX' => 0,
]);
$delegation = factory(Delegation::class)->states('last_thread')->create([
'APP_NUMBER' => $application->APP_NUMBER,
'APP_UID' => $application->APP_UID,
'DEL_THREAD_STATUS' => 'CLOSED',
'USR_UID' => $delegation->USR_UID,
'USR_ID' => $delegation->USR_ID,
'PRO_ID' => $delegation->PRO_ID,
'DEL_INDEX' => 2,
'DEL_LAST_INDEX' => 1,
]);
return $delegation;
}
/**
@@ -59,7 +91,7 @@ class ParticipatedTest extends TestCase
* @param int
* @return object
*/
public function createMultipleParticipated($cases)
public function createMultipleParticipated($cases = 2)
{
$user = factory(\ProcessMaker\Model\User::class)->create();
@@ -69,6 +101,7 @@ class ParticipatedTest extends TestCase
'DEL_INDEX' => 1,
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'DEL_LAST_INDEX' => 0,
]);
factory(Delegation::class)->states('last_thread')->create([
'APP_UID' => $delegation->APP_UID,
@@ -79,17 +112,20 @@ class ParticipatedTest extends TestCase
'USR_ID' => $delegation->USR_ID,
'PRO_ID' => $delegation->PRO_ID,
'DEL_INDEX' => 2,
'DEL_LAST_INDEX' => 1,
]);
}
return $user;
}
/**
* It tests the getData method without filters
* It tests the getData without filters
*
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getColumnsView()
* @covers \ProcessMaker\Model\Delegation::scopeParticipated()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::setUserUid()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::setUserId()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::setOrderByColumn()
* @test
*/
public function it_get_result_without_filters()
@@ -104,18 +140,22 @@ class ParticipatedTest extends TestCase
$participated->setUserId($cases['USR_ID']);
// Set OrderBYColumn value
$participated->setOrderByColumn('APP_NUMBER');
// Call to getData method
$res = $participated->getData();
// This assert that the expected numbers of results are returned
$this->assertEquals(2, count($res));
// Get the data
$result = $participated->getData();
// Asserts with the result
$this->assertNotEmpty($result);
}
/**
* It tests the getData method with specific filter StartedByMe
* It tests the getData the specific filter StartedByMe
*
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::filters()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::setCaseStatus()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::setUserUid()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::setUserId()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::setParticipatedStatus()
* @test
*/
public function it_filter_by_started_by_me()
@@ -128,28 +168,31 @@ class ParticipatedTest extends TestCase
$participated->setUserUid($cases->USR_UID);
// Set the user ID
$participated->setUserId($cases->USR_ID);
// Get only the TO_DO
$participated->setCaseStatus('TO_DO');
// Set the filter STARTED
$participated->setParticipatedStatus('STARTED');
// Set OrderBYColumn value
$participated->setOrderByColumn('APP_NUMBER');
// Call to getData method
$res = $participated->getData();
// This assert that the expected numbers of results are returned
$this->assertEquals(1, count($res));
// Get the data
$result = $participated->getData();
// Asserts with the result
$this->assertNotEmpty($result);
}
/**
* It tests the getData method with specific filter CompletedByMe
* It tests the getData the specific filter CompletedByMe
*
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::filters()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::setUserUid()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::setUserId()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::setParticipatedStatus()
* @test
*/
public function it_filter_by_completed_by_me()
{
// Create factories related to the participated cases
$cases = $this->createParticipated();
$cases = $this->createParticipatedCompleted();
// Create new Participated object
$participated = new Participated();
// Set the user UID
@@ -158,20 +201,22 @@ class ParticipatedTest extends TestCase
$participated->setUserId($cases->USR_ID);
// Set the filter COMPLETED
$participated->setParticipatedStatus('COMPLETED');
// Set OrderBYColumn value
$participated->setOrderByColumn('APP_NUMBER');
// Call to getData method
$res = $participated->getData();
// This assert that the expected numbers of results are returned
$this->assertEquals(0, count($res));
// Get the data
$result = $participated->getData();
// Asserts with the result
$this->assertNotEmpty($result);
}
/**
* It tests the getData method with processId filter
* It tests the getData the specific filter setProcessId
*
* @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_process()
@@ -186,22 +231,83 @@ class ParticipatedTest extends TestCase
$participated->setUserUid($cases['USR_UID']);
// Set the user ID
$participated->setUserId($cases['USR_ID']);
// Set the process ID
// Set the process
$participated->setProcessId($cases['PRO_ID']);
// Set OrderBYColumn value
$participated->setOrderByColumn('APP_NUMBER');
// Call to getData method
$res = $participated->getData();
// This assert that the expected numbers of results are returned
$this->assertEquals(2, count($res));
// Get the data
$result = $participated->getData();
// Asserts with the result
$this->assertNotEmpty($result);
}
/**
* It tests the getData method with processId filter
* It tests the getData method with case number filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::filters()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::setCasesNumbers()
* @test
*/
public function it_filter_by_specific_cases()
{
// 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->setCasesNumbers([$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
*
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::filters()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::setRangeCasesFromTo()
* @test
*/
public function it_filter_by_range_cases()
{
// 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 range of case numbers
$rangeOfCases = $cases['APP_NUMBER'] . "-" . $cases['APP_NUMBER'];
$participated->setRangeCasesFromTo([$rangeOfCases]);
// Get the data
$result = $participated->getData();
// Asserts with the result
$this->assertNotEmpty($result);
}
/**
* It tests the getData the specific filter setCaseTitle
*
* @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::setCaseTitle()
* @test
*/
public function it_filter_by_thread_title()
@@ -221,18 +327,123 @@ class ParticipatedTest extends TestCase
// Set the title
$participated->setCaseTitle($cases->DEL_TITLE);
// Get the data
$res = $participated->getData();
// Asserts
$this->assertCount(1, $res);
$result = $participated->getData();
// Asserts with the result
$this->assertNotEmpty($result);
}
/**
* It tests the getCounter method
* It tests the getData the specific filter status
*
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getCounter()
* @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::setCaseStatus()
* @test
*/
public function it_get_counter()
public function it_filter_by_status()
{
// 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 status
$participated->setCaseStatus('TO_DO');
// Get the data
$result = $participated->getData();
// Asserts with the result
$this->assertNotEmpty($result);
}
/**
* It tests the getData the specific filter setStartCaseFrom and getStartCaseTo
*
* @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::setStartCaseFrom()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::setStartCaseTo()
* @test
*/
public function it_filter_by_start_date()
{
// 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 range of dates
$date = date('Y-m-d');
$participated->setStartCaseFrom($date);
$participated->setStartCaseTo($date);
// Get the data
$result = $participated->getData();
// Asserts with the result
$this->assertEmpty($result);
}
/**
* It tests the getData the specific filter setFinishCaseFrom and setFinishCaseTo
*
* @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::setFinishCaseFrom()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::setFinishCaseTo()
* @test
*/
public function it_filter_by_finish_date()
{
// 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 range of dates
$date = date('Y-m-d');
$participated->setFinishCaseFrom($date);
$participated->setFinishCaseTo($date);
// Get the data
$result = $participated->getData();
// Asserts with the result
$this->assertEmpty($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_progress()
{
// Create factories related to the participated cases
$cases = $this->createParticipated();
@@ -244,14 +455,123 @@ class ParticipatedTest extends TestCase
$participated->setUserId($cases->USR_ID);
// Set participated status
$participated->setParticipatedStatus('IN_PROGRESS');
// Get result
$res = $participated->getCounter();
// Assert the result of getCounter method
$this->assertEquals(1, $res);
// Get the data
$result = $participated->getData();
// Asserts with the result
$this->assertNotEmpty($result);
}
/**
* It tests the getPagingCounters() method
* It tests the specific filter setParticipatedStatus = STARTED
*
* @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()
{
// Create factories related to the participated cases
$cases = $this->createParticipated();
// 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 = COMPLETED
*
* @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_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('COMPLETED');
// Get the data
$result = $participated->getData();
// Asserts with the result
$this->assertNotEmpty($result);
}
/**
* It tests the getCounter
*
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getCounter()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::setParticipatedStatus()
* @test
*/
public function it_get_counter()
{
// Create factories related to the in started cases
$cases = $this->createParticipated();
// 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->getCounter();
// Asserts with the result
$this->assertTrue($result > 0);
// Create factories related to the in progress cases
$cases = $this->createParticipated();
// 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('IN_PROGRESS');
// Get the data
$result = $participated->getCounter();
// Asserts with the result
$this->assertTrue($result > 0);
// Create factories related to the complete 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('COMPLETED');
// Get the data
$result = $participated->getCounter();
// Asserts with the result
$this->assertTrue($result > 0);
}
/**
* It tests the getPagingCounters
*
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getPagingCounters()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::filters()
@@ -259,23 +579,40 @@ class ParticipatedTest extends TestCase
*/
public function it_should_test_get_paging_counters_method()
{
$cases = $this->createMultipleParticipated(3);
// Create factories related to the in started cases
$cases = $this->createParticipated();
$participated = new Participated();
$participated->setUserId($cases->USR_ID);
$participated->setUserUid($cases->USR_UID);
$participated->setCaseUid($cases->APP_UID);
$participated->setParticipatedStatus('STARTED');
// Get the data
$result = $participated->getPagingCounters();
// Asserts with the result
$this->assertTrue($result >= 0);
$res = $participated->getPagingCounters();
$this->assertEquals(3, $res);
// Create factories related to the in progress cases
$cases = $this->createParticipated();
$participated = new Participated();
$participated->setUserId($cases->USR_ID);
$participated->setUserUid($cases->USR_UID);
$participated->setCaseUid($cases->APP_UID);
$participated->setParticipatedStatus('IN_PROGRESS');
// Get the data
$result = $participated->getPagingCounters();
// Asserts with the result
$this->assertTrue($result >= 0);
$delegation = Delegation::select()->where('USR_ID', $cases->USR_ID)->first();
$participated->setCaseNumber($delegation->APP_NUMBER);
$participated->setProcessId($delegation->PRO_ID);
$participated->setTaskId($delegation->TAS_ID);
$participated->setCaseUid($delegation->APP_UID);
$res = $participated->getPagingCounters();
$this->assertEquals(1, $res);
// Create factories related to the complete cases
$cases = $this->createParticipatedCompleted();
$participated = new Participated();
$participated->setUserId($cases->USR_ID);
$participated->setUserUid($cases->USR_UID);
$participated->setCaseUid($cases->APP_UID);
$participated->setParticipatedStatus('COMPLETED');
// Get the data
$result = $participated->getPagingCounters();
// Asserts with the result
$this->assertTrue($result >= 0);
}
}

View File

@@ -2,11 +2,15 @@
namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases;
use DateInterval;
use Datetime;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\BusinessModel\Cases\Paused;
use ProcessMaker\Model\AdditionalTables;
use ProcessMaker\Model\Application;
use ProcessMaker\Model\AppDelay;
use ProcessMaker\Model\CaseList;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\Process;
use ProcessMaker\Model\Task;
@@ -136,13 +140,15 @@ class PausedTest extends TestCase
* @param int
* @return object
*/
public function createMultiplePaused($cases)
public function createMultiplePaused($cases, $category = 1, $user = null)
{
$user = factory(\ProcessMaker\Model\User::class)->create();
if (is_null($user)) {
$user = factory(User::class)->create();
}
for ($i = 0; $i < $cases; $i = $i + 1) {
$process1 = factory(Process::class)->create(
['PRO_CATEGORY' => '1']
['PRO_CATEGORY' => 1, 'CATEGORY_ID' => $category]
);
$task = factory(Task::class)->create([
@@ -241,6 +247,32 @@ class PausedTest extends TestCase
$this->assertNotEmpty($res);
}
/**
* It tests the getData method with case number filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Paused::filters()
* @test
*/
public function it_filter_by_specific_cases()
{
// 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);
//Set app number
$paused->setCasesNumbers([$cases->APP_NUMBER]);
//Call to getData method
$res = $paused->getData();
//This asserts there are results for the filtered app number
$this->assertNotEmpty($res);
}
/**
* It tests the getData method with taskId filter
*
@@ -360,4 +392,478 @@ class PausedTest extends TestCase
$res = $paused->getPagingCounters();
$this->assertEquals(1, $res);
}
/**
* It tests the getCountersByProcesses() method without filters
*
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getCountersByProcesses()
* @test
*/
public function it_should_test_get_counters_by_processes_method_no_filter()
{
$cases = $this->createMultiplePaused(2);
$paused = new Paused();
$paused->setUserId($cases->USR_ID);
$paused->setUserUid($cases->USR_ID);
$res = $paused->getCountersByProcesses();
$this->assertCount(2, $res);
}
/**
* It tests the getCountersByProcesses() method with the category filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getCountersByProcesses()
* @test
*/
public function it_should_test_get_counters_by_processes_method_category()
{
$user = factory(User::class)->create();
$this->createMultiplePaused(3, 2, $user);
$this->createMultiplePaused(2, 3, $user);
$paused = new Paused();
$paused->setUserId($user->USR_ID);
$paused->setUserUid($user->USR_ID);
$res = $paused->getCountersByProcesses(2);
$this->assertCount(3, $res);
}
/**
* It tests the getCountersByProcesses() method with the top ten filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getCountersByProcesses()
* @test
*/
public function it_should_test_get_counters_by_processes_method_top_ten()
{
$user = factory(User::class)->create();
$this->createMultiplePaused(20, 2, $user);
$paused = new Paused();
$paused->setUserId($user->USR_ID);
$paused->setUserUid($user->USR_UID);
$res = $paused->getCountersByProcesses(null, true);
$this->assertCount(10, $res);
}
/**
* It tests the getCountersByProcesses() method with the processes filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getCountersByProcesses()
* @test
*/
public function it_should_test_get_counters_by_processes_method_processes_filter()
{
$user = factory(User::class)->create();
$process1 = factory(Process::class)->create();
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => '',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process1->PRO_UID,
'TAS_TYPE' => 'NORMAL'
]);
$application1 = factory(Application::class)->create();
factory(Delegation::class)->create([
'APP_UID' => $application1->APP_UID,
'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_UID' => $application1->APP_UID,
'APP_NUMBER' => $application1->APP_NUMBER,
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'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(AppDelay::class)->create([
'APP_DELEGATION_USER' => $user->USR_UID,
'PRO_UID' => $process1->PRO_UID,
'APP_NUMBER' => $delegation1->APP_NUMBER,
'APP_DEL_INDEX' => $delegation1->DEL_INDEX,
'APP_DISABLE_ACTION_USER' => 0,
'APP_TYPE' => 'PAUSE'
]);
$this->createMultiplePaused(3, 2, $user);
$paused = new Paused();
$paused->setUserId($user->USR_ID);
$paused->setUserUid($user->USR_UID);
$res = $paused->getCountersByProcesses(null, false, [$process1->PRO_ID]);
$this->assertCount(1, $res);
}
/**
* It tests the getCountersByRange() method
*
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getCountersByRange()
* @test
*/
public function it_should_test_get_counters_by_range_method()
{
$user = factory(User::class)->create();
$process1 = factory(Process::class)->create();
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => '',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process1->PRO_UID,
'TAS_TYPE' => 'NORMAL'
]);
$application1 = factory(Application::class)->create();
factory(Delegation::class)->create([
'APP_UID' => $application1->APP_UID,
'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_UID' => $application1->APP_UID,
'APP_NUMBER' => $application1->APP_NUMBER,
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'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_DELEGATE_DATE' => '2021-05-23 00:00:00'
]);
factory(AppDelay::class)->create([
'APP_DELEGATION_USER' => $user->USR_UID,
'PRO_UID' => $process1->PRO_UID,
'APP_NUMBER' => $delegation1->APP_NUMBER,
'APP_DEL_INDEX' => $delegation1->DEL_INDEX,
'APP_DISABLE_ACTION_USER' => 0,
'APP_TYPE' => 'PAUSE'
]);
$application2 = factory(Application::class)->create();
factory(Delegation::class)->create([
'APP_UID' => $application2->APP_UID,
'APP_NUMBER' => $application2->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
]);
$delegation2 = factory(Delegation::class)->create([
'APP_UID' => $application2->APP_UID,
'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' => $process1->PRO_ID,
'PRO_UID' => $process1->PRO_UID,
'DEL_PREVIOUS' => 1,
'DEL_INDEX' => 2,
'DEL_DELEGATE_DATE' => '2021-05-24 09:52:32'
]);
factory(AppDelay::class)->create([
'APP_DELEGATION_USER' => $user->USR_UID,
'PRO_UID' => $process1->PRO_UID,
'APP_NUMBER' => $delegation2->APP_NUMBER,
'APP_DEL_INDEX' => $delegation2->DEL_INDEX,
'APP_DISABLE_ACTION_USER' => 0,
'APP_TYPE' => 'PAUSE'
]);
$paused = new Paused();
$paused->setUserId($user->USR_ID);
$paused->setUserUid($user->USR_UID);
$res = $paused->getCountersByRange();
$this->assertCount(2, $res);
$res = $paused->getCountersByRange(null, null, null, 'month');
$this->assertCount(1, $res);
$res = $paused->getCountersByRange(null, null, null, 'year');
$this->assertCount(1, $res);
$res = $paused->getCountersByRange($process1->PRO_ID);
$this->assertCount(2, $res);
$res = $paused->getCountersByRange(null, '2021-05-20', '2021-05-23');
$this->assertCount(1, $res);
}
/**
* This tests the getCustomListCount() method.
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getCustomListCount()
* @test
*/
public function it_should_test_getCustomListCounts_method()
{
$cases = $this->createMultiplePaused(3);
$additionalTables = factory(AdditionalTables::class)->create();
$query = ""
. "CREATE TABLE IF NOT EXISTS `{$additionalTables->ADD_TAB_NAME}` ("
. "`APP_UID` varchar(32) NOT NULL,"
. "`APP_NUMBER` int(11) NOT NULL,"
. "`APP_STATUS` varchar(10) NOT NULL,"
. "`VAR1` varchar(255) DEFAULT NULL,"
. "`VAR2` varchar(255) DEFAULT NULL,"
. "`VAR3` varchar(255) DEFAULT NULL,"
. "PRIMARY KEY (`APP_UID`),"
. "KEY `indexTable` (`APP_UID`))";
DB::statement($query);
$caseList = factory(CaseList::class)->create([
'CAL_TYPE' => 'paused',
'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID,
'USR_ID' => $cases->USR_ID
]);
$paused = new Paused();
$paused->setUserId($cases->USR_ID);
$paused->setUserUid($cases->USR_UID);
$res = $paused->getCustomListCount($caseList->CAL_ID, 'paused');
//assertions
$this->assertArrayHasKey('label', $res);
$this->assertArrayHasKey('name', $res);
$this->assertArrayHasKey('description', $res);
$this->assertArrayHasKey('tableName', $res);
$this->assertArrayHasKey('total', $res);
$this->assertEquals($additionalTables->ADD_TAB_NAME, $res['tableName']);
$this->assertEquals(3, $res['total']);
}
/**
* It tests the getCasesRisk() method with the ontime filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getCasesRisk()
* @test
*/
public function it_should_test_get_cases_risk_on_time()
{
$date = new DateTime('now');
$currentDate = $date->format('Y-m-d H:i:s');
$diff1Day = new DateInterval('P1D');
$diff2Days = new DateInterval('P2D');
$user = factory(User::class)->create();
$process1 = factory(Process::class)->create();
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => '',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process1->PRO_UID,
'TAS_TYPE' => 'NORMAL'
]);
$application1 = factory(Application::class)->create();
factory(Delegation::class)->create([
'APP_UID' => $application1->APP_UID,
'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_DELEGATE_DATE' => $currentDate,
'DEL_RISK_DATE' => $date->add($diff1Day),
'DEL_TASK_DUE_DATE' => $date->add($diff2Days)
]);
$delegation1 = factory(Delegation::class)->create([
'APP_UID' => $application1->APP_UID,
'APP_NUMBER' => $application1->APP_NUMBER,
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'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_DELEGATE_DATE' => $currentDate,
'DEL_RISK_DATE' => $date->add($diff1Day),
'DEL_TASK_DUE_DATE' => $date->add($diff2Days)
]);
factory(AppDelay::class)->create([
'APP_DELEGATION_USER' => $user->USR_UID,
'PRO_UID' => $process1->PRO_UID,
'APP_NUMBER' => $delegation1->APP_NUMBER,
'APP_DEL_INDEX' => $delegation1->DEL_INDEX,
'APP_DISABLE_ACTION_USER' => 0,
'APP_TYPE' => 'PAUSE'
]);
$this->createMultiplePaused(3, 2, $user);
$paused = new Paused();
$paused->setUserId($user->USR_ID);
$paused->setUserUid($user->USR_UID);
$res = $paused->getCasesRisk($process1->PRO_ID);
$this->assertCount(1, $res);
}
/**
* It tests the getCasesRisk() method with the at risk filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getCasesRisk()
* @test
*/
public function it_should_test_get_cases_risk_at_risk()
{
$date = new DateTime('now');
$currentDate = $date->format('Y-m-d H:i:s');
$diff2Days = new DateInterval('P2D');
$user = factory(User::class)->create();
$process1 = factory(Process::class)->create();
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => '',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process1->PRO_UID,
'TAS_TYPE' => 'NORMAL'
]);
$application1 = factory(Application::class)->create();
factory(Delegation::class)->create([
'APP_UID' => $application1->APP_UID,
'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_DELEGATE_DATE' => $currentDate,
'DEL_RISK_DATE' => $currentDate,
'DEL_TASK_DUE_DATE' => $date->add($diff2Days)
]);
$delegation1 = factory(Delegation::class)->create([
'APP_UID' => $application1->APP_UID,
'APP_NUMBER' => $application1->APP_NUMBER,
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'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_DELEGATE_DATE' => $currentDate,
'DEL_RISK_DATE' => $currentDate,
'DEL_TASK_DUE_DATE' => $date->add($diff2Days)
]);
factory(AppDelay::class)->create([
'APP_DELEGATION_USER' => $user->USR_UID,
'PRO_UID' => $process1->PRO_UID,
'APP_NUMBER' => $delegation1->APP_NUMBER,
'APP_DEL_INDEX' => $delegation1->DEL_INDEX,
'APP_DISABLE_ACTION_USER' => 0,
'APP_TYPE' => 'PAUSE'
]);
$this->createMultiplePaused(3, 2, $user);
$paused = new Paused();
$paused->setUserId($user->USR_ID);
$paused->setUserUid($user->USR_UID);
$res = $paused->getCasesRisk($process1->PRO_ID, null, null, 'AT_RISK');
$this->assertCount(1, $res);
}
/**
* It tests the getCasesRisk() method with the overdue filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getCasesRisk()
* @test
*/
public function it_should_test_get_cases_risk_overdue()
{
$date = new DateTime('now');
$currentDate = $date->format('Y-m-d H:i:s');
$diff2Days = new DateInterval('P2D');
$user = factory(User::class)->create();
$process1 = factory(Process::class)->create();
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => '',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process1->PRO_UID,
'TAS_TYPE' => 'NORMAL'
]);
$application1 = factory(Application::class)->create();
factory(Delegation::class)->create([
'APP_UID' => $application1->APP_UID,
'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_DELEGATE_DATE' => $currentDate,
'DEL_RISK_DATE' => $currentDate,
'DEL_TASK_DUE_DATE' => $date->sub($diff2Days)
]);
$delegation1 = factory(Delegation::class)->create([
'APP_UID' => $application1->APP_UID,
'APP_NUMBER' => $application1->APP_NUMBER,
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'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_DELEGATE_DATE' => $currentDate,
'DEL_RISK_DATE' => $currentDate,
'DEL_TASK_DUE_DATE' => $date->sub($diff2Days)
]);
factory(AppDelay::class)->create([
'APP_DELEGATION_USER' => $user->USR_UID,
'PRO_UID' => $process1->PRO_UID,
'APP_NUMBER' => $delegation1->APP_NUMBER,
'APP_DEL_INDEX' => $delegation1->DEL_INDEX,
'APP_DISABLE_ACTION_USER' => 0,
'APP_TYPE' => 'PAUSE'
]);
$this->createMultiplePaused(3, 2, $user);
$paused = new Paused();
$paused->setUserId($user->USR_ID);
$paused->setUserUid($user->USR_UID);
$res = $paused->getCasesRisk($process1->PRO_ID, null, null, 'OVERDUE');
$this->assertCount(1, $res);
}
}

View File

@@ -56,8 +56,8 @@ class SearchTest extends TestCase
// Create new Search object
$search = new Search();
$result = $search->getData();
// This assert that the expected numbers of results are returned
$this->assertEquals(count($cases), count($result));
// Asserts with the result
$this->assertNotEmpty($result);
}
/**
@@ -66,6 +66,7 @@ class SearchTest extends TestCase
* @covers \ProcessMaker\BusinessModel\Cases\Search::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Search::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Search::filters()
* @covers \ProcessMaker\BusinessModel\Cases\Search::setCaseNumber()
* @test
*/
public function it_filter_by_app_number()
@@ -75,10 +76,8 @@ class SearchTest extends TestCase
// Create new Search object
$search = new Search();
$search->setCaseNumber($cases[0]->APP_NUMBER);
// Set order by column value
$search->setOrderByColumn('APP_NUMBER');
$result = $search->getData();
// This assert that the expected numbers of results are returned
// Asserts with the result
$this->assertEquals($cases[0]->APP_NUMBER, $result[0]['APP_NUMBER']);
}
@@ -88,6 +87,7 @@ class SearchTest extends TestCase
* @covers \ProcessMaker\BusinessModel\Cases\Search::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Search::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Search::filters()
* @covers \ProcessMaker\BusinessModel\Cases\Search::setCasesNumbers()
* @test
*/
public function it_filter_by_specific_cases()
@@ -97,10 +97,8 @@ class SearchTest extends TestCase
// Create new Search object
$search = new Search();
$search->setCasesNumbers([$cases[0]->APP_NUMBER]);
// Set order by column value
$search->setOrderByColumn('APP_NUMBER');
$result = $search->getData();
// This assert that the expected numbers of results are returned
// Asserts with the result
$this->assertEquals($cases[0]->APP_NUMBER, $result[0]['APP_NUMBER']);
}
@@ -110,6 +108,7 @@ class SearchTest extends TestCase
* @covers \ProcessMaker\BusinessModel\Cases\Search::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Search::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Search::filters()
* @covers \ProcessMaker\BusinessModel\Cases\Search::setRangeCasesFromTo()
* @test
*/
public function it_filter_by_range_cases()
@@ -120,10 +119,32 @@ class SearchTest extends TestCase
$search = new Search();
$rangeOfCases = $cases[0]->APP_NUMBER . "-" . $cases[0]->APP_NUMBER;
$search->setRangeCasesFromTo([$rangeOfCases]);
// Set order by column value
$search->setOrderByColumn('APP_NUMBER');
$result = $search->getData();
// This assert that the expected numbers of results are returned
// Asserts with the result
$this->assertNotEmpty($result);
}
/**
* Tests the specific filter setCasesNumbers and setRangeCasesFromTo
*
* @covers \ProcessMaker\BusinessModel\Cases\Search::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Search::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Search::filters()
* @covers \ProcessMaker\BusinessModel\Cases\Search::setCasesNumbers()
* @covers \ProcessMaker\BusinessModel\Cases\Search::setRangeCasesFromTo()
* @test
*/
public function it_filter_by_cases_and_range_cases()
{
// Create factories related to the delegation cases
$cases = $this->createSearch();
// Create new Search object
$search = new Search();
$search->setCasesNumbers([$cases[0]->APP_NUMBER]);
$rangeOfCases = $cases[0]->APP_NUMBER . "-" . $cases[0]->APP_NUMBER;
$search->setRangeCasesFromTo([$rangeOfCases]);
$result = $search->getData();
// Asserts with the result
$this->assertNotEmpty($result);
}
@@ -133,6 +154,7 @@ class SearchTest extends TestCase
* @covers \ProcessMaker\BusinessModel\Cases\Search::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Search::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Search::filters()
* @covers \ProcessMaker\BusinessModel\Cases\Search::setProcessId()
* @test
*/
public function it_filter_by_process()
@@ -142,10 +164,8 @@ class SearchTest extends TestCase
// Create new Search object
$search = new Search();
$search->setProcessId($cases[0]->PRO_ID);
// Set order by column value
$search->setOrderByColumn('APP_NUMBER');
$result = $search->getData();
// This assert that the expected numbers of results are returned
// Asserts with the result
$this->assertNotEmpty($result);
}
@@ -155,6 +175,7 @@ class SearchTest extends TestCase
* @covers \ProcessMaker\BusinessModel\Cases\Search::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Search::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Search::filters()
* @covers \ProcessMaker\BusinessModel\Cases\Search::setTaskId()
* @test
*/
public function it_filter_by_task()
@@ -164,10 +185,8 @@ class SearchTest extends TestCase
// Create new Search object
$search = new Search();
$search->setTaskId($cases[0]->TAS_ID);
// Set order by column value
$search->setOrderByColumn('APP_NUMBER');
$result = $search->getData();
// This assert that the expected numbers of results are returned
// Asserts with the result
$this->assertNotEmpty($result);
}
@@ -177,6 +196,7 @@ class SearchTest extends TestCase
* @covers \ProcessMaker\BusinessModel\Cases\Search::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Search::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Search::filters()
* @covers \ProcessMaker\BusinessModel\Cases\Search::setCaseTitle()
* @test
*/
public function it_filter_by_thread_title()
@@ -196,12 +216,34 @@ class SearchTest extends TestCase
$this->assertNotEmpty($res);
}
/**
* It tests the getData with setCategoryId
*
* @covers \ProcessMaker\BusinessModel\Cases\Search::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Search::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Search::filters()
* @covers \ProcessMaker\BusinessModel\Cases\Search::setCategoryId()
* @test
*/
public function it_filter_by_category()
{
// Create factories related to the delegation cases
$cases = $this->createSearch();
// Create new Search object
$search = new Search();
$search->setCategoryId(12);
$result = $search->getData();
// Asserts with the result
$this->assertEmpty($result);
}
/**
* It tests the getData with user
*
* @covers \ProcessMaker\BusinessModel\Cases\Search::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Search::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Search::filters()
* @covers \ProcessMaker\BusinessModel\Cases\Search::setUserId()
* @test
*/
public function it_filter_by_user()
@@ -211,19 +253,66 @@ class SearchTest extends TestCase
// Create new Search object
$search = new Search();
$search->setUserId($cases[0]->USR_ID);
// Set order by column value
$search->setOrderByColumn('APP_NUMBER');
$result = $search->getData();
// This assert that the expected numbers of results are returned
// Asserts with the result
$this->assertNotEmpty($result);
}
/**
* It tests the getData with priority
* It tests the getData with setStartCaseFrom and setStartCaseTo
*
* @covers \ProcessMaker\BusinessModel\Cases\Search::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Search::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Search::filters()
* @covers \ProcessMaker\BusinessModel\Cases\Search::setStartCaseFrom()
* @covers \ProcessMaker\BusinessModel\Cases\Search::setStartCaseTo()
* @test
*/
public function it_filter_by_start_date()
{
// Create factories related to the delegation cases
$cases = $this->createSearch();
// Create new Search object
$search = new Search();
$date = date('Y-m-d');
$search->setStartCaseFrom($date);
$search->setStartCaseTo($date);
$result = $search->getData();
// Asserts with the result
$this->assertEmpty($result);
}
/**
* It tests the getData with setFinishCaseFrom and setFinishCaseTo
*
* @covers \ProcessMaker\BusinessModel\Cases\Search::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Search::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Search::filters()
* @covers \ProcessMaker\BusinessModel\Cases\Search::setFinishCaseFrom()
* @covers \ProcessMaker\BusinessModel\Cases\Search::setFinishCaseTo()
* @test
*/
public function it_filter_by_finish_date()
{
// Create factories related to the delegation cases
$cases = $this->createSearch();
// Create new Search object
$search = new Search();
$date = date('Y-m-d');
$search->setFinishCaseFrom($date);
$search->setFinishCaseTo($date);
$result = $search->getData();
// Asserts with the result
$this->assertEmpty($result);
}
/**
* It tests the getData with status
*
* @covers \ProcessMaker\BusinessModel\Cases\Search::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Search::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Search::filters()
* @covers \ProcessMaker\BusinessModel\Cases\Search::setCaseStatuses()
* @test
*/
public function it_filter_by_status()
@@ -233,10 +322,8 @@ class SearchTest extends TestCase
// Create new Search object
$search = new Search();
$search->setCaseStatuses(['TO_DO']);
// Set order by column value
$search->setOrderByColumn('APP_NUMBER');
$result = $search->getData();
// This assert that the expected numbers of results are returned
// Asserts with the result
$this->assertNotEmpty($result);
}
@@ -253,12 +340,9 @@ class SearchTest extends TestCase
$casesNotSubmitted = factory(Delegation::class, 5)->states('web_entry')->create();
// Create new Search object
$search = new Search();
// Set order by column value
$search->setOrderByColumn('APP_NUMBER');
$result = $search->getData();
// Review if the cases not submitted are not considered
$this->assertNotEmpty($result);
$this->assertEquals(count($result) , count($cases));
}
/**
@@ -273,8 +357,6 @@ class SearchTest extends TestCase
$cases = $this->createSearch();
// Create new Search object
$search = new Search();
// Set order by column value
$search->setOrderByColumn('APP_NUMBER');
$total = $search->getCounter();
// The count for search was disabled for performance issues
$this->assertEquals($total, 0);
@@ -293,8 +375,6 @@ class SearchTest extends TestCase
$cases = $this->createSearch();
// Create new Search object
$search = new Search();
// Set order by column value
$search->setOrderByColumn('APP_NUMBER');
$total = $search->getPagingCounters();
// The count for search was disabled for performance issues
$this->assertEquals($total, 0);

View File

@@ -31,19 +31,26 @@ class SupervisingTest extends TestCase
/**
* Create supervising cases factories
* This function define a specific user in the supervisors list
*
* @param string
* @param int $cases
*
* @return array
*/
public function createSupervising()
public function createSupervising(int $cases = 2)
{
// Create process
$process = factory(Process::class)->create();
// Create user
$user = factory(User::class)->create();
// Define this user like process supervisor
factory(ProcessUser::class)->create(
[
'PRO_UID' => $process->PRO_UID,
'USR_UID' => $user->USR_UID,
'PU_TYPE' => 'SUPERVISOR'
]
);
// Create a task
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'NORMAL',
@@ -55,246 +62,112 @@ class SupervisingTest extends TestCase
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID,
]);
// Create 3 cases
$app1 = factory(Application::class)->states('todo')->create([
'APP_STATUS' => 'TO_DO',
'APP_STATUS_ID' => 2,
'PRO_UID' => $process->PRO_UID,
'APP_INIT_USER' => $user->USR_UID,
'APP_CUR_USER' => $user->USR_UID,
]);
$app2 = factory(Application::class)->states('todo')->create([
'APP_STATUS' => 'TO_DO',
'APP_STATUS_ID' => 2,
'PRO_UID' => $process->PRO_UID,
'APP_INIT_USER' => $user->USR_UID,
'APP_CUR_USER' => $user->USR_UID,
]);
$app3 = factory(Application::class)->states('todo')->create([
'APP_STATUS' => 'TO_DO',
'APP_STATUS_ID' => 2,
'PRO_UID' => $process->PRO_UID,
'APP_INIT_USER' => $user->USR_UID,
'APP_CUR_USER' => $user->USR_UID,
]);
// Create the registers in delegation
factory(Delegation::class)->create([
"APP_UID" => $app1['APP_UID'],
'TAS_ID' => $task->TAS_ID,
'TAS_UID' => $task->TAS_UID,
'DEL_THREAD_STATUS' => 'CLOSED',
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process->PRO_ID,
'PRO_UID' => $process->PRO_UID,
'APP_NUMBER' => $app1['APP_NUMBER'],
'DEL_INDEX' => 1,
'DEL_PREVIOUS' => 0
]);
factory(Delegation::class, 1)->create([
"APP_UID" => $app1['APP_UID'],
'TAS_ID' => $task2->TAS_ID,
'TAS_UID' => $task2->TAS_UID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process->PRO_ID,
'PRO_UID' => $process->PRO_UID,
'APP_NUMBER' => $app1['APP_NUMBER'],
'DEL_INDEX' => 2,
'DEL_PREVIOUS' => 1
]);
factory(Delegation::class, 1)->create([
"APP_UID" => $app2['APP_UID'],
'TAS_ID' => $task->TAS_ID,
'TAS_UID' => $task->TAS_UID,
'DEL_THREAD_STATUS' => 'CLOSED',
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process->PRO_ID,
'PRO_UID' => $process->PRO_UID,
'APP_NUMBER' => $app2['APP_NUMBER'],
'DEL_INDEX' => 1,
'DEL_PREVIOUS' => 0
]);
factory(Delegation::class, 1)->create([
"APP_UID" => $app2['APP_UID'],
'TAS_ID' => $task2->TAS_ID,
'TAS_UID' => $task2->TAS_UID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process->PRO_ID,
'PRO_UID' => $process->PRO_UID,
'APP_NUMBER' => $app2['APP_NUMBER'],
'DEL_INDEX' => 2,
'DEL_PREVIOUS' => 1
]);
factory(Delegation::class, 1)->create([
"APP_UID" => $app3['APP_UID'],
'TAS_ID' => $task->TAS_ID,
'TAS_UID' => $task->TAS_UID,
'DEL_THREAD_STATUS' => 'CLOSED',
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process->PRO_ID,
'PRO_UID' => $process->PRO_UID,
'APP_NUMBER' => $app3['APP_NUMBER'],
'DEL_INDEX' => 1,
'DEL_PREVIOUS' => 0
]);
$delegation = factory(Delegation::class)->create([
"APP_UID" => $app3['APP_UID'],
'TAS_ID' => $task2->TAS_ID,
'TAS_UID' => $task2->TAS_UID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process->PRO_ID,
'PRO_UID' => $process->PRO_UID,
'APP_NUMBER' => $app3['APP_NUMBER'],
'DEL_INDEX' => 2,
'DEL_PREVIOUS' => 1
]);
// Create the register in the ProcessUser table
factory(ProcessUser::class)->create(
[
// Create n cases related to the process
$delegation = [];
for ($i = 0; $i < $cases; $i = $i + 1) {
// Create case
$app = factory(Application::class)->states('todo')->create([
'PRO_UID' => $process->PRO_UID,
'APP_INIT_USER' => $user->USR_UID,
'APP_CUR_USER' => $user->USR_UID,
]);
// Create two threads
$delegation = factory(Delegation::class)->create([
'APP_UID' => $app['APP_UID'],
'TAS_ID' => $task->TAS_ID,
'TAS_UID' => $task->TAS_UID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_UID' => $user->USR_UID,
'PU_TYPE' => 'SUPERVISOR'
]
);
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process->PRO_ID,
'PRO_UID' => $process->PRO_UID,
'APP_NUMBER' => $app['APP_NUMBER'],
'DEL_INDEX' => 1,
'DEL_PREVIOUS' => 0,
'DEL_LAST_INDEX' => 0
]);
$delegation = factory(Delegation::class)->create([
'APP_UID' => $app['APP_UID'],
'TAS_ID' => $task2->TAS_ID,
'TAS_UID' => $task2->TAS_UID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process->PRO_ID,
'PRO_UID' => $process->PRO_UID,
'APP_NUMBER' => $app['APP_NUMBER'],
'DEL_INDEX' => 2,
'DEL_PREVIOUS' => 1,
'DEL_LAST_INDEX' => 1
]);
}
return $delegation;
}
/**
* Create many supervising cases for one user
*
* @param int
* @return object
* Create supervising cases factories
* This function define a group user in the supervisors list
*
* @param int $cases
*
* @return array
*/
public function createMultipleSupervising($cases)
public function createGroupSupervising(int $cases = 2)
{
$user = factory(\ProcessMaker\Model\User::class)->create();
// Create process
$process = factory(Process::class)->create();
// Create user
$user = factory(User::class)->create();
// Create group
$group = factory(GroupUser::class)->create([
'USR_UID' => $user->USR_UID,
]);
// Define this group like process supervisor
factory(ProcessUser::class)->create(
[
'PRO_UID' => $process->PRO_UID,
'USR_UID' => $group->GRP_UID,
'PU_TYPE' => 'GROUP_SUPERVISOR'
]
);
// Create a task
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'NORMAL',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID,
]);
$task2 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'NORMAL',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID,
]);
// Create n cases related to the process
$delegation = [];
for ($i = 0; $i < $cases; $i = $i + 1) {
// Create process
$process = factory(Process::class)->create();
// Create user
$user = factory(User::class)->create();
// Create a task
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'NORMAL',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID,
]);
$task2 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'NORMAL',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID,
]);
// Create 3 cases
$app1 = factory(Application::class)->states('todo')->create([
'APP_STATUS' => 'TO_DO',
'APP_STATUS_ID' => 2,
// Create case
$app = factory(Application::class)->states('todo')->create([
'PRO_UID' => $process->PRO_UID,
'APP_INIT_USER' => $user->USR_UID,
'APP_CUR_USER' => $user->USR_UID,
]);
$app2 = factory(Application::class)->states('todo')->create([
'APP_STATUS' => 'TO_DO',
'APP_STATUS_ID' => 2,
'PRO_UID' => $process->PRO_UID,
'APP_INIT_USER' => $user->USR_UID,
'APP_CUR_USER' => $user->USR_UID,
]);
$app3 = factory(Application::class)->states('todo')->create([
'APP_STATUS' => 'TO_DO',
'APP_STATUS_ID' => 2,
'PRO_UID' => $process->PRO_UID,
'APP_INIT_USER' => $user->USR_UID,
'APP_CUR_USER' => $user->USR_UID,
]);
// Create the registers in delegation
factory(Delegation::class)->create([
"APP_UID" => $app1['APP_UID'],
// Create two threads
$delegation = factory(Delegation::class)->create([
'APP_UID' => $app['APP_UID'],
'TAS_ID' => $task->TAS_ID,
'TAS_UID' => $task->TAS_UID,
'DEL_THREAD_STATUS' => 'CLOSED',
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process->PRO_ID,
'PRO_UID' => $process->PRO_UID,
'APP_NUMBER' => $app1['APP_NUMBER'],
'DEL_INDEX' => 1,
'DEL_PREVIOUS' => 0
]);
factory(Delegation::class, 1)->create([
"APP_UID" => $app1['APP_UID'],
'TAS_ID' => $task2->TAS_ID,
'TAS_UID' => $task2->TAS_UID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process->PRO_ID,
'PRO_UID' => $process->PRO_UID,
'APP_NUMBER' => $app1['APP_NUMBER'],
'DEL_INDEX' => 2,
'DEL_PREVIOUS' => 1
]);
factory(Delegation::class, 1)->create([
"APP_UID" => $app2['APP_UID'],
'TAS_ID' => $task->TAS_ID,
'TAS_UID' => $task->TAS_UID,
'DEL_THREAD_STATUS' => 'CLOSED',
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process->PRO_ID,
'PRO_UID' => $process->PRO_UID,
'APP_NUMBER' => $app2['APP_NUMBER'],
'APP_NUMBER' => $app['APP_NUMBER'],
'DEL_INDEX' => 1,
'DEL_PREVIOUS' => 0
]);
factory(Delegation::class, 1)->create([
"APP_UID" => $app2['APP_UID'],
'TAS_ID' => $task2->TAS_ID,
'TAS_UID' => $task2->TAS_UID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process->PRO_ID,
'PRO_UID' => $process->PRO_UID,
'APP_NUMBER' => $app2['APP_NUMBER'],
'DEL_INDEX' => 2,
'DEL_PREVIOUS' => 1
]);
factory(Delegation::class, 1)->create([
"APP_UID" => $app3['APP_UID'],
'TAS_ID' => $task->TAS_ID,
'TAS_UID' => $task->TAS_UID,
'DEL_THREAD_STATUS' => 'CLOSED',
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process->PRO_ID,
'PRO_UID' => $process->PRO_UID,
'APP_NUMBER' => $app3['APP_NUMBER'],
'DEL_INDEX' => 1,
'DEL_PREVIOUS' => 0
'DEL_PREVIOUS' => 0,
'DEL_LAST_INDEX' => 0
]);
$delegation = factory(Delegation::class)->create([
"APP_UID" => $app3['APP_UID'],
'APP_UID' => $app['APP_UID'],
'TAS_ID' => $task2->TAS_ID,
'TAS_UID' => $task2->TAS_UID,
'DEL_THREAD_STATUS' => 'OPEN',
@@ -302,69 +175,68 @@ class SupervisingTest extends TestCase
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process->PRO_ID,
'PRO_UID' => $process->PRO_UID,
'APP_NUMBER' => $app3['APP_NUMBER'],
'APP_NUMBER' => $app['APP_NUMBER'],
'DEL_INDEX' => 2,
'DEL_PREVIOUS' => 1
'DEL_PREVIOUS' => 1,
'DEL_LAST_INDEX' => 1
]);
// Create the register in the ProcessUser table
factory(ProcessUser::class)->create(
[
'PRO_UID' => $process->PRO_UID,
'USR_UID' => $user->USR_UID,
'PU_TYPE' => 'SUPERVISOR'
]
);
}
return $user;
return $delegation;
}
/**
* Tests the getData() method when the user is a supervisor of the process(es)
*
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::setUserUid()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::setUserId()
* @test
*/
public function it_should_test_the_get_data_method_when_the_user_is_supervisor()
{
$cases = $this->createSupervising();
// Instance the Supervising class
$Supervising = new Supervising();
$supervising = new Supervising();
// Set the user UID
$Supervising->setUserUid($cases->USR_UID);
// Set the user ID
$Supervising->setUserId($cases->USR_ID);
// Call the getData method
$res = $Supervising->getData();
// Asserts the result contains 3 registers
$this->assertCount(3, $res);
$supervising->setUserUid($cases->USR_UID);
// Set the user
$supervising->setUserId($cases->USR_ID);
// Get the data
$result = $supervising->getData();
// Asserts with the result
$this->assertNotEmpty($result);
}
/**
* Tests the getData() method when the user belongs to a group supervisor
*
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::setUserUid()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::setUserId()
* @test
*/
public function it_should_test_the_get_data_method_when_the_user_belong_to_a_group_supervisor()
{
$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);
//Call the getData method
$res = $Supervising->getData();
// Asserts the result contains 3 registers
$this->assertCount(3, $res);
$supervising = new Supervising();
// Set the user UID
$supervising->setUserUid($cases->USR_UID);
// Set the user ID
$supervising->setUserId($cases->USR_ID);
// Get the data
$result = $supervising->getData();
// Asserts with the result
$this->assertNotEmpty($result);
}
/**
* Tests the getData() method when the user is not a supervisor neither belongs to a group supervisor
*
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::setUserUid()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::setUserId()
* @test
*/
public function it_should_test_the_get_data_method_when_the_user_is_not_supervisor()
@@ -372,118 +244,142 @@ class SupervisingTest extends TestCase
$user = factory(User::class)->create();
$cases = $this->createSupervising();
// Instance the Supervising object
$Supervising = new Supervising();
//Set the user UID
$Supervising->setUserUid($user->USR_UID);
//Set the user ID
$Supervising->setUserId($user->USR_ID);
//Call the getData method
$res = $Supervising->getData();
// Asserts the result
$this->assertEmpty($res);
$supervising = new Supervising();
// Set the user UID
$supervising->setUserUid($user->USR_UID);
// Set the user
$supervising->setUserId($user->USR_ID);
// Get the data
$result = $supervising->getData();
// Asserts with the result
$this->assertEmpty($result);
}
/**
* Tests the getCounter() method
*
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::getCounter()
* @test
*/
public function it_should_count_the_data()
{
$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);
//Call the getCounter method
$res = $Supervising->getCounter();
//Assert the counter
$this->assertEquals(3, $res);
}
/**
* Tests the filter by APP_NUMBER
* Tests the specific filter setCaseNumber
*
* @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::setCaseNumber()
* @test
*/
public function it_filter_by_app_number()
{
$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);
$Supervising->setCaseNumber($cases->APP_NUMBER);
//Call the getData method
$res = $Supervising->getData();
// Asserts the result contains 3 registers
$this->assertCount(1, $res);
//Asserts that the result contains the app number searched
$this->assertContains($cases->APP_NUMBER, $res[0]);
}
/**
* Tests the filter by process
*
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::filters()
* @test
*/
public function it_filter_by_process()
{
$cases = $this->createSupervising();
// Instance the Supervising object
$Supervising = new Supervising();
$supervising = new Supervising();
// Set the user UID
$Supervising->setUserUid($cases['USR_UID']);
// Set the user ID
$Supervising->setUserId($cases['USR_ID']);
// Set the process Id filter
$Supervising->setProcessId($cases['PRO_ID']);
// Call the getData method
$res = $Supervising->getData();
$this->assertCount(3, $res);
$supervising->setUserUid($cases->USR_UID);
// Set the user
$supervising->setUserId($cases->USR_ID);
// Set the case number
$supervising->setCaseNumber($cases->APP_NUMBER);
// Get the data
$result = $supervising->getData();
// Asserts with the result
$this->assertNotEmpty($result);
}
/**
* Tests the filter by process
* Tests the specific filter setCasesNumbers
*
* @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::setCasesNumbers()
* @test
*/
public function it_filter_by_task()
public function it_filter_by_specific_cases()
{
$cases = $this->createSupervising();
// Instance the Supervising object
$Supervising = new Supervising();
$supervising = new Supervising();
// Set the user UID
$Supervising->setUserUid($cases['USR_UID']);
// Set the user ID
$Supervising->setUserId($cases['USR_ID']);
// Set the process Id filter
$Supervising->setTaskId($cases['TAS_ID']);
// Call the getData method
$res = $Supervising->getData();
$this->assertCount(3, $res);
$supervising->setUserUid($cases->USR_UID);
// Set the user
$supervising->setUserId($cases->USR_ID);
// Set the case numbers
$supervising->setCasesNumbers([$cases->APP_NUMBER]);
// Get the data
$result = $supervising->getData();
// Asserts with the result
$this->assertNotEmpty($result);
}
/**
* It tests the getData method with case title filter
* Tests the specific filter setRangeCasesFromTo
*
* @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::setRangeCasesFromTo()
* @test
*/
public function it_filter_by_range_cases()
{
$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 range of case numbers
$rangeOfCases = $cases->APP_NUMBER . "-" . $cases->APP_NUMBER;
$supervising->setRangeCasesFromTo([$rangeOfCases]);
// Get the data
$result = $supervising->getData();
// Asserts with the result
$this->assertNotEmpty($result);
}
/**
* Tests the specific filter setCasesNumbers and setRangeCasesFromTo
*
* @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::setCasesNumbers()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::setRangeCasesFromTo()
* @test
*/
public function it_filter_by_cases_and_range_cases()
{
$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 range of case numbers
$rangeOfCases = $cases->APP_NUMBER . "-" . $cases->APP_NUMBER;
$supervising->setCasesNumbers([$cases->APP_NUMBER]);
$supervising->setRangeCasesFromTo([$rangeOfCases]);
// Get the data
$result = $supervising->getData();
// Asserts with the result
$this->assertNotEmpty($result);
}
/**
* Tests the specific filter caseTitle
*
* @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::setCaseTitle()
* @test
*/
public function it_filter_by_thread_title()
@@ -504,9 +400,155 @@ class SupervisingTest extends TestCase
// Set the title
$supervising->setCaseTitle($title);
// Get the data
$res = $supervising->getData();
// Asserts
$this->assertCount(1, $res);
$result = $supervising->getData();
// Asserts with the result
$this->assertNotEmpty($result);
}
/**
* Tests the specific filter process
*
* @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::setProcessId()
* @test
*/
public function it_filter_by_process()
{
$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->setProcessId($cases['PRO_ID']);
// Get the data
$result = $supervising->getData();
// Asserts with the result
$this->assertNotEmpty($result);
}
/**
* Tests the specific filter task
*
* @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::setTaskId()
* @test
*/
public function it_filter_by_task()
{
$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 task
$supervising->setTaskId($cases['TAS_ID']);
// Get the data
$result = $supervising->getData();
// Asserts with the result
$this->assertNotEmpty($result);
}
/**
* Tests the specific filter status
*
* @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::setCaseStatus()
* @test
*/
public function it_filter_by_status()
{
$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 task
$supervising->setCaseStatus('TO_DO');
// Get the data
$result = $supervising->getData();
// Asserts with the result
$this->assertNotEmpty($result);
}
/**
* It tests the getData the specific filter setStartCaseFrom and getStartCaseTo
*
* @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::setStartCaseFrom()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::setStartCaseTo()
* @test
*/
public function it_filter_by_start_date()
{
$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 range of dates
$date = date('Y-m-d');
$supervising->setStartCaseFrom($date);
$supervising->setStartCaseTo($date);
// Get the data
$result = $supervising->getData();
// Asserts with the result
$this->assertEmpty($result);
}
/**
* It tests the getData the specific filter setFinishCaseFrom and setFinishCaseTo
*
* @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::setFinishCaseFrom()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::setFinishCaseTo()
* @test
*/
public function it_filter_by_finish_date()
{
$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 range of dates
$date = date('Y-m-d');
$supervising->setFinishCaseFrom($date);
$supervising->setFinishCaseTo($date);
// Get the data
$result = $supervising->getData();
// Asserts with the result
$this->assertEmpty($result);
}
/**
@@ -515,6 +557,9 @@ class SupervisingTest extends TestCase
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::filters()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::setOrderByColumn()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::setUserUid()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::setUserId()
* @test
*/
public function it_order_by_column()
@@ -525,38 +570,62 @@ class SupervisingTest extends TestCase
'APP_NUMBER',
'DEL_TITLE',
'PRO_TITLE',
'TAS_TITLE',
'APP_CREATE_DATE',
'APP_FINISH_DATE'
];
$index = array_rand($columnsView);
// 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 order by value
$Supervising->setOrderByColumn($columnsView[$index]);
//Call the getData method
$result = $Supervising->getData();
$supervising = new Supervising();
// Set the user UID
$supervising->setUserUid($cases['USR_UID']);
// Set the user ID
$supervising->setUserId($cases['USR_ID']);
// Set the order by value
$supervising->setOrderByColumn($columnsView[$index]);
// Get the data
$result = $supervising->getData();
// Asserts with the result
$this->assertNotEmpty($result);
}
/**
* Tests the getCounter() method
*
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::getCounter()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::setUserUid()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::setUserId()
* @test
*/
public function it_should_count_the_data()
{
$cases = $this->createSupervising();
// Instance the Supervising object
$supervising = new Supervising();
// Set the user UID
$supervising->setUserUid($cases->USR_UID);
// Set the user
$supervising->setUserId($cases->USR_ID);
// Get the data
$result = $supervising->getCounter();
// Asserts with the result
$this->assertTrue($result > 0 );
}
/**
* It tests the getPagingCounters() method
*
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::getPagingCounters()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::filters()
* @test
*/
public function it_should_test_get_paging_counters_method()
{
$cases = $this->createMultipleSupervising(3);
$cases = $this->createSupervising(3);
$supervising = new Supervising();
$supervising->setUserId($cases->USR_ID);
$supervising->setUserUid($cases->USR_UID);
$res = $supervising->getPagingCounters();
$this->assertEquals(3, $res);
$supervising->setCaseUid($cases->APP_UID);
// Get the count
$result = $supervising->getPagingCounters();
// Asserts with the result
$this->assertTrue($result > 0 );
}
}

View File

@@ -1,13 +1,17 @@
<?php
namespace Tests\unit\workflow\src\ProcessMaker\BusinessModel\Cases;
namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases;
use DateInterval;
use Datetime;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\BusinessModel\Cases\Unassigned;
use ProcessMaker\Model\AdditionalTables;
use ProcessMaker\Model\AppAssignSelfServiceValue;
use ProcessMaker\Model\AppAssignSelfServiceValueGroup;
use ProcessMaker\Model\Application;
use ProcessMaker\Model\CaseList;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\GroupUser;
use ProcessMaker\Model\Groupwf;
@@ -88,7 +92,6 @@ class UnassignedTest extends TestCase
'taskUser' => $taskUser,
'delegation' => $delegation
];
}
/**
@@ -135,7 +138,7 @@ class UnassignedTest extends TestCase
$selfValueGroup = factory(AppAssignSelfServiceValueGroup::class)->create([
'ID' => $appSelfValueUser->ID,
'GRP_UID' => $user->USR_UID,
'ASSIGNEE_ID' => ($userAssignee) ? $user->USR_ID: $group->GRP_ID,
'ASSIGNEE_ID' => ($userAssignee) ? $user->USR_ID : $group->GRP_ID,
'ASSIGNEE_TYPE' => $relation
]);
//Create the register in delegation relate to self-service
@@ -418,4 +421,453 @@ class UnassignedTest extends TestCase
$res = $unassigned->getPagingCounters();
$this->assertNotEmpty($res);
}
}
/**
* It tests the getCountersByProcesses() method without filters
*
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getCountersByProcesses()
* @test
*/
public function it_should_test_get_counters_by_processes_method_no_filter()
{
$cases = $this->createMultipleUnassigned(3);
$unassigned = new Unassigned();
$unassigned->setUserId($cases->USR_ID);
$unassigned->setUserUid($cases->USR_UID);
$res = $unassigned->getCountersByProcesses();
$this->assertCount(3, $res);
}
/**
* It tests the getCountersByProcesses() method with the category filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getCountersByProcesses()
* @test
*/
public function it_should_test_get_counters_by_processes_method_category()
{
$user = factory(User::class)->create();
$process1 = factory(Process::class)->create([
'CATEGORY_ID' => 2
]);
$process2 = factory(Process::class)->create([
'CATEGORY_ID' => 3
]);
$application = factory(Application::class)->create([
'APP_STATUS_ID' => 2
]);
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process1->PRO_UID,
'PRO_ID' => $process1->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' => $process1->PRO_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
'DEL_DELEGATE_DATE' => date('Y-m-d H:m:s', strtotime("-1 year"))
]);
$task2 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process2->PRO_UID,
'PRO_ID' => $process2->PRO_ID,
]);
factory(TaskUser::class)->create([
'TAS_UID' => $task2->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1,
'TU_TYPE' => 1
]);
factory(Delegation::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'TAS_ID' => $task2->TAS_ID,
'PRO_ID' => $process2->PRO_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
'DEL_DELEGATE_DATE' => date('Y-m-d H:m:s', strtotime("-2 year"))
]);
$unassigned = new Unassigned();
$unassigned->setUserId($user->USR_ID);
$unassigned->setUserUid($user->USR_UID);
$res = $unassigned->getCountersByProcesses(2);
$this->assertCount(1, $res);
}
/**
* It tests the getCountersByProcesses() method with the top ten filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getCountersByProcesses()
* @test
*/
public function it_should_test_get_counters_by_processes_method_top_ten()
{
$cases = $this->createMultipleUnassigned(20);
$unassigned = new Unassigned();
$unassigned->setUserId($cases->USR_ID);
$unassigned->setUserUid($cases->USR_UID);
$res = $unassigned->getCountersByProcesses(null, true);
$this->assertCount(10, $res);
}
/**
* It tests the getCountersByProcesses() method with the processes filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getCountersByProcesses()
* @test
*/
public function it_should_test_get_counters_by_processes_method_processes()
{
$user = factory(User::class)->create();
$process1 = factory(Process::class)->create([
'CATEGORY_ID' => 2
]);
$process2 = factory(Process::class)->create([
'CATEGORY_ID' => 3
]);
$application = factory(Application::class)->create([
'APP_STATUS_ID' => 2
]);
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process1->PRO_UID,
'PRO_ID' => $process1->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' => $process1->PRO_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
'DEL_DELEGATE_DATE' => date('Y-m-d H:m:s', strtotime("-1 year"))
]);
$task2 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process2->PRO_UID,
'PRO_ID' => $process2->PRO_ID,
]);
factory(TaskUser::class)->create([
'TAS_UID' => $task2->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1,
'TU_TYPE' => 1
]);
factory(Delegation::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'TAS_ID' => $task2->TAS_ID,
'PRO_ID' => $process2->PRO_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
'DEL_DELEGATE_DATE' => date('Y-m-d H:m:s', strtotime("-2 year"))
]);
$unassigned = new Unassigned();
$unassigned->setUserId($user->USR_ID);
$unassigned->setUserUid($user->USR_UID);
$res = $unassigned->getCountersByProcesses(null, false, [$process1->PRO_ID]);
$this->assertCount(1, $res);
}
/**
* It tests the getCountersByRange() method
*
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getCountersByRange()
* @test
*/
public function it_should_test_get_counters_by_range_method()
{
$user = factory(User::class)->create();
$process1 = factory(Process::class)->create([
'CATEGORY_ID' => 2
]);
$process2 = factory(Process::class)->create([
'CATEGORY_ID' => 3
]);
$application = factory(Application::class)->create([
'APP_STATUS_ID' => 2
]);
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process1->PRO_UID,
'PRO_ID' => $process1->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' => $process1->PRO_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
'DEL_DELEGATE_DATE' => '2021-05-21 09:52:32'
]);
$task2 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process2->PRO_UID,
'PRO_ID' => $process2->PRO_ID,
]);
factory(TaskUser::class)->create([
'TAS_UID' => $task2->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1,
'TU_TYPE' => 1
]);
factory(Delegation::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'TAS_ID' => $task2->TAS_ID,
'PRO_ID' => $process2->PRO_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
'DEL_DELEGATE_DATE' => '2021-05-24 09:52:32'
]);
$unassigned = new Unassigned();
$unassigned->setUserId($user->USR_ID);
$unassigned->setUserUid($user->USR_UID);
$res = $unassigned->getCountersByRange();
$this->assertCount(2, $res);
$res = $unassigned->getCountersByRange(null, null, null, 'month');
$this->assertCount(1, $res);
$res = $unassigned->getCountersByRange(null, null, null, 'year');
$this->assertCount(1, $res);
$res = $unassigned->getCountersByRange($process1->PRO_ID);
$this->assertCount(1, $res);
$res = $unassigned->getCountersByRange(null, '2021-05-20', '2021-05-23');
$this->assertCount(1, $res);
}
/**
* It tests the getCustomListCount() method
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getCustomListCount()
* @test
*/
public function it_should_test_getCustomListCount_method()
{
$cases = $this->createMultipleUnassigned(0);
$additionalTables = factory(AdditionalTables::class)->create();
$query = ""
. "CREATE TABLE IF NOT EXISTS `{$additionalTables->ADD_TAB_NAME}` ("
. "`APP_UID` varchar(32) NOT NULL,"
. "`APP_NUMBER` int(11) NOT NULL,"
. "`APP_STATUS` varchar(10) NOT NULL,"
. "`VAR1` varchar(255) DEFAULT NULL,"
. "`VAR2` varchar(255) DEFAULT NULL,"
. "`VAR3` varchar(255) DEFAULT NULL,"
. "PRIMARY KEY (`APP_UID`),"
. "KEY `indexTable` (`APP_UID`))";
DB::statement($query);
$caseList = factory(CaseList::class)->create([
'CAL_TYPE' => 'unassigned',
'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID,
'USR_ID' => $cases->USR_ID
]);
$unassigned = new Unassigned();
$unassigned->setUserId($cases->USR_ID);
$unassigned->setUserUid($cases->USR_UID);
$res = $unassigned->getCustomListCount($caseList->CAL_ID, 'unassigned');
//assertions
$this->assertArrayHasKey('label', $res);
$this->assertArrayHasKey('name', $res);
$this->assertArrayHasKey('description', $res);
$this->assertArrayHasKey('tableName', $res);
$this->assertArrayHasKey('total', $res);
$this->assertEquals($additionalTables->ADD_TAB_NAME, $res['tableName']);
$this->assertEquals(0, $res['total']);
//for user or group
$cases = $this->createSelfServiceUserOrGroup();
$unassigned = new Unassigned();
$unassigned->setUserUid($cases['taskUser']->USR_UID);
$unassigned->setUserId($cases['delegation']->USR_ID);
$res = $unassigned->getCustomListCount($caseList->CAL_ID, 'unassigned');
//assertions
$this->assertArrayHasKey('label', $res);
$this->assertArrayHasKey('name', $res);
$this->assertArrayHasKey('description', $res);
$this->assertArrayHasKey('tableName', $res);
$this->assertArrayHasKey('total', $res);
$this->assertEquals($additionalTables->ADD_TAB_NAME, $res['tableName']);
$this->assertEquals(0, $res['total']);
}
/**
* It tests the getCasesRisk() method with ontime filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getCasesRisk()
* @test
*/
public function it_should_test_get_cases_risk_on_time()
{
$date = new DateTime('now');
$currentDate = $date->format('Y-m-d H:i:s');
$diff1Day = new DateInterval('P1D');
$diff2Days = new DateInterval('P2D');
$user = factory(User::class)->create();
$process1 = factory(Process::class)->create([
'CATEGORY_ID' => 2
]);
$application = factory(Application::class)->create([
'APP_STATUS_ID' => 2
]);
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process1->PRO_UID,
'PRO_ID' => $process1->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' => $process1->PRO_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
'DEL_DELEGATE_DATE' => $currentDate,
'DEL_RISK_DATE' => $date->add($diff1Day),
'DEL_TASK_DUE_DATE' => $date->add($diff2Days)
]);
$unassigned = new Unassigned();
$unassigned->setUserId($user->USR_ID);
$unassigned->setUserUid($user->USR_UID);
$res = $unassigned->getCasesRisk($process1->PRO_ID);
$this->assertCount(1, $res);
}
/**
* It tests the getCasesRisk() method with at risk filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getCasesRisk()
* @test
*/
public function it_should_test_get_cases_risk_at_risk()
{
$date = new DateTime('now');
$currentDate = $date->format('Y-m-d H:i:s');
$diff2Days = new DateInterval('P2D');
$user = factory(User::class)->create();
$process1 = factory(Process::class)->create([
'CATEGORY_ID' => 2
]);
$application = factory(Application::class)->create([
'APP_STATUS_ID' => 2
]);
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process1->PRO_UID,
'PRO_ID' => $process1->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' => $process1->PRO_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
'DEL_DELEGATE_DATE' => $currentDate,
'DEL_RISK_DATE' => $currentDate,
'DEL_TASK_DUE_DATE' => $date->add($diff2Days)
]);
$unassigned = new Unassigned();
$unassigned->setUserId($user->USR_ID);
$unassigned->setUserUid($user->USR_UID);
$res = $unassigned->getCasesRisk($process1->PRO_ID, null, null, 'AT_RISK');
$this->assertCount(1, $res);
}
/**
* It tests the getCasesRisk() method with overdue filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getCasesRisk()
* @test
*/
public function it_should_test_get_cases_risk_overdue()
{
$date = new DateTime('now');
$currentDate = $date->format('Y-m-d H:i:s');
$diff2Days = new DateInterval('P2D');
$user = factory(User::class)->create();
$process1 = factory(Process::class)->create([
'CATEGORY_ID' => 2
]);
$application = factory(Application::class)->create([
'APP_STATUS_ID' => 2
]);
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process1->PRO_UID,
'PRO_ID' => $process1->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' => $process1->PRO_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
'DEL_DELEGATE_DATE' => $currentDate,
'DEL_RISK_DATE' => $currentDate,
'DEL_TASK_DUE_DATE' => $date->sub($diff2Days)
]);
$unassigned = new Unassigned();
$unassigned->setUserId($user->USR_ID);
$unassigned->setUserUid($user->USR_UID);
$res = $unassigned->getCasesRisk($process1->PRO_ID, null, null, 'OVERDUE');
$this->assertCount(1, $res);
}
}

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;
@@ -42,6 +43,7 @@ class CasesTest extends TestCase
* This checks the delete case
*
* @covers \ProcessMaker\BusinessModel\Cases::deleteCase()
*
* @test
* @expectedException Exception
*/
@@ -63,6 +65,7 @@ class CasesTest extends TestCase
* This checks the delete case
*
* @covers \ProcessMaker\BusinessModel\Cases::deleteCase()
*
* @test
* @expectedException Exception
*/
@@ -84,6 +87,7 @@ class CasesTest extends TestCase
* This checks the delete case
*
* @covers \ProcessMaker\BusinessModel\Cases::deleteCase()
*
* @test
* @expectedException Exception
*/
@@ -375,6 +379,47 @@ class CasesTest extends TestCase
self::assertCount(1, Cases::dynaFormsByApplication($application->APP_UID, $task2->TAS_UID, '', 'TO_DO'));
// Get DynaForms assigned as steps for the second task when the application status is COMPLETED
self::assertCount(2, Cases::dynaFormsByApplication($application->APP_UID, $task2->TAS_UID, '', '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

@@ -340,7 +340,7 @@ class EmailServerTest extends TestCase
// Assert the status is false
$this->assertFalse($result['success']);
// Assert the message of the result is empty
$this->assertEmpty($result['msg']);
$this->assertNotEmpty($result['msg']);
}
/**

View File

@@ -0,0 +1,56 @@
<?php
namespace ProcessMaker\BusinessModel;
use ProcessMaker\BusinessModel\Table;
use ProcessMaker\Model\AdditionalTables;
use Tests\TestCase;
class TableTest extends TestCase
{
/**
* Method setUp.
*/
public function setUp()
{
parent::setUp();
AdditionalTables::truncate();
}
/**
* Method tearDown.
*/
public function tearDown()
{
parent::tearDown();
}
/**
* This test getTables() method.
* @test
* @covers \ProcessMaker\BusinessModel\Table::getTables()
*/
public function it_should_test_getTables_method()
{
$additionalTables = factory(AdditionalTables::class)
->create();
$proUid = $additionalTables->PRO_UID;
$search = $additionalTables->ADD_TAB_NAME;
$table = new Table();
$result = $table->getTables($proUid, true, false, $search);
//assertions
$this->assertNotEmpty($result);
$this->assertEquals($additionalTables->ADD_TAB_NAME, $result[0]['rep_tab_name']);
$search = '';
$table = new Table();
$result = $table->getTables($proUid, true, false, $search);
//assertions
$this->assertNotEmpty($result);
$this->assertEquals($additionalTables->ADD_TAB_NAME, $result[0]['rep_tab_name']);
}
}

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

@@ -0,0 +1,64 @@
<?php
namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use ProcessMaker\Model\AppThread;
use Tests\TestCase;
/**
* Class AppThreadTest
*
* @coversDefaultClass \ProcessMaker\Model\AppThread
*/
class AppThreadTest extends TestCase
{
use DatabaseTransactions;
/**
* Set up function.
*/
public function setUp()
{
parent::setUp();
}
/**
* This test scopeAppUid
*
* @covers \ProcessMaker\Model\AppThread::scopeAppUid()
* @test
*/
public function it_return_scope_app_uid()
{
$table = factory(AppThread::class)->create();
$this->assertCount(1, $table->appUid($table->APP_UID)->get());
}
/**
* This test scopeIndex
*
* @covers \ProcessMaker\Model\AppThread::scopeIndex()
* @test
*/
public function it_return_scope_index()
{
$table = factory(AppThread::class)->create();
$this->assertCount(1, $table->index($table->DEL_INDEX)->get());
}
/**
* This test getThread
*
* @covers \ProcessMaker\Model\AppThread::getThread()
* @covers \ProcessMaker\Model\AppThread::scopeAppUid()
* @covers \ProcessMaker\Model\AppThread::scopeIndex()
* @test
*/
public function it_return_thread()
{
$table = factory(AppThread::class)->create();
$result = AppThread::getThread($table->APP_UID, $table->DEL_INDEX);
$this->assertNotEmpty($result);
}
}

View File

@@ -87,6 +87,11 @@ class ApplicationTest extends TestCase
{
$table = factory(Application::class)->states('foreign_keys')->create();
$usrId = User::getId($table->APP_INIT_USER);
factory(Delegation::class)->states('foreign_keys')->create([
'APP_UID' => $table->APP_UID,
'APP_NUMBER' => $table->APP_NUMBER,
'USR_ID' => $usrId,
]);
$this->assertCount(1, $table->joinDelegation()->userId($usrId)->get());
}
@@ -162,6 +167,20 @@ class ApplicationTest extends TestCase
$this->assertCount(1, $table->rangeOfCases([$table->APP_NUMBER.'-'.$table->APP_NUMBER])->get());
}
/**
* This test scopeCasesOrRangeOfCases
*
* @covers \ProcessMaker\Model\Application::scopeCasesOrRangeOfCases()
* @test
*/
public function it_return_scope_cases_or_range_of_cases()
{
$table = factory(Application::class)->states('foreign_keys')->create();
$cases = [$table->APP_NUMBER];
$rangeCases = [$table->APP_NUMBER.'-'.$table->APP_NUMBER];
$this->assertCount(1, $table->casesOrRangeOfCases($cases, $rangeCases)->get());
}
/**
* This test scopeCasesFrom
*

View File

@@ -0,0 +1,461 @@
<?php
namespace tests\unit\workflow\engine\src\ProcessMaker\Model;
use ProcessMaker\Model\AdditionalTables;
use ProcessMaker\Model\CaseList;
use Tests\TestCase;
class CaseListTest extends TestCase
{
/**
* setUp method.
*/
public function setUp()
{
parent::setUp();
}
/**
* teardown method.
*/
public function tearDown()
{
parent::tearDown();
}
/**
* This tests the getColumnNameFromAlias method.
* @test
* @covers \ProcessMaker\Model\CaseList::createSetting()
*/
public function it_should_test_getColumnNameFromAlias()
{
$data = [
'id' => 1,
'type' => 'inbox',
'name' => 'test1',
'description' => 'my description',
'tableUid' => '',
'columns' => [],
'userId' => 1,
'iconList' => 'deafult.png',
'iconColor' => 'red',
'iconColorScreen' => 'blue',
'createDate' => date('Y-m-d H:m:s'),
'updateDate' => date('Y-m-d H:m:s')
];
$array = CaseList::getColumnNameFromAlias($data);
//asserts
$this->assertArrayHasKey("CAL_ID", $array);
$this->assertArrayHasKey("CAL_TYPE", $array);
$this->assertArrayHasKey("CAL_NAME", $array);
$this->assertArrayHasKey("CAL_DESCRIPTION", $array);
$this->assertArrayHasKey("ADD_TAB_UID", $array);
$this->assertArrayHasKey("CAL_COLUMNS", $array);
$this->assertArrayHasKey("USR_ID", $array);
$this->assertArrayHasKey("CAL_ICON_LIST", $array);
$this->assertArrayHasKey("CAL_ICON_COLOR", $array);
$this->assertArrayHasKey("CAL_ICON_COLOR_SCREEN", $array);
$this->assertArrayHasKey("CAL_CREATE_DATE", $array);
$this->assertArrayHasKey("CAL_UPDATE_DATE", $array);
}
/**
* This tests the getAliasFromColumnName method.
* @test
* @covers \ProcessMaker\Model\CaseList::createSetting()
*/
public function it_should_test_getAliasFromColumnName()
{
$data = [
'CAL_ID' => 1,
'CAL_TYPE' => 'inbox',
'CAL_NAME' => 'test1',
'CAL_DESCRIPTION' => 'my description',
'ADD_TAB_UID' => 'my description',
'CAL_COLUMNS' => [],
'USR_ID' => 1,
'CAL_ICON_LIST' => 'deafult.png',
'CAL_ICON_COLOR' => 'red',
'CAL_ICON_COLOR_SCREEN' => 'blue',
'CAL_CREATE_DATE' => date('Y-m-d H:m:s'),
'CAL_UPDATE_DATE' => date('Y-m-d H:m:s')
];
$array = CaseList::getAliasFromColumnName($data);
//asserts
$this->assertArrayHasKey("id", $array);
$this->assertArrayHasKey("type", $array);
$this->assertArrayHasKey("name", $array);
$this->assertArrayHasKey("description", $array);
$this->assertArrayHasKey("tableUid", $array);
$this->assertArrayHasKey("columns", $array);
$this->assertArrayHasKey("userId", $array);
$this->assertArrayHasKey("iconList", $array);
$this->assertArrayHasKey("iconColor", $array);
$this->assertArrayHasKey("iconColorScreen", $array);
$this->assertArrayHasKey("createDate", $array);
$this->assertArrayHasKey("updateDate", $array);
}
/**
* This tests the createSetting method.
* @test
* @covers \ProcessMaker\Model\CaseList::createSetting()
*/
public function it_should_test_createSetting()
{
$data = [
'type' => 'inbox',
'name' => 'test1',
'description' => 'my description',
'tableUid' => '',
'columns' => [],
'userId' => 1,
'iconList' => 'deafult.png',
'iconColor' => 'red',
'iconColorScreen' => 'blue',
'createDate' => date('Y-m-d H:m:s'),
'updateDate' => date('Y-m-d H:m:s')
];
$caseList = CaseList::createSetting($data, $data['userId']);
//asserts
$this->assertEquals($data['type'], $caseList->CAL_TYPE);
$this->assertEquals($data['name'], $caseList->CAL_NAME);
$this->assertEquals($data['description'], $caseList->CAL_DESCRIPTION);
$this->assertEquals($data['tableUid'], $caseList->ADD_TAB_UID);
$this->assertEquals($data['columns'], $caseList->CAL_COLUMNS);
$this->assertEquals($data['userId'], $caseList->USR_ID);
$this->assertEquals($data['iconList'], $caseList->CAL_ICON_LIST);
$this->assertEquals($data['iconColor'], $caseList->CAL_ICON_COLOR);
$this->assertEquals($data['iconColorScreen'], $caseList->CAL_ICON_COLOR_SCREEN);
}
/**
* This tests the updateSetting method.
* @test
* @covers \ProcessMaker\Model\CaseList::updateSetting()
*/
public function it_should_test_updateSetting()
{
$data = [
'type' => 'inbox',
'name' => 'test1',
'description' => 'my description',
'tableUid' => '',
'columns' => [],
'userId' => 1,
'iconList' => 'deafult.png',
'iconColor' => 'red',
'iconColorScreen' => 'blue',
'createDate' => date('Y-m-d H:m:s'),
'updateDate' => date('Y-m-d H:m:s')
];
$model = CaseList::createSetting($data, $data['userId']);
$id = $model->CAL_ID;
$data2 = [
'type' => 'todo',
'name' => 'new name',
'description' => 'new deescription',
];
$caseList = CaseList::updateSetting($id, $data2, $data['userId']);
//asserts
$this->assertEquals($data2['type'], $caseList->CAL_TYPE);
$this->assertEquals($data2['name'], $caseList->CAL_NAME);
$this->assertEquals($data2['description'], $caseList->CAL_DESCRIPTION);
$this->assertEquals($data['tableUid'], $caseList->ADD_TAB_UID);
$this->assertEquals($data['columns'], $caseList->CAL_COLUMNS);
$this->assertEquals($data['userId'], $caseList->USR_ID);
$this->assertEquals($data['iconList'], $caseList->CAL_ICON_LIST);
$this->assertEquals($data['iconColor'], $caseList->CAL_ICON_COLOR);
$this->assertEquals($data['iconColorScreen'], $caseList->CAL_ICON_COLOR_SCREEN);
}
/**
* This tests the deleteSetting method.
* @test
* @covers \ProcessMaker\Model\CaseList::deleteSetting()
*/
public function it_should_test_deleteSetting()
{
$data = [
'type' => 'inbox',
'name' => 'test1',
'description' => 'my description',
'tableUid' => '',
'columns' => [],
'userId' => 1,
'iconList' => 'deafult.png',
'iconColor' => 'red',
'iconColorScreen' => 'blue',
'createDate' => date('Y-m-d H:m:s'),
'updateDate' => date('Y-m-d H:m:s')
];
$model = CaseList::createSetting($data, $data['userId']);
$id = $model->CAL_ID;
$caseList = CaseList::deleteSetting($id);
//asserts
$this->assertEquals($data['type'], $caseList->CAL_TYPE);
$this->assertEquals($data['name'], $caseList->CAL_NAME);
$this->assertEquals($data['description'], $caseList->CAL_DESCRIPTION);
$this->assertEquals($data['tableUid'], $caseList->ADD_TAB_UID);
$this->assertEquals($data['columns'], $caseList->CAL_COLUMNS);
$this->assertEquals($data['userId'], $caseList->USR_ID);
$this->assertEquals($data['iconList'], $caseList->CAL_ICON_LIST);
$this->assertEquals($data['iconColor'], $caseList->CAL_ICON_COLOR);
$this->assertEquals($data['iconColorScreen'], $caseList->CAL_ICON_COLOR_SCREEN);
}
/**
* This tests the getSetting method.
* @test
* @covers \ProcessMaker\Model\CaseList::deleteSetting()
*/
public function it_should_test_getSetting()
{
CaseList::truncate();
$data = [
'type' => 'inbox',
'name' => 'test1',
'description' => 'my description',
'tableUid' => '',
'columns' => [],
'userId' => 1,
'iconList' => 'deafult.png',
'iconColor' => 'red',
'iconColorScreen' => 'blue'
];
$model1 = CaseList::createSetting($data, $data['userId']);
$model2 = CaseList::createSetting($data, $data['userId']);
$model3 = CaseList::createSetting($data, $data['userId']);
$model4 = CaseList::createSetting($data, $data['userId']);
//assert total
$result = CaseList::getSetting('inbox', '', 0, 10);
$this->assertArrayHasKey("total", $result);
$this->assertArrayHasKey("data", $result);
$this->assertEquals(4, $result['total']);
//assert page 1
$result = CaseList::getSetting('inbox', '', 0, 2);
$this->assertArrayHasKey("total", $result);
$this->assertArrayHasKey("data", $result);
$this->assertEquals(4, $result['total']);
$this->assertEquals(2, count($result['data']));
//assert page 2
$result = CaseList::getSetting('inbox', '', 2, 2);
$this->assertArrayHasKey("total", $result);
$this->assertArrayHasKey("data", $result);
$this->assertEquals(4, $result['total']);
$this->assertEquals(2, count($result['data']));
//assert search
$result = CaseList::getSetting('inbox', 'test1', 0, 10);
$this->assertArrayHasKey("total", $result);
$this->assertArrayHasKey("data", $result);
$this->assertEquals(4, $result['total']);
$this->assertEquals(4, count($result['data']));
//assert search no exist result
$result = CaseList::getSetting('inbox', 'xxxx', 0, 10);
$this->assertArrayHasKey("total", $result);
$this->assertArrayHasKey("data", $result);
$this->assertEquals(0, $result['total']);
$this->assertEquals(0, count($result['data']));
}
/**
* This tests the import method.
* @test
* @covers \ProcessMaker\Model\CaseList::import()
*/
public function it_should_test_import()
{
$additionalTables = factory(AdditionalTables::class)->create();
$data = [
'type' => 'inbox',
'name' => 'test1',
'description' => 'my description',
'tableUid' => $additionalTables->ADD_TAB_UID,
'columns' => [],
'iconList' => 'deafult.png',
'iconColor' => 'red',
'iconColorScreen' => 'blue',
'tableName' => $additionalTables->ADD_TAB_NAME
];
$json = json_encode($data);
$tempFile = sys_get_temp_dir() . '/test_' . random_int(10000, 99999);
file_put_contents($tempFile, $json);
$_FILES = [
'file_content' => [
'tmp_name' => $tempFile,
'error' => 0
]
];
$request_data = [
'invalidFields' => 'continue',
'duplicateName' => 'continue'
];
$ownerId = 1;
$result = CaseList::import($request_data, $ownerId);
//assert
$this->assertArrayHasKey('type', $result);
$this->assertArrayHasKey('name', $result);
$this->assertArrayHasKey('description', $result);
$this->assertEquals($data['type'], $result['type']);
$this->assertEquals($data['name'], $result['name']);
$this->assertEquals($data['description'], $result['description']);
}
/**
* This tests the export method.
* @test
* @covers \ProcessMaker\Model\CaseList::export()
*/
public function it_should_test_export()
{
CaseList::truncate();
$data = [
'type' => 'inbox',
'name' => 'test export',
'description' => 'my description',
'tableUid' => '',
'columns' => [],
'userId' => 1,
'iconList' => 'deafult.png',
'iconColor' => 'red',
'iconColorScreen' => 'blue'
];
CaseList::createSetting($data, $data['userId']);
$result = CaseList::export($data['userId']);
//assert
$this->assertArrayHasKey('type', $result['data']);
$this->assertArrayHasKey('name', $result['data']);
$this->assertArrayHasKey('description', $result['data']);
$this->assertEquals($data['type'], $result['data']['type']);
$this->assertEquals($data['name'], $result['data']['name']);
$this->assertEquals($data['description'], $result['data']['description']);
//assert file export
$this->assertFileExists($result['filename']);
}
/**
* This test the formattingColumns method.
* @test
* @covers \ProcessMaker\Model\CaseList::formattingColumns()
*/
public function it_should_test_formattingColumns()
{
$additionalTables = factory(\ProcessMaker\Model\AdditionalTables::class)->create();
$fields = factory(\ProcessMaker\Model\Fields::class, 5)->create([
'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID
]);
factory(CaseList::class)->create([
'CAL_TYPE' => 'inbox',
'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID
]);
factory(CaseList::class)->create([
'CAL_TYPE' => 'draft',
'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID
]);
factory(CaseList::class)->create([
'CAL_TYPE' => 'paused',
'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID
]);
factory(CaseList::class)->create([
'CAL_TYPE' => 'unassigned',
'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID
]);
$columns = [
[
"field" => "case_number",
"enableFilter" => false,
"set" => true
],
[
"field" => "case_title",
"enableFilter" => false,
"set" => true
],
];
$result = CaseList::formattingColumns('inbox', $additionalTables->ADD_TAB_UID, $columns);
$this->assertNotEmpty($result);
$this->assertArrayHasKey('field', $result[0]);
$this->assertArrayHasKey('name', $result[0]);
$this->assertArrayHasKey('type', $result[0]);
$this->assertArrayHasKey('source', $result[0]);
$this->assertArrayHasKey('typeSearch', $result[0]);
$this->assertArrayHasKey('enableFilter', $result[0]);
$this->assertArrayHasKey('set', $result[0]);
$result = CaseList::formattingColumns('draft', $additionalTables->ADD_TAB_UID, $columns);
$this->assertNotEmpty($result);
$this->assertArrayHasKey('field', $result[1]);
$this->assertArrayHasKey('name', $result[1]);
$this->assertArrayHasKey('type', $result[1]);
$this->assertArrayHasKey('source', $result[1]);
$this->assertArrayHasKey('typeSearch', $result[1]);
$this->assertArrayHasKey('enableFilter', $result[1]);
$this->assertArrayHasKey('set', $result[1]);
$result = CaseList::formattingColumns('paused', $additionalTables->ADD_TAB_UID, $columns);
$this->assertNotEmpty($result);
$this->assertArrayHasKey('field', $result[2]);
$this->assertArrayHasKey('name', $result[2]);
$this->assertArrayHasKey('type', $result[2]);
$this->assertArrayHasKey('source', $result[2]);
$this->assertArrayHasKey('typeSearch', $result[2]);
$this->assertArrayHasKey('enableFilter', $result[2]);
$this->assertArrayHasKey('set', $result[2]);
$result = CaseList::formattingColumns('unassigned', $additionalTables->ADD_TAB_UID, $columns);
$this->assertNotEmpty($result);
$this->assertArrayHasKey('field', $result[3]);
$this->assertArrayHasKey('name', $result[3]);
$this->assertArrayHasKey('type', $result[3]);
$this->assertArrayHasKey('source', $result[3]);
$this->assertArrayHasKey('typeSearch', $result[3]);
$this->assertArrayHasKey('enableFilter', $result[3]);
$this->assertArrayHasKey('set', $result[3]);
}
/**
* This test the getReportTables method.
* @test
* @covers \ProcessMaker\Model\CaseList::getReportTables()
*/
public function it_should_test_getReportTables()
{
AdditionalTables::truncate();
$additionalTables = factory(AdditionalTables::class, 10)->create();
$search = '';
$result = CaseList::getReportTables($search);
$this->assertNotEmpty($result);
$this->assertCount(10, $result);
$this->assertArrayHasKey('name', $result[0]);
$this->assertArrayHasKey('description', $result[0]);
$this->assertArrayHasKey('fields', $result[0]);
}
}

View File

@@ -2,6 +2,8 @@
namespace Tests\unit\workflow\src\ProcessMaker\Model;
use DateInterval;
use Datetime;
use G;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
@@ -139,6 +141,29 @@ class DelegationTest extends TestCase
$this->assertCount(1, $table->threadOpen()->get());
}
/**
* This test scopeThreadPause
*
* @covers \ProcessMaker\Model\Delegation::scopeThreadPause()
* @test
*/
public function it_return_scope_thread_pause()
{
$table = factory(Delegation::class)->states('foreign_keys')->create();
$this->assertCount(0, $table->threadPause()->get());
}
/**
* This test scopeOpenAndPause
*
* @covers \ProcessMaker\Model\Delegation::scopeOpenAndPause()
* @test
*/
public function it_return_scope_thread_open_and_pause()
{
$table = factory(Delegation::class)->states('foreign_keys')->create();
$this->assertCount(1, $table->openAndPause()->get());
}
/**
* This test scopeCaseStarted
*
@@ -147,7 +172,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());
}
@@ -403,6 +428,60 @@ class DelegationTest extends TestCase
$this->assertCount(1, $table->dueTo($table->DEL_TASK_DUE_DATE)->get());
}
/**
* This test scopeOnTime
*
* @covers \ProcessMaker\Model\Delegation::scopeOnTime()
* @test
*/
public function it_return_scope_on_time()
{
$table = factory(Delegation::class)->states('closed')->create();
$this->assertCount(1, $table->onTime($table->DEL_DELEGATE_DATE)->get());
}
/**
* This test scopeAtRisk
*
* @covers \ProcessMaker\Model\Delegation::scopeAtRisk()
* @test
*/
public function it_return_scope_at_risk()
{
$date = new DateTime('now');
$currentDate = $date->format('Y-m-d H:i:s');
$diff2Days = new DateInterval('P2D');
$table = factory(Delegation::class)->create([
'DEL_THREAD_STATUS' => 'CLOSED',
'DEL_DELEGATE_DATE' => $currentDate,
'DEL_RISK_DATE' => $currentDate,
'DEL_TASK_DUE_DATE' => $date->add($diff2Days)
]);
$this->assertCount(1, $table->atRisk($table->DEL_DELEGATE_DATE)->get());
}
/**
* This test scopeOverdue
*
* @covers \ProcessMaker\Model\Delegation::scopeOverdue()
* @test
*/
public function it_return_scope_overdue()
{
$date = new DateTime('now');
$currentDate = $date->format('Y-m-d H:i:s');
$diff2Days = new DateInterval('P2D');
$table = factory(Delegation::class)->create([
'DEL_THREAD_STATUS' => 'CLOSED',
'DEL_DELEGATE_DATE' => $currentDate,
'DEL_RISK_DATE' => $currentDate,
'DEL_TASK_DUE_DATE' => $date->sub($diff2Days)
]);
$this->assertCount(1, $table->overdue($table->DEL_DELEGATE_DATE)->get());
}
/**
* This test scopeCase
*
@@ -463,6 +542,20 @@ class DelegationTest extends TestCase
$this->assertCount(1, $table->positiveCases()->get());
}
/**
* This test scopeCasesOrRangeOfCases
*
* @covers \ProcessMaker\Model\Delegation::scopeCasesOrRangeOfCases()
* @test
*/
public function it_return_scope_cases_and_range_of_cases()
{
$table = factory(Delegation::class)->states('foreign_keys')->create();
$cases = [$table->APP_NUMBER];
$rangeCases = [$table->APP_NUMBER . '-' . $table->APP_NUMBER];
$this->assertCount(1, $table->casesOrRangeOfCases($cases, $rangeCases)->get());
}
/**
* This test scopeRangeOfCases
*
@@ -549,6 +642,18 @@ class DelegationTest extends TestCase
$this->assertCount(1, $table->processId($table->PRO_ID)->get());
}
/**
* This test scopeTask
*
* @covers \ProcessMaker\Model\Delegation::scopeTask()
* @test
*/
public function it_return_scope_task_id()
{
$table = factory(Delegation::class)->states('foreign_keys')->create();
$this->assertCount(1, $table->task($table->TAS_ID)->get());
}
/**
* This test scopeTask
*
@@ -634,9 +739,39 @@ class DelegationTest extends TestCase
* @test
*/
public function it_return_scope_process_in_list()
{
$process = factory(Process::class)->create();
$table = factory(Delegation::class)->states('foreign_keys')->create([
'PRO_ID' => $process->PRO_ID
]);
$this->assertCount(1, $table->joinProcess()->processInList([$table->PRO_ID])->get());
}
/**
* This test scopeParticipated
*
* @covers \ProcessMaker\Model\Delegation::scopeParticipated()
* @test
*/
public function it_return_scope_participated()
{
$table = factory(Delegation::class)->states('foreign_keys')->create();
$this->assertCount(1, $table->processInList([$table->PRO_ID])->get());
$this->assertCount(1, $table->participated($table->USR_ID)->get());
}
/**
* This test scopeCategoryId
*
* @covers \ProcessMaker\Model\Delegation::scopeCategoryId()
* @test
*/
public function it_return_scope_category()
{
$process = factory(Process::class)->create();
$table = factory(Delegation::class)->states('foreign_keys')->create([
'PRO_ID' => $process->PRO_ID
]);
$this->assertCount(1, $table->joinProcess()->categoryId($process->CATEGORY_ID)->get());
}
/**
@@ -2035,6 +2170,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));
}
/**
@@ -3117,6 +3254,28 @@ class DelegationTest extends TestCase
$this->assertNotEmpty($result);
}
/**
* This check the return of thread info
*
* @covers \ProcessMaker\Model\Delegation::getDatesFromThread()
* @test
*/
public function it_get_thread_dates()
{
$delegation = factory(Delegation::class)->states('foreign_keys')->create();
$task = new Task();
$taskInfo = $task->load($delegation->TAS_UID);
$taskInfo = head($taskInfo);
$taskType = $taskInfo['TAS_TYPE'];
$result = Delegation::getDatesFromThread(
$delegation->APP_UID,
$delegation->DEL_INDEX,
$delegation->TAS_UID,
$taskType
);
$this->assertNotEmpty($result);
}
/**
* This check the return of pending threads
*
@@ -3128,6 +3287,8 @@ class DelegationTest extends TestCase
$delegation = factory(Delegation::class)->states('foreign_keys')->create();
$result = Delegation::getPendingThreads($delegation->APP_NUMBER);
$this->assertNotEmpty($result);
$result = Delegation::getPendingThreads($delegation->APP_NUMBER, false);
$this->assertNotEmpty($result);
}
/**
@@ -3204,8 +3365,34 @@ class DelegationTest extends TestCase
]);
$res = Delegation::hasActiveParentsCases($parents);
// Assert the result is true
$this->assertTrue($res);
$res = Delegation::hasActiveParentsCases([]);
$this->assertFalse($res);
}
/**
* This check the return cases completed by specific user
*
* @covers \ProcessMaker\Model\Delegation::casesCompletedBy()
* @test
*/
public function it_get_cases_completed_by_specific_user()
{
$delegation = factory(Delegation::class)->states('last_thread')->create();
$result = Delegation::casesCompletedBy($delegation->USR_ID);
$this->assertNotEmpty($result);
}
/**
* This check the return cases completed by specific user
*
* @covers \ProcessMaker\Model\Delegation::casesStartedBy()
* @test
*/
public function it_get_cases_started_by_specific_user()
{
$delegation = factory(Delegation::class)->states('first_thread')->create();
$result = Delegation::casesStartedBy($delegation->USR_ID);
$this->assertNotEmpty($result);
}
}

View File

@@ -0,0 +1,115 @@
<?php
namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use ProcessMaker\Model\ProcessCategory;
use Tests\TestCase;
/**
* Class ProcessTest
*
* @coversDefaultClass \ProcessMaker\Model\ProcessCategory
*/
class ProcessCategoryTest extends TestCase
{
use DatabaseTransactions;
/**
* Call the setUp parent method
*/
public function setUp()
{
parent::setUp();
ProcessCategory::query()->delete();
}
/**
* Tests the getProcessCategories method without paremeters
*
* @test
*/
public function it_tests_get_process_categories_method_without_paremeters()
{
factory(ProcessCategory::class)->create([
'CATEGORY_ID' => 1
]);
factory(ProcessCategory::class)->create([
'CATEGORY_ID' => 2
]);
factory(ProcessCategory::class)->create([
'CATEGORY_ID' => 3
]);
factory(ProcessCategory::class)->create([
'CATEGORY_ID' => 4
]);
$result = ProcessCategory::getProcessCategories();
$this->assertCount(4, $result);
}
/**
* Tests the getProcessCategories method filtered by name
*
* @test
*/
public function it_tests_get_process_categories_method_filter_by_name()
{
factory(ProcessCategory::class)->create([
'CATEGORY_ID' => 1,
'CATEGORY_NAME' => 'Category1'
]);
factory(ProcessCategory::class)->create([
'CATEGORY_ID' => 2,
'CATEGORY_NAME' => 'Category2'
]);
factory(ProcessCategory::class)->create([
'CATEGORY_ID' => 3,
'CATEGORY_NAME' => 'Category3'
]);
factory(ProcessCategory::class)->create([
'CATEGORY_ID' => 4,
'CATEGORY_NAME' => 'Category4'
]);
$result = ProcessCategory::getProcessCategories('1');
$this->assertCount(1, $result);
}
/**
* Tests the getProcessCategories method with start and limit parameters
*
* @test
*/
public function it_tests_get_process_categories_method_with_start_limit()
{
factory(ProcessCategory::class)->create([
'CATEGORY_ID' => 1,
]);
factory(ProcessCategory::class)->create([
'CATEGORY_ID' => 2,
]);
factory(ProcessCategory::class)->create([
'CATEGORY_ID' => 3,
]);
factory(ProcessCategory::class)->create([
'CATEGORY_ID' => 4,
]);
$result = ProcessCategory::getProcessCategories(null, 1, 3);
$this->assertCount(3, $result);
}
/**
* Tests the getCategoryId method
*
* @test
*/
public function it_tests_get_category_id_method()
{
$processCategory = factory(ProcessCategory::class)->create();
$result = ProcessCategory::getCategoryId($processCategory->CATEGORY_UID);
$this->assertEquals($processCategory->CATEGORY_ID, $result);
}
}

View File

@@ -0,0 +1,114 @@
<?php
namespace Tests\unit\workflow\src\ProcessMaker\Model;
use G;
use ProcessMaker\Model\UserConfig;
use Tests\TestCase;
class UserConfigTest extends TestCase
{
/**
* Setup method,
*/
public function setUp()
{
parent::setUp();
UserConfig::truncate();
}
/**
* Teardown method.
*/
public function tearDown()
{
parent::tearDown();
}
/**
* It test the method getSetting.
* @test
* @covers \ProcessMaker\Model\UserConfig::getSetting()
*/
public function it_should_test_getSetting()
{
$id = 1;
$name = "test";
$setting = ["test" => 1];
$result = UserConfig::addSetting($id, $name, $setting);
//assert get
$result = UserConfig::getSetting($id, $name);
$this->assertArrayHasKey("id", $result);
$this->assertArrayHasKey("name", $result);
$this->assertArrayHasKey("setting", $result);
$this->assertEquals($result["id"], $id);
$this->assertEquals($result["name"], $name);
$this->assertEquals($result["setting"], (object) $setting);
}
/**
* It test the method addSetting.
* @test
* @covers \ProcessMaker\Model\UserConfig::addSetting()
*/
public function it_should_test_addSetting()
{
$id = 1;
$name = "test";
$setting = ["test" => 1];
$result = UserConfig::addSetting($id, $name, $setting);
$this->assertArrayHasKey("id", $result);
$this->assertArrayHasKey("name", $result);
$this->assertArrayHasKey("setting", $result);
$this->assertEquals($result["id"], $id);
$this->assertEquals($result["name"], $name);
$this->assertEquals($result["setting"], (object) $setting);
}
/**
* It test the method editSetting.
* @test
* @covers \ProcessMaker\Model\UserConfig::editSetting()
*/
public function it_should_test_editSetting()
{
$id = 1;
$name = "test";
$setting = ["test" => 1];
$result = UserConfig::addSetting($id, $name, $setting);
//assert edit
$setting = ["test" => 2, "test2" => 3];
$result = UserConfig::editSetting($id, $name, $setting);
$this->assertArrayHasKey("id", $result);
$this->assertArrayHasKey("name", $result);
$this->assertArrayHasKey("setting", $result);
$this->assertEquals($result["id"], $id);
$this->assertEquals($result["name"], $name);
$this->assertEquals($result["setting"], (object) $setting);
}
/**
* It test the method deleteSetting.
* @test
* @covers \ProcessMaker\Model\UserConfig::deleteSetting()
*/
public function it_should_test_deleteSetting()
{
$id = 2;
$name = "test2";
$setting = ["test2" => 1];
$result = UserConfig::addSetting($id, $name, $setting);
//assert delete
$result = UserConfig::deleteSetting($id, $name);
$this->assertArrayHasKey("id", $result);
$this->assertArrayHasKey("name", $result);
$this->assertArrayHasKey("setting", $result);
$this->assertEquals($result["id"], $id);
$this->assertEquals($result["name"], $name);
}
}

View File

@@ -0,0 +1,157 @@
<?php
namespace Tests\unit\workflow\engine\src\ProcessMaker\Services\Api;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Luracast\Restler\Data\ApiMethodInfo;
use Luracast\Restler\Defaults;
use Luracast\Restler\HumanReadableCache;
use Maveriks\Extension\Restler;
use ProcessMaker\BusinessModel\Cases\Unassigned;
use ProcessMaker\Services\Api\Metrics;
use ReflectionClass;
use Tests\TestCase;
use Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases\DraftTest;
use Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases\InboxTest;
use Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases\PausedTest;
use Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases\UnassignedTest;
/**
* Class MetricsTest
*
* @coversDefaultClass @covers \ProcessMaker\Services\Api\Metrics
*/
class MetricsTest extends TestCase
{
use DatabaseTransactions;
/**
* Method set up.
*/
public function setUp()
{
parent::setUp();
}
/**
* Initialize Rest API.
* @param string $userUid
* @return Restler
*/
private function initializeRestApi(string $userUid)
{
//server
$reflection = new ReflectionClass('\ProcessMaker\Services\OAuth2\Server');
$reflectionPropertyUserId = $reflection->getProperty('userId');
$reflectionPropertyUserId->setAccessible(true);
$reflectionPropertyUserId->setValue($userUid);
$reflectionPropertyDSN = $reflection->getProperty('dsn');
$reflectionPropertyDSN->setAccessible(true);
$reflectionPropertyDSN->setValue('mysql:host=' . env('DB_HOST') . ';dbname=' . env('DB_DATABASE'));
$reflectionPropertyUserName = $reflection->getProperty('dbUser');
$reflectionPropertyUserName->setAccessible(true);
$reflectionPropertyUserName->setValue(env('DB_USERNAME'));
$reflectionPropertyPassword = $reflection->getProperty('dbPassword');
$reflectionPropertyPassword->setAccessible(true);
$reflectionPropertyPassword->setValue(env('DB_PASSWORD'));
//application
Defaults::$cacheDirectory = PATH_DB . config('system.workspace') . PATH_SEP;
HumanReadableCache::$cacheDir = PATH_DB . config('system.workspace') . PATH_SEP;
$rest = new Restler(true);
$rest->setFlagMultipart(false);
$rest->setAPIVersion('1.0');
$rest->addAuthenticationClass('ProcessMaker\\Services\\OAuth2\\Server', '');
$rest->addAuthenticationClass('ProcessMaker\\Policies\\AccessControl');
$rest->addAuthenticationClass('ProcessMaker\\Policies\\ControlUnderUpdating');
$rest->apiMethodInfo = new ApiMethodInfo();
return $rest;
}
/**
* Tests the getCountersList method with empty lists
*
* @test
*/
public function it_tests_get_counters_list_method_empty_lists()
{
$user = factory(\ProcessMaker\Model\User::class)->create();
$this->initializeRestApi($user->USR_UID);
$metrics = new Metrics();
$res = $metrics->getCountersList();
$this->assertEquals(0, $res[0]['Total']);
$this->assertEquals(0, $res[1]['Total']);
$this->assertEquals(0, $res[2]['Total']);
$this->assertEquals(0, $res[3]['Total']);
}
/**
* Tests the getCountersList method
*
* @test
*/
public function it_tests_get_counters_list_method_inbox()
{
$inbox = new InboxTest();
$user = $inbox->createMultipleInbox(10);
$this->initializeRestApi($user->USR_UID);
$metrics = new Metrics();
$res = $metrics->getCountersList();
$this->assertEquals(10, $res[0]['Total']);
}
/**
* Tests the getCountersList method
*
* @test
*/
public function it_tests_get_counters_list_method_draft()
{
$draft = new DraftTest();
$user = $draft->createManyDraft(10);
$this->initializeRestApi($user->USR_UID);
$metrics = new Metrics();
$res = $metrics->getCountersList();
$this->assertNotEmpty($res);
}
/**
* Tests the getCountersList method
*
* @test
*/
public function it_tests_get_counters_list_method_paused()
{
$paused = new PausedTest();
$user = $paused->createMultiplePaused(5);
$this->initializeRestApi($user->USR_UID);
$metrics = new Metrics();
$res = $metrics->getCountersList();
$this->assertEquals(5, $res[2]['Total']);
}
/**
* Tests the getCountersList method
*
* @test
*/
public function it_tests_get_counters_list_method_unassigned()
{
$unassignedTest = new UnassignedTest();
$cases = $unassignedTest->createMultipleUnassigned(3);
$unassigned = new Unassigned();
$unassigned->setUserId($cases->USR_ID);
$unassigned->setUserUid($cases->USR_UID);
$this->initializeRestApi($cases->USR_UID);
$metrics = new Metrics();
$res = $metrics->getCountersList();
$this->assertNotEmpty($res);
}
}

View File

@@ -364,8 +364,8 @@ class TaskTest extends TestCase
public function it_should_test_fillReportByUser_method($asynchronous)
{
$task = new Task($asynchronous, '');
$dateInit = $this->faker->dateTime;
$dateFinish = $this->faker->dateTime;
$dateInit = $this->faker->dateTime->format("Y-m-d H:i:s");
$dateFinish = $this->faker->dateTime->format("Y-m-d H:i:s");
//assert synchronous for cron file
if ($asynchronous === false) {
@@ -394,8 +394,8 @@ class TaskTest extends TestCase
public function it_should_test_fillReportByProcess_method($asynchronous)
{
$task = new Task($asynchronous, '');
$dateInit = $this->faker->dateTime;
$dateFinish = $this->faker->dateTime;
$dateInit = $this->faker->dateTime->format("Y-m-d H:i:s");
$dateFinish = $this->faker->dateTime->format("Y-m-d H:i:s");
//assert synchronous for cron file
if ($asynchronous === false) {