Merged in feature/PMCORE-1216 (pull request #7527)
PMCORE-1216 Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
@@ -0,0 +1,325 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases;
|
||||
|
||||
use G;
|
||||
use ProcessMaker\BusinessModel\Cases\AbstractCases;
|
||||
use ProcessMaker\Model\Application;
|
||||
use ProcessMaker\Model\Process;
|
||||
use ProcessMaker\Model\ProcessCategory;
|
||||
use ProcessMaker\Model\User;
|
||||
use Tests\TestCase;
|
||||
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \ProcessMaker\BusinessModel\Cases\AbstractCases
|
||||
*/
|
||||
class AbstractCasesTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* This check the getter and setter related to the category
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCategoryUid()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getCategoryUid()
|
||||
* @test
|
||||
*/
|
||||
public function it_return_set_get_category()
|
||||
{
|
||||
$category = factory(ProcessCategory::class)->create();
|
||||
$absCases = new AbstractCases();
|
||||
$absCases->setCategoryUid($category->CATEGORY_UID);
|
||||
$actual = $absCases->getCategoryUid();
|
||||
$this->assertEquals($category->CATEGORY_UID, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* This check the getter and setter related to the process
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setProcessUid()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getProcessUid()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setProcessId()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getProcessId()
|
||||
* @test
|
||||
*/
|
||||
public function it_return_set_get_process()
|
||||
{
|
||||
$process = factory(Process::class)->create();
|
||||
$absCases = new AbstractCases();
|
||||
$absCases->setProcessUid($process->PRO_UID);
|
||||
$actual = $absCases->getProcessUid();
|
||||
$this->assertEquals($process->PRO_UID, $actual);
|
||||
$absCases->setProcessId($process->PRO_ID);
|
||||
$actual = $absCases->getProcessId();
|
||||
$this->assertEquals($process->PRO_ID, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* This check the getter and setter related to the user
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setUserUid()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getUserUid()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setUserId()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getUserId()
|
||||
* @test
|
||||
*/
|
||||
public function it_return_set_get_user()
|
||||
{
|
||||
$users = factory(User::class)->create();
|
||||
$absCases = new AbstractCases();
|
||||
$absCases->setUserUid($users->USR_UID);
|
||||
$actual = $absCases->getUserUid();
|
||||
$this->assertEquals($users->USR_UID, $actual);
|
||||
$absCases->setUserId($users->USR_ID);
|
||||
$actual = $absCases->getUserId();
|
||||
$this->assertEquals($users->USR_ID, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* This check the getter and setter related to the search
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setValueToSearch()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getValueToSearch()
|
||||
* @test
|
||||
*/
|
||||
public function it_return_set_get_search()
|
||||
{
|
||||
$absCases = new AbstractCases();
|
||||
$text = G::generateUniqueID();
|
||||
$absCases->setValueToSearch($text);
|
||||
$actual = $absCases->getValueToSearch();
|
||||
$this->assertEquals($text, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* This check the getter and setter related to the inbox status
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setInboxStatus()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getInboxStatus()
|
||||
* @test
|
||||
*/
|
||||
public function it_return_set_get_inbox_status()
|
||||
{
|
||||
$absCases = new AbstractCases();
|
||||
$arguments = ['', 'ALL', 'READ', 'UNREAD'];
|
||||
$index = array_rand($arguments);
|
||||
$absCases->setInboxStatus($arguments[$index]);
|
||||
$actual = $absCases->getInboxStatus();
|
||||
if (empty($arguments[$index])) {
|
||||
$this->assertEquals($arguments[$index], 'ALL');
|
||||
} else {
|
||||
$this->assertEquals($arguments[$index], $actual);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This check the getter and setter related to the participated status
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setParticipatedStatus()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getParticipatedStatus()
|
||||
* @test
|
||||
*/
|
||||
public function it_return_set_get_participated_status()
|
||||
{
|
||||
$absCases = new AbstractCases();
|
||||
$arguments = ['', 'ALL', 'STARTED', 'COMPLETED'];
|
||||
$index = array_rand($arguments);
|
||||
$absCases->setParticipatedStatus($arguments[$index]);
|
||||
$actual = $absCases->getParticipatedStatus();
|
||||
if (empty($arguments[$index])) {
|
||||
$this->assertEquals($arguments[$index], 'ALL');
|
||||
} else {
|
||||
$this->assertEquals($arguments[$index], $actual);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This check the getter and setter related to the risk status
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setRiskStatus()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getRiskStatus()
|
||||
* @test
|
||||
*/
|
||||
public function it_return_set_get_risk_status()
|
||||
{
|
||||
$absCases = new AbstractCases();
|
||||
$arguments = ['', 'ALL', 'ON_TIME', 'AT_RISK', 'OVERDUE'];
|
||||
$index = array_rand($arguments);
|
||||
$absCases->setRiskStatus($arguments[$index]);
|
||||
$actual = $absCases->getRiskStatus();
|
||||
if (empty($arguments[$index])) {
|
||||
$this->assertEquals($arguments[$index], 'ALL');
|
||||
} else {
|
||||
$this->assertEquals($arguments[$index], $actual);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This check the getter and setter related to the case status
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCaseStatus()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getCaseStatus()
|
||||
* @test
|
||||
*/
|
||||
public function it_return_set_get_case_status()
|
||||
{
|
||||
$absCases = new AbstractCases();
|
||||
$arguments = ['', 'ALL', 'DRAFT', 'TO_DO', 'COMPLETED', 'CANCELLED', 'CANCELED'];
|
||||
$index = array_rand($arguments);
|
||||
$absCases->setCaseStatus($arguments[$index]);
|
||||
$actual = $absCases->getCaseStatus();
|
||||
if (empty($arguments[$index])) {
|
||||
$this->assertEquals($arguments[$index], 'ALL');
|
||||
} else {
|
||||
$this->assertEquals($arguments[$index], $actual);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This check the getter and setter related to the case
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCaseUid()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getCaseUid()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCaseNumber()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getCaseNumber()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCasesUids()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getCasesUids()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCasesNumbers()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getCasesNumbers()
|
||||
* @test
|
||||
*/
|
||||
public function it_return_set_get_case()
|
||||
{
|
||||
$application = factory(Application::class)->create();
|
||||
$absCases = new AbstractCases();
|
||||
$absCases->setCaseUid($application->APP_UID);
|
||||
$actual = $absCases->getCaseUid();
|
||||
$this->assertEquals($application->APP_UID, $actual);
|
||||
$absCases->setCaseNumber($application->APP_NUMBER);
|
||||
$actual = $absCases->getCaseNumber();
|
||||
$this->assertEquals($application->APP_NUMBER, $actual);
|
||||
$absCases->setCasesUids([$application->APP_UID]);
|
||||
$actual = $absCases->getCasesUids();
|
||||
$this->assertEquals([$application->APP_UID], $actual);
|
||||
$absCases->setCasesNumbers([$application->APP_NUMBER]);
|
||||
$actual = $absCases->getCasesNumbers();
|
||||
$this->assertEquals([$application->APP_NUMBER], $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* This check the getter and setter related to the newest than date
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setNewestThan()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getNewestThan()
|
||||
* @test
|
||||
*/
|
||||
public function it_return_set_get_newest_than()
|
||||
{
|
||||
$absCases = new AbstractCases();
|
||||
$text = date('Y-m-d');
|
||||
$absCases->setNewestThan($text);
|
||||
$actual = $absCases->getNewestThan();
|
||||
$this->assertEquals($text, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* This check the getter and setter related to the oldest than date
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setOldestThan()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getOldestThan()
|
||||
* @test
|
||||
*/
|
||||
public function it_return_set_get_oldest_than()
|
||||
{
|
||||
$absCases = new AbstractCases();
|
||||
$text = date('Y-m-d');
|
||||
$absCases->setOldestThan($text);
|
||||
$actual = $absCases->getOldestThan();
|
||||
$this->assertEquals($text, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* This check the getter and setter related to the oldest than date
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setOrderByColumn()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getOrderByColumn()
|
||||
* @test
|
||||
*/
|
||||
public function it_return_set_get_order_by_column()
|
||||
{
|
||||
$absCases = new AbstractCases();
|
||||
$text = 'APP_NUMBER';
|
||||
$absCases->setOrderByColumn($text);
|
||||
$actual = $absCases->getOrderByColumn();
|
||||
$this->assertEquals($text, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* This check the getter and setter related to the order direction
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setOrderDirection()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getOrderDirection()
|
||||
* @test
|
||||
*/
|
||||
public function it_return_set_get_order_direction()
|
||||
{
|
||||
$absCases = new AbstractCases();
|
||||
$arguments = ['DESC', 'ASC'];
|
||||
$index = array_rand($arguments);
|
||||
$absCases->setOrderDirection($arguments[$index]);
|
||||
$actual = $absCases->getOrderDirection();
|
||||
$this->assertEquals($arguments[$index], $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* This check the getter and setter related to the paged, offset and limit
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setPaged()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getPaged()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setOffset()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getOffset()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setLimit()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::getLimit()
|
||||
* @test
|
||||
*/
|
||||
public function it_return_set_get_paged_offset()
|
||||
{
|
||||
$absCases = new AbstractCases();
|
||||
$number = 1000;
|
||||
$absCases->setPaged($number);
|
||||
$actual = $absCases->getPaged();
|
||||
$absCases->setOffset($number);
|
||||
$actual = $absCases->getOffset();
|
||||
$this->assertEquals($number, $actual);
|
||||
$absCases->setLimit($number);
|
||||
$actual = $absCases->getLimit();
|
||||
$this->assertEquals($number, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* This check the setter related all the properties
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setProperties()
|
||||
* @test
|
||||
*/
|
||||
public function it_return_set_get_properties()
|
||||
{
|
||||
$absCases = new AbstractCases();
|
||||
$properties = [
|
||||
'category' => G::generateUniqueID(),
|
||||
'process' => G::generateUniqueID(),
|
||||
'user' => G::generateUniqueID(),
|
||||
'search' => G::generateUniqueID(),
|
||||
'caseLink' => G::generateUniqueID(),
|
||||
'appUidCheck' => [G::generateUniqueID()],
|
||||
];
|
||||
$absCases->setProperties($properties);
|
||||
$actual = $absCases->getCategoryUid();
|
||||
$this->assertEquals($properties['category'], $actual);
|
||||
$actual = $absCases->getProcessUid();
|
||||
$this->assertEquals($properties['process'], $actual);
|
||||
$actual = $absCases->getUserUid();
|
||||
$this->assertEquals($properties['user'], $actual);
|
||||
$actual = $absCases->getValueToSearch();
|
||||
$this->assertEquals($properties['search'], $actual);
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ class DraftTest extends TestCase
|
||||
/**
|
||||
* This checks the counters is working properly in draft
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getCounter()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getCounter()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_count_cases()
|
||||
@@ -66,7 +66,7 @@ class DraftTest extends TestCase
|
||||
/**
|
||||
* This checks to make sure pagination is working properly in draft
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getData()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_return_draft_paged()
|
||||
@@ -113,7 +113,7 @@ class DraftTest extends TestCase
|
||||
/**
|
||||
* This ensures ordering ascending and descending works by case number APP_NUMBER in draft
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getData()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_return_draft_sort_by_case_number()
|
||||
@@ -157,7 +157,7 @@ class DraftTest extends TestCase
|
||||
/**
|
||||
* This ensures ordering ascending and descending works by case title APP_TITLE in draft
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getData()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_return_draft_sort_by_case_title()
|
||||
@@ -201,7 +201,7 @@ class DraftTest extends TestCase
|
||||
/**
|
||||
* This ensures ordering ascending and descending works by case title PRO_TITLE in draft
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getData()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_return_draft_sort_by_process()
|
||||
@@ -241,7 +241,7 @@ class DraftTest extends TestCase
|
||||
/**
|
||||
* This ensures ordering ascending and descending works by task title TAS_TITLE in draft
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getData()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_return_draft_sort_by_task_title()
|
||||
@@ -280,7 +280,7 @@ class DraftTest extends TestCase
|
||||
/**
|
||||
* This ensures ordering ascending and descending works by due date DEL_TASK_DUE_DATE in draft
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getData()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_return_draft_sort_due_date()
|
||||
@@ -327,7 +327,7 @@ class DraftTest extends TestCase
|
||||
/**
|
||||
* This ensures ordering ascending and descending works by last modified APP_UPDATE_DATE in draft
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getData()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_return_draft_sort_last_modified()
|
||||
@@ -371,7 +371,7 @@ class DraftTest extends TestCase
|
||||
/**
|
||||
* This ensures searching specific cases and review the page in draft
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getData()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_search_draft_search_specific_case_uid()
|
||||
@@ -411,7 +411,7 @@ class DraftTest extends TestCase
|
||||
/**
|
||||
* This ensures searching specific cases and review the page in draft
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getData()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_search_draft_search_specific_cases_uid_array()
|
||||
@@ -447,7 +447,7 @@ class DraftTest extends TestCase
|
||||
/**
|
||||
* This ensures searching specific process and review the page in draft
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getData()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_search_draft_search_specific_process()
|
||||
|
||||
@@ -2,20 +2,18 @@
|
||||
|
||||
namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases;
|
||||
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use ProcessMaker\BusinessModel\Cases\Inbox;
|
||||
use ProcessMaker\Model\Application;
|
||||
use ProcessMaker\Model\Delegation;
|
||||
use ProcessMaker\Model\Process;
|
||||
use ProcessMaker\Model\Task;
|
||||
use ProcessMaker\Model\User;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class InboxTest
|
||||
*
|
||||
* @coversDefaultClass \ProcessMaker\BusinessModel\Cases\Inbox
|
||||
* @package Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases
|
||||
*/
|
||||
class InboxTest extends TestCase
|
||||
{
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases;
|
||||
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use ProcessMaker\BusinessModel\Cases\Reassign;
|
||||
use ProcessMaker\Model\Delegation;
|
||||
use ProcessMaker\Model\Process;
|
||||
use ProcessMaker\Model\Task;
|
||||
use ProcessMaker\Model\User;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \ProcessMaker\BusinessModel\Cases\Reassign
|
||||
*/
|
||||
class ReassignTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
/**
|
||||
* It tests the getData method without filters
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Reassign::getData()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_get_data_method_without_filters()
|
||||
{
|
||||
$cases = 25;
|
||||
factory(Delegation::class, $cases)->states('foreign_keys')->create();
|
||||
//Create new Reassign object
|
||||
$reassign = new Reassign();
|
||||
//Set OrderBYColumn value
|
||||
$reassign->setOrderByColumn('APP_DELEGATION.APP_NUMBER');
|
||||
//Call to getData method
|
||||
$res = $reassign->getData();
|
||||
//This assert that the expected numbers of results are returned
|
||||
$this->assertEquals($cases, count($res));
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the getData method with user filter
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Reassign::getData()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_get_data_method_with_user_filter()
|
||||
{
|
||||
// Create user
|
||||
$user = factory(User::class)->create();
|
||||
// Create delegation related to the specific user
|
||||
factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'USR_UID' => $user->USR_UID,
|
||||
]);
|
||||
// Create other delegations
|
||||
$cases = 5;
|
||||
factory(Delegation::class, $cases)->states('foreign_keys')->create();
|
||||
//Create new Reassign object
|
||||
$reassign = new Reassign();
|
||||
//Set the user UID
|
||||
$reassign->setUserUid($user->USR_UID);
|
||||
//Set the user ID
|
||||
$reassign->setUserId($user->USR_ID);
|
||||
//Set OrderBYColumn value
|
||||
$reassign->setOrderByColumn('APP_DELEGATION.APP_NUMBER');
|
||||
//Call to getData method
|
||||
$res = $reassign->getData();
|
||||
//This assert that the expected numbers of results are returned
|
||||
$this->assertEquals(1, count($res));
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the getData method with process filter
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Reassign::getData()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_get_data_method_with_process_filter()
|
||||
{
|
||||
// Create user
|
||||
$process = factory(Process::class)->create();
|
||||
// Create delegation related to the specific user
|
||||
factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'PRO_ID' => $process->PRO_ID,
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
]);
|
||||
// Create other delegations
|
||||
$cases = 5;
|
||||
factory(Delegation::class, $cases)->states('foreign_keys')->create();
|
||||
//Create new Reassign object
|
||||
$reassign = new Reassign();
|
||||
//Set the process
|
||||
$reassign->setProcessId($process->PRO_ID);
|
||||
$reassign->setProcessUid($process->PRO_UID);
|
||||
//Set OrderBYColumn value
|
||||
$reassign->setOrderByColumn('APP_DELEGATION.APP_NUMBER');
|
||||
//Call to getData method
|
||||
$res = $reassign->getData();
|
||||
//This assert that the expected numbers of results are returned
|
||||
$this->assertEquals(1, count($res));
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the getCounter method
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Reassign::getCounter()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_the_counter_for_reassign()
|
||||
{
|
||||
// Create user
|
||||
$user = factory(User::class)->create();
|
||||
$cases = 25;
|
||||
factory(Delegation::class, $cases)->states('foreign_keys')->create([
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'USR_UID' => $user->USR_UID,
|
||||
]);
|
||||
//Create the Inbox object
|
||||
$reassign = new Reassign();
|
||||
//Set the user UID
|
||||
$reassign->setUserUid($user->USR_UID);
|
||||
//Set the user ID
|
||||
$reassign->setUserId($user->USR_ID);
|
||||
$res = $reassign->getCounter();
|
||||
//Assert the result of getCounter method
|
||||
$this->assertEquals($cases, $res);
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@
|
||||
* long as it does not already exist in the output directory.
|
||||
*
|
||||
* @package classes.model
|
||||
* @deprecated Method deprecated in Release 3.6.0
|
||||
*/
|
||||
class ListCompletedPeer extends BaseListCompletedPeer {
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ require_once 'classes/model/om/BaseListMyInbox.php';
|
||||
* long as it does not already exist in the output directory.
|
||||
*
|
||||
* @package classes.model
|
||||
* @deprecated Method deprecated in Release 3.6.0
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
class ListMyInbox extends BaseListMyInbox implements ListInterface
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
* long as it does not already exist in the output directory.
|
||||
*
|
||||
* @package classes.model
|
||||
* @deprecated Method deprecated in Release 3.6.0
|
||||
*/
|
||||
class ListMyInboxPeer extends BaseListMyInboxPeer {
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ require_once 'classes/model/om/BaseListParticipatedHistory.php';
|
||||
* long as it does not already exist in the output directory.
|
||||
*
|
||||
* @package classes.model
|
||||
* @deprecated Method deprecated in Release 3.6.0
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
class ListParticipatedHistory extends BaseListParticipatedHistory implements ListInterface
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
* long as it does not already exist in the output directory.
|
||||
*
|
||||
* @package classes.model
|
||||
* @deprecated Method deprecated in Release 3.6.0
|
||||
*/
|
||||
class ListParticipatedHistoryPeer extends BaseListParticipatedHistoryPeer {
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ require_once 'classes/model/om/BaseListUnassignedGroup.php';
|
||||
* long as it does not already exist in the output directory.
|
||||
*
|
||||
* @package classes.model
|
||||
* @deprecated Method deprecated in Release 3.6.0
|
||||
*/
|
||||
// @codingStandardsIgnoreStart
|
||||
class ListUnassignedGroup extends BaseListUnassignedGroup
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
* long as it does not already exist in the output directory.
|
||||
*
|
||||
* @package classes.model
|
||||
* @deprecated Method deprecated in Release 3.6.0
|
||||
*/
|
||||
class ListUnassignedGroupPeer extends BaseListUnassignedGroupPeer {
|
||||
|
||||
|
||||
@@ -465,6 +465,16 @@ class AbstractCases implements CasesInterface
|
||||
$this->oldestThan = $oldestThan;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Oldest Than value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getOldestThan()
|
||||
{
|
||||
return $this->oldestThan;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set order by column
|
||||
*
|
||||
@@ -488,16 +498,6 @@ class AbstractCases implements CasesInterface
|
||||
return $this->orderByColumn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Oldest Than value
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getOldestThan()
|
||||
{
|
||||
return $this->oldestThan;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set order direction
|
||||
*
|
||||
|
||||
@@ -3,11 +3,9 @@
|
||||
namespace ProcessMaker\BusinessModel\Cases;
|
||||
|
||||
use ProcessMaker\Model\Delegation;
|
||||
use ProcessMaker\Model\Task;
|
||||
|
||||
class Inbox extends AbstractCases
|
||||
{
|
||||
|
||||
/**
|
||||
* Get the data corresponding to List Inbox
|
||||
*
|
||||
@@ -39,7 +37,7 @@ class Inbox extends AbstractCases
|
||||
break;
|
||||
}
|
||||
|
||||
if ($this->getProcessId() != '') {
|
||||
if (!empty($this->getProcessId())) {
|
||||
// Scope to search for an specific process
|
||||
$query->processId($this->getProcessId());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\BusinessModel\Cases;
|
||||
|
||||
use ProcessMaker\Model\Delegation;
|
||||
|
||||
class Reassign extends AbstractCases
|
||||
{
|
||||
/**
|
||||
* Get the data corresponding to Reassign
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getData()
|
||||
{
|
||||
// Start the query for get the cases related to the user
|
||||
$query = Delegation::query()->select();
|
||||
|
||||
// Scope that sets the queries for reassign
|
||||
if (!empty($this->getUserId())) {
|
||||
$query->inbox($this->getUserId());
|
||||
}
|
||||
|
||||
// Scope to search for an specific process
|
||||
if (!empty($this->getProcessId())) {
|
||||
$query->processId($this->getProcessId());
|
||||
}
|
||||
|
||||
// The order by clause
|
||||
$query->orderBy($this->getOrderByColumn(), $this->getOrderDirection());
|
||||
|
||||
// The limit by clause
|
||||
$query->offset($this->getOffset())->limit($this->getLimit());
|
||||
|
||||
// Execute the query
|
||||
$results = $query->get();
|
||||
|
||||
// Return the values as an array format
|
||||
return $results->values()->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of rows corresponding to the List Inbox
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getCounter()
|
||||
{
|
||||
$query = Delegation::query()->select();
|
||||
|
||||
// Scope that sets the queries for reassign
|
||||
if (!empty($this->getUserId())) {
|
||||
$query->inbox($this->getUserId());
|
||||
} else {
|
||||
// Scope that sets the queries for List Inbox
|
||||
$query->inboxWithoutUser();
|
||||
}
|
||||
|
||||
// Return the number of rows
|
||||
return $query->count();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -78,6 +78,30 @@ class Delegation extends Model
|
||||
return $query->where('DEL_INDEX', '=', $index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to get the started by me
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeCaseStarted($query)
|
||||
{
|
||||
return $query->where('DEL_INDEX', '=', 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to get the completed by me
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeCaseCompleted($query)
|
||||
{
|
||||
return $query->appStatusId(3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to only include a specific delegate date
|
||||
*
|
||||
@@ -190,6 +214,17 @@ class Delegation extends Model
|
||||
return $query->where('APP_DELEGATION.DEL_THREAD_STATUS', '=', 'OPEN');
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to get the last thread
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeLastThread($query)
|
||||
{
|
||||
return $query->where('APP_DELEGATION.DEL_LAST_INDEX', '=', 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a query to only include threads without user
|
||||
*
|
||||
@@ -411,6 +446,27 @@ class Delegation extends Model
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope the Inbox cases
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeInboxWithoutUser($query)
|
||||
{
|
||||
// This scope is for the join with the APP_DELEGATION table
|
||||
$query->appStatusId(2);
|
||||
|
||||
// Scope for the restriction of the task that must not be searched for
|
||||
$query->excludeTaskTypes(Task::DUMMY_TASKS);
|
||||
|
||||
// Scope that establish that the DEL_THREAD_STATUS must be OPEN
|
||||
$query->threadOpen();
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a self service cases
|
||||
*
|
||||
@@ -449,6 +505,24 @@ class Delegation extends Model
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a participated cases
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
* @param int $user
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeParticipated($query, $user)
|
||||
{
|
||||
// Scope to set the user
|
||||
$query->userId($user);
|
||||
// Scope to set the last thread
|
||||
$query->lastThread();
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get specific cases unassigned that the user can view
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user