Merged in release/3.7.3 (pull request #8351)

release/3.7.3
This commit is contained in:
Paula Quispe
2022-01-17 20:52:18 +00:00
142 changed files with 5095 additions and 1774 deletions

View File

@@ -0,0 +1,132 @@
<?php
namespace Tests\unit\workflow\engine\classes\PmFunctions;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\Model\Application;
use ProcessMaker\Model\Delegation;
use RBAC;
use Tests\TestCase;
/**
* Test the PMFCaseInformation() function
*
* @link http://wiki.processmaker.com/index.php/ProcessMaker_Functions#PMFCaseInformation.28.29
*/
class PMFCaseInformation extends TestCase
{
use DatabaseTransactions;
/**
* Method set up.
*/
public function setUp()
{
parent::setUp();
}
/**
* It tests the PMFCaseInformation() function with the default parameters
*
* @test
*/
public function it_should_test_this_pmfunction_default_parameters()
{
$table = factory(Application::class)->states('foreign_keys')->create();
// Force commit for propel
DB::commit();
// Call the funtion
$result = PMFCaseInformation($table->APP_UID, 0, 0);
$this->assertNotEmpty($result);
// Colums to return with the default parameters
$this->assertArrayHasKey('APP_UID', $result);
$this->assertArrayHasKey('APP_NUMBER', $result);
$this->assertArrayHasKey('APP_STATUS', $result);
$this->assertArrayHasKey('APP_STATUS_ID', $result);
$this->assertArrayHasKey('PRO_UID', $result);
$this->assertArrayHasKey('APP_INIT_USER', $result);
$this->assertArrayHasKey('APP_CUR_USER', $result);
$this->assertArrayHasKey('APP_CREATE_DATE', $result);
$this->assertArrayHasKey('APP_INIT_DATE', $result);
$this->assertArrayHasKey('APP_FINISH_DATE', $result);
$this->assertArrayHasKey('APP_UPDATE_DATE', $result);
$this->assertArrayHasKey('PRO_ID', $result);
$this->assertArrayHasKey('APP_INIT_USER_ID', $result);
// When the index = 0 those values will not return
$this->assertArrayNotHasKey('DEL_INDEX', $result);
$this->assertArrayNotHasKey('DEL_PREVIOUS', $result);
$this->assertArrayNotHasKey('DEL_TYPE', $result);
$this->assertArrayNotHasKey('DEL_PRIORITY', $result);
$this->assertArrayNotHasKey('DEL_THREAD_STATUS', $result);
$this->assertArrayNotHasKey('DEL_THREAD', $result);
$this->assertArrayNotHasKey('DEL_DELEGATE_DATE', $result);
$this->assertArrayNotHasKey('DEL_INIT_DATE', $result);
$this->assertArrayNotHasKey('DEL_TASK_DUE_DATE', $result);
$this->assertArrayNotHasKey('DEL_FINISH_DATE', $result);
// When the returnAppData = 0, false this value will not return
$this->assertArrayNotHasKey('APP_DATA', $result);
}
/**
* It tests the PMFCaseInformation() function with index parameter
*
* @test
*/
public function it_should_test_this_pmfunction_index_parameter()
{
$application = factory(Application::class)->states('todo')->create();
$table = factory(Delegation::class)->states('foreign_keys')->create([
'APP_NUMBER' => $application->APP_NUMBER,
'APP_UID' => $application->APP_UID,
]);
// Force commit for propel
DB::commit();
// Call the funtion
$result = PMFCaseInformation($table->APP_UID, $table->DEL_INDEX, 0);
$this->assertNotEmpty($result);
// When the index != 0 those values will return
$this->assertArrayHasKey('DEL_INDEX', $result);
$this->assertArrayHasKey('DEL_PREVIOUS', $result);
$this->assertArrayHasKey('DEL_TYPE', $result);
$this->assertArrayHasKey('DEL_PRIORITY', $result);
$this->assertArrayHasKey('DEL_THREAD_STATUS', $result);
$this->assertArrayHasKey('DEL_THREAD', $result);
$this->assertArrayHasKey('DEL_DELEGATE_DATE', $result);
$this->assertArrayHasKey('DEL_INIT_DATE', $result);
$this->assertArrayHasKey('DEL_TASK_DUE_DATE', $result);
$this->assertArrayHasKey('DEL_FINISH_DATE', $result);
}
/**
* It tests the PMFCaseInformation() function with returnAppData parameter
*
* @test
*/
public function it_should_test_this_pmfunction_app_data_parameter()
{
$application = factory(Application::class)->states('todo')->create();
$table = factory(Delegation::class)->states('foreign_keys')->create([
'APP_NUMBER' => $application->APP_NUMBER,
'APP_UID' => $application->APP_UID,
]);
// Force commit for propel
DB::commit();
// Call the funtion
$result = PMFCaseInformation($table->APP_UID, 0, true);
$this->assertNotEmpty($result);
// When the returnAppData = true, the case data will return
$this->assertArrayHasKey('APP_DATA', $result);
}
/**
* It tests the exception caseUid is required in the PMFCaseInformation() function
*
* @test
*/
public function it_should_test_exception_user_required()
{
$this->expectExceptionMessage('**ID_REQUIRED_FIELD**');
$result = PMFCaseInformation('', 0, 0);
}
}

View File

@@ -6,6 +6,9 @@ use Exception;
use G;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use ProcessMaker\BusinessModel\Cases\AbstractCases;
use ProcessMaker\BusinessModel\Cases\Draft;
use ProcessMaker\BusinessModel\Cases\Paused;
use ProcessMaker\BusinessModel\Cases\Unassigned;
use ProcessMaker\Model\Application;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\Process;
@@ -738,6 +741,8 @@ class AbstractCasesTest extends TestCase
$absCases = new AbstractCases();
$properties = [];
$absCases->setProperties($properties);
$actual = $absCases->getCategoryId();
$this->assertEquals(0, $actual);
$actual = $absCases->getProcessId();
$this->assertEquals(0, $actual);
$actual = $absCases->getTaskId();
@@ -784,6 +789,7 @@ class AbstractCasesTest extends TestCase
* This check the setter related all the properties
*
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setProperties()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCategoryId()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setProcessId()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setTaskId()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setUserId()
@@ -799,6 +805,7 @@ class AbstractCasesTest extends TestCase
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setOffset()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setLimit()
*
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getCategoryId()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getProcessId()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getTaskId()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getUserId()
@@ -820,6 +827,7 @@ class AbstractCasesTest extends TestCase
$absCases = new AbstractCases();
$properties = [
// Filters that works for all list
'category' => rand(),
'process' => rand(),
'task' => rand(),
'user' => rand(),
@@ -836,6 +844,8 @@ class AbstractCasesTest extends TestCase
];
$absCases->setProperties($properties);
// Tasks - Cases
$actual = $absCases->getCategoryId();
$this->assertEquals($properties['category'], $actual);
$actual = $absCases->getProcessId();
$this->assertEquals($properties['process'], $actual);
$actual = $absCases->getTaskId();
@@ -887,6 +897,33 @@ class AbstractCasesTest extends TestCase
$this->assertNotEmpty($result);
}
/**
* This check the get task color
*
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getTaskColor()
* @test
*/
public function it_return_task_color_class()
{
$absCases = new Draft();
$dueDate = date('Y-m-d');
// Review on-time
$result = $absCases->getTaskColor($dueDate,'DRAFT' ,'2000-01-01');
$this->assertNotEmpty($result);
$absCases = new Paused();
$dueDate = date('Y-m-d');
// Review on-time
$result = $absCases->getTaskColor($dueDate,'PAUSED' ,'2000-01-01');
$this->assertNotEmpty($result);
$absCases = new Unassigned();
$dueDate = date('Y-m-d');
// Review on-time
$result = $absCases->getTaskColor($dueDate,'UNASSIGNED' ,'2000-01-01');
$this->assertNotEmpty($result);
}
/**
* This check task color according the due date
*
@@ -925,5 +962,31 @@ class AbstractCasesTest extends TestCase
$result = $absCases->threadInformation($thread, true, true);
$this->assertNotEmpty($result);
}
// APP_STATUS = DRAFT
foreach ($taskPending as $thread) {
$thread['APP_STATUS'] = 'DRAFT';
$result = $absCases->threadInformation($thread, true, true);
$this->assertNotEmpty($result);
}
// APP_STATUS = COMPLETED
foreach ($taskPending as $thread) {
$thread['APP_STATUS'] = 'COMPLETED';
$result = $absCases->threadInformation($thread, true, true);
$this->assertNotEmpty($result);
}
// DEL_THREAD_STATUS = PAUSED
foreach ($taskPending as $thread) {
$thread['APP_STATUS'] = 'TO_DO';
$thread['DEL_THREAD_STATUS'] = 'PAUSED';
$result = $absCases->threadInformation($thread, true, true);
$this->assertNotEmpty($result);
}
// TAS_ASSIGN_TYPE = SELF_SERVICE
foreach ($taskPending as $thread) {
$thread['APP_STATUS'] = 'TO_DO';
$thread['TAS_ASSIGN_TYPE'] = 'SELF_SERVICE';
$result = $absCases->threadInformation($thread, true, true);
$this->assertNotEmpty($result);
}
}
}

View File

@@ -28,6 +28,7 @@ class DraftTest extends TestCase
public function setUp()
{
parent::setUp();
Delegation::truncate();
}
/**
@@ -436,6 +437,7 @@ class DraftTest extends TestCase
* It tests the getCountersByProcesses() method with the top ten filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getCountersByProcesses()
* @covers \ProcessMaker\Model\Delegation::scopeTopTen()
* @test
*/
public function it_should_test_get_counters_by_processes_method_top_ten()
@@ -788,7 +790,7 @@ class DraftTest extends TestCase
'APP_INIT_USER' => $user->USR_UID,
'APP_CUR_USER' => $user->USR_UID,
]);
factory(Delegation::class)->states('foreign_keys')->create([
$del = factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 1,
'USR_UID' => $application[0]->APP_INIT_USER,
@@ -804,7 +806,7 @@ class DraftTest extends TestCase
$draft = new Draft();
$draft->setUserId($user->USR_ID);
$draft->setUserUid($user->USR_ID);
$res = $draft->getCasesRisk($process->PRO_ID);
$res = $draft->getCasesRisk($process->PRO_ID, $currentDate, $currentDate, 'ON_TIME', 10);
$this->assertCount(1, $res);
}
@@ -881,4 +883,18 @@ class DraftTest extends TestCase
$res = $draft->getCasesRisk($process->PRO_ID, null, null, 'OVERDUE');
$this->assertCount(1, $res);
}
/**
* This tests the getCounterMetrics() method
*
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getCounterMetrics()
* @test
*/
public function it_should_test_get_counter_metrics()
{
$this->createDraft();
$draft = new Draft();
$result = $draft->getCounterMetrics();
$this->assertTrue($result > 0);
}
}

View File

@@ -291,7 +291,7 @@ class HomeTest extends TestCase
'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'];
$arguments = [$caseList->CAL_ID, 0, 0, 0, 0, 15, 0, '', '', 'APP_NUMBER,DESC'];
$home = new Home($application->APP_INIT_USER);
$result = $home->getCustomDraft(...$arguments);
@@ -344,7 +344,7 @@ class HomeTest extends TestCase
'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'];
$arguments = [$caseList->CAL_ID, 0, 0, 0, 0, 15, 0, '', '', 'APP_NUMBER,DESC'];
$home = new Home($application->APP_INIT_USER);
$result = $home->getCustomDraft(...$arguments);
@@ -423,7 +423,7 @@ class HomeTest extends TestCase
'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'];
$arguments = [$caseList->CAL_ID, 0, 0, 0, 0, 15, 0, '', '', 'APP_NUMBER,DESC'];
$home = new Home($application->APP_INIT_USER);
$result = $home->getCustomDraft(...$arguments);
@@ -522,7 +522,7 @@ class HomeTest extends TestCase
'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'];
$arguments = [$caseList->CAL_ID, 0, 0, 0, 0, 15, 0, '', '', 'APP_NUMBER,DESC'];
$home = new Home($application1->APP_INIT_USER);
$result = $home->getCustomDraft(...$arguments);

View File

@@ -31,6 +31,14 @@ class InboxTest extends TestCase
public function setUp()
{
parent::setUp();
Delegation::truncate();
}
/**
* Method tearDown
*/
public function tearDown() {
parent::tearDown();
}
/**
@@ -44,6 +52,7 @@ class InboxTest extends TestCase
{
$delegation = factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_PREVIOUS' => 1,
'DEL_INDEX' => 2,
]);
@@ -118,6 +127,7 @@ class InboxTest extends TestCase
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::filters()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::setProcessId()
* @test
*/
public function it_filter_by_process()
@@ -126,9 +136,11 @@ class InboxTest extends TestCase
$cases = $this->createInbox();
// Create new Inbox object
$inbox = new Inbox();
// Apply filters
$inbox->setUserId($cases->USR_ID);
$inbox->setProcessId($cases->PRO_ID);
$inbox->setOrderByColumn('APP_NUMBER');
// Call to getData method
$res = $inbox->getData();
$this->assertNotEmpty($res);
}
@@ -139,6 +151,7 @@ class InboxTest extends TestCase
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::filters()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::setCaseNumber()
* @test
*/
public function it_filter_by_app_number()
@@ -147,9 +160,11 @@ class InboxTest extends TestCase
$cases = $this->createInbox();
// Create new Inbox object
$inbox = new Inbox();
// Apply filters
$inbox->setUserId($cases->USR_ID);
$inbox->setCaseNumber($cases->APP_NUMBER);
$inbox->setOrderByColumn('APP_NUMBER');
// Call to getData method
$res = $inbox->getData();
$this->assertNotEmpty($res);
}
@@ -160,6 +175,7 @@ class InboxTest extends TestCase
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::filters()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::setCasesNumbers()
* @test
*/
public function it_filter_by_specific_cases()
@@ -168,9 +184,11 @@ class InboxTest extends TestCase
$cases = $this->createInbox();
// Create new Inbox object
$inbox = new Inbox();
// Apply filters
$inbox->setUserId($cases->USR_ID);
$inbox->setCasesNumbers([$cases->APP_NUMBER]);
$inbox->setOrderByColumn('APP_NUMBER');
// Call to getData method
$res = $inbox->getData();
$this->assertNotEmpty($res);
}
@@ -181,6 +199,8 @@ class InboxTest extends TestCase
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::filters()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::setCasesNumbers()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::setRangeCasesFromTo()
* @test
*/
public function it_filter_by_range_cases()
@@ -189,10 +209,13 @@ class InboxTest extends TestCase
$cases = $this->createInbox();
// Create new Inbox object
$inbox = new Inbox();
// Apply filters
$inbox->setUserId($cases->USR_ID);
$rangeOfCases = $cases->APP_NUMBER . "-" . $cases->APP_NUMBER;
$inbox->setCasesNumbers([$cases->APP_NUMBER]);
$inbox->setRangeCasesFromTo([$rangeOfCases]);
$inbox->setOrderByColumn('APP_NUMBER');
// Call to getData method
$res = $inbox->getData();
$this->assertNotEmpty($res);
}
@@ -212,26 +235,59 @@ class InboxTest extends TestCase
$cases = $this->createInbox();
// Create new Inbox object
$inbox = new Inbox();
// Apply filters
$inbox->setUserId($cases->USR_ID);
$inbox->setTaskId($cases->TAS_ID);
// Call to getData method
$res = $inbox->getData();
$this->assertNotEmpty($res);
}
/**
* It tests the getData method with setDelegateFrom and setDelegateTo filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::filters()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::setDelegateFrom()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::setDelegateTo()
* @test
*/
public function it_filter_by_delegate_from_to()
{
// Create factories related to the to_do cases
$cases = $this->createInbox();
// Create new Inbox object
$inbox = new Inbox();
// Apply filters
$inbox->setUserId($cases->USR_ID);
$inbox->setDelegateFrom($cases->DEL_DELEGATE_DATE->format("Y-m-d"));
$inbox->setDelegateTo($cases->DEL_DELEGATE_DATE->format("Y-m-d"));
// Call to getData method
$res = $inbox->getData();
$this->assertEmpty($res);
}
/**
* It tests the getData method with case title filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::filters()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::setCaseTitle()
* @test
*/
public function it_filter_by_thread_title()
{
// Create factories related to the to_do cases
$cases = $this->createInbox();
$usrId = $cases->USR_ID;
$title = $cases->DEL_TITLE;
$delegation = factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_PREVIOUS' => 1,
'DEL_INDEX' => 2,
'DEL_TITLE' => 'Test',
]);
$usrId = $delegation->USR_ID;
$title = 'Test';
// We need to commit the records inserted because is needed for the "fulltext" index
DB::commit();
// Create new Inbox object
@@ -245,12 +301,44 @@ class InboxTest extends TestCase
$this->assertNotEmpty($result);
}
/**
* It tests the getData method with send by filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::filters()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::setSendBy()
* @test
*/
public function it_filter_send_by()
{
// Create factories related to the to_do cases
$cases = $this->createInbox();
// Create the previous thread with the same user
$delegation = factory(Delegation::class)->states('foreign_keys')->create([
'APP_NUMBER' => $cases->APP_NUMBER,
'APP_UID' => $cases->APP_UID,
'USR_ID' => $cases->USR_ID,
'DEL_THREAD_STATUS' => 'CLOSED',
'DEL_INDEX' => 1,
]);
// Create new Inbox object
$inbox = new Inbox();
// Apply filters
$inbox->setUserId($cases->USR_ID);
$inbox->setSendBy($cases->USR_ID);
// Call to getData method
$res = $inbox->getData();
$this->assertNotEmpty($res);
}
/**
* It tests the getData method using order by column
*
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::filters()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::setOrderByColumn()
* @test
*/
public function it_order_by_column()
@@ -755,4 +843,18 @@ class InboxTest extends TestCase
$res = $inbox->getCasesRisk($process->PRO_ID, null, null, "OVERDUE");
$this->assertCount(1, $res);
}
/**
* It tests the getCounterMetrics method
*
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getCounterMetrics()
* @test
*/
public function it_tests_get_counter_metrics()
{
$this->createInbox();
$inbox = new Inbox();
$res = $inbox->getCounterMetrics();
$this->assertTrue($res > 0);
}
}

View File

@@ -32,6 +32,7 @@ class PausedTest extends TestCase
public function setUp()
{
parent::setUp();
Delegation::truncate();
}
/**
@@ -201,7 +202,7 @@ class PausedTest extends TestCase
* It tests the getData method without filters
*
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getColumnsView()
* @covers \ProcessMaker\Model\Delegation::scopePaused()
* @test
*/
@@ -225,7 +226,7 @@ class PausedTest extends TestCase
* 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::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Paused::filters()
* @test
*/
@@ -251,7 +252,7 @@ class PausedTest extends TestCase
* 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::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Paused::filters()
* @test
*/
@@ -277,7 +278,7 @@ class PausedTest extends TestCase
* It tests the getData method with taskId filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Paused::filters()
* @test
*/
@@ -303,7 +304,7 @@ class PausedTest extends TestCase
* It tests the getData method with processId filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Paused::filters()
* @test
*/
@@ -328,7 +329,7 @@ class PausedTest extends TestCase
* It tests the getData method with case title filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Paused::filters()
* @test
*/
@@ -348,6 +349,51 @@ class PausedTest extends TestCase
$this->assertNotEmpty($res);
}
/**
* It tests the getData method with setDelegateFrom and setDelegateTo filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Paused::filters()
* @test
*/
public function it_filter_by_delegate_from_to()
{
// Create factories related to the paused cases
$cases = $this->createPaused();
// Create new Paused object
$paused = new Paused();
$paused->setUserUid($cases->USR_UID);
$paused->setUserId($cases->USR_ID);
$paused->setDelegateFrom($cases->DEL_DELEGATE_DATE->format("Y-m-d"));
$paused->setDelegateTo($cases->DEL_DELEGATE_DATE->format("Y-m-d"));
// Get data
$res = $paused->getData();
$this->assertEmpty($res);
}
/**
* It tests the getData method with send by filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Paused::filters()
* @covers \ProcessMaker\BusinessModel\Cases\Paused::setSendBy()
* @test
*/
public function it_filter_send_by()
{
// Create factories related to the to_do cases
$cases = $this->createPaused();
// Create new Paused object
$paused = new Paused();
$paused->setUserId($cases->USR_ID);
$paused->setSendBy($cases->USR_ID);
$res = $paused->getData();
$this->assertNotEmpty($res);
}
/**
* It tests the getCounter() method
*
@@ -866,4 +912,19 @@ class PausedTest extends TestCase
$res = $paused->getCasesRisk($process1->PRO_ID, null, null, 'OVERDUE');
$this->assertCount(1, $res);
}
/**
* It tests the getCounterMetrics() method
*
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getCounterMetrics()
* @test
*/
public function it_tests_get_counter_metrics()
{
$this->createMultiplePaused(3);
$paused = new Paused();
$res = $paused->getCounterMetrics();
$this->assertTrue($res > 0);
}
}

View File

@@ -34,6 +34,8 @@ class UnassignedTest extends TestCase
public function setUp()
{
parent::setUp();
Delegation::truncate();
Groupwf::truncate();
}
/**
@@ -211,6 +213,7 @@ class UnassignedTest extends TestCase
$cases = $this->createSelfServiceUserOrGroup();
//Review the count self-service
$unassigned = new Unassigned;
// Apply filters
$unassigned->setUserUid($cases['taskUser']->USR_UID);
$unassigned->setUserId($cases['delegation']->USR_ID);
$result = $unassigned->getCounter();
@@ -229,6 +232,7 @@ class UnassignedTest extends TestCase
$cases = $this->createSelfServiceByVariable();
//Review the count self-service
$unassigned = new Unassigned;
// Apply filters
$unassigned->setUserUid($cases['user']->USR_UID);
$unassigned->setUserId($cases['delegation']->USR_ID);
$result = $unassigned->getCounter();
@@ -247,6 +251,7 @@ class UnassignedTest extends TestCase
$cases = $this->createSelfServiceUserOrGroup(2);
//Review the count self-service
$unassigned = new Unassigned;
// Apply filters
$unassigned->setUserUid($cases['taskUser']->USR_UID);
$unassigned->setUserId($cases['delegation']->USR_ID);
$result = $unassigned->getCounter();
@@ -265,6 +270,7 @@ class UnassignedTest extends TestCase
$cases = $this->createSelfServiceByVariable(2, false);
//Review the count self-service
$unassigned = new Unassigned;
// Apply filters
$unassigned->setUserUid($cases['user']->USR_UID);
$unassigned->setUserId($cases['delegation']->USR_ID);
$result = $unassigned->getCounter();
@@ -284,10 +290,12 @@ class UnassignedTest extends TestCase
$casesGroup = $this->createSelfServiceUserOrGroup(2);
//Review the count self-service
$unassigned = new Unassigned;
// Apply filters
$unassigned->setUserUid($casesUser['taskUser']->USR_UID);
$unassigned->setUserId($casesUser['delegation']->USR_ID);
$result = $unassigned->getCounter();
$this->assertNotEmpty($result);
// Apply filters
$unassigned->setUserUid($casesGroup['taskUser']->USR_UID);
$unassigned->setUserId($casesGroup['delegation']->USR_ID);
$result = $unassigned->getCounter();
@@ -305,13 +313,15 @@ class UnassignedTest extends TestCase
{
$casesUser = $this->createSelfServiceByVariable();
$casesGroup = $this->createSelfServiceByVariable(2, false);
//Review the count self-service
// Review the count self-service
$unassigned = new Unassigned;
// Apply filters
$unassigned->setUserUid($casesUser['user']->USR_UID);
$unassigned->setUserId($casesUser['delegation']->USR_ID);
$result = $unassigned->getCounter();
$this->assertNotEmpty($result);
$unassigned = new Unassigned;
// Apply filters
$unassigned->setUserUid($casesGroup['user']->USR_UID);
$unassigned->setUserId($casesGroup['delegation']->USR_ID);
$result = $unassigned->getCounter();
@@ -331,9 +341,34 @@ class UnassignedTest extends TestCase
$cases = $this->createSelfServiceUserOrGroup();
// Create new object
$unassigned = new Unassigned();
// Set the user UID
// Apply filters
$unassigned->setUserUid($cases['taskUser']->USR_UID);
$unassigned->setUserId($cases['delegation']->USR_ID);
// Set OrderByColumn value
$unassigned->setOrderByColumn('APP_NUMBER');
// Call to getData method
$res = $unassigned->getData();
// This assert that the expected numbers of results are returned
$this->assertNotEmpty($res);
}
/**
* This ensures get data from self-service-user-assigned with filter setCasesNumbers
*
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::filters()
* @test
*/
public function it_filter_by_case_numbers()
{
// Create factories related to the unassigned cases
$cases = $this->createSelfServiceUserOrGroup();
// Create new object
$unassigned = new Unassigned();
// Apply filters
$unassigned->setUserUid($cases['taskUser']->USR_UID);
$unassigned->setUserId($cases['delegation']->USR_ID);
$unassigned->setCasesNumbers([$cases['delegation']->APP_NUMBER]);
// Set OrderBYColumn value
$unassigned->setOrderByColumn('APP_NUMBER');
// Call to getData method
@@ -342,6 +377,54 @@ class UnassignedTest extends TestCase
$this->assertNotEmpty($res);
}
/**
* This ensures get data from self-service-user-assigned with filter setRangeCasesFromTo
*
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::filters()
* @test
*/
public function it_filter_by_range_cases()
{
// Create factories related to the unassigned cases
$cases = $this->createSelfServiceUserOrGroup();
// Create new object
$unassigned = new Unassigned();
// Apply filters
$unassigned->setUserUid($cases['taskUser']->USR_UID);
$unassigned->setUserId($cases['delegation']->USR_ID);
$rangeOfCases = $cases['delegation']->APP_NUMBER . "-" . $cases['delegation']->APP_NUMBER;
$unassigned->setRangeCasesFromTo([$rangeOfCases]);
// Call to getData method
$res = $unassigned->getData();
// This assert that the expected numbers of results are returned
$this->assertNotEmpty($res);
}
/**
* This ensures get data from self-service-user-assigned with setDelegateFrom and setDelegateTo filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::filters()
* @test
*/
public function it_filter_by_delegate_from_to()
{
// Create factories related to the unassigned cases
$cases = $this->createSelfServiceUserOrGroup();
// Create new object
$unassigned = new Unassigned();
// Apply filters
$unassigned->setUserUid($cases['taskUser']->USR_UID);
$unassigned->setUserId($cases['delegation']->USR_ID);
$unassigned->setDelegateFrom(date('Y-m-d'));
$unassigned->setDelegateTo(date('Y-m-d'));
// Call to getData method
$res = $unassigned->getData();
// This assert that the expected numbers of results are returned
$this->assertEmpty($res);
}
/**
* It tests the getData method with case title filter
*
@@ -361,9 +444,9 @@ class UnassignedTest extends TestCase
DB::commit();
// Create new Unassigned object
$unassigned = new Unassigned();
// Apply filters
$unassigned->setUserUid($usrUid);
$unassigned->setUserId($usrId);
// Set the title
$unassigned->setCaseTitle($title);
// Get the data
$res = $unassigned->getData();
@@ -870,4 +953,18 @@ class UnassignedTest extends TestCase
$res = $unassigned->getCasesRisk($process1->PRO_ID, null, null, 'OVERDUE');
$this->assertCount(1, $res);
}
/**
* This the getCounterMetrics method
*
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getCounterMetrics()
* @test
*/
public function it_tests_get_counter_metrics()
{
$this->createSelfServiceUserOrGroup();
$unassigned = new Unassigned;
$result = $unassigned->getCounterMetrics();
$this->assertTrue($result > 0);
}
}

View File

@@ -13,6 +13,11 @@ use ProcessMaker\Model\Process;
use ProcessMaker\Model\Task;
use Tests\TestCase;
/**
* Class AbeConfigurationTest
*
* @coversDefaultClass \ProcessMaker\Model\AbeConfiguration
*/
class AbeConfigurationTest extends TestCase
{
/**

View File

@@ -0,0 +1,51 @@
<?php
namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use ProcessMaker\Model\AbeConfiguration;
use ProcessMaker\Model\AbeRequest;
use ProcessMaker\Model\Application;
use Tests\TestCase;
/**
* Class AbeRequestTest
*
* @coversDefaultClass \ProcessMaker\Model\AbeRequest
*/
class AbeRequestTest extends TestCase
{
use DatabaseTransactions;
/**
* Test has one to APP_UID
*
* @covers \ProcessMaker\Model\AbeRequest::application()
* @test
*/
public function it_has_one_application()
{
$table = factory(AbeRequest::class)->create([
'APP_UID' => function () {
return factory(Application::class)->create()->APP_UID;
}
]);
$this->assertInstanceOf(Application::class, $table->application);
}
/**
* Test has one to ABE_UID
*
* @covers \ProcessMaker\Model\AbeRequest::abeConfiguration()
* @test
*/
public function it_has_one_abe_configuration()
{
$table = factory(AbeRequest::class)->create([
'ABE_UID' => function () {
return factory(AbeConfiguration::class)->create()->ABE_UID;
}
]);
$this->assertInstanceOf(AbeConfiguration::class, $table->abeConfiguration);
}
}

View File

@@ -6,6 +6,11 @@ use ProcessMaker\Model\AdditionalTables;
use ProcessMaker\Model\Fields;
use Tests\TestCase;
/**
* Class AdditionalTablesTest
*
* @coversDefaultClass \ProcessMaker\Model\AdditionalTables
*/
class AdditionalTablesTest extends TestCase
{
/**
@@ -78,4 +83,23 @@ class AdditionalTablesTest extends TestCase
$this->assertArrayHasKey('rows', $row);
}
}
/**
* Test update the offline property
*
* @covers \ProcessMaker\Model\AdditionalTables::updatePropertyOffline()
* @test
*/
public function it_update_property_offline()
{
$pmTable = factory(AdditionalTables::class)->create(['ADD_TAB_OFFLINE' => 0]);
$results = AdditionalTables::updatePropertyOffline([$pmTable->ADD_TAB_UID], 1);
// Check the update
$pmTableQuery = AdditionalTables::query()->select(['ADD_TAB_OFFLINE']);
$pmTableQuery->where('ADD_TAB_UID', $pmTable->ADD_TAB_UID);
$result = $pmTableQuery->get()->values()->toArray();
// Assert, the update was executed
$this->assertEquals($result[0]['ADD_TAB_OFFLINE'], 1);
}
}

View File

@@ -0,0 +1,34 @@
<?php
namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use ProcessMaker\Model\AppAssignSelfServiceValue;
use ProcessMaker\Model\AppAssignSelfServiceValueGroup;
use Tests\TestCase;
/**
* Class AppAssignSelfServiceValueGroupTest
*
* @coversDefaultClass \ProcessMaker\Model\AppAssignSelfServiceValueGroup
*/
class AppAssignSelfServiceValueGroupTest extends TestCase
{
use DatabaseTransactions;
/**
* Test belongs to ID
*
* @covers \ProcessMaker\Model\AppAssignSelfServiceValueGroup::appSelfService()
* @test
*/
public function it_has_a_id_defined()
{
$table = factory(AppAssignSelfServiceValueGroup::class)->create([
'ID' => function () {
return factory(AppAssignSelfServiceValue::class)->create()->ID;
}
]);
$this->assertInstanceOf(AppAssignSelfServiceValue::class, $table->appSelfService);
}
}

View File

@@ -0,0 +1,106 @@
<?php
namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use ProcessMaker\Model\AppAssignSelfServiceValue;
use ProcessMaker\Model\AppAssignSelfServiceValueGroup;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\GroupUser;
use ProcessMaker\Model\Groupwf;
use ProcessMaker\Model\RbacUsers;
use ProcessMaker\Model\Task;
use ProcessMaker\Model\User;
use Tests\TestCase;
/**
* Class AppAssignSelfServiceValueTest
*
* @coversDefaultClass \ProcessMaker\Model\AppAssignSelfServiceValue
*/
class AppAssignSelfServiceValueTest extends TestCase
{
use DatabaseTransactions;
/**
* Test belongs to APP_NUMBER
*
* @covers \ProcessMaker\Model\AppAssignSelfServiceValue::appNumber()
* @test
*/
public function it_belong_app_number()
{
$table = factory(AppAssignSelfServiceValue::class)->create([
'APP_NUMBER' => function () {
return factory(Delegation::class)->create()->APP_NUMBER;
}
]);
$this->assertInstanceOf(Delegation::class, $table->appNumber);
}
/**
* Test belongs to DEL_INDEX
*
* @covers \ProcessMaker\Model\AppAssignSelfServiceValue::index()
* @test
*/
public function it_belong_index()
{
$table = factory(AppAssignSelfServiceValue::class)->create([
'DEL_INDEX' => function () {
return factory(Delegation::class)->create()->DEL_INDEX;
}
]);
$this->assertInstanceOf(Delegation::class, $table->index);
}
/**
* Test belongs to TAS_ID
*
* @covers \ProcessMaker\Model\AppAssignSelfServiceValue::task()
* @test
*/
public function it_belong_task()
{
$table = factory(AppAssignSelfServiceValue::class)->create([
'TAS_ID' => function () {
return factory(Task::class)->create()->TAS_ID;
}
]);
$this->assertInstanceOf(Task::class, $table->task);
}
/**
* It tests getSelfServiceCasesByEvaluatePerUser()
*
* @covers \ProcessMaker\Model\AppAssignSelfServiceValue::getSelfServiceCasesByEvaluatePerUser()
* @test
*/
public function it_should_self_service_by_value()
{
// Assign user in a group
$rbacUser = factory(RbacUsers::class)->create();
$user = factory(User::class)->create([
'USR_UID' => $rbacUser['USR_UID']
]);
$group = factory(Groupwf::class)->create();
$table = factory(GroupUser::class)->create([
'GRP_UID' => $group['GRP_UID'],
'GRP_ID' => $group['GRP_ID'],
'USR_UID' => $user['USR_UID'],
'USR_ID' => $user['USR_ID'],
]);
// Create the selfservice
$self = factory(AppAssignSelfServiceValue::class)->create([
'GRP_UID' => $group['GRP_UID'],
]);
$table = factory(AppAssignSelfServiceValueGroup::class)->create([
'ID' => $self['ID'],
'GRP_UID' => $group['GRP_UID'],
'ASSIGNEE_ID' => $group['GRP_ID'],
'ASSIGNEE_TYPE' => 2,
]);
$result = AppAssignSelfServiceValue::getSelfServiceCasesByEvaluatePerUser($user['USR_UID']);
$this->assertNotEmpty($result);
}
}

View File

@@ -7,7 +7,7 @@ use ProcessMaker\Model\AppTimeoutAction;
use Tests\TestCase;
/**
* Class DelegationTest
* Class AppTimeoutActionTest
*
* @coversDefaultClass \ProcessMaker\Model\AppTimeoutAction
*/

View File

@@ -0,0 +1,30 @@
<?php
namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use ProcessMaker\Model\BpmnProject;
use Tests\TestCase;
/**
* Class BpmnProjectTest
*
* @coversDefaultClass \ProcessMaker\Model\BpmnProject
*/
class BpmnProjectTest extends TestCase
{
use DatabaseTransactions;
/**
* Test if is a BPMN process
*
* @covers \ProcessMaker\Model\BpmnProject::isBpmnProcess()
* @test
*/
public function it_is_bpmn_process()
{
$table = factory(BpmnProject::class)->create();
$result = BpmnProject::isBpmnProcess($table->PRJ_UID);
$this->assertEquals($result, 1);
}
}

View File

@@ -6,9 +6,13 @@ use ProcessMaker\Model\AdditionalTables;
use ProcessMaker\Model\CaseList;
use Tests\TestCase;
/**
* Class CaseListTest
*
* @coversDefaultClass \ProcessMaker\Model\CaseList
*/
class CaseListTest extends TestCase
{
/**
* setUp method.
*/
@@ -28,6 +32,7 @@ class CaseListTest extends TestCase
/**
* This tests the getColumnNameFromAlias method.
* @test
* @covers \ProcessMaker\Model\CaseList::getColumnNameFromAlias()
* @covers \ProcessMaker\Model\CaseList::createSetting()
*/
public function it_should_test_getColumnNameFromAlias()
@@ -67,6 +72,8 @@ class CaseListTest extends TestCase
* This tests the getAliasFromColumnName method.
* @test
* @covers \ProcessMaker\Model\CaseList::createSetting()
* @covers \ProcessMaker\Model\CaseList::getColumnNameFromAlias()
* @covers \ProcessMaker\Model\CaseList::getAliasFromColumnName()
*/
public function it_should_test_getAliasFromColumnName()
{
@@ -105,6 +112,7 @@ class CaseListTest extends TestCase
* This tests the createSetting method.
* @test
* @covers \ProcessMaker\Model\CaseList::createSetting()
* @covers \ProcessMaker\Model\CaseList::getColumnNameFromAlias()
*/
public function it_should_test_createSetting()
{
@@ -139,6 +147,7 @@ class CaseListTest extends TestCase
* This tests the updateSetting method.
* @test
* @covers \ProcessMaker\Model\CaseList::updateSetting()
* @covers \ProcessMaker\Model\CaseList::createSetting()
*/
public function it_should_test_updateSetting()
{
@@ -181,6 +190,7 @@ class CaseListTest extends TestCase
* This tests the deleteSetting method.
* @test
* @covers \ProcessMaker\Model\CaseList::deleteSetting()
* @covers \ProcessMaker\Model\CaseList::createSetting()
*/
public function it_should_test_deleteSetting()
{
@@ -217,6 +227,9 @@ class CaseListTest extends TestCase
/**
* This tests the getSetting method.
* @test
* @covers \ProcessMaker\Model\CaseList::getSetting()
* @covers \ProcessMaker\Model\CaseList::createSetting()
* @covers \ProcessMaker\Model\CaseList::getColumnNameFromAlias()
* @covers \ProcessMaker\Model\CaseList::deleteSetting()
*/
public function it_should_test_getSetting()
@@ -322,6 +335,9 @@ class CaseListTest extends TestCase
/**
* This tests the export method.
* @test
* @covers \ProcessMaker\Model\CaseList::getAliasFromColumnName()
* @covers \ProcessMaker\Model\CaseList::createSetting()
* @covers \ProcessMaker\Model\CaseList::getColumnNameFromAlias()
* @covers \ProcessMaker\Model\CaseList::export()
*/
public function it_should_test_export()

View File

@@ -5,9 +5,12 @@ namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use ProcessMaker\Model\Consolidated;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\Task;
use Tests\TestCase;
/**
* Class ConsolidatedTest
*
* @coversDefaultClass \ProcessMaker\Model\Consolidated
*/
class ConsolidatedTest extends TestCase
@@ -22,6 +25,22 @@ class ConsolidatedTest extends TestCase
parent::setUp();
}
/**
* Test belongs to TAS_UID
*
* @covers \ProcessMaker\Model\Consolidated::task()
* @test
*/
public function it_has_a_task()
{
$table = factory(Consolidated::class)->create([
'TAS_UID' => function () {
return factory(Task::class)->create()->TAS_UID;
}
]);
$this->assertInstanceOf(Task::class, $table->task);
}
/**
* Create consolidated cases factories
*
@@ -42,6 +61,7 @@ class ConsolidatedTest extends TestCase
* This checks the counters is working properly in draft
*
* @covers \ProcessMaker\Model\Consolidated::getCounterActive()
* @covers \ProcessMaker\Model\Consolidated::scopeActive()
* @test
*/
public function it_should_count_cases_consolidated()
@@ -57,7 +77,11 @@ class ConsolidatedTest extends TestCase
/**
* This checks the counters is working properly in consolidated
*
* @covers \ProcessMaker\Model\Consolidated::getCounterActive()
* @covers \ProcessMaker\Model\Consolidated::getConsolidated()
* @covers \ProcessMaker\Model\Consolidated::scopeJoinPendingCases()
* @covers \ProcessMaker\Model\Consolidated::scopeActive()
* @covers \ProcessMaker\Model\Consolidated::scopeJoinProcess()
* @covers \ProcessMaker\Model\Consolidated::scopeJoinTask()
* @test
*/
public function it_should_count_cases()

View File

@@ -1154,7 +1154,11 @@ class DelegationTest extends TestCase
*/
public function it_should_search_and_filter_by_app_title()
{
$delegations = factory(Delegation::class, 1)->states('foreign_keys')->create();
$delegations = factory(Delegation::class, 1)->states('foreign_keys')->create([
'APP_NUMBER' => function () {
return factory(Application::class)->create()->APP_NUMBER;
}
]);
$title = $delegations->last()->DEL_TITLE;
// We need to commit the records inserted because is needed for the "fulltext" index
DB::commit();
@@ -3421,7 +3425,7 @@ class DelegationTest extends TestCase
public function it_get_thread_title()
{
$delegation = factory(Delegation::class)->states('foreign_keys')->create();
$result = Delegation::getThreadTitle($delegation->TAS_UID, $delegation->APP_NUMBER, $delegation->DEL_INDEX, []);
$result = Delegation::getThreadTitle($delegation->TAS_UID, $delegation->APP_NUMBER, $delegation->DEL_PREVIOUS, []);
$this->assertNotEmpty($result);
}
@@ -3580,6 +3584,19 @@ class DelegationTest extends TestCase
$this->assertNotEmpty($result);
}
/**
* This check the return cases thread title
*
* @covers \ProcessMaker\Model\Delegation::casesThreadTitle()
* @test
*/
public function it_get_cases_thread_title()
{
$delegation = factory(Delegation::class)->states('foreign_keys')->create();
$result = Delegation::casesThreadTitle($delegation->DEL_TITLE);
$this->assertNotEmpty($result);
}
/**
* Test the scopeParticipatedUser
*
@@ -3596,4 +3613,83 @@ class DelegationTest extends TestCase
$res = $table->joinApplication()->participatedUser($table->USR_ID)->get();
$this->assertCount(1, $res);
}
}
/**
* Test the scopeInboxMetrics
*
* @covers \ProcessMaker\Model\Delegation::scopeInboxMetrics()
* @test
*/
public function it_tests_scope_inbox_metrics()
{
$application = factory(Application::class)->states('todo')->create();
$table = factory(Delegation::class)->states('foreign_keys')->create([
'APP_NUMBER' => $application->APP_NUMBER,
'APP_UID' => $application->APP_UID,
]);
$res = $table->inboxMetrics()->get();
$this->assertCount(1, $res);
}
/**
* Test the scopeDraftMetrics
*
* @covers \ProcessMaker\Model\Delegation::scopeDraftMetrics()
* @test
*/
public function it_tests_scope_draft_metrics()
{
$application = factory(Application::class)->states('draft')->create();
$table = factory(Delegation::class)->states('foreign_keys')->create([
'APP_NUMBER' => $application->APP_NUMBER,
'APP_UID' => $application->APP_UID,
]);
$res = $table->draftMetrics()->get();
$this->assertCount(1, $res);
}
/**
* Test the scopePausedMetrics
*
* @covers \ProcessMaker\Model\Delegation::scopePausedMetrics()
* @test
*/
public function it_tests_scope_paused_metrics()
{
$application = factory(Application::class)->states('paused')->create();
$appDelay = factory(AppDelay::class)->states('paused_foreign_keys')->create([
'APP_NUMBER' => $application->APP_NUMBER,
'APP_UID' => $application->APP_UID,
]);
$table = factory(Delegation::class)->states('foreign_keys')->create([
'APP_NUMBER' => $application->APP_NUMBER,
'APP_UID' => $application->APP_UID,
'DEL_INDEX' => $appDelay->APP_DEL_INDEX,
]);
$res = $table->pausedMetrics()->get();
$this->assertCount(1, $res);
}
/**
* Test the scopeSelfServiceMetrics
*
* @covers \ProcessMaker\Model\Delegation::scopeSelfServiceMetrics()
* @test
*/
public function it_tests_scope_self_service_metrics()
{
$application = factory(Application::class)->states('paused')->create();
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
]);
$delegation = factory(Delegation::class)->states('foreign_keys')->create([
'APP_NUMBER' => $application->APP_NUMBER,
'APP_UID' => $application->APP_UID,
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
$res = $delegation->selfServiceMetrics()->get();
$this->assertCount(1, $res);
}
}

View File

@@ -47,4 +47,22 @@ class DocumentsTest extends TestCase
$this->assertNotEmpty($result);
}
/**
* This test get files
*
* @test
* @covers \ProcessMaker\Model\Documents::getFiles()
* @covers \ProcessMaker\Model\Documents::scopeDocId()
*/
public function it_should_test_get_files()
{
$appNote = factory(AppNotes::class)->create();
$appDocument = factory(Documents::class)->create([
'DOC_ID' => $appNote->NOTE_ID
]);
$result = Documents::getFiles($appDocument->DOC_ID);
$this->assertNotEmpty($result);
}
}

View File

@@ -2,14 +2,86 @@
namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use ProcessMaker\Model\Dynaform;
use ProcessMaker\Model\Process;
use Tests\TestCase;
/**
* Class DynaformTest
*
* @coversDefaultClass \ProcessMaker\Model\Dynaform
*/
class DynaformTest extends TestCase
{
use DatabaseTransactions;
/**
* Call the setUp parent method
*/
public function setUp()
{
parent::setUp();
}
/**
* Test belongs to PRO_UID
*
* @covers \ProcessMaker\Model\Dynaform::process()
* @test
*/
public function it_has_a_process()
{
$dynaForm = factory(Dynaform::class)->create([
'PRO_UID' => function () {
return factory(Process::class)->create()->PRO_UID;
}
]);
$this->assertInstanceOf(Process::class, $dynaForm->process);
}
/**
* Tests get form by process
*
* @covers \ProcessMaker\Model\Dynaform::getByProUid()
* @test
*/
public function it_tests_get_by_pro_uid()
{
$dynaForm = factory(Dynaform::class)->states('foreign_keys')->create();
$result = Dynaform::getByProUid($dynaForm->PRO_UID);
$this->assertNotEmpty($result);
}
/**
* Tests get form by uid
*
* @covers \ProcessMaker\Model\Dynaform::getByDynUid()
* @test
*/
public function it_tests_get_by_dyn_uid()
{
$dynaForm = factory(Dynaform::class)->states('foreign_keys')->create();
$result = Dynaform::getByDynUid($dynaForm->DYN_UID);
$this->assertNotEmpty($result);
}
/**
* Tests get form by process excluding a uid
*
* @covers \ProcessMaker\Model\Dynaform::getByProUidExceptDynUid()
* @test
*/
public function it_tests_get_by_process_exclude_dyn_uid()
{
$dynaForm = factory(Dynaform::class)->states('foreign_keys')->create();
$result = Dynaform::getByProUidExceptDynUid($dynaForm->PRO_UID, $dynaForm->DYN_UID);
$this->assertEmpty($result);
}
/**
* It tests the process scope in the dynaform model
*
* @covers \ProcessMaker\Model\Dynaform::scopeProcess()
* @test
*/
public function it_should_test_process_scope_in_dynaform_model()

View File

@@ -6,6 +6,11 @@ use ProcessMaker\Model\EmailEvent;
use ProcessMaker\Model\EmailServerModel;
use Tests\TestCase;
/**
* Class EmailEventTest
*
* @coversDefaultClass \ProcessMaker\Model\EmailEvent
*/
class EmailEventTest extends TestCase
{
/**

View File

@@ -5,6 +5,11 @@ namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
use ProcessMaker\Model\EmailServerModel;
use Tests\TestCase;
/**
* Class EmailServerModelTest
*
* @coversDefaultClass \ProcessMaker\Model\EmailServerModel
*/
class EmailServerModelTest extends TestCase
{
/**

View File

@@ -6,6 +6,11 @@ use ProcessMaker\Model\AdditionalTables;
use ProcessMaker\Model\Fields;
use Tests\TestCase;
/**
* Class FieldsTest
*
* @coversDefaultClass \ProcessMaker\Model\Fields
*/
class FieldsTest extends TestCase
{
/**

View File

@@ -10,7 +10,7 @@ use ProcessMaker\Model\User;
use Tests\TestCase;
/**
* Class ProcessTest
* Class GroupUserTest
*
* @coversDefaultClass \ProcessMaker\Model\GroupUser
*/
@@ -18,9 +18,95 @@ class GroupUserTest extends TestCase
{
use DatabaseTransactions;
/**
* Method set up.
*/
public function setUp()
{
parent::setUp();
GroupUser::truncate();
}
/**
* Test belongs to USR_UID
*
* @covers \ProcessMaker\Model\GroupUser::user()
* @test
*/
public function it_belong_user()
{
$table = factory(GroupUser::class)->create([
'USR_UID' => function () {
return factory(User::class)->create()->USR_UID;
}
]);
$this->assertInstanceOf(User::class, $table->user);
}
/**
* Test belongs to GRP_ID
*
* @covers \ProcessMaker\Model\GroupUser::groupsWf()
* @test
*/
public function it_belong_group()
{
$table = factory(GroupUser::class)->create([
'GRP_ID' => function () {
return factory(Groupwf::class)->create()->GRP_ID;
}
]);
$this->assertInstanceOf(Groupwf::class, $table->groupsWf);
}
/**
* This test scopeUser
*
* @covers \ProcessMaker\Model\GroupUser::scopeUser()
* @test
*/
public function it_return_scope_user()
{
$table = factory(GroupUser::class)->states('foreign_keys')->create();
$this->assertNotEmpty($table->user($table->USR_UID)->get());
}
/**
* It tests the messages related assignUserToGroup() method
*
* @covers \ProcessMaker\Model\GroupUser::assignUserToGroup()
* @test
*/
public function it_should_test_message()
{
// When the user does not exist
$user = factory(User::class)->create();
$group = factory(Groupwf::class)->create();
$result = GroupUser::assignUserToGroup('', 0, '', 0);
$this->assertNotEmpty($result);
// When the group does not exist
$rbacUser = factory(RbacUsers::class)->create();
$user = factory(User::class)->create([
'USR_UID' => $rbacUser['USR_UID']
]);
$group = factory(Groupwf::class)->create();
$result = GroupUser::assignUserToGroup($user['USR_UID'], 0, '', 0);
$this->assertNotEmpty($result);
// When the user already exist in a group
$rbacUser = factory(RbacUsers::class)->create();
$user = factory(User::class)->create([
'USR_UID' => $rbacUser['USR_UID']
]);
$group = factory(Groupwf::class)->create();
GroupUser::assignUserToGroup($user['USR_UID'], $user['USR_ID'], $group['GRP_UID'], $group['GRP_ID']);
$result = GroupUser::assignUserToGroup($user['USR_UID'], $user['USR_ID'], $group['GRP_UID'], $group['GRP_ID']);
$this->assertNotEmpty($result);
}
/**
* It tests the assignUserToGroup() method
*
* @covers \ProcessMaker\Model\GroupUser::assignUserToGroup()
* @test
*/
public function it_should_test_the_assign_user_to_group_method()
@@ -46,6 +132,8 @@ class GroupUserTest extends TestCase
/**
* It tests the verifyUserIsInGroup() method
*
* @covers \ProcessMaker\Model\GroupUser::verifyUserIsInGroup()
* @covers \ProcessMaker\Model\GroupUser::assignUserToGroup()
* @test
*/
public function it_should_test_the_verify_user_is_in_group_method()

View File

@@ -3,11 +3,12 @@
namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use ProcessMaker\Model\GroupUser;
use ProcessMaker\Model\Groupwf;
use Tests\TestCase;
/**
* Class ProcessTest
* Class GroupwfTest
*
* @coversDefaultClass \ProcessMaker\Model\Groupwf
*/
@@ -15,6 +16,43 @@ class GroupwfTest extends TestCase
{
use DatabaseTransactions;
/**
* Method set up.
*/
public function setUp()
{
parent::setUp();
Groupwf::truncate();
}
/**
* Test belongs to GRP_ID
*
* @covers \ProcessMaker\Model\Groupwf::groupUsers()
* @test
*/
public function it_belong_group()
{
$table = factory(Groupwf::class)->create([
'GRP_ID' => function () {
return factory(GroupUser::class)->create()->GRP_ID;
}
]);
$this->assertInstanceOf(GroupUser::class, $table->groupUsers);
}
/**
* This test scopeActive
*
* @covers \ProcessMaker\Model\Groupwf::scopeActive()
* @test
*/
public function it_return_scope_active()
{
$table = factory(Groupwf::class)->create();
$this->assertNotEmpty($table->active()->get());
}
/**
* It tests the verifyGroupExists() method
*

View File

@@ -0,0 +1,60 @@
<?php
namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use ProcessMaker\Model\InputDocument;
use ProcessMaker\Model\Process;
use Tests\TestCase;
/**
* Class InputDocumentTest
*
* @coversDefaultClass \ProcessMaker\Model\InputDocument
*/
class InputDocumentTest extends TestCase
{
use DatabaseTransactions;
/**
* Test belongs to PRO_UID
*
* @covers \ProcessMaker\Model\InputDocument::process()
* @test
*/
public function it_has_a_process_defined()
{
$table = factory(InputDocument::class)->create([
'PRO_UID' => function () {
return factory(Process::class)->create()->PRO_UID;
}
]);
$this->assertInstanceOf(Process::class, $table->process);
}
/**
* Test get input by process
*
* @covers \ProcessMaker\Model\InputDocument::getByProUid()
* @test
*/
public function it_get_by_process()
{
$table = factory(InputDocument::class)->create();
$result = InputDocument::getByProUid($table->PRO_UID);
$this->assertNotEmpty($result);
}
/**
* Test get input by uid
*
* @covers \ProcessMaker\Model\InputDocument::getByInpDocUid()
* @test
*/
public function it_get_by_uid()
{
$table = factory(InputDocument::class)->create();
$result = InputDocument::getByInpDocUid($table->INP_DOC_UID);
$this->assertNotEmpty($result);
}
}

View File

@@ -0,0 +1,60 @@
<?php
namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use ProcessMaker\Model\OutputDocument;
use ProcessMaker\Model\Process;
use Tests\TestCase;
/**
* Class OutputDocumentTest
*
* @coversDefaultClass \ProcessMaker\Model\OutputDocument
*/
class OutputDocumentTest extends TestCase
{
use DatabaseTransactions;
/**
* Test belongs to PRO_UID
*
* @covers \ProcessMaker\Model\OutputDocument::process()
* @test
*/
public function it_has_a_process_defined()
{
$table = factory(OutputDocument::class)->create([
'PRO_UID' => function () {
return factory(Process::class)->create()->PRO_UID;
}
]);
$this->assertInstanceOf(Process::class, $table->process);
}
/**
* Test get output by process
*
* @covers \ProcessMaker\Model\OutputDocument::getByProUid()
* @test
*/
public function it_get_by_process()
{
$table = factory(OutputDocument::class)->create();
$result = OutputDocument::getByProUid($table->PRO_UID);
$this->assertNotEmpty($result);
}
/**
* Test get output by uid
*
* @covers \ProcessMaker\Model\OutputDocument::getByOutDocUid()
* @test
*/
public function it_get_by_uid()
{
$table = factory(OutputDocument::class)->create();
$result = OutputDocument::getByOutDocUid($table->OUT_DOC_UID);
$this->assertNotEmpty($result);
}
}

View File

@@ -7,7 +7,7 @@ use ProcessMaker\Model\ProcessCategory;
use Tests\TestCase;
/**
* Class ProcessTest
* Class ProcessCategoryTest
*
* @coversDefaultClass \ProcessMaker\Model\ProcessCategory
*/
@@ -24,9 +24,25 @@ class ProcessCategoryTest extends TestCase
ProcessCategory::query()->delete();
}
/**
* Tests get categories
*
* @covers \ProcessMaker\Model\ProcessCategory::getCategories()
* @test
*/
public function it_tests_get_categories()
{
$processCategory = factory(ProcessCategory::class)->create();
$result = ProcessCategory::getCategories();
$this->assertNotEmpty($result);
}
/**
* Tests the getProcessCategories method without paremeters
*
* @covers \ProcessMaker\Model\ProcessCategory::getProcessCategories()
* @covers \ProcessMaker\Model\ProcessCategory::scopeCategoryName()
* @test
*/
public function it_tests_get_process_categories_method_without_paremeters()
@@ -51,6 +67,8 @@ class ProcessCategoryTest extends TestCase
/**
* Tests the getProcessCategories method filtered by name
*
* @covers \ProcessMaker\Model\ProcessCategory::getProcessCategories()
* @covers \ProcessMaker\Model\ProcessCategory::scopeCategoryName()
* @test
*/
public function it_tests_get_process_categories_method_filter_by_name()
@@ -79,6 +97,8 @@ class ProcessCategoryTest extends TestCase
/**
* Tests the getProcessCategories method with start and limit parameters
*
* @covers \ProcessMaker\Model\ProcessCategory::getProcessCategories()
* @covers \ProcessMaker\Model\ProcessCategory::scopeCategoryName()
* @test
*/
public function it_tests_get_process_categories_method_with_start_limit()
@@ -103,6 +123,7 @@ class ProcessCategoryTest extends TestCase
/**
* Tests the getCategoryId method
*
* @covers \ProcessMaker\Model\ProcessCategory::getCategoryId()
* @test
*/
public function it_tests_get_category_id_method()
@@ -112,4 +133,19 @@ class ProcessCategoryTest extends TestCase
$this->assertEquals($processCategory->CATEGORY_ID, $result);
}
/**
* Tests get category
*
* @covers \ProcessMaker\Model\ProcessCategory::getCategory()
* @covers \ProcessMaker\Model\ProcessCategory::scopeCategory()
* @test
*/
public function it_tests_get_category()
{
$processCategory = factory(ProcessCategory::class)->create();
$result = ProcessCategory::getCategory($processCategory->CATEGORY_ID);
$this->assertNotEmpty($result);
}
}

View File

@@ -258,8 +258,10 @@ class ProcessTest extends TestCase
* It tests the process list
*
* @covers \ProcessMaker\Model\Process::getProcessesFilter()
* @covers \ProcessMaker\Model\Process::getListColumns()
* @covers \ProcessMaker\Model\Process::scopeJoinUsers()
* @covers \ProcessMaker\Model\Process::scopeJoinCategory()
* @covers \ProcessMaker\Model\Process::scopeNoStatus()
* @covers \ProcessMaker\Model\Process::scopeSubProcess()
* @test
*/
public function it_should_test_process_without_filter()
@@ -278,7 +280,11 @@ class ProcessTest extends TestCase
* It tests the process list with specific category
*
* @covers \ProcessMaker\Model\Process::getProcessesFilter()
* @covers \ProcessMaker\Model\Process::getListColumns()
* @covers \ProcessMaker\Model\Process::scopeJoinUsers()
* @covers \ProcessMaker\Model\Process::scopeJoinCategory()
* @covers \ProcessMaker\Model\Process::scopeCategory()
* @covers \ProcessMaker\Model\Process::scopePerUser()
* @test
*/
public function it_should_test_process_with_category_filter()
@@ -288,16 +294,23 @@ class ProcessTest extends TestCase
return factory(ProcessCategory::class)->create()->CATEGORY_UID;
}
]);
$result = Process::getProcessesFilter(
$process->PRO_CATEGORY
);
$result = Process::getProcessesFilter($process->PRO_CATEGORY);
// Assert with the specific category
$this->assertEquals($process->PRO_CATEGORY, $result[0]['PRO_CATEGORY']);
$process = factory(Process::class)->create();
$result = Process::getProcessesFilter('NONE');
// Assert when the category is empty
$this->assertEmpty($result);
}
/**
* It tests the process list with specific process
*
* @covers \ProcessMaker\Model\Process::getProcessesFilter()
* @covers \ProcessMaker\Model\Process::getListColumns()
* @covers \ProcessMaker\Model\Process::scopeJoinUsers()
* @covers \ProcessMaker\Model\Process::scopeJoinCategory()
* @covers \ProcessMaker\Model\Process::scopeProcess()
* @test
*/
@@ -315,6 +328,9 @@ class ProcessTest extends TestCase
* It tests the process list with specific process title
*
* @covers \ProcessMaker\Model\Process::getProcessesFilter()
* @covers \ProcessMaker\Model\Process::getListColumns()
* @covers \ProcessMaker\Model\Process::scopeJoinUsers()
* @covers \ProcessMaker\Model\Process::scopeJoinCategory()
* @covers \ProcessMaker\Model\Process::scopeTitle()
* @test
*/
@@ -329,10 +345,41 @@ class ProcessTest extends TestCase
$this->assertEquals($process->PRO_TITLE, $result[0]['PRO_TITLE']);
}
/**
* It tests the process list with suprocess filter
*
* @covers \ProcessMaker\Model\Process::getProcessesFilter()
* @covers \ProcessMaker\Model\Process::getListColumns()
* @covers \ProcessMaker\Model\Process::scopeJoinUsers()
* @covers \ProcessMaker\Model\Process::scopeJoinCategory()
* @covers \ProcessMaker\Model\Process::scopeSubProcess()
* @test
*/
public function it_should_test_process_subprocess_filter()
{
$process = factory(Process::class)->create([
'PRO_SUBPROCESS' => 1
]);
$result = Process::getProcessesFilter(
null,
null,
null,
$process->PRO_CREATE_USER,
0,
25,
'ASC',
'PRO_CREATE_DATE',
true,
true
);
$this->assertEquals($process->PRO_CREATE_USER, $result[0]['USR_UID']);
}
/**
* It tests the count process
*
* @covers \ProcessMaker\Model\Process::getCounter()
* @covers \ProcessMaker\Model\Process::scopePerUser()
* @test
*/
public function it_should_test_count_process()
@@ -346,6 +393,8 @@ class ProcessTest extends TestCase
* It test get processes for the new home view
*
* @covers \ProcessMaker\Model\Process::getProcessesForHome()
* @covers \ProcessMaker\Model\Process::scopeCategoryId()
* @covers \ProcessMaker\Model\Process::scopeStatus()
* @test
*/
public function it_should_test_get_processes_for_home()
@@ -356,11 +405,13 @@ class ProcessTest extends TestCase
// Create five processes (4 active, 1 inactive)
factory(Process::class)->create([
'PRO_TITLE' => 'My Process 1',
'PRO_CATEGORY' => $processCategory->CATEGORY_UID
'PRO_CATEGORY' => $processCategory->CATEGORY_UID,
'CATEGORY_ID' => $processCategory->CATEGORY_ID
]);
factory(Process::class)->create([
'PRO_TITLE' => 'My Process 2',
'PRO_CATEGORY' => $processCategory->CATEGORY_UID
'PRO_CATEGORY' => $processCategory->CATEGORY_UID,
'CATEGORY_ID' => $processCategory->CATEGORY_ID
]);
factory(Process::class)->create([
'PRO_TITLE' => 'My Process 3',
@@ -376,8 +427,21 @@ class ProcessTest extends TestCase
// Assertions
$this->assertCount(4, Process::getProcessesForHome());
$this->assertCount(3, Process::getProcessesForHome('My Process'));
$this->assertCount(2, Process::getProcessesForHome(null, $processCategory->CATEGORY_UID));
$this->assertCount(2, Process::getProcessesForHome(null, $processCategory->CATEGORY_ID));
$this->assertCount(4, Process::getProcessesForHome(null, null, null, 2));
$this->assertCount(1, Process::getProcessesForHome(null, null, 2, 1));
$this->assertCount(1, Process::getProcessesForHome(null, null, 2, 1, true));
}
/**
* It tests the isActive process
*
* @covers \ProcessMaker\Model\Process::isActive()
* @test
*/
public function it_should_test_is_active()
{
$process = factory(Process::class)->create();
$total = Process::isActive($process->PRO_ID);
$this->assertEquals(1, $total);
}
}

View File

@@ -0,0 +1,33 @@
<?php
namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use ProcessMaker\Model\ProcessUser;
use Tests\TestCase;
/**
* Class ProcessUserTest
*
* @coversDefaultClass \ProcessMaker\Model\ProcessUser
*/
class ProcessUserTest extends TestCase
{
use DatabaseTransactions;
/**
* Test get process of supervisor
*
* @covers \ProcessMaker\Model\ProcessUser::scopeProcessSupervisor()
* @covers \ProcessMaker\Model\ProcessUser::scopeProcessGroupSupervisor()
* @covers \ProcessMaker\Model\ProcessUser::scopeJoinProcess()
* @covers \ProcessMaker\Model\ProcessUser::getProcessesOfSupervisor()
* @test
*/
public function it_get_process_of_supervisor()
{
$table = factory(ProcessUser::class)->states('foreign_keys')->create();
$result = ProcessUser::getProcessesOfSupervisor($table->USR_UID);
$this->assertNotEmpty($result);
}
}

View File

@@ -7,7 +7,9 @@ use ProcessMaker\Model\ProcessVariables;
use Tests\TestCase;
/**
* @coversDefaultClass ProcessMaker\Model\ProcessVariables
* Class ProcessVariablesTest
*
* @coversDefaultClass \ProcessMaker\Model\ProcessVariables
*/
class ProcessVariablesTest extends TestCase
{

View File

@@ -9,7 +9,7 @@ use ProcessMaker\Model\RbacUsers;
use Tests\TestCase;
/**
* Class ProcessTest
* Class RbacUsersTest
*
* @coversDefaultClass \ProcessMaker\Model\SubProcess
*/

View File

@@ -0,0 +1,35 @@
<?php
namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use ProcessMaker\Model\Step;
use Tests\TestCase;
/**
* Class StepTest
*
* @coversDefaultClass \ProcessMaker\Model\Step
*/
class StepTest extends TestCase
{
use DatabaseTransactions;
/**
* Test get specific step
*
* @covers \ProcessMaker\Model\Step::getByProcessTaskAndStepType()
* @test
*/
public function it_get_specific_step()
{
$table = factory(Step::class)->create();
$result = Step::getByProcessTaskAndStepType(
$table->PRO_UID,
$table->TAS_UID,
$table->STEP_TYPE_OBJ,
$table->STEP_UID_OBJ
);
$this->assertNotEmpty($result);
}
}

View File

@@ -8,7 +8,7 @@ use ProcessMaker\Model\SubProcess;
use Tests\TestCase;
/**
* Class ProcessTest
* Class SubProcessTest
*
* @coversDefaultClass \ProcessMaker\Model\SubProcess
*/

View File

@@ -20,6 +20,31 @@ class TaskTest extends TestCase
{
use DatabaseTransactions;
/**
* It tests the get taskId
*
* @covers \ProcessMaker\Model\Task::getTask()
* @test
*/
public function it_get_task()
{
$task = factory(Task::class)->create();
$result = Task::getTask($task->TAS_ID);
$this->assertNotEmpty($result);
}
/**
* This test scopeExcludedTasks
*
* @covers \ProcessMaker\Model\Task::scopeExcludedTasks()
* @test
*/
public function it_scope_exclude_tasks()
{
$table = factory(Task::class)->create();
$this->assertNotEmpty($table->excludedTasks()->get());
}
/**
* This checks to make get the name of the task
*
@@ -30,32 +55,60 @@ class TaskTest extends TestCase
{
// Intermediate email event
$task = factory(Task::class)->create([
'TAS_TITLE' => 'INTERMEDIATE-THROW-EMAIL-EVENT'
'TAS_TITLE' => 'INTERMEDIATE-THROW-EMAIL-EVENT',
'TAS_TYPE' => 'INTERMEDIATE-THROW-EMAIL-EVENT'
]);
$taskInstance = new Task();
$title = $taskInstance->title($task->TAS_ID);
$this->assertEquals($title, G::LoadTranslation('ID_INTERMEDIATE_THROW_EMAIL_EVENT'));
$this->assertEquals($title['title'], G::LoadTranslation('ID_INTERMEDIATE_THROW_EMAIL_EVENT'));
// Intermediate throw message event
$task = factory(Task::class)->create([
'TAS_TITLE' => 'INTERMEDIATE-THROW-MESSAGE-EVENT'
'TAS_TITLE' => 'INTERMEDIATE-THROW-MESSAGE-EVENT',
'TAS_TYPE' => 'INTERMEDIATE-THROW-MESSAGE-EVENT'
]);
$taskInstance = new Task();
$title = $taskInstance->title($task->TAS_ID);
$this->assertEquals($title, G::LoadTranslation('ID_INTERMEDIATE_THROW_MESSAGE_EVENT'));
$this->assertEquals($title['title'], G::LoadTranslation('ID_INTERMEDIATE_THROW_MESSAGE_EVENT'));
// Intermediate catch message event
$task = factory(Task::class)->create([
'TAS_TITLE' => 'INTERMEDIATE-CATCH-MESSAGE-EVENT'
'TAS_TITLE' => 'INTERMEDIATE-CATCH-MESSAGE-EVENT',
'TAS_TYPE' => 'INTERMEDIATE-CATCH-MESSAGE-EVENT'
]);
$taskInstance = new Task();
$title = $taskInstance->title($task->TAS_ID);
$this->assertEquals($title, G::LoadTranslation('ID_INTERMEDIATE_CATCH_MESSAGE_EVENT'));
$this->assertEquals($title['title'], G::LoadTranslation('ID_INTERMEDIATE_CATCH_MESSAGE_EVENT'));
// Intermediate timer event
$task = factory(Task::class)->create([
'TAS_TITLE' => 'INTERMEDIATE-CATCH-TIMER-EVENT'
'TAS_TITLE' => 'INTERMEDIATE-CATCH-TIMER-EVENT',
'TAS_TYPE' => 'INTERMEDIATE-CATCH-TIMER-EVENT'
]);
$taskInstance = new Task();
$title = $taskInstance->title($task->TAS_ID);
$this->assertEquals($title, G::LoadTranslation('ID_INTERMEDIATE_CATCH_TIMER_EVENT'));
$this->assertEquals($title['title'], G::LoadTranslation('ID_INTERMEDIATE_CATCH_TIMER_EVENT'));
// Script task
$task = factory(Task::class)->create([
'TAS_TITLE' => 'SCRIPT-TASK',
'TAS_TYPE' => 'SCRIPT-TASK'
]);
$taskInstance = new Task();
$title = $taskInstance->title($task->TAS_ID);
$this->assertEquals($title['title'], G::LoadTranslation('ID_SCRIPT_TASK_UNTITLED'));
// Service task
$task = factory(Task::class)->create([
'TAS_TITLE' => 'SERVICE-TASK',
'TAS_TYPE' => 'SERVICE-TASK'
]);
$taskInstance = new Task();
$title = $taskInstance->title($task->TAS_ID);
$this->assertEquals($title['title'], G::LoadTranslation('ID_SERVICE_TASK_UNTITLED'));
// None
$task = factory(Task::class)->create([
'TAS_TITLE' => 'SUBPROCESS',
'TAS_TYPE' => 'SUBPROCESS'
]);
$taskInstance = new Task();
$title = $taskInstance->title($task->TAS_ID);
$this->assertEquals($title['title'], G::LoadTranslation('ID_ANONYMOUS'));
}
/**
@@ -191,6 +244,8 @@ class TaskTest extends TestCase
* It test get tasks for the new home view
*
* @covers \ProcessMaker\Model\Task::getTasksForHome()
* @covers \ProcessMaker\Model\Task::scopeTitle()
* @covers \ProcessMaker\Model\Task::scopeProcess()
* @test
*/
public function it_should_test_get_tasks_for_home_method()

View File

@@ -9,7 +9,7 @@ use ProcessMaker\Model\Triggers;
use Tests\TestCase;
/**
* Class DelegationTest
* Class TriggersTest
*
* @coversDefaultClass \ProcessMaker\Model\Triggers
*/

View File

@@ -6,9 +6,13 @@ use G;
use ProcessMaker\Model\UserConfig;
use Tests\TestCase;
/**
* Class UserConfigTest
*
* @coversDefaultClass \ProcessMaker\Model\UserConfig
*/
class UserConfigTest extends TestCase
{
/**
* Setup method,
*/

View File

@@ -8,6 +8,13 @@ use Luracast\Restler\Defaults;
use Luracast\Restler\HumanReadableCache;
use Maveriks\Extension\Restler;
use ProcessMaker\BusinessModel\Cases\Unassigned;
use ProcessMaker\Model\AppDelay;
use ProcessMaker\Model\Application as ApplicationModel;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\Process;
use ProcessMaker\Model\Task;
use ProcessMaker\Model\TaskUser;
use ProcessMaker\Model\User;
use ProcessMaker\Services\Api\Metrics;
use ReflectionClass;
use Tests\TestCase;
@@ -31,6 +38,7 @@ class MetricsTest extends TestCase
public function setUp()
{
parent::setUp();
Delegation::truncate();
}
/**
* Initialize Rest API.
@@ -80,6 +88,8 @@ class MetricsTest extends TestCase
*/
public function it_tests_get_counters_list_method_empty_lists()
{
ApplicationModel::truncate();
$user = factory(\ProcessMaker\Model\User::class)->create();
$this->initializeRestApi($user->USR_UID);
@@ -154,4 +164,560 @@ class MetricsTest extends TestCase
$res = $metrics->getCountersList();
$this->assertNotEmpty($res);
}
/**
* Tests the getProcessTotalCases method with inbox
*
* @test
*/
public function it_tests_get_process_total_cases_inbox()
{
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_PREVIOUS' => 1,
'DEL_INDEX' => 2,
]);
$metrics = new Metrics();
$res = $metrics->getProcessTotalCases('inbox');
$this->assertNotEmpty($res);
}
/**
* Tests the getProcessTotalCases method with draft
*
* @test
*/
public function it_tests_get_process_total_cases_draft()
{
$application = factory(ApplicationModel::class)->states('draft')->create();
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 1,
'USR_UID' => $application->APP_INIT_USER,
'USR_ID' => $application->APP_INIT_USER_ID,
'APP_UID' => $application->APP_UID,
'APP_NUMBER' => $application->APP_NUMBER,
]);
$metrics = new Metrics();
$res = $metrics->getProcessTotalCases('draft');
$this->assertNotEmpty($res);
}
/**
* Tests the getProcessTotalCases method with paused
*
* @test
*/
public function it_tests_get_process_total_cases_paused()
{
$process1 = factory(Process::class)->create(
['PRO_CATEGORY' => '1']
);
$process2 = factory(Process::class)->create(
['PRO_CATEGORY' => '2']
);
$user = factory(User::class)->create();
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => '',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process1->PRO_UID,
'TAS_TYPE' => 'NORMAL'
]);
$application1 = factory(ApplicationModel::class)->create();
$application2 = factory(ApplicationModel::class)->create();
factory(Delegation::class)->create([
'APP_NUMBER' => $application1->APP_NUMBER,
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'CLOSED',
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process1->PRO_ID,
'PRO_UID' => $process1->PRO_UID,
'DEL_PREVIOUS' => 0,
'DEL_INDEX' => 1
]);
$delegation1 = factory(Delegation::class)->create([
'APP_NUMBER' => $application1->APP_NUMBER,
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'CLOSED',
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process1->PRO_ID,
'PRO_UID' => $process1->PRO_UID,
'DEL_PREVIOUS' => 1,
'DEL_INDEX' => 2
]);
factory(Delegation::class)->create([
'APP_NUMBER' => $application2->APP_NUMBER,
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process2->PRO_ID,
'PRO_UID' => $process2->PRO_UID,
'DEL_PREVIOUS' => 0,
'DEL_INDEX' => 1
]);
$delegation2 = factory(Delegation::class)->create([
'APP_NUMBER' => $application2->APP_NUMBER,
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process2->PRO_ID,
'PRO_UID' => $process2->PRO_UID,
'DEL_PREVIOUS' => 1,
'DEL_INDEX' => 2
]);
factory(AppDelay::class, 5)->create([
'APP_DELEGATION_USER' => $user->USR_UID,
'PRO_UID' => $process2->PRO_UID,
'APP_NUMBER' => $delegation1->APP_NUMBER,
'APP_DEL_INDEX' => $delegation1->DEL_INDEX,
'APP_DISABLE_ACTION_USER' => 0,
'APP_TYPE' => 'PAUSE'
]);
factory(AppDelay::class, 5)->create([
'APP_DELEGATION_USER' => $user->USR_UID,
'PRO_UID' => $process2->PRO_UID,
'APP_NUMBER' => $delegation2->APP_NUMBER,
'APP_DEL_INDEX' => $delegation2->DEL_INDEX,
'APP_DISABLE_ACTION_USER' => 0,
'APP_TYPE' => 'PAUSE'
]);
$metrics = new Metrics();
$res = $metrics->getProcessTotalCases('paused');
$this->assertNotEmpty($res);
}
/**
* Tests the getProcessTotalCases method with unassigned
*
* @test
*/
public function it_tests_get_process_total_cases_unassigned()
{
$user = factory(\ProcessMaker\Model\User::class)->create();
$process = factory(Process::class)->create();
$application = factory(ApplicationModel::class)->create([
'APP_STATUS_ID' => 2
]);
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID,
'PRO_ID' => $process->PRO_ID,
]);
factory(TaskUser::class)->create([
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1,
'TU_TYPE' => 1
]);
factory(Delegation::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'TAS_ID' => $task->TAS_ID,
'PRO_ID' => $process->PRO_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
'DEL_DELEGATE_DATE' => date('Y-m-d H:i:s', strtotime("-1 year"))
]);
$metrics = new Metrics();
$res = $metrics->getProcessTotalCases('unassigned');
$this->assertNotEmpty($res);
}
/**
* Tests the getTotalCasesByRange method with inbox
*
* @test
*/
public function it_tests_get_total_cases_by_range_inbox()
{
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_PREVIOUS' => 1,
'DEL_INDEX' => 2,
]);
$metrics = new Metrics();
$res = $metrics->getTotalCasesByRange('inbox');
$this->assertNotEmpty($res);
}
/**
* Tests the getTotalCasesByRange method with draft
*
* @test
*/
public function it_tests_get_total_cases_by_range_draft()
{
$application = factory(ApplicationModel::class)->states('draft')->create();
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 1,
'USR_UID' => $application->APP_INIT_USER,
'USR_ID' => $application->APP_INIT_USER_ID,
'APP_UID' => $application->APP_UID,
'APP_NUMBER' => $application->APP_NUMBER,
]);
$metrics = new Metrics();
$res = $metrics->getTotalCasesByRange('draft');
$this->assertNotEmpty($res);
}
/**
* Tests the getTotalCasesByRange method with paused
*
* @test
*/
public function it_tests_get_total_cases_by_range_paused()
{
$process1 = factory(Process::class)->create(
['PRO_CATEGORY' => '1']
);
$process2 = factory(Process::class)->create(
['PRO_CATEGORY' => '2']
);
$user = factory(User::class)->create();
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => '',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process1->PRO_UID,
'TAS_TYPE' => 'NORMAL'
]);
$application1 = factory(ApplicationModel::class)->create();
$application2 = factory(ApplicationModel::class)->create();
factory(Delegation::class)->create([
'APP_NUMBER' => $application1->APP_NUMBER,
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'CLOSED',
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process1->PRO_ID,
'PRO_UID' => $process1->PRO_UID,
'DEL_PREVIOUS' => 0,
'DEL_INDEX' => 1
]);
$delegation1 = factory(Delegation::class)->create([
'APP_NUMBER' => $application1->APP_NUMBER,
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'CLOSED',
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process1->PRO_ID,
'PRO_UID' => $process1->PRO_UID,
'DEL_PREVIOUS' => 1,
'DEL_INDEX' => 2
]);
factory(Delegation::class)->create([
'APP_NUMBER' => $application2->APP_NUMBER,
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process2->PRO_ID,
'PRO_UID' => $process2->PRO_UID,
'DEL_PREVIOUS' => 0,
'DEL_INDEX' => 1
]);
$delegation2 = factory(Delegation::class)->create([
'APP_NUMBER' => $application2->APP_NUMBER,
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process2->PRO_ID,
'PRO_UID' => $process2->PRO_UID,
'DEL_PREVIOUS' => 1,
'DEL_INDEX' => 2
]);
factory(AppDelay::class, 5)->create([
'APP_DELEGATION_USER' => $user->USR_UID,
'PRO_UID' => $process2->PRO_UID,
'APP_NUMBER' => $delegation1->APP_NUMBER,
'APP_DEL_INDEX' => $delegation1->DEL_INDEX,
'APP_DISABLE_ACTION_USER' => 0,
'APP_TYPE' => 'PAUSE'
]);
factory(AppDelay::class, 5)->create([
'APP_DELEGATION_USER' => $user->USR_UID,
'PRO_UID' => $process2->PRO_UID,
'APP_NUMBER' => $delegation2->APP_NUMBER,
'APP_DEL_INDEX' => $delegation2->DEL_INDEX,
'APP_DISABLE_ACTION_USER' => 0,
'APP_TYPE' => 'PAUSE'
]);
$metrics = new Metrics();
$res = $metrics->getTotalCasesByRange('paused');
$this->assertNotEmpty($res);
}
/**
* Tests the getTotalCasesByRange method with unassigned
*
* @test
*/
public function it_tests_get_total_cases_by_range_unassigned()
{
$user = factory(\ProcessMaker\Model\User::class)->create();
$process = factory(Process::class)->create();
$application = factory(ApplicationModel::class)->create([
'APP_STATUS_ID' => 2
]);
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID,
'PRO_ID' => $process->PRO_ID,
]);
factory(TaskUser::class)->create([
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1,
'TU_TYPE' => 1
]);
factory(Delegation::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'TAS_ID' => $task->TAS_ID,
'PRO_ID' => $process->PRO_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
'DEL_DELEGATE_DATE' => date('Y-m-d H:i:s', strtotime("-1 year"))
]);
$metrics = new Metrics();
$res = $metrics->getTotalCasesByRange('unassigned');
$this->assertNotEmpty($res);
}
/**
* Tests the getCasesRiskByProcess method with inbox
*
* @test
*/
public function it_tests_get_cases_risk_by_process_inbox()
{
$process = factory(Process::class)->create();
$delegation = factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_PREVIOUS' => 1,
'DEL_INDEX' => 2,
'PRO_ID' => $process->PRO_ID,
'DEL_RISK_DATE' => date('Y-m-d H:i:s'),
'DEL_TASK_DUE_DATE' => date('Y-m-d H:i:s', strtotime("+1 hour"))
]);
$metrics = new Metrics();
$res = $metrics->getCasesRiskByProcess('inbox', $delegation->PRO_ID, null, null, 'AT_RISK');
$this->assertNotEmpty($res);
}
/**
* Tests the getCasesRiskByProcess method with draft
*
* @test
*/
public function it_tests_get_cases_risk_by_process_draft()
{
$process = factory(Process::class)->create();
$application = factory(ApplicationModel::class)->states('draft')->create();
$delegation = factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 1,
'USR_UID' => $application->APP_INIT_USER,
'USR_ID' => $application->APP_INIT_USER_ID,
'APP_UID' => $application->APP_UID,
'APP_NUMBER' => $application->APP_NUMBER,
'PRO_ID' => $process->PRO_ID,
'DEL_RISK_DATE' => date('Y-m-d H:i:s'),
'DEL_TASK_DUE_DATE' => date('Y-m-d H:i:s', strtotime("+1 hour"))
]);
$metrics = new Metrics();
$res = $metrics->getCasesRiskByProcess('draft', $delegation->PRO_ID, null, null, 'AT_RISK');
$this->assertNotEmpty($res);
}
/**
* Tests the getCasesRiskByProcess method with paused
*
* @test
*/
public function it_tests_get_cases_risk_by_process_paused()
{
$process1 = factory(Process::class)->create(
['PRO_CATEGORY' => '1']
);
$process2 = factory(Process::class)->create(
['PRO_CATEGORY' => '2']
);
$user = factory(User::class)->create();
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => '',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process1->PRO_UID,
'TAS_TYPE' => 'NORMAL'
]);
$application1 = factory(ApplicationModel::class)->create();
$application2 = factory(ApplicationModel::class)->create();
factory(Delegation::class)->create([
'APP_NUMBER' => $application1->APP_NUMBER,
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'CLOSED',
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process1->PRO_ID,
'PRO_UID' => $process1->PRO_UID,
'DEL_PREVIOUS' => 0,
'DEL_INDEX' => 1,
'DEL_RISK_DATE' => date('Y-m-d H:i:s'),
'DEL_TASK_DUE_DATE' => date('Y-m-d H:i:s', strtotime("+1 hour"))
]);
$delegation1 = factory(Delegation::class)->create([
'APP_NUMBER' => $application1->APP_NUMBER,
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'CLOSED',
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process1->PRO_ID,
'PRO_UID' => $process1->PRO_UID,
'DEL_PREVIOUS' => 1,
'DEL_INDEX' => 2,
'DEL_RISK_DATE' => date('Y-m-d H:i:s'),
'DEL_TASK_DUE_DATE' => date('Y-m-d H:i:s', strtotime("+1 hour"))
]);
factory(Delegation::class)->create([
'APP_NUMBER' => $application2->APP_NUMBER,
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process2->PRO_ID,
'PRO_UID' => $process2->PRO_UID,
'DEL_PREVIOUS' => 0,
'DEL_INDEX' => 1,
'DEL_RISK_DATE' => date('Y-m-d H:i:s'),
'DEL_TASK_DUE_DATE' => date('Y-m-d H:i:s', strtotime("+1 hour"))
]);
$delegation2 = factory(Delegation::class)->create([
'APP_NUMBER' => $application2->APP_NUMBER,
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID,
'PRO_ID' => $process2->PRO_ID,
'PRO_UID' => $process2->PRO_UID,
'DEL_PREVIOUS' => 1,
'DEL_INDEX' => 2,
'DEL_RISK_DATE' => date('Y-m-d H:i:s'),
'DEL_TASK_DUE_DATE' => date('Y-m-d H:i:s', strtotime("+1 hour"))
]);
factory(AppDelay::class, 5)->create([
'APP_DELEGATION_USER' => $user->USR_UID,
'PRO_UID' => $process2->PRO_UID,
'APP_NUMBER' => $delegation1->APP_NUMBER,
'APP_DEL_INDEX' => $delegation1->DEL_INDEX,
'APP_DISABLE_ACTION_USER' => 0,
'APP_TYPE' => 'PAUSE'
]);
factory(AppDelay::class, 5)->create([
'APP_DELEGATION_USER' => $user->USR_UID,
'PRO_UID' => $process2->PRO_UID,
'APP_NUMBER' => $delegation2->APP_NUMBER,
'APP_DEL_INDEX' => $delegation2->DEL_INDEX,
'APP_DISABLE_ACTION_USER' => 0,
'APP_TYPE' => 'PAUSE'
]);
$metrics = new Metrics();
$res = $metrics->getCasesRiskByProcess('paused', $delegation1->PRO_ID, null, null, 'AT_RISK');
$this->assertNotEmpty($res);
}
/**
* Tests the getCasesRiskByProcess method with unassigned
*
* @test
*/
public function it_tests_get_cases_risk_by_process_unassigned()
{
$user = factory(\ProcessMaker\Model\User::class)->create();
$process = factory(Process::class)->create();
$application = factory(ApplicationModel::class)->create([
'APP_STATUS_ID' => 2
]);
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID,
'PRO_ID' => $process->PRO_ID,
]);
factory(TaskUser::class)->create([
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1,
'TU_TYPE' => 1
]);
$delegation = factory(Delegation::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'TAS_ID' => $task->TAS_ID,
'PRO_ID' => $process->PRO_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
'DEL_DELEGATE_DATE' => date('Y-m-d H:i:s', strtotime("-1 year")),
'DEL_RISK_DATE' => date('Y-m-d H:i:s'),
'DEL_TASK_DUE_DATE' => date('Y-m-d H:i:s', strtotime("+1 hour"))
]);
unset($RBAC);
$metrics = new Metrics();
$res = $metrics->getCasesRiskByProcess('unassigned', $delegation->PRO_ID, null, null, 'AT_RISK');
$this->assertNotEmpty($res);
}
/**
* Tests the getProcessTotalCases method with exception
*
* @test
*/
public function it_tests_get_process_total_cases_exception()
{
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_PREVIOUS' => 1,
'DEL_INDEX' => 2,
]);
$metrics = new Metrics();
$this->expectExceptionMessage("Undefined variable: list");
$metrics->getProcessTotalCases(12, 123, "asda");
}
/**
* Tests the getTotalCasesByRange method with exception
*
* @test
*/
public function it_tests_get_total_cases_by_range_exception()
{
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_PREVIOUS' => 1,
'DEL_INDEX' => 2,
]);
$metrics = new Metrics();
$this->expectExceptionMessage("Undefined variable: list");
$metrics->getTotalCasesByRange(12, 123, "asda");
}
/**
* Tests the getCasesRiskByProcess method with exception
*
* @test
*/
public function it_tests_get_counters_list_exception()
{
factory(Delegation::class)->states('foreign_keys')->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_PREVIOUS' => 1,
'DEL_INDEX' => 2,
]);
$metrics = new Metrics();
$this->expectExceptionMessage("Undefined variable: list");
$metrics->getCasesRiskByProcess(12, 123, "asda");
}
}