PMCORE-2397

This commit is contained in:
Paula Quispe
2020-12-09 19:04:05 -04:00
parent bb38e8acd8
commit 9565312ca9
20 changed files with 806 additions and 1431 deletions

View File

@@ -6,7 +6,7 @@ use Faker\Generator as Faker;
$factory->define(\ProcessMaker\Model\AppAssignSelfServiceValue::class, function(Faker $faker) { $factory->define(\ProcessMaker\Model\AppAssignSelfServiceValue::class, function(Faker $faker) {
return [ return [
'ID' => $faker->unique()->numberBetween(1, 2000), 'ID' => $faker->unique()->numberBetween(5000),
'APP_UID' => G::generateUniqueID(), 'APP_UID' => G::generateUniqueID(),
'DEL_INDEX' => 2, 'DEL_INDEX' => 2,
'PRO_UID' => G::generateUniqueID(), 'PRO_UID' => G::generateUniqueID(),

View File

@@ -6,7 +6,7 @@ use Faker\Generator as Faker;
$factory->define(\ProcessMaker\Model\AppAssignSelfServiceValueGroup::class, function(Faker $faker) { $factory->define(\ProcessMaker\Model\AppAssignSelfServiceValueGroup::class, function(Faker $faker) {
return [ return [
'ID' => $faker->unique()->numberBetween(1, 2000), 'ID' => $faker->unique()->numberBetween(5000),
'GRP_UID' => G::generateUniqueID(), 'GRP_UID' => G::generateUniqueID(),
'ASSIGNEE_ID' => $faker->unique()->numberBetween(1, 2000), 'ASSIGNEE_ID' => $faker->unique()->numberBetween(1, 2000),
'ASSIGNEE_TYPE' => $faker->unique()->numberBetween(1, 2000), 'ASSIGNEE_TYPE' => $faker->unique()->numberBetween(1, 2000),

View File

@@ -16,9 +16,9 @@ $factory->define(\ProcessMaker\Model\Delegation::class, function(Faker $faker) {
]); ]);
// Return with default values // Return with default values
return [ return [
'DELEGATION_ID' => $faker->unique()->numberBetween(5000),
'APP_UID' => $application->APP_UID, 'APP_UID' => $application->APP_UID,
'DEL_INDEX' => 1, 'DEL_INDEX' => 1,
'DELEGATION_ID' => $faker->unique()->randomNumber,
'APP_NUMBER' => $application->APP_NUMBER, 'APP_NUMBER' => $application->APP_NUMBER,
'DEL_PREVIOUS' => 0, 'DEL_PREVIOUS' => 0,
'PRO_UID' => $process->PRO_UID, 'PRO_UID' => $process->PRO_UID,
@@ -62,6 +62,7 @@ $factory->state(\ProcessMaker\Model\Delegation::class, 'foreign_keys', function
// Return with default values // Return with default values
return [ return [
'DELEGATION_ID' => $faker->unique()->numberBetween(5000),
'APP_UID' => $application->APP_UID, 'APP_UID' => $application->APP_UID,
'DEL_INDEX' => 1, 'DEL_INDEX' => 1,
'APP_NUMBER' => $application->APP_NUMBER, 'APP_NUMBER' => $application->APP_NUMBER,

View File

@@ -103,11 +103,15 @@ class AbstractCasesTest extends TestCase
public function it_return_set_get_priority() public function it_return_set_get_priority()
{ {
$absCases = new AbstractCases(); $absCases = new AbstractCases();
$arguments = ['VL', 'L', 'N', 'H', 'VH']; $arguments = ['', 'VL', 'L', 'N', 'H', 'VH'];
$index = array_rand($arguments); $index = array_rand($arguments);
$absCases->setPriority($arguments[$index]); $absCases->setPriority($arguments[$index]);
$actual = $absCases->getPriority(); $actual = $absCases->getPriority();
$this->assertEquals($index, $actual); $this->assertEquals($index, $actual);
// Empty
$absCases->setPriority('');
$actual = $absCases->getPriority();
$this->assertEquals(0, $actual);
} }
/** /**
@@ -120,7 +124,7 @@ class AbstractCasesTest extends TestCase
public function it_return_set_get_priorities() public function it_return_set_get_priorities()
{ {
$absCases = new AbstractCases(); $absCases = new AbstractCases();
$arguments = ['VL', 'L', 'N', 'H', 'VH']; $arguments = ['', 'VL', 'L', 'N', 'H', 'VH'];
$index = array_rand($arguments); $index = array_rand($arguments);
$absCases->setPriorities([$arguments[$index]]); $absCases->setPriorities([$arguments[$index]]);
$actual = $absCases->getPriorities(); $actual = $absCases->getPriorities();
@@ -148,6 +152,8 @@ class AbstractCasesTest extends TestCase
* *
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCaseNumberFrom() * @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCaseNumberFrom()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCaseNumberTo() * @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCaseNumberTo()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getCaseNumberFrom()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getCaseNumberTo()
* @test * @test
*/ */
public function it_return_set_get_range_case_number() public function it_return_set_get_range_case_number()
@@ -191,11 +197,11 @@ class AbstractCasesTest extends TestCase
public function it_return_set_get_inbox_status() public function it_return_set_get_inbox_status()
{ {
$absCases = new AbstractCases(); $absCases = new AbstractCases();
$arguments = ['ALL', 'READ', 'UNREAD']; $arguments = ['READ', 'UNREAD'];
$index = array_rand($arguments); $index = array_rand($arguments);
$absCases->setInboxStatus($arguments[$index]); $absCases->setInboxStatus($arguments[$index]);
$actual = $absCases->getInboxStatus(); $actual = $absCases->getInboxStatus();
if ($arguments[$index] === 'ALL') { if ($arguments[$index] === '') {
$this->assertEmpty($actual); $this->assertEmpty($actual);
} else { } else {
$this->assertEquals($arguments[$index], $actual); $this->assertEquals($arguments[$index], $actual);
@@ -212,15 +218,11 @@ class AbstractCasesTest extends TestCase
public function it_return_set_get_participated_status() public function it_return_set_get_participated_status()
{ {
$absCases = new AbstractCases(); $absCases = new AbstractCases();
$arguments = ['ALL', 'STARTED', 'COMPLETED']; $arguments = ['STARTED', 'COMPLETED'];
$index = array_rand($arguments); $index = array_rand($arguments);
$absCases->setParticipatedStatus($arguments[$index]); $absCases->setParticipatedStatus($arguments[$index]);
$actual = $absCases->getParticipatedStatus(); $actual = $absCases->getParticipatedStatus();
if ($arguments[$index] === 'ALL') { $this->assertEquals($arguments[$index], $actual);
$this->assertEmpty($actual);
} else {
$this->assertEquals($arguments[$index], $actual);
}
} }
/** /**
@@ -233,15 +235,11 @@ class AbstractCasesTest extends TestCase
public function it_return_set_get_risk_status() public function it_return_set_get_risk_status()
{ {
$absCases = new AbstractCases(); $absCases = new AbstractCases();
$arguments = ['ALL', 'ON_TIME', 'AT_RISK', 'OVERDUE']; $arguments = ['ON_TIME', 'AT_RISK', 'OVERDUE'];
$index = array_rand($arguments); $index = array_rand($arguments);
$absCases->setRiskStatus($arguments[$index]); $absCases->setRiskStatus($arguments[$index]);
$actual = $absCases->getRiskStatus(); $actual = $absCases->getRiskStatus();
if ($arguments[$index] === 'ALL') { $this->assertEquals($arguments[$index], $actual);
$this->assertEmpty($actual);
} else {
$this->assertEquals($arguments[$index], $actual);
}
} }
/** /**
@@ -254,16 +252,15 @@ class AbstractCasesTest extends TestCase
public function it_return_set_get_case_status() public function it_return_set_get_case_status()
{ {
$absCases = new AbstractCases(); $absCases = new AbstractCases();
$arguments = ['ALL', 'DRAFT', 'TO_DO', 'COMPLETED', 'CANCELED']; $arguments = ['', 'DRAFT', 'TO_DO', 'COMPLETED', 'CANCELED'];
$index = array_rand($arguments); $index = array_rand($arguments);
$absCases->setCaseStatus($arguments[$index]); $absCases->setCaseStatus($arguments[$index]);
$actual = $absCases->getCaseStatus(); $actual = $absCases->getCaseStatus();
$this->assertEquals($index, $actual); $this->assertEquals($index, $actual);
if ($arguments[$index] === 'ALL') { // Incorrect canceled status
$this->assertEquals(0, $actual); $absCases->setCaseStatuses(['CANCELLED']);
} else { $actual = $absCases->getCaseStatuses();
$this->assertEquals($index, $actual); $this->assertEquals([4], $actual);
}
} }
/** /**
@@ -276,11 +273,15 @@ class AbstractCasesTest extends TestCase
public function it_return_set_get_case_statuses() public function it_return_set_get_case_statuses()
{ {
$absCases = new AbstractCases(); $absCases = new AbstractCases();
$arguments = ['DRAFT', 'TO_DO', 'COMPLETED', 'CANCELED']; $arguments = ['', 'DRAFT', 'TO_DO', 'COMPLETED', 'CANCELED'];
$index = array_rand($arguments); $index = array_rand($arguments);
$absCases->setCaseStatuses([$arguments[$index]]); $absCases->setCaseStatuses([$arguments[$index]]);
$actual = $absCases->getCaseStatuses(); $actual = $absCases->getCaseStatuses();
$this->assertEquals([$index], $actual); $this->assertEquals([$index], $actual);
// Incorrect canceled status
$absCases->setCaseStatuses(['CANCELLED']);
$actual = $absCases->getCaseStatuses();
$this->assertEquals([4], $actual);
} }
/** /**
@@ -314,6 +315,62 @@ class AbstractCasesTest extends TestCase
$this->assertEquals([$application->APP_NUMBER], $actual); $this->assertEquals([$application->APP_NUMBER], $actual);
} }
/**
* This check the getter and setter related to the filter cases
*
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setFilterCases()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getFilterCases()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCasesNumbers()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getCasesNumbers()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setRangeCasesFromTo()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getRangeCasesFromTo()
* @test
*/
public function it_return_set_get_filter_cases()
{
$absCases = new AbstractCases();
$text = '1,3-5,8,10-15';
$absCases->setFilterCases($text);
$actual = $absCases->getFilterCases();
$this->assertEquals($text, $actual);
$actual = $absCases->getCasesNumbers();
$this->assertEquals([1,8], $actual);
$actual = $absCases->getRangeCasesFromTo();
$this->assertEquals(['3-5','10-15'], $actual);
}
/**
* This check the getter and setter related to the start case from
*
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setStartCaseFrom()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getStartCaseFrom()
* @test
*/
public function it_return_set_get_start_case_from()
{
$absCases = new AbstractCases();
$text = date('Y-m-d');
$absCases->setStartCaseFrom($text);
$actual = $absCases->getStartCaseFrom();
$this->assertEquals($text, $actual);
}
/**
* This check the getter and setter related to the start case to
*
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setStartCaseTo()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getStartCaseTo()
* @test
*/
public function it_return_set_get_start_case_to()
{
$absCases = new AbstractCases();
$text = date('Y-m-d');
$absCases->setStartCaseTo($text);
$actual = $absCases->getStartCaseTo();
$this->assertEquals($text, $actual);
}
/** /**
* This check the getter and setter related to the newest than date * This check the getter and setter related to the newest than date
* *
@@ -321,7 +378,7 @@ class AbstractCasesTest extends TestCase
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getDelegateFrom() * @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getDelegateFrom()
* @test * @test
*/ */
public function it_return_set_get_newest_than() public function it_return_set_get_delegation_from()
{ {
$absCases = new AbstractCases(); $absCases = new AbstractCases();
$text = date('Y-m-d'); $text = date('Y-m-d');
@@ -337,7 +394,7 @@ class AbstractCasesTest extends TestCase
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getDelegateTo() * @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getDelegateTo()
* @test * @test
*/ */
public function it_return_set_get_oldest_than() public function it_return_set_get_delegation_to()
{ {
$absCases = new AbstractCases(); $absCases = new AbstractCases();
$text = date('Y-m-d'); $text = date('Y-m-d');
@@ -346,6 +403,102 @@ class AbstractCasesTest extends TestCase
$this->assertEquals($text, $actual); $this->assertEquals($text, $actual);
} }
/**
* This check the getter and setter related to the finish case from
*
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setFinishCaseFrom()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getFinishCaseFrom()
* @test
*/
public function it_return_set_get_finish_case_from()
{
$absCases = new AbstractCases();
$text = date('Y-m-d');
$absCases->setFinishCaseFrom($text);
$actual = $absCases->getFinishCaseFrom();
$this->assertEquals($text, $actual);
}
/**
* This check the getter and setter related to the finish case to
*
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setFinishCaseTo()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getFinishCaseTo()
* @test
*/
public function it_return_set_get_finish_case_to()
{
$absCases = new AbstractCases();
$text = date('Y-m-d');
$absCases->setFinishCaseTo($text);
$actual = $absCases->getFinishCaseTo();
$this->assertEquals($text, $actual);
}
/**
* This check the getter and setter related to the finish delegate from
*
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setFinishFrom()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getFinishFrom()
* @test
*/
public function it_return_set_get_finish_delegate_from()
{
$absCases = new AbstractCases();
$text = date('Y-m-d');
$absCases->setFinishFrom($text);
$actual = $absCases->getFinishFrom();
$this->assertEquals($text, $actual);
}
/**
* This check the getter and setter related to the finish delegate to
*
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setFinishTo()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getFinishTo()
* @test
*/
public function it_return_set_get_finish_delegate_to()
{
$absCases = new AbstractCases();
$text = date('Y-m-d');
$absCases->setFinishTo($text);
$actual = $absCases->getFinishTo();
$this->assertEquals($text, $actual);
}
/**
* This check the getter and setter related to the due date from
*
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setDueFrom()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getDueFrom()
* @test
*/
public function it_return_set_get_due_from()
{
$absCases = new AbstractCases();
$text = date('Y-m-d');
$absCases->setDueFrom($text);
$actual = $absCases->getDueFrom();
$this->assertEquals($text, $actual);
}
/**
* This check the getter and setter related to the due date to
*
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setDueTo()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getDueTo()
* @test
*/
public function it_return_set_get_due_to()
{
$absCases = new AbstractCases();
$text = date('Y-m-d');
$absCases->setDueTo($text);
$actual = $absCases->getDueTo();
$this->assertEquals($text, $actual);
}
/** /**
* This check the getter and setter related to the oldest than date * This check the getter and setter related to the oldest than date
* *
@@ -436,7 +589,7 @@ class AbstractCasesTest extends TestCase
$actual = $absCases->getPriorities(); $actual = $absCases->getPriorities();
$this->assertEmpty($actual); $this->assertEmpty($actual);
$actual = $absCases->getCaseStatuses(); $actual = $absCases->getCaseStatuses();
$this->assertEmpty($actual); $this->assertEquals([1,2,3,4], $actual);
$actual = $absCases->getFilterCases(); $actual = $absCases->getFilterCases();
$this->assertEmpty($actual); $this->assertEmpty($actual);
$actual = $absCases->getDelegateFrom(); $actual = $absCases->getDelegateFrom();
@@ -465,6 +618,11 @@ class AbstractCasesTest extends TestCase
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setUserId() * @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setUserId()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCaseNumber() * @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCaseNumber()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCaseTitle() * @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::setParticipatedStatus()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCaseStatus() * @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCaseStatus()
@@ -472,6 +630,12 @@ class AbstractCasesTest extends TestCase
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setStartCaseTo() * @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setStartCaseTo()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setFinishCaseFrom() * @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setFinishCaseFrom()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setFinishCaseTo() * @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::setFilterCases()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCaseStatuses() * @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCaseStatuses()
@@ -480,6 +644,12 @@ class AbstractCasesTest extends TestCase
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setDelegateTo() * @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setDelegateTo()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setDueFrom() * @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setDueFrom()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setDueTo() * @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::setCaseUid() * @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCaseUid()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCasesUids() * @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCasesUids()
@@ -488,6 +658,13 @@ class AbstractCasesTest extends TestCase
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setPaged() * @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setPaged()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setOffset() * @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setOffset()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setLimit() * @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setLimit()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getCaseUid()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getCasesUids()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getOrderByColumn()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getOrderDirection()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getPaged()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getOffset()
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getLimit()
* @test * @test
*/ */
public function it_return_set_get_properties() public function it_return_set_get_properties()
@@ -534,21 +711,23 @@ class AbstractCasesTest extends TestCase
$this->assertEquals($properties['user'], $actual); $this->assertEquals($properties['user'], $actual);
$actual = $absCases->getCaseNumber(); $actual = $absCases->getCaseNumber();
$this->assertEquals($properties['caseNumber'], $actual); $this->assertEquals($properties['caseNumber'], $actual);
$actual = $absCases->getCaseTitle();
$this->assertEquals($properties['caseTitle'], $actual);
// Home - Search // Home - Search
$actual = $absCases->getPriorities(); $actual = $absCases->getPriorities();
$this->assertNotEmpty($actual); $this->assertEmpty($actual);
$actual = $absCases->getCaseStatuses(); $actual = $absCases->getCaseStatuses();
$this->assertNotEmpty($actual); $this->assertNotEmpty($actual);
$actual = $absCases->getFilterCases(); $actual = $absCases->getFilterCases();
$this->assertEquals([1,8], $actual); $this->assertEmpty($actual);
$actual = $absCases->getCasesNumbers(); $actual = $absCases->getCasesNumbers();
$this->assertEquals(['3-5','10-15'], $actual); $this->assertEmpty($actual);
$actual = $absCases->getRangeCasesFromTo(); $actual = $absCases->getRangeCasesFromTo();
$this->assertNotEmpty($actual); $this->assertEmpty($actual);
$actual = $absCases->getDelegateFrom(); $actual = $absCases->getDelegateFrom();
$this->assertEquals($properties['delegationDateFrom'], $actual); $this->assertEmpty($actual);
$actual = $absCases->getDelegateTo(); $actual = $absCases->getDelegateTo();
$this->assertEquals($properties['delegationDateTo'], $actual); $this->assertEmpty($actual);
// Home - My cases // Home - My cases
$actual = $absCases->getParticipatedStatus(); $actual = $absCases->getParticipatedStatus();
$this->assertEmpty($actual); $this->assertEmpty($actual);
@@ -582,4 +761,36 @@ class AbstractCasesTest extends TestCase
$actual = $absCases->getLimit(); $actual = $absCases->getLimit();
$this->assertEquals($properties['limit'], $actual); $this->assertEquals($properties['limit'], $actual);
} }
/**
* This check the get task color
*
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getTaskColor()
* @test
*/
public function it_return_task_color()
{
$absCases = new AbstractCases();
$dueDate = date('Y-m-d');
$result = $absCases->getTaskColor($dueDate);
$this->assertNotEmpty($result);
}
/**
* This check task color according the due date
*
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::prepareTaskPending()
* @test
*/
public function it_return_task_pending_result()
{
$task = factory(Task::class, 2)->create();
$absCases = new AbstractCases();
$pending = '[
{"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"}
]';
$result = $absCases->prepareTaskPending($pending);
$this->assertNotEmpty($result);
}
} }

View File

@@ -3,6 +3,7 @@
namespace Tests\unit\workflow\src\ProcessMaker\BusinessModel\Cases; namespace Tests\unit\workflow\src\ProcessMaker\BusinessModel\Cases;
use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\BusinessModel\Cases\Draft; use ProcessMaker\BusinessModel\Cases\Draft;
use ProcessMaker\Model\Application; use ProcessMaker\Model\Application;
use ProcessMaker\Model\Delegation; use ProcessMaker\Model\Delegation;
@@ -65,92 +66,138 @@ class DraftTest extends TestCase
* It tests the getData method without filters * It tests the getData method without filters
* *
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getData() * @covers \ProcessMaker\BusinessModel\Cases\Draft::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @test * @test
*/ */
public function it_should_test_get_data_method_without_filters() public function it_get_result_without_filters()
{ {
// Create factories related to the draft cases // Create factories related to the draft cases
$cases = $this->createDraft(); $cases = $this->createDraft();
// Create new Draft object // Create new Draft object
$inbox = new Inbox(); $draft = new Inbox();
// Set the user ID // Set the user ID
$inbox->setUserId($cases->USR_ID); $draft->setUserId($cases->USR_ID);
$inbox->setOrderByColumn('APP_NUMBER'); $draft->setOrderByColumn('APP_NUMBER');
$res = $inbox->getData(); $res = $draft->getData();
$this->assertNotEmpty($res); $this->assertNotEmpty($res);
} }
/** /**
* It tests the getData method with Process Filter * It tests the getData method with processId filter
* *
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getData() * @covers \ProcessMaker\BusinessModel\Cases\Draft::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Draft::filters()
* @test * @test
*/ */
public function it_should_test_get_data_by_process_filter() public function it_filter_by_process()
{ {
// Create factories related to the draft cases // Create factories related to the draft cases
$cases = $this->createDraft(); $cases = $this->createDraft();
// Create new Draft object // Create new Draft object
$inbox = new Draft(); $draft = new Draft();
$inbox->setUserId($cases->USR_ID); $draft->setUserId($cases->USR_ID);
$inbox->setProcessId($cases->PRO_ID); $draft->setProcessId($cases->PRO_ID);
$inbox->setOrderByColumn('APP_NUMBER'); $draft->setOrderByColumn('APP_NUMBER');
$res = $inbox->getData(); $res = $draft->getData();
$this->assertNotEmpty($res); $this->assertNotEmpty($res);
} }
/** /**
* It tests the getData method using OrderBy * It tests the getData method with case number filter
* *
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getData() * @covers \ProcessMaker\BusinessModel\Cases\Draft::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Draft::filters()
* @test * @test
*/ */
public function it_should_test_get_data_by_case_number() public function it_filter_by_app_number()
{ {
// Create factories related to the draft cases // Create factories related to the draft cases
$cases = $this->createDraft(); $cases = $this->createDraft();
// Create new Draft object // Create new Draft object
$inbox = new Draft(); $draft = new Draft();
$inbox->setUserId($cases->USR_ID); $draft->setUserId($cases->USR_ID);
$inbox->setCaseNumber($cases->APP_NUMBER); $draft->setCaseNumber($cases->APP_NUMBER);
$inbox->setOrderByColumn('APP_NUMBER'); $draft->setOrderByColumn('APP_NUMBER');
$res = $inbox->getData(); $res = $draft->getData();
$this->assertNotEmpty($res); $this->assertNotEmpty($res);
} }
/** /**
* It tests the getData method using OrderBy * It tests the getData method with taskId filter
* *
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getData() * @covers \ProcessMaker\BusinessModel\Cases\Draft::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Draft::filters()
* @test * @test
*/ */
public function it_should_test_get_data_by_task_filter() public function it_filter_by_task()
{ {
// Create factories related to the draft cases // Create factories related to the draft cases
$cases = $this->createDraft(); $cases = $this->createDraft();
// Create new Draft object // Create new Draft object
$inbox = new Draft(); $draft = new Draft();
$inbox->setUserId($cases->USR_ID); $draft->setUserId($cases->USR_ID);
$inbox->setTaskId($cases->TAS_ID); $draft->setTaskId($cases->TAS_ID);
$res = $inbox->getData(); $res = $draft->getData();
$this->assertNotEmpty($res); $this->assertNotEmpty($res);
} }
/** /**
* It tests the getData method using OrderBy * It tests the getData method with case title filter
* *
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getData() * @covers \ProcessMaker\BusinessModel\Cases\Draft::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Draft::filters()
* @test * @test
*/ */
public function it_should_test_get_data_by_case_title() public function it_filter_by_thread_title()
{ {
// Create factories related to the to_do cases // Create factories related to the to_do cases
$cases = $this->createDraft(); $cases = $this->createDraft();
$title = $cases->last()->DEL_TITLE;
// We need to commit the records inserted because is needed for the "fulltext" index
DB::commit();
// Create new Draft object // Create new Draft object
$inbox = new Draft(); $draft = new Draft();
$inbox->setUserId($cases->USR_ID); $draft->setUserId($cases->USR_ID);
$res = $inbox->getData(); // Set the title
$draft->setCaseTitle($cases->DEL_TITLE);
// Get the data
$res = $draft->getData();
// Asserts
$this->assertNotEmpty($res);
}
/**
* It tests the getData method using order by column
*
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Draft::filters()
* @test
*/
public function it_order_by_column()
{
// Create factories related to the to_do cases
$cases = $this->createDraft();
$columnsView = [
'APP_NUMBER',
'DEL_TITLE',
'PRO_TITLE',
'TAS_TITLE',
'DEL_TASK_DUE_DATE',
'DEL_DELEGATE_DATE'
];
$index = array_rand($columnsView);
// Create new Inbox object
$draft = new Draft();
$draft->setUserId($cases->USR_ID);
// Define the column to order
$draft->setOrderByColumn($columnsView[$index]);
$res = $draft->getData();
$this->assertNotEmpty($res); $this->assertNotEmpty($res);
} }
} }

View File

@@ -3,6 +3,7 @@
namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases; namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases;
use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\BusinessModel\Cases\Inbox; use ProcessMaker\BusinessModel\Cases\Inbox;
use ProcessMaker\Model\Delegation; use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\Process; use ProcessMaker\Model\Process;
@@ -36,13 +37,31 @@ class InboxTest extends TestCase
return $delegation; return $delegation;
} }
/**
* It tests the getCounter method
*
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getCounter()
* @test
*/
public function it_get_counter()
{
// Create factories related to the to_do cases
$cases = $this->createInbox();
// Create the Inbox object
$inbox = new Inbox();
$inbox->setUserId($cases->USR_ID);
$res = $inbox->getCounter();
$this->assertTrue($res > 0);
}
/** /**
* It tests the getData method without filters * It tests the getData method without filters
* *
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData() * @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @test * @test
*/ */
public function it_should_test_get_data_method_without_filters() public function it_get_result_without_filters()
{ {
// Create factories related to the to_do cases // Create factories related to the to_do cases
$cases = $this->createInbox(); $cases = $this->createInbox();
@@ -59,12 +78,14 @@ class InboxTest extends TestCase
} }
/** /**
* It tests the getData method with Process Filter * It tests the getData method with processId filter
* *
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData() * @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::filters()
* @test * @test
*/ */
public function it_should_test_get_data_by_process_filter() public function it_filter_by_process()
{ {
// Create factories related to the to_do cases // Create factories related to the to_do cases
$cases = $this->createInbox(); $cases = $this->createInbox();
@@ -78,12 +99,14 @@ class InboxTest extends TestCase
} }
/** /**
* It tests the getData method using OrderBy * It tests the getData method with case number filter
* *
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData() * @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::filters()
* @test * @test
*/ */
public function it_should_test_get_data_by_case_number() public function it_filter_by_app_number()
{ {
// Create factories related to the to_do cases // Create factories related to the to_do cases
$cases = $this->createInbox(); $cases = $this->createInbox();
@@ -97,12 +120,14 @@ class InboxTest extends TestCase
} }
/** /**
* It tests the getData method using OrderBy * It tests the getData method with taskId filter
* *
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData() * @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::filters()
* @test * @test
*/ */
public function it_should_test_get_data_by_task_filter() public function it_filter_by_task()
{ {
// Create factories related to the to_do cases // Create factories related to the to_do cases
$cases = $this->createInbox(); $cases = $this->createInbox();
@@ -116,36 +141,57 @@ class InboxTest extends TestCase
} }
/** /**
* It tests the getData method using OrderBy * It tests the getData method with case title filter
* *
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData() * @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::filters()
* @test * @test
*/ */
public function it_should_test_get_data_by_case_title() public function it_filter_by_thread_title()
{ {
// Create factories related to the to_do cases // Create factories related to the to_do cases
$cases = $this->createInbox(); $cases = $this->createInbox();
// We need to commit the records inserted because is needed for the "fulltext" index
DB::commit();
// Create new Inbox object // Create new Inbox object
$inbox = new Inbox(); $inbox = new Inbox();
$inbox->setUserId($cases->USR_ID); $inbox->setUserId($cases->USR_ID);
// Set the title
$inbox->setCaseTitle($cases->DEL_TITLE);
// Get the data
$res = $inbox->getData(); $res = $inbox->getData();
// Asserts
$this->assertNotEmpty($res); $this->assertNotEmpty($res);
} }
/** /**
* It tests the getCounter method * It tests the getData method using order by column
* *
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getCounter() * @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::filters()
* @test * @test
*/ */
public function it_should_test_the_counter_for_inbox() public function it_order_by_column()
{ {
// Create factories related to the to_do cases // Create factories related to the to_do cases
$cases = $this->createInbox(); $cases = $this->createInbox();
// Create the Inbox object $columnsView = [
'APP_NUMBER',
'DEL_TITLE',
'PRO_TITLE',
'TAS_TITLE',
'DEL_TASK_DUE_DATE',
'DEL_DELEGATE_DATE'
];
$index = array_rand($columnsView);
// Create new Inbox object
$inbox = new Inbox(); $inbox = new Inbox();
$inbox->setUserId($cases->USR_ID); $inbox->setUserId($cases->USR_ID);
$res = $inbox->getCounter(); // Define the column to order
$this->assertTrue($res > 0); $inbox->setOrderByColumn($columnsView[$index]);
$res = $inbox->getData();
$this->assertNotEmpty($res);
} }
} }

View File

@@ -3,6 +3,7 @@
namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases; namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases;
use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\BusinessModel\Cases\Participated; use ProcessMaker\BusinessModel\Cases\Participated;
use ProcessMaker\Model\Application; use ProcessMaker\Model\Application;
use ProcessMaker\Model\Delegation; use ProcessMaker\Model\Delegation;
@@ -48,9 +49,10 @@ class ParticipatedTest extends TestCase
* It tests the getData method without filters * It tests the getData method without filters
* *
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getData() * @covers \ProcessMaker\BusinessModel\Cases\Participated::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @test * @test
*/ */
public function it_should_test_get_data_method_without_filters() public function it_get_result_without_filters()
{ {
// Create factories related to the participated cases // Create factories related to the participated cases
$cases = $this->createParticipated(); $cases = $this->createParticipated();
@@ -68,95 +70,15 @@ class ParticipatedTest extends TestCase
$this->assertEquals(1, count($res)); $this->assertEquals(1, count($res));
} }
/**
* It tests the getData method with process
*
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getData()
* @test
*/
public function it_should_test_get_data_method_with_specific_process()
{
// 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 the process ID
$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(1, count($res));
}
/**
* It tests the getData method with process category
*
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getData()
* @test
*/
public function it_should_test_get_data_method_with_specific_process_category()
{
// Create factories related to the participated cases
$cases = $this->createParticipated();
$process = Process::query()->where('PRO_ID', $cases->PRO_ID)->get()->toArray();
$process = head($process);
// 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 the process ID
$participated->setProcessId($cases->PRO_ID);
// Set the category
$participated->setCategoryUid($process['PRO_CATEGORY']);
// 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));
}
/**
* It tests the getData method with specific TO_DO status
*
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getData()
* @test
*/
public function it_should_test_get_data_method_with_case_to_do()
{
// 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 the case status
$participated->setCaseStatus('TO_DO');
// 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));
}
/** /**
* It tests the getData method with specific filter StartedByMe * It tests the getData method with specific filter StartedByMe
* *
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getData() * @covers \ProcessMaker\BusinessModel\Cases\Participated::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::filters()
* @test * @test
*/ */
public function it_should_test_get_data_method_started_by_me_filter() public function it_filter_by_started_by_me()
{ {
// Create factories related to the participated cases // Create factories related to the participated cases
$cases = $this->createParticipated(); $cases = $this->createParticipated();
@@ -173,16 +95,18 @@ class ParticipatedTest extends TestCase
// Call to getData method // Call to getData method
$res = $participated->getData(); $res = $participated->getData();
// This assert that the expected numbers of results are returned // This assert that the expected numbers of results are returned
$this->assertEquals(0, count($res)); $this->assertEquals(1, count($res));
} }
/** /**
* It tests the getData method with specific filter CompletedByMe * It tests the getData method with specific filter CompletedByMe
* *
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getData() * @covers \ProcessMaker\BusinessModel\Cases\Participated::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::filters()
* @test * @test
*/ */
public function it_should_test_get_data_method_completed_by_me_filter() public function it_filter_by_completed_by_me()
{ {
// Create factories related to the participated cases // Create factories related to the participated cases
$cases = $this->createParticipated(); $cases = $this->createParticipated();
@@ -202,13 +126,73 @@ class ParticipatedTest extends TestCase
$this->assertEquals(0, count($res)); $this->assertEquals(0, count($res));
} }
/**
* It tests the getData method with processId filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::filters()
* @test
*/
public function it_filter_by_process()
{
// 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 process ID
$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(1, count($res));
}
/**
* It tests the getData method with processId filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::filters()
* @test
*/
public function it_filter_by_thread_title()
{
// Create factories related to the participated cases
$cases = $this->createParticipated();
// We need to commit the records inserted because is needed for the "fulltext" index
DB::commit();
// 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 title
$participated->setCaseTitle($cases->DEL_TITLE);
// Get the data
$res = $participated->getData();
// Asserts
$this->assertCount(1, $res);
}
/** /**
* It tests the getCounter method * It tests the getCounter method
* *
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getCounter() * @covers \ProcessMaker\BusinessModel\Cases\Participated::getCounter()
* @test * @test
*/ */
public function it_should_test_the_counter_for_participated() public function it_get_counter()
{ {
// Create factories related to the participated cases // Create factories related to the participated cases
$cases = $this->createParticipated(); $cases = $this->createParticipated();

View File

@@ -3,6 +3,7 @@
namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases; namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases;
use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\BusinessModel\Cases\Paused; use ProcessMaker\BusinessModel\Cases\Paused;
use ProcessMaker\Model\Application; use ProcessMaker\Model\Application;
use ProcessMaker\Model\AppDelay; use ProcessMaker\Model\AppDelay;
@@ -15,8 +16,7 @@ use Tests\TestCase;
/** /**
* Class PausedTest * Class PausedTest
* *
* @coversDefaultClass ProcessMaker\BusinessModel\Cases\Paused * @coversDefaultClass \ProcessMaker\BusinessModel\Cases\Paused
* @package Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases
*/ */
class PausedTest extends TestCase class PausedTest extends TestCase
{ {
@@ -126,12 +126,12 @@ class PausedTest extends TestCase
* It tests the getData method without filters * It tests the getData method without filters
* *
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getData() * @covers \ProcessMaker\BusinessModel\Cases\Paused::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @test * @test
*/ */
public function it_should_test_get_data_method_without_filters() public function it_get_result_without_filters()
{ {
// Create factories related to the paused cases
// Create factories related to the to_do cases
$cases = $this->createPaused(); $cases = $this->createPaused();
// Create new Paused object // Create new Paused object
$paused = new Paused(); $paused = new Paused();
@@ -146,14 +146,16 @@ class PausedTest extends TestCase
} }
/** /**
* It tests the getData method with app number filter * It tests the getData method with case number filter
* *
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getData() * @covers \ProcessMaker\BusinessModel\Cases\Paused::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Paused::filters()
* @test * @test
*/ */
public function it_should_test_get_data_by_case_number() public function it_filter_by_app_number()
{ {
// Create factories related to the to_do cases // Create factories related to the paused cases
$cases = $this->createPaused(); $cases = $this->createPaused();
//Create new Paused object //Create new Paused object
$paused = new Paused(); $paused = new Paused();
@@ -173,11 +175,13 @@ class PausedTest extends TestCase
* It tests the getData method with taskId filter * It tests the getData method with taskId filter
* *
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getData() * @covers \ProcessMaker\BusinessModel\Cases\Paused::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Paused::filters()
* @test * @test
*/ */
public function it_should_test_get_data_by_task_filter() public function it_filter_by_task()
{ {
// Create factories related to the to_do cases // Create factories related to the paused cases
$cases = $this->createPaused(); $cases = $this->createPaused();
// Create new Paused object // Create new Paused object
$paused = new Paused(); $paused = new Paused();
@@ -194,14 +198,16 @@ class PausedTest extends TestCase
} }
/** /**
* It tests the getData method using OrderBy Case Number * It tests the getData method with processId filter
* *
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getData() * @covers \ProcessMaker\BusinessModel\Cases\Paused::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Paused::filters()
* @test * @test
*/ */
public function it_should_test_get_data_by_process_filter() public function it_filter_by_process()
{ {
// Create factories related to the to_do cases // Create factories related to the paused cases
$cases = $this->createPaused(); $cases = $this->createPaused();
// Create new Paused object // Create new Paused object
$paused = new Paused(); $paused = new Paused();
@@ -210,25 +216,32 @@ class PausedTest extends TestCase
// Set the user ID // Set the user ID
$paused->setUserId($cases->USR_ID); $paused->setUserId($cases->USR_ID);
$paused->setProcessId($cases->PRO_ID); $paused->setProcessId($cases->PRO_ID);
// Call to getData method // Get the data
$res = $paused->getData(); $res = $paused->getData();
// Asserts
$this->assertNotEmpty($res); $this->assertNotEmpty($res);
} }
/** /**
* It tests the getData method using OrderBy * It tests the getData method with case title filter
* *
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getData() * @covers \ProcessMaker\BusinessModel\Cases\Paused::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Paused::filters()
* @test * @test
*/ */
public function it_should_test_get_data_by_case_title() public function it_filter_by_thread_title()
{ {
// Create factories related to the to_do cases // Create factories related to the paused cases
$cases = $this->createPaused(); $cases = $this->createPaused();
// Create new Inbox object // We need to commit the records inserted because is needed for the "fulltext" index
DB::commit();
// Create new Paused object
$paused = new Paused(); $paused = new Paused();
$paused->setUserUid($cases->USR_UID); $paused->setUserUid($cases->USR_UID);
$paused->setUserId($cases->USR_ID); $paused->setUserId($cases->USR_ID);
// Set the title
$paused->setCaseTitle($cases->DEL_TITLE);
$res = $paused->getData(); $res = $paused->getData();
$this->assertNotEmpty($res); $this->assertNotEmpty($res);
} }

View File

@@ -3,6 +3,7 @@
namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases; namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases;
use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\BusinessModel\Cases\Search; use ProcessMaker\BusinessModel\Cases\Search;
use ProcessMaker\Model\Delegation; use ProcessMaker\Model\Delegation;
use Tests\TestCase; use Tests\TestCase;
@@ -43,9 +44,10 @@ class SearchTest extends TestCase
* It tests the getData method without filters * It tests the getData method without filters
* *
* @covers \ProcessMaker\BusinessModel\Cases\Search::getData() * @covers \ProcessMaker\BusinessModel\Cases\Search::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @test * @test
*/ */
public function it_should_test_get_data_method_without_filters() public function it_get_result_without_filters()
{ {
// Create factories related to the delegation cases // Create factories related to the delegation cases
$cases = $this->createSearch(); $cases = $this->createSearch();
@@ -60,9 +62,11 @@ class SearchTest extends TestCase
* It tests the getData with case number * It tests the getData with case number
* *
* @covers \ProcessMaker\BusinessModel\Cases\Search::getData() * @covers \ProcessMaker\BusinessModel\Cases\Search::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Search::filters()
* @test * @test
*/ */
public function it_should_test_get_data_method_with_specific_case_number() public function it_filter_by_app_number()
{ {
// Create factories related to the delegation cases // Create factories related to the delegation cases
$cases = $this->createSearch(); $cases = $this->createSearch();
@@ -76,33 +80,15 @@ class SearchTest extends TestCase
$this->assertEquals($cases[0]->APP_NUMBER, $result[0]['APP_NUMBER']); $this->assertEquals($cases[0]->APP_NUMBER, $result[0]['APP_NUMBER']);
} }
/**
* It tests the getData with priority
*
* @covers \ProcessMaker\BusinessModel\Cases\Search::getData()
* @test
*/
public function it_should_test_get_data_method_with_specific_priority()
{
// Create factories related to the delegation cases
$cases = $this->createSearch();
// Create new Search object
$search = new Search();
$search->setPriority('N');
// Set order by column value
$search->setOrderByColumn('APP_NUMBER');
$result = $search->getData();
// This assert that the expected numbers of results are returned
$this->assertNotEmpty($result);
}
/** /**
* It tests the getData with process * It tests the getData with process
* *
* @covers \ProcessMaker\BusinessModel\Cases\Search::getData() * @covers \ProcessMaker\BusinessModel\Cases\Search::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Search::filters()
* @test * @test
*/ */
public function it_should_test_get_data_method_with_specific_process() public function it_filter_by_process()
{ {
// Create factories related to the delegation cases // Create factories related to the delegation cases
$cases = $this->createSearch(); $cases = $this->createSearch();
@@ -120,9 +106,11 @@ class SearchTest extends TestCase
* It tests the getData with task * It tests the getData with task
* *
* @covers \ProcessMaker\BusinessModel\Cases\Search::getData() * @covers \ProcessMaker\BusinessModel\Cases\Search::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Search::filters()
* @test * @test
*/ */
public function it_should_test_get_data_method_with_specific_task() public function it_filter_by_task()
{ {
// Create factories related to the delegation cases // Create factories related to the delegation cases
$cases = $this->createSearch(); $cases = $this->createSearch();
@@ -136,13 +124,40 @@ class SearchTest extends TestCase
$this->assertNotEmpty($result); $this->assertNotEmpty($result);
} }
/**
* It tests the getData method with case title filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Search::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Search::filters()
* @test
*/
public function it_filter_by_thread_title()
{
// Create factories related to the to_do cases
$cases = $this->createSearch();
$title = $cases->last()->DEL_TITLE;
// We need to commit the records inserted because is needed for the "fulltext" index
DB::commit();
// Create new Draft object
$search = new Search();
// Set the title
$search->setCaseTitle($title);
// Get the data
$res = $search->getData();
// Asserts
$this->assertNotEmpty($res);
}
/** /**
* It tests the getData with user * It tests the getData with user
* *
* @covers \ProcessMaker\BusinessModel\Cases\Search::getData() * @covers \ProcessMaker\BusinessModel\Cases\Search::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Search::filters()
* @test * @test
*/ */
public function it_should_test_get_data_method_with_specific_user() public function it_filter_by_user()
{ {
// Create factories related to the delegation cases // Create factories related to the delegation cases
$cases = $this->createSearch(); $cases = $this->createSearch();
@@ -156,6 +171,28 @@ class SearchTest extends TestCase
$this->assertNotEmpty($result); $this->assertNotEmpty($result);
} }
/**
* It tests the getData with priority
*
* @covers \ProcessMaker\BusinessModel\Cases\Search::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Search::filters()
* @test
*/
public function it_filter_by_priority()
{
// Create factories related to the delegation cases
$cases = $this->createSearch();
// Create new Search object
$search = new Search();
$search->setPriority('N');
// Set order by column value
$search->setOrderByColumn('APP_NUMBER');
$result = $search->getData();
// This assert that the expected numbers of results are returned
$this->assertNotEmpty($result);
}
/** /**
* It tests the getCounter method * It tests the getCounter method
* *

View File

@@ -3,6 +3,7 @@
namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases; namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases;
use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\BusinessModel\Cases\Supervising; use ProcessMaker\BusinessModel\Cases\Supervising;
use ProcessMaker\Model\Application; use ProcessMaker\Model\Application;
use ProcessMaker\Model\Delegation; use ProcessMaker\Model\Delegation;
@@ -188,7 +189,7 @@ class SupervisingTest extends TestCase
/** /**
* Tests the getData() method when the user belongs to a group supervisor * Tests the getData() method when the user belongs to a group supervisor
* *
* covers \ProcessMaker\BusinessModel\Cases\Supervising::getData() * @covers \ProcessMaker\BusinessModel\Cases\Supervising::getData()
* @test * @test
*/ */
public function it_should_test_the_get_data_method_when_the_user_belong_to_a_group_supervisor() public function it_should_test_the_get_data_method_when_the_user_belong_to_a_group_supervisor()
@@ -209,7 +210,7 @@ class SupervisingTest extends TestCase
/** /**
* Tests the getData() method when the user is not a supervisor neither belongs to a group supervisor * 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::getData()
* @test * @test
*/ */
public function it_should_test_the_get_data_method_when_the_user_is_not_supervisor() public function it_should_test_the_get_data_method_when_the_user_is_not_supervisor()
@@ -231,7 +232,7 @@ class SupervisingTest extends TestCase
/** /**
* Tests the getCounter() method * Tests the getCounter() method
* *
* covers \ProcessMaker\BusinessModel\Cases\Supervising::getCounter() * @covers \ProcessMaker\BusinessModel\Cases\Supervising::getCounter()
* @test * @test
*/ */
public function it_should_count_the_data() public function it_should_count_the_data()
@@ -252,662 +253,137 @@ class SupervisingTest extends TestCase
/** /**
* Tests the filter by APP_NUMBER * Tests the filter by APP_NUMBER
* *
* covers \ProcessMaker\BusinessModel\Cases\Supervising::getData() * @covers \ProcessMaker\BusinessModel\Cases\Supervising::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::filters()
* @test * @test
*/ */
public function it_filters_by_app_number() public function it_filter_by_app_number()
{ {
//Create process $cases = $this->createSupervising();
$process = factory(Process::class)->create();
//Create user
$user = factory(User::class)->create();
//Create a task
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => '',
'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,
]);
$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 register in delegation
factory(Delegation::class, 1)->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
]);
factory(Delegation::class, 1)->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(
[
'PRO_UID' => $process->PRO_UID,
'USR_UID' => $user->USR_UID,
'PU_TYPE' => 'SUPERVISOR'
]
);
// Instance the Supervising object // Instance the Supervising object
$Supervising = new Supervising(); $Supervising = new Supervising();
//Set the user UID //Set the user UID
$Supervising->setUserUid($user->USR_UID); $Supervising->setUserUid($cases->USR_UID);
//Set the user ID //Set the user ID
$Supervising->setUserId($user->USR_ID); $Supervising->setUserId($cases->USR_ID);
$Supervising->setCaseNumber($cases->APP_NUMBER);
$Supervising->setCaseNumber($app3['APP_NUMBER']);
//Call the getData method //Call the getData method
$res = $Supervising->getData(); $res = $Supervising->getData();
// Asserts the result contains 3 registers // Asserts the result contains 3 registers
$this->assertCount(1, $res); $this->assertCount(1, $res);
//Asserts that the result contains the app number searched //Asserts that the result contains the app number searched
$this->assertContains($app3['APP_NUMBER'], $res[0]); $this->assertContains($cases->APP_NUMBER, $res[0]);
} }
/** /**
* Tests the filter by process * Tests the filter by process
* *
* covers \ProcessMaker\BusinessModel\Cases\Supervising::getData() * @covers \ProcessMaker\BusinessModel\Cases\Supervising::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::filters()
* @test * @test
*/ */
public function it_filters_by_process() public function it_filter_by_process()
{ {
//Create process $cases = $this->createSupervising();
$process = factory(Process::class)->create();
$process2 = factory(Process::class)->create();
//Create user
$user = factory(User::class)->create();
//Create a task
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => '',
'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,
]);
$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' => $process2->PRO_UID,
'APP_INIT_USER' => $user->USR_UID,
'APP_CUR_USER' => $user->USR_UID,
]);
//Create the register in delegation
factory(Delegation::class, 1)->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' => $process2->PRO_ID,
'PRO_UID' => $process2->PRO_UID,
'APP_NUMBER' => $app3['APP_NUMBER'],
'DEL_INDEX' => 1,
'DEL_PREVIOUS' =>0
]);
factory(Delegation::class, 1)->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' => $process2->PRO_ID,
'PRO_UID' => $process2->PRO_UID,
'APP_NUMBER' => $app3['APP_NUMBER'],
'DEL_INDEX' => 2,
'DEL_PREVIOUS' =>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'
]
);
factory(ProcessUser::class)->create(
[
'PRO_UID' => $process2->PRO_UID,
'USR_UID' => $user->USR_UID,
'PU_TYPE' => 'SUPERVISOR'
]
);
// Instance the Supervising object // Instance the Supervising object
$Supervising = new Supervising(); $Supervising = new Supervising();
// Set the user UID
//Set the user UID $Supervising->setUserUid($cases->USR_UID);
$Supervising->setUserUid($user->USR_UID); // Set the user ID
$Supervising->setUserId($cases->USR_ID);
//Set the user ID // Set the process Id filter
$Supervising->setUserId($user->USR_ID); $Supervising->setProcessId($cases->PRO_ID);
// Call the getData method
//Set the process Id filter
$Supervising->setProcessId($process2['PRO_ID']);
//Call the getData method
$res = $Supervising->getData(); $res = $Supervising->getData();
$this->assertCount(1, $res);
}
/**
* Tests the filter by process
*
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::filters()
* @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 process Id filter
$Supervising->setProcessId($cases->TAS_ID);
// Call the getData method
$res = $Supervising->getData();
$this->assertCount(1, $res);
}
/**
* It tests the getData method with case title filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::filters()
* @test
*/
public function it_filter_by_thread_title()
{
// Create factories related to the to_do cases
$cases = $this->createSupervising();
// We need to commit the records inserted because is needed for the "fulltext" index
DB::commit();
// Create new Inbox object
$supervising = new Supervising();
// Set the user UID
$supervising->setUserUid($cases->USR_UID);
// Set the user ID
$supervising->setUserId($cases->USR_ID);
// Set the title
$supervising->setCaseTitle($cases->DEL_TITLE);
// Get the data
$res = $supervising->getData();
// Asserts
$this->assertCount(1, $res); $this->assertCount(1, $res);
} }
/** /**
* Tests the order by value * Tests the order by value
* *
* covers \ProcessMaker\BusinessModel\Cases\Supervising::getData() * @covers \ProcessMaker\BusinessModel\Cases\Supervising::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::filters()
* @test * @test
*/ */
public function it_orders_the_query_by_column() public function it_order_by_column()
{ {
//Create process // Create factories related to the supervising cases
$process = factory(Process::class)->create(); $cases = $this->createSupervising();
$process2 = factory(Process::class)->create(); $columnsView = [
'APP_NUMBER',
//Create user 'DEL_TITLE',
$user = factory(User::class)->create(); 'PRO_TITLE',
'TAS_TITLE',
//Create a task 'APP_CREATE_DATE',
$task = factory(Task::class)->create([ 'APP_FINISH_DATE'
'TAS_ASSIGN_TYPE' => '', ];
'TAS_GROUP_VARIABLE' => '', $index = array_rand($columnsView);
'PRO_UID' => $process->PRO_UID,
]);
$task2 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'NORMAL',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID,
]);
$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' => $process2->PRO_UID,
'APP_INIT_USER' => $user->USR_UID,
'APP_CUR_USER' => $user->USR_UID,
]);
//Create the register in delegation
factory(Delegation::class, 1)->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' => $process2->PRO_ID,
'PRO_UID' => $process2->PRO_UID,
'APP_NUMBER' => $app3['APP_NUMBER'],
'DEL_INDEX' => 1,
'DEL_PREVIOUS' =>0
]);
factory(Delegation::class, 1)->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' => $process2->PRO_ID,
'PRO_UID' => $process2->PRO_UID,
'APP_NUMBER' => $app3['APP_NUMBER'],
'DEL_INDEX' => 2,
'DEL_PREVIOUS' =>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'
]
);
factory(ProcessUser::class)->create(
[
'PRO_UID' => $process2->PRO_UID,
'USR_UID' => $user->USR_UID,
'PU_TYPE' => 'SUPERVISOR'
]
);
// Instance the Supervising object // Instance the Supervising object
$Supervising = new Supervising(); $Supervising = new Supervising();
//Set the user UID //Set the user UID
$Supervising->setUserUid($user->USR_UID); $Supervising->setUserUid($cases->USR_UID);
//Set the user ID //Set the user ID
$Supervising->setUserId($user->USR_ID); $Supervising->setUserId($cases->USR_ID);
//Set the order by value
//Set the orderby value $Supervising->setOrderByColumn($columnsView[$index]);
$Supervising->setOrderByColumn('APPLICATION.APP_NUMBER');
//Call the getData method //Call the getData method
$res = $Supervising->getData(); $res = $Supervising->getData();
$this->assertCount(3, $res); $this->assertCount(3, $res);
$this->assertTrue($res[0]['APP_NUMBER'] > $res[1]['APP_NUMBER']); $this->assertTrue($res[0]['APP_NUMBER'] > $res[1]['APP_NUMBER']);
} }
/**
* Tests the limit in the order by clausule
*
* covers \ProcessMaker\BusinessModel\Cases\Supervising::getData()
* @test
*/
public function it_set_the_limit_in_the_order_by_clausule()
{
//Create process
$process = factory(Process::class)->create();
$process2 = factory(Process::class)->create();
//Create user
$user = factory(User::class)->create();
//Create a task
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => '',
'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,
]);
$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' => $process2->PRO_UID,
'APP_INIT_USER' => $user->USR_UID,
'APP_CUR_USER' => $user->USR_UID,
]);
//Create the register in delegation
factory(Delegation::class, 1)->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' => $process2->PRO_ID,
'PRO_UID' => $process2->PRO_UID,
'APP_NUMBER' => $app3['APP_NUMBER'],
'DEL_INDEX' => 1,
'DEL_PREVIOUS' =>0
]);
factory(Delegation::class, 1)->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' => $process2->PRO_ID,
'PRO_UID' => $process2->PRO_UID,
'APP_NUMBER' => $app3['APP_NUMBER'],
'DEL_INDEX' => 2,
'DEL_PREVIOUS' =>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'
]
);
factory(ProcessUser::class)->create(
[
'PRO_UID' => $process2->PRO_UID,
'USR_UID' => $user->USR_UID,
'PU_TYPE' => 'SUPERVISOR'
]
);
// 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);
//Set the limit value
$Supervising->setLimit(1);
//Call the getData method
$res = $Supervising->getData();
$this->assertCount(1, $res);
}
} }

View File

@@ -3,6 +3,7 @@
namespace Tests\unit\workflow\src\ProcessMaker\BusinessModel\Cases; namespace Tests\unit\workflow\src\ProcessMaker\BusinessModel\Cases;
use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\BusinessModel\Cases\Unassigned; use ProcessMaker\BusinessModel\Cases\Unassigned;
use ProcessMaker\Model\AppAssignSelfServiceValue; use ProcessMaker\Model\AppAssignSelfServiceValue;
use ProcessMaker\Model\AppAssignSelfServiceValueGroup; use ProcessMaker\Model\AppAssignSelfServiceValueGroup;
@@ -23,6 +24,56 @@ class UnassignedTest extends TestCase
{ {
use DatabaseTransactions; use DatabaseTransactions;
/**
* Create unassigned cases factories
*
* @param string
*
* @return array
*/
public function createSelfServiceUser()
{
// Create user`
$user = factory(User::class)->create();
for ($i = 1; $i <= 2; $i++) {
//Create process
$process = factory(Process::class)->create();
//Create application
$application = factory(Application::class)->create([
'APP_STATUS_ID' => 2
]);
//Create a task self service
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID,
'PRO_ID' => $process->PRO_ID,
]);
//Assign a user in the task
$taskUser = factory(TaskUser::class)->create([
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create the register in delegation relate to self-service
$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:m:s', strtotime("-$i year"))
]);
}
return [
'taskUser' => $taskUser,
'delegation' => $delegation
];
}
/** /**
* This checks the counters is working properly in self-service user assigned * This checks the counters is working properly in self-service user assigned
* *
@@ -806,577 +857,53 @@ class UnassignedTest extends TestCase
} }
/** /**
* This ensures ordering ascending and descending works by case number APP_NUMBER in self-service-user-assigned * This ensures get data from self-service-user-assigned without filters
* *
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getData() * @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getData()
* @test * @test
*/ */
public function it_should_return_self_service_user_assigned_sort_by_case_number() public function it_test_unassigned_by_user_without_filters()
{ {
//Create process // Create factories related to the unassigned cases
$process = factory(Process::class)->create(); $cases = $this->createSelfServiceUser();
//Create application // Create new object
$application1 = factory(Application::class)->create([ $unassigned = new Unassigned();
'APP_STATUS_ID' => 2, // Set the user UID
'APP_NUMBER' => 2001, $unassigned->setUserUid($cases['taskUser']->USR_UID);
]); // Set OrderBYColumn value
$application2 = factory(Application::class)->create([
'APP_STATUS_ID' => 2,
'APP_NUMBER' => 2002,
]);
//Create user
$user = factory(User::class)->create();
//Create a task self service
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create the register in delegation relate to self-service
factory(Delegation::class, 2)->create([
'APP_NUMBER' => $application1->APP_NUMBER,
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Create the register in delegation relate to self-service
factory(Delegation::class, 2)->create([
'APP_NUMBER' => $application2->APP_NUMBER,
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
// Get first page, the minor case id
$unassigned = new Unassigned;
$unassigned->setUserUid($user->USR_UID);
$unassigned->setOrderByColumn('APP_NUMBER'); $unassigned->setOrderByColumn('APP_NUMBER');
$unassigned->setOrderDirection('ASC'); // Call to getData method
$unassigned->setOffset(0); $res = $unassigned->getData();
$unassigned->setLimit(25); // This assert that the expected numbers of results are returned
$results = $unassigned->getData(); $this->assertNotEmpty($res);
$this->assertEquals(2001, $results[0]['APP_NUMBER']);
$this->assertEquals(2001, $results[1]['APP_NUMBER']);
$this->assertEquals(2002, $results[2]['APP_NUMBER']);
$this->assertEquals(2002, $results[3]['APP_NUMBER']);
// Get first page, the major case id
$unassigned->setOrderDirection('DESC');
$results = $unassigned->getData();
$this->assertEquals(2002, $results[0]['APP_NUMBER']);
$this->assertEquals(2002, $results[1]['APP_NUMBER']);
$this->assertEquals(2001, $results[2]['APP_NUMBER']);
$this->assertEquals(2001, $results[3]['APP_NUMBER']);
} }
/** /**
* This ensures ordering ascending and descending works by case title APP_TITLE in self-service-user-assigned * It tests the getData method with case title filter
* *
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getData() * @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::filters()
* @test * @test
*/ */
public function it_should_return_self_service_user_assigned_sort_by_case_title() public function it_filter_by_thread_title()
{ {
$this->markTestIncomplete( // Create factories related to the unassigned cases
'This test needs to write when the column DELEGATION.DEL_THREAD was added' $cases = $this->createSelfServiceUser();
); $usrUid = $cases->last()->USR_UID;
//Create process $usrId = $cases->last()->USR_ID;
$process = factory(Process::class)->create(); $title = $cases->last()->DEL_TITLE;
//Create application // We need to commit the records inserted because is needed for the "fulltext" index
$application1 = factory(Application::class)->create([ DB::commit();
'APP_STATUS_ID' => 2, // Create new Unassigned object
'APP_NUMBER' => 2001, $unassigned = new Unassigned();
'APP_TITLE' => 'Request # 2001' $unassigned->setUserUid($usrUid);
]); $unassigned->setUserId($usrId);
$application2 = factory(Application::class)->create([ // Set the title
'APP_STATUS_ID' => 2, $unassigned->setCaseTitle($title);
'APP_NUMBER' => 2002, // Get the data
'APP_TITLE' => 'Request # 2002' $res = $unassigned->getData();
]); // Asserts
//Create user $this->assertNotEmpty($res);
$user = factory(User::class)->create();
//Create a task self service
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create the register in delegation relate to self-service
factory(Delegation::class, 2)->create([
'APP_NUMBER' => $application1->APP_NUMBER,
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Create the register in delegation relate to self-service
factory(Delegation::class, 2)->create([
'APP_NUMBER' => $application2->APP_NUMBER,
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
$unassigned = new Unassigned;
$unassigned->setUserUid($user->USR_UID);
$unassigned->setOrderByColumn('APPLICATION.APP_TITLE');
$unassigned->setOrderDirection('ASC');
$unassigned->setOffset(0);
$unassigned->setLimit(25);
// Get first page, the minor case title
$results = $unassigned->getData();
$this->assertEquals('Request # 2001', $results[0]['APP_TITLE']);
$this->assertEquals('Request # 2001', $results[1]['APP_TITLE']);
$this->assertEquals('Request # 2002', $results[2]['APP_TITLE']);
$this->assertEquals('Request # 2002', $results[3]['APP_TITLE']);
// Get first page, the major case title
$unassigned->setOrderDirection('DESC');
$results = $unassigned->getData();
$this->assertEquals('Request # 2002', $results[0]['APP_TITLE']);
$this->assertEquals('Request # 2002', $results[1]['APP_TITLE']);
$this->assertEquals('Request # 2001', $results[2]['APP_TITLE']);
$this->assertEquals('Request # 2001', $results[3]['APP_TITLE']);
}
/**
* This ensures ordering ascending and descending works by case title PRO_TITLE in self-service-user-assigned
*
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getData()
* @test
*/
public function it_should_return_self_service_user_assigned_sort_by_process()
{
//Create user
$user = factory(User::class)->create();
for ($i = 1; $i <= 2; $i++) {
$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
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create the register in delegation relate to self-service
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,
]);
}
$unassigned = new Unassigned;
$unassigned->setUserUid($user->USR_UID);
$unassigned->setOrderByColumn('PRO_TITLE');
$unassigned->setOrderDirection('ASC');
$unassigned->setOffset(0);
$unassigned->setLimit(25);
// Get first page, the minor process title
$results = $unassigned->getData();
$this->assertGreaterThan($results[0]['PRO_TITLE'], $results[1]['PRO_TITLE']);
// Get first page, the major process title
$unassigned->setOrderDirection('DESC');
$results = $unassigned->getData();
$this->assertLessThan($results[0]['PRO_TITLE'], $results[1]['PRO_TITLE']);
}
/**
* This ensures ordering ascending and descending works by task title TAS_TITLE in self-service-user-assigned
*
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getData()
* @test
*/
public function it_should_return_self_service_user_assigned_sort_by_task_title()
{
//Create user
$user = factory(User::class)->create();
for ($i = 1; $i <= 2; $i++) {
//Create process
$process = factory(Process::class)->create();
//Create application
$application = factory(Application::class)->create([
'APP_STATUS_ID' => 2
]);
//Create a task self service
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID,
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
factory(Delegation::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'TAS_ID' => $task->TAS_ID,
'PRO_ID' => $process->id,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
}
$unassigned = new Unassigned;
$unassigned->setUserUid($user->USR_UID);
$unassigned->setOrderByColumn('TAS_TITLE');
$unassigned->setOrderDirection('ASC');
$unassigned->setOffset(0);
$unassigned->setLimit(25);
// Get first page, the minor task title
$results = $unassigned->getData();
$this->assertGreaterThan($results[0]['TAS_TITLE'], $results[1]['TAS_TITLE']);
// Get first page, the major task title
$unassigned->setOrderDirection('DESC');
$results = $unassigned->getData();
$this->assertLessThan($results[0]['TAS_TITLE'], $results[1]['TAS_TITLE']);
}
/**
* This ensures ordering ascending and descending works by due date DEL_TASK_DUE_DATE in self-service-user-assigned
*
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getData()
* @test
*/
public function it_should_return_self_service_user_assigned_sort_due_date()
{
//Create user
$user = factory(User::class)->create();
for ($i = 1; $i <= 2; $i++) {
//Create process
$process = factory(Process::class)->create();
//Create application
$application = factory(Application::class)->create([
'APP_STATUS_ID' => 2
]);
//Create a task self service
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID,
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create the register in delegation relate to self-service
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,
]);
}
$unassigned = new Unassigned;
$unassigned->setUserUid($user->USR_UID);
$unassigned->setOrderByColumn('DEL_TASK_DUE_DATE');
$unassigned->setOrderDirection('ASC');
$unassigned->setOffset(0);
$unassigned->setLimit(25);
// Get first page, the minor due date
$results = $unassigned->getData();
$this->assertGreaterThan($results[0]['DEL_TASK_DUE_DATE'], $results[1]['DEL_TASK_DUE_DATE']);
// Get first page, the major due date
$unassigned->setOrderDirection('DESC');
$results = $unassigned->getData();
$this->assertLessThan($results[0]['DEL_TASK_DUE_DATE'], $results[1]['DEL_TASK_DUE_DATE']);
}
/**
* This ensures ordering ascending and descending works by last modified APP_UPDATE_DATE in
* self-service-user-assigned
*
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getData()
* @test
*/
public function it_should_return_self_service_user_assigned_sort_delegate_date()
{
//Create user
$user = factory(User::class)->create();
for ($i = 1; $i <= 2; $i++) {
//Create process
$process = factory(Process::class)->create();
//Create application
$application = factory(Application::class)->create([
'APP_STATUS_ID' => 2,
]);
//Create a task self service
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID,
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create the register in delegation relate to self-service
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,
]);
}
$unassigned = new Unassigned;
$unassigned->setUserUid($user->USR_UID);
$unassigned->setOrderByColumn('DEL_DELEGATE_DATE');
$unassigned->setOrderDirection('ASC');
$unassigned->setOffset(0);
$unassigned->setLimit(25);
// Get first page, the minor update date
$results = $unassigned->getData();
$this->assertGreaterThan($results[0]['DEL_DELEGATE_DATE'], $results[1]['DEL_DELEGATE_DATE']);
// Get first page, the major update date
$unassigned->setOrderDirection('DESC');
$results = $unassigned->getData();
$this->assertLessThan($results[0]['DEL_DELEGATE_DATE'], $results[1]['DEL_DELEGATE_DATE']);
}
/**
* This ensures searching by newest than and review the page in self-service-user-assigned
*
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getData()
* @test
*/
public function it_should_search_self_service_user_assigned_by_newest_than()
{
//Create user
$user = factory(User::class)->create();
for ($i = 1; $i <= 2; $i++) {
//Create process
$process = factory(Process::class)->create();
//Create application
$application = factory(Application::class)->create([
'APP_STATUS_ID' => 2
]);
//Create a task self service
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID,
'PRO_ID' => $process->PRO_ID,
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create the register in delegation relate to self-service
$del = 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("+$i year"))
]);
}
$unassigned = new Unassigned;
$unassigned->setUserUid($user->USR_UID);
$dateToFilter = date('Y-m-d', strtotime('+1 year'));
$unassigned->setDelegateFrom($dateToFilter);
$unassigned->setOrderByColumn('DEL_DELEGATE_DATE');
$unassigned->setOrderDirection('ASC');
$unassigned->setOffset(0);
$unassigned->setLimit(25);
// Get the newest than (>=) delegate date
$results = $unassigned->getData();
$this->assertGreaterThan($results[0]['DEL_DELEGATE_DATE'], $results[1]['DEL_DELEGATE_DATE']);
// Get the newest than (>=) delegate date
$unassigned->setDelegateFrom($dateToFilter);
$unassigned->setOrderDirection('DESC');
$results = $unassigned->getData();
$this->assertLessThan($results[0]['DEL_DELEGATE_DATE'], $results[1]['DEL_DELEGATE_DATE']);
}
/**
* This ensures searching by newest than and review the page in self-service-user-assigned
*
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getData()
* @test
*/
public function it_should_search_self_service_user_assigned_by_oldest_than()
{
//Create user
$user = factory(User::class)->create();
for ($i = 1; $i <= 2; $i++) {
//Create process
$process = factory(Process::class)->create();
//Create application
$application = factory(Application::class)->create([
'APP_STATUS_ID' => 2
]);
//Create a task self service
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID,
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create the register in delegation relate to self-service
$del = 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("-$i year"))
]);
}
$unassigned = new Unassigned;
$unassigned->setUserUid($user->USR_UID);
$dateToFilter = date('Y-m-d', strtotime('+1 year'));
$unassigned->setDelegateTo($dateToFilter);
$unassigned->setOrderByColumn('DEL_DELEGATE_DATE');
$unassigned->setOrderDirection('ASC');
$unassigned->setOffset(0);
$unassigned->setLimit(25);
// Get the oldest than (<=) delegate date
$results = $unassigned->getData();
$this->assertGreaterThan($results[0]['DEL_DELEGATE_DATE'], $results[1]['DEL_DELEGATE_DATE']);
}
/**
* This ensures searching specific cases and review the page in self-service-user-assigned
*
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getData()
* @test
*/
public function it_should_search_self_service_user_assigned_specific_case_uid()
{
//Create user
$user = factory(User::class)->create();
for ($i = 1; $i <= 2; $i++) {
//Create process
$process = factory(Process::class)->create([
'PRO_TITLE' => 'China Supplier Payment Proposal'
]);
//Create application
$application = factory(Application::class)->create([
'APP_STATUS_ID' => 2
]);
//Create a task self service
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID,
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create the register in delegation relate to self-service
factory(Delegation::class)->create([
'APP_UID' => $application->APP_UID,
'APP_NUMBER' => $application->APP_NUMBER,
'TAS_ID' => $task->TAS_ID,
'PRO_ID' => $process->PRO_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0
]);
}
$unassigned = new Unassigned;
$unassigned->setUserUid($user->USR_UID);
$unassigned->setOrderByColumn('APP_DELEGATION.APP_UID');
$unassigned->setOrderDirection('ASC');
$unassigned->setOffset(0);
$unassigned->setLimit(25);
// Get the specific case uid
$unassigned->setCaseUid($application->APP_UID);
$results = $unassigned->getData();
$this->assertEquals($application->APP_UID, $results[0]['APP_UID']);
}
/**
* This ensures searching specific process and review the page in self-service-user-assigned
*
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getData()
* @test
*/
public function it_should_search_self_service_user_assigned_specific_process()
{
//Create user
$user = factory(User::class)->create();
for ($i = 1; $i <= 2; $i++) {
//Create process
$process = factory(Process::class)->create();
//Create application
$application = factory(Application::class)->create([
'APP_STATUS_ID' => 2
]);
//Create a task self service
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create the register in delegation relate to self-service
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,
]);
}
$unassigned = new Unassigned;
$unassigned->setUserUid($user->USR_UID);
$unassigned->setOrderByColumn('PRO_TITLE');
$unassigned->setOrderDirection('ASC');
$unassigned->setProcessId($process->PRO_ID);
$unassigned->setOffset(0);
$unassigned->setLimit(25);
// Get first page, the minor process title
$results = $unassigned->getData();
$this->assertEquals($process->PRO_TITLE, $results[0]['PRO_TITLE']);
} }
} }

View File

@@ -12,20 +12,26 @@ use ProcessMaker\Model\User;
class AbstractCases implements CasesInterface class AbstractCases implements CasesInterface
{ {
// Constants for validate values // Constants for validate values
const INBOX_STATUSES = ['ALL', 'READ', 'UNREAD']; const INBOX_STATUSES = ['READ', 'UNREAD'];
const PARTICIPATED_STATUSES = ['ALL', 'STARTED', 'IN_PROGRESS', 'COMPLETED', 'SUPERVISING']; const PARTICIPATED_STATUSES = ['STARTED', 'IN_PROGRESS', 'COMPLETED', 'SUPERVISING'];
const RISK_STATUSES = ['ALL', 'ON_TIME', 'AT_RISK', 'OVERDUE']; const RISK_STATUSES = ['ON_TIME', 'AT_RISK', 'OVERDUE'];
const CASE_STATUSES = [1 => 'DRAFT', 2 => 'TO_DO', 3 => 'COMPLETED', 4 => 'CANCELED']; const CASE_STATUSES = [1 => 'DRAFT', 2 => 'TO_DO', 3 => 'COMPLETED', 4 => 'CANCELED'];
const ORDER_DIRECTIONS = ['DESC', 'ASC']; const ORDER_DIRECTIONS = ['DESC', 'ASC'];
const CORRECT_CANCELED_STATUS = 'CANCELED'; const CORRECT_CANCELED_STATUS = 'CANCELED';
const INCORRECT_CANCELED_STATUS = 'CANCELLED'; const INCORRECT_CANCELED_STATUS = 'CANCELLED';
const PRIORITIES = [1 => 'VL', 2 => 'L', 3 => 'N', 4 => 'H', 5 => 'VH']; const PRIORITIES = [1 => 'VL', 2 => 'L', 3 => 'N', 4 => 'H', 5 => 'VH'];
// Task Colors
const TASK_COLORS = [1 => 'green', 2 => 'red', 3 => 'orange', 4 => 'blue', 5 => 'gray']; const TASK_COLORS = [1 => 'green', 2 => 'red', 3 => 'orange', 4 => 'blue', 5 => 'gray'];
const COLOR_OVERDUE = 1; const COLOR_OVERDUE = 1;
const COLOR_ON_TIME = 2; const COLOR_ON_TIME = 2;
const COLOR_DRAFT = 3; const COLOR_DRAFT = 3;
const COLOR_PAUSED = 4; const COLOR_PAUSED = 4;
const COLOR_UNASSIGNED = 5; const COLOR_UNASSIGNED = 5;
// Status values
const STATUS_DRAFT = 1;
const STATUS_TODO = 2;
const STATUS_COMPLETED = 3;
const STATUS_CANCELED = 4;
// Filter by category from a process, know as "$category" in the old lists classes // Filter by category from a process, know as "$category" in the old lists classes
private $categoryUid = ''; private $categoryUid = '';
@@ -286,11 +292,6 @@ class AbstractCases implements CasesInterface
throw new Exception("Inbox status '{$inboxStatus}' is not valid."); throw new Exception("Inbox status '{$inboxStatus}' is not valid.");
} }
// If empty string is sent, use value 'ALL'
if ($inboxStatus === '') {
$inboxStatus = 'ALL';
}
$this->inboxStatus = $inboxStatus; $this->inboxStatus = $inboxStatus;
} }
@@ -321,11 +322,6 @@ class AbstractCases implements CasesInterface
throw new Exception("Participated status '{$participatedStatus}' is not valid."); throw new Exception("Participated status '{$participatedStatus}' is not valid.");
} }
// If empty string will not apply the filter
if ($participatedStatus === 'ALL') {
$participatedStatus = '';
}
$this->participatedStatus = $participatedStatus; $this->participatedStatus = $participatedStatus;
} }
@@ -356,11 +352,6 @@ class AbstractCases implements CasesInterface
throw new Exception("Risk status '{$riskStatus}' is not valid."); throw new Exception("Risk status '{$riskStatus}' is not valid.");
} }
// If empty string will not apply the filter
if ($riskStatus === 'ALL') {
$riskStatus = '';
}
$this->riskStatus = $riskStatus; $this->riskStatus = $riskStatus;
} }

View File

@@ -11,7 +11,7 @@ class Draft extends AbstractCases
public $columnsView = [ public $columnsView = [
// Columns view in the cases list // Columns view in the cases list
'APP_DELEGATION.APP_NUMBER', // Case # 'APP_DELEGATION.APP_NUMBER', // Case #
'APP_DELEGATION.APP_NUMBER AS APP_TITLE', // Case Title @todo: Filter by case title, pending from other PRD 'APP_DELEGATION.DEL_TITLE', // Case Title
'PROCESS.PRO_TITLE', // Process 'PROCESS.PRO_TITLE', // Process
'TASK.TAS_TITLE', // Task 'TASK.TAS_TITLE', // Task
'APP_DELEGATION.DEL_TASK_DUE_DATE', // Due Date 'APP_DELEGATION.DEL_TASK_DUE_DATE', // Due Date
@@ -48,7 +48,7 @@ class Draft extends AbstractCases
} }
// Specific case title // Specific case title
if (!empty($this->getCaseTitle())) { if (!empty($this->getCaseTitle())) {
// @todo: Filter by case title, pending from other PRD $query->title($this->getCaseTitle());
} }
// Specific process // Specific process
if ($this->getProcessId()) { if ($this->getProcessId()) {

View File

@@ -11,7 +11,7 @@ class Inbox extends AbstractCases
public $columnsView = [ public $columnsView = [
// Columns view in the cases list // Columns view in the cases list
'APP_DELEGATION.APP_NUMBER', // Case # 'APP_DELEGATION.APP_NUMBER', // Case #
'APP_DELEGATION.APP_NUMBER AS APP_TITLE', // Case Title @todo: Filter by case title, pending from other PRD 'APP_DELEGATION.DEL_TITLE', // Case Title
'PROCESS.PRO_TITLE', // Process 'PROCESS.PRO_TITLE', // Process
'TASK.TAS_TITLE', // Task 'TASK.TAS_TITLE', // Task
'USERS.USR_USERNAME', // Current UserName 'USERS.USR_USERNAME', // Current UserName
@@ -51,7 +51,7 @@ class Inbox extends AbstractCases
} }
// Specific case title // Specific case title
if (!empty($this->getCaseTitle())) { if (!empty($this->getCaseTitle())) {
// @todo: Filter by case title, pending from other PRD $query->title($this->getCaseTitle());
} }
// Specific process // Specific process
if ($this->getProcessId()) { if ($this->getProcessId()) {

View File

@@ -12,7 +12,7 @@ class Participated extends AbstractCases
public $columnsView = [ public $columnsView = [
// Columns view in the cases list // Columns view in the cases list
'APP_DELEGATION.APP_NUMBER', // Case # 'APP_DELEGATION.APP_NUMBER', // Case #
'APP_DELEGATION.APP_NUMBER AS APP_TITLE', // Case Title @todo: Filter by case title, pending from other PRD 'APP_DELEGATION.DEL_TITLE', // Case Title
'PROCESS.PRO_TITLE', // Process Name 'PROCESS.PRO_TITLE', // Process Name
'TASK.TAS_TITLE', // Pending Task 'TASK.TAS_TITLE', // Pending Task
'APPLICATION.APP_STATUS', // Status 'APPLICATION.APP_STATUS', // Status
@@ -51,7 +51,7 @@ class Participated extends AbstractCases
} }
// Specific case title // Specific case title
if (!empty($this->getCaseTitle())) { if (!empty($this->getCaseTitle())) {
// @todo: Filter by case title, pending from other PRD $query->title($this->getCaseTitle());
} }
// Scope to search for an specific process // Scope to search for an specific process
if ($this->getProcessId()) { if ($this->getProcessId()) {
@@ -164,10 +164,6 @@ class Participated extends AbstractCases
$startDate = (string)$item['APP_CREATE_DATE']; $startDate = (string)$item['APP_CREATE_DATE'];
$endDate = !empty($item['APP_FINISH_DATE']) ? $item['APP_FINISH_DATE'] : date("Y-m-d H:i:s"); $endDate = !empty($item['APP_FINISH_DATE']) ? $item['APP_FINISH_DATE'] : date("Y-m-d H:i:s");
$item['DURATION'] = getDiffBetweenDates($startDate, $endDate); $item['DURATION'] = getDiffBetweenDates($startDate, $endDate);
// Get the detail related to the open thread
if (!empty($item['PENDING'])) {
$item['PENDING'] = $this->prepareTaskPending($item['PENDING']);
}
switch ($filter) { switch ($filter) {
case 'STARTED': case 'STARTED':
$result = []; $result = [];
@@ -194,7 +190,10 @@ class Participated extends AbstractCases
} }
break; break;
case 'IN_PROGRESS': case 'IN_PROGRESS':
$item['PENDING'] = $this->prepareTaskPending($item['PENDING']); // Get the detail related to the open thread
if (!empty($item['PENDING'])) {
$item['PENDING'] = $this->prepareTaskPending($item['PENDING']);
}
break; break;
case 'COMPLETED': case 'COMPLETED':
$result = []; $result = [];
@@ -238,7 +237,7 @@ class Participated extends AbstractCases
// Only distinct APP_NUMBER // Only distinct APP_NUMBER
$query->distinct(); $query->distinct();
// Scope for in progress cases // Scope for in progress cases
$query->statusIds([Application::STATUS_DRAFT, Application::STATUS_TODO]); $query->statusIds([self::STATUS_DRAFT, self::STATUS_TODO]);
break; break;
case 'COMPLETED': case 'COMPLETED':
// Scope that search for the COMPLETED // Scope that search for the COMPLETED

View File

@@ -11,7 +11,7 @@ class Paused extends AbstractCases
public $columnsView = [ public $columnsView = [
// Columns view in the cases list // Columns view in the cases list
'APP_DELEGATION.APP_NUMBER', // Case # 'APP_DELEGATION.APP_NUMBER', // Case #
'APP_DELEGATION.APP_NUMBER AS APP_TITLE', // Case Title @todo: Filter by case title, pending from other PRD 'APP_DELEGATION.DEL_TITLE', // Case Title
'PROCESS.PRO_TITLE', // Process 'PROCESS.PRO_TITLE', // Process
'TASK.TAS_TITLE', // Task 'TASK.TAS_TITLE', // Task
'USERS.USR_USERNAME', // Current UserName 'USERS.USR_USERNAME', // Current UserName
@@ -51,7 +51,7 @@ class Paused extends AbstractCases
} }
// Specific case title // Specific case title
if (!empty($this->getCaseTitle())) { if (!empty($this->getCaseTitle())) {
// @todo: Filter by case title, pending from other PRD $query->title($this->getCaseTitle());
} }
// Specific process // Specific process
if ($this->getProcessId()) { if ($this->getProcessId()) {

View File

@@ -12,7 +12,7 @@ class Search extends AbstractCases
public $columnsView = [ public $columnsView = [
// Columns view in the cases list // Columns view in the cases list
'APP_DELEGATION.APP_NUMBER', // Case # 'APP_DELEGATION.APP_NUMBER', // Case #
'APP_DELEGATION.APP_NUMBER AS APP_TITLE', // Case Title @todo: Filter by case title, pending from other PRD 'APP_DELEGATION.DEL_TITLE', // Case Title
'PROCESS.PRO_TITLE', // Process 'PROCESS.PRO_TITLE', // Process
'TASK.TAS_TITLE', // Task 'TASK.TAS_TITLE', // Task
'APPLICATION.APP_STATUS', // Status 'APPLICATION.APP_STATUS', // Status
@@ -61,7 +61,7 @@ class Search extends AbstractCases
} }
// Specific case title // Specific case title
if (!empty($this->getCaseTitle())) { if (!empty($this->getCaseTitle())) {
// @todo: Filter by case title, pending from other PRD $query->title($this->getCaseTitle());
} }
// Filter by process // Filter by process
if ($this->getProcessId()) { if ($this->getProcessId()) {
@@ -103,7 +103,7 @@ class Search extends AbstractCases
$casesOpen = []; $casesOpen = [];
$casesClosed = []; $casesClosed = [];
foreach ($statuses as $row) { foreach ($statuses as $row) {
if ($row === Application::STATUS_DRAFT or $row === Application::STATUS_TODO) { if ($row === self::STATUS_DRAFT or $row === self::STATUS_TODO) {
$casesOpen[] = $row; $casesOpen[] = $row;
} else { } else {
$casesClosed[] = $row; $casesClosed[] = $row;

View File

@@ -11,7 +11,7 @@ class Supervising extends AbstractCases
public $columnsView = [ public $columnsView = [
// Columns view in the cases list // Columns view in the cases list
'APP_DELEGATION.APP_NUMBER', // Case # 'APP_DELEGATION.APP_NUMBER', // Case #
'APP_DELEGATION.APP_NUMBER AS APP_TITLE', // Case Title @todo: Filter by case title, pending from other PRD 'APP_DELEGATION.DEL_TITLE', // Case Title
'PROCESS.PRO_TITLE', // Process Name 'PROCESS.PRO_TITLE', // Process Name
'TASK.TAS_TITLE', // Pending Task 'TASK.TAS_TITLE', // Pending Task
'APPLICATION.APP_STATUS', // Status 'APPLICATION.APP_STATUS', // Status
@@ -49,7 +49,7 @@ class Supervising extends AbstractCases
} }
// Specific case title // Specific case title
if (!empty($this->getCaseTitle())) { if (!empty($this->getCaseTitle())) {
// @todo: Filter by case title, pending from other PRD $query->title($this->getCaseTitle());
} }
// Scope to search for an specific process // Scope to search for an specific process
if ($this->getProcessId()) { if ($this->getProcessId()) {
@@ -125,8 +125,8 @@ class Supervising extends AbstractCases
$query->joinUser(); $query->joinUser();
// Join with application // Join with application
$query->joinApplication(); $query->joinApplication();
// Only cases in progress // Only cases in to_do
$query->caseInProgress(); $query->caseTodo();
// Scope that return the results for an specific user // Scope that return the results for an specific user
$query->userId($this->getUserId()); $query->userId($this->getUserId());
// Scope the specific array of processes supervising // Scope the specific array of processes supervising

View File

@@ -12,7 +12,7 @@ class Unassigned extends AbstractCases
public $columnsView = [ public $columnsView = [
// Columns view in the cases list // Columns view in the cases list
'APP_DELEGATION.APP_NUMBER', // Case # 'APP_DELEGATION.APP_NUMBER', // Case #
'APP_DELEGATION.APP_NUMBER AS APP_TITLE', // Case Title @todo: Filter by case title, pending from other PRD 'APP_DELEGATION.DEL_TITLE', // Case Title
'PROCESS.PRO_TITLE', // Process 'PROCESS.PRO_TITLE', // Process
'TASK.TAS_TITLE', // Task 'TASK.TAS_TITLE', // Task
'USERS.USR_USERNAME', // Current UserName 'USERS.USR_USERNAME', // Current UserName
@@ -52,7 +52,7 @@ class Unassigned extends AbstractCases
} }
// Specific case title // Specific case title
if ($this->getCaseTitle()) { if ($this->getCaseTitle()) {
// @todo: Filter by case title, pending from other PRD $query->title($this->getCaseTitle());
} }
// Specific process // Specific process
if ($this->getProcessId()) { if ($this->getProcessId()) {
@@ -88,7 +88,7 @@ class Unassigned extends AbstractCases
} }
// Add join for application, for get the case title when the case status is TO_DO // Add join for application, for get the case title when the case status is TO_DO
$query->joinApplication(); $query->joinApplication();
$query->status(Application::STATUS_TODO); $query->status(self::STATUS_TODO);
/** Apply filters */ /** Apply filters */
$this->filters($query); $this->filters($query);
/** Apply order and pagination */ /** Apply order and pagination */

View File

@@ -153,7 +153,19 @@ class Delegation extends Model
*/ */
public function scopeCaseInProgress($query) public function scopeCaseInProgress($query)
{ {
return $query->where('APPLICATION.APP_STATUS_ID', 2); return $query->statusIds([Application::STATUS_DRAFT, Application::STATUS_TODO]);
}
/**
* Scope a query to get the to_do cases
*
* @param \Illuminate\Database\Eloquent\Builder $query
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeCaseTodo($query)
{
return $query->where('APPLICATION.APP_STATUS_ID', Application::STATUS_TODO);
} }
/** /**
@@ -165,7 +177,7 @@ class Delegation extends Model
*/ */
public function scopeCaseCompleted($query) public function scopeCaseCompleted($query)
{ {
return $query->where('APPLICATION.APP_STATUS_ID', 3); return $query->where('APPLICATION.APP_STATUS_ID', Application::STATUS_COMPLETED);
} }
/** /**
@@ -373,6 +385,37 @@ class Delegation extends Model
return $query->where('APP_DELEGATION.APP_NUMBER', '=', $appNumber); return $query->where('APP_DELEGATION.APP_NUMBER', '=', $appNumber);
} }
/**
* Scope a query to only include a specific case title
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param string $search
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeTitle($query, string $search)
{
$config = System::getSystemConfiguration();
if ((int)$config['disable_advanced_search_case_title_fulltext'] === 0) {
// Cleaning "fulltext" operators in order to avoid unexpected results
$search = str_replace(
['-', '+', '<', '>', '(', ')', '~', '*', '"'],
['', '', '', '', '', '', '', '', ''],
$search
);
// Build the "fulltext" expression
$search = '+"' . preg_replace('/\s+/', '" +"', addslashes($search)) . '"';
// Searching using "fulltext" index
$query->whereRaw("MATCH(APP_DELEGATION.DEL_TITLE) AGAINST('{$search}' IN BOOLEAN MODE)");
} else {
// Searching using "like" operator
$query->where('APP_DELEGATION.DEL_TITLE', 'LIKE', "%${$search}%");
}
return $query;
}
/** /**
* Scope a query to only include specific cases * Scope a query to only include specific cases
* *