PMCORE-1216
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -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