Merged in feature/PMCORE-2543 (pull request #7614)
PMCORE-2543 Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
@@ -22,7 +22,6 @@ class DraftTest extends TestCase
|
|||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->markTestIncomplete();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -45,6 +44,33 @@ class DraftTest extends TestCase
|
|||||||
return $delegation;
|
return $delegation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create many draft cases for one user
|
||||||
|
*
|
||||||
|
* @param int
|
||||||
|
* @return object
|
||||||
|
*/
|
||||||
|
public function createManyDraft($cases)
|
||||||
|
{
|
||||||
|
$user = factory(\ProcessMaker\Model\User::class)->create();
|
||||||
|
|
||||||
|
for ($i = 0; $i < $cases; $i = $i + 1) {
|
||||||
|
$application = factory(Application::class)->states('draft')->create([
|
||||||
|
'APP_INIT_USER' => $user->USR_UID,
|
||||||
|
'APP_CUR_USER' => $user->USR_UID,
|
||||||
|
]);
|
||||||
|
factory(Delegation::class)->states('foreign_keys')->create([
|
||||||
|
'DEL_THREAD_STATUS' => 'OPEN',
|
||||||
|
'DEL_INDEX' => 1,
|
||||||
|
'APP_UID' => $application->APP_UID,
|
||||||
|
'APP_NUMBER' => $application->APP_NUMBER,
|
||||||
|
'USR_ID' => $user->USR_ID
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $user;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This checks the counters is working properly in draft
|
* This checks the counters is working properly in draft
|
||||||
*
|
*
|
||||||
@@ -57,7 +83,7 @@ class DraftTest extends TestCase
|
|||||||
$cases = $this->createDraft();
|
$cases = $this->createDraft();
|
||||||
// Create new Draft object
|
// Create new Draft object
|
||||||
$draft = new Draft();
|
$draft = new Draft();
|
||||||
$draft->setUserId($cases->USR_ID);
|
$draft->setUserId($cases['USR_ID']);
|
||||||
$result = $draft->getCounter();
|
$result = $draft->getCounter();
|
||||||
$this->assertTrue($result > 0);
|
$this->assertTrue($result > 0);
|
||||||
}
|
}
|
||||||
@@ -74,9 +100,9 @@ class DraftTest extends TestCase
|
|||||||
// 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
|
||||||
$draft = new Inbox();
|
$draft = new Draft();
|
||||||
// Set the user ID
|
// Set the user ID
|
||||||
$draft->setUserId($cases->USR_ID);
|
$draft->setUserId($cases['USR_ID']);
|
||||||
$draft->setOrderByColumn('APP_NUMBER');
|
$draft->setOrderByColumn('APP_NUMBER');
|
||||||
$res = $draft->getData();
|
$res = $draft->getData();
|
||||||
$this->assertNotEmpty($res);
|
$this->assertNotEmpty($res);
|
||||||
@@ -96,8 +122,8 @@ class DraftTest extends TestCase
|
|||||||
$cases = $this->createDraft();
|
$cases = $this->createDraft();
|
||||||
// Create new Draft object
|
// Create new Draft object
|
||||||
$draft = new Draft();
|
$draft = new Draft();
|
||||||
$draft->setUserId($cases->USR_ID);
|
$draft->setUserId($cases['USR_ID']);
|
||||||
$draft->setProcessId($cases->PRO_ID);
|
$draft->setProcessId($cases['PRO_ID']);
|
||||||
$draft->setOrderByColumn('APP_NUMBER');
|
$draft->setOrderByColumn('APP_NUMBER');
|
||||||
$res = $draft->getData();
|
$res = $draft->getData();
|
||||||
$this->assertNotEmpty($res);
|
$this->assertNotEmpty($res);
|
||||||
@@ -117,8 +143,8 @@ class DraftTest extends TestCase
|
|||||||
$cases = $this->createDraft();
|
$cases = $this->createDraft();
|
||||||
// Create new Draft object
|
// Create new Draft object
|
||||||
$draft = new Draft();
|
$draft = new Draft();
|
||||||
$draft->setUserId($cases->USR_ID);
|
$draft->setUserId($cases['USR_ID']);
|
||||||
$draft->setCaseNumber($cases->APP_NUMBER);
|
$draft->setCaseNumber($cases['APP_NUMBER']);
|
||||||
$draft->setOrderByColumn('APP_NUMBER');
|
$draft->setOrderByColumn('APP_NUMBER');
|
||||||
$res = $draft->getData();
|
$res = $draft->getData();
|
||||||
$this->assertNotEmpty($res);
|
$this->assertNotEmpty($res);
|
||||||
@@ -138,11 +164,10 @@ class DraftTest extends TestCase
|
|||||||
$cases = $this->createDraft();
|
$cases = $this->createDraft();
|
||||||
// Create new Draft object
|
// Create new Draft object
|
||||||
$draft = new Draft();
|
$draft = new Draft();
|
||||||
$draft->setUserId($cases->USR_ID);
|
$draft->setUserId($cases['USR_ID']);
|
||||||
$draft->setTaskId($cases->TAS_ID);
|
$draft->setTaskId($cases['TAS_ID']);
|
||||||
$res = $draft->getData();
|
$res = $draft->getData();
|
||||||
$this->assertNotEmpty($res);
|
$this->assertNotEmpty($res);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -157,14 +182,14 @@ class DraftTest extends TestCase
|
|||||||
{
|
{
|
||||||
// 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;
|
$title = $cases['DEL_TITLE'];
|
||||||
// We need to commit the records inserted because is needed for the "fulltext" index
|
// We need to commit the records inserted because is needed for the "fulltext" index
|
||||||
DB::commit();
|
DB::commit();
|
||||||
// Create new Draft object
|
// Create new Draft object
|
||||||
$draft = new Draft();
|
$draft = new Draft();
|
||||||
$draft->setUserId($cases->USR_ID);
|
$draft->setUserId($cases['USR_ID']);
|
||||||
// Set the title
|
// Set the title
|
||||||
$draft->setCaseTitle($cases->DEL_TITLE);
|
$draft->setCaseTitle($cases['DEL_TITLE']);
|
||||||
// Get the data
|
// Get the data
|
||||||
$res = $draft->getData();
|
$res = $draft->getData();
|
||||||
// Asserts
|
// Asserts
|
||||||
@@ -194,10 +219,39 @@ class DraftTest extends TestCase
|
|||||||
$index = array_rand($columnsView);
|
$index = array_rand($columnsView);
|
||||||
// Create new Inbox object
|
// Create new Inbox object
|
||||||
$draft = new Draft();
|
$draft = new Draft();
|
||||||
$draft->setUserId($cases->USR_ID);
|
$draft->setUserId($cases['USR_ID']);
|
||||||
// Define the column to order
|
// Define the column to order
|
||||||
$draft->setOrderByColumn($columnsView[$index]);
|
$draft->setOrderByColumn($columnsView[$index]);
|
||||||
$res = $draft->getData();
|
$res = $draft->getData();
|
||||||
$this->assertNotEmpty($res);
|
$this->assertNotEmpty($res);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
* It tests the getPagingCounters() method
|
||||||
|
*
|
||||||
|
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getPagingCounters()
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_should_test_get_paging_counters_method()
|
||||||
|
{
|
||||||
|
$cases = $this->createManyDraft(3);
|
||||||
|
|
||||||
|
$draft = new Draft();
|
||||||
|
$draft->setUserId($cases->USR_ID);
|
||||||
|
$draft->setUserUid($cases->USR_UID);
|
||||||
|
|
||||||
|
$res = $draft->getPagingCounters();
|
||||||
|
$this->assertEquals(3, $res);
|
||||||
|
|
||||||
|
$delegation = Delegation::select()->where('USR_ID', $cases->USR_ID)->first();
|
||||||
|
|
||||||
|
$draft->setCaseNumber($delegation->APP_NUMBER);
|
||||||
|
$draft->setProcessId($delegation->PRO_ID);
|
||||||
|
$draft->setTaskId($delegation->TAS_ID);
|
||||||
|
$draft->setCaseUid($delegation->APP_UID);
|
||||||
|
|
||||||
|
$res = $draft->getPagingCounters();
|
||||||
|
|
||||||
|
$this->assertEquals(1, $res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -37,6 +37,27 @@ class InboxTest extends TestCase
|
|||||||
return $delegation;
|
return $delegation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create many inbox cases for one user
|
||||||
|
*
|
||||||
|
* @param int
|
||||||
|
* @return object
|
||||||
|
*/
|
||||||
|
public function createMultipleInbox($cases)
|
||||||
|
{
|
||||||
|
$user = factory(\ProcessMaker\Model\User::class)->create();
|
||||||
|
|
||||||
|
for ($i = 0; $i < $cases; $i = $i + 1) {
|
||||||
|
factory(Delegation::class)->states('foreign_keys')->create([
|
||||||
|
'DEL_THREAD_STATUS' => 'OPEN',
|
||||||
|
'DEL_INDEX' => 2,
|
||||||
|
'USR_UID' => $user->USR_UID,
|
||||||
|
'USR_ID' => $user->USR_ID,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
return $user;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* It tests the getCounter method
|
* It tests the getCounter method
|
||||||
*
|
*
|
||||||
@@ -156,9 +177,10 @@ class InboxTest extends TestCase
|
|||||||
DB::commit();
|
DB::commit();
|
||||||
// Create new Inbox object
|
// Create new Inbox object
|
||||||
$inbox = new Inbox();
|
$inbox = new Inbox();
|
||||||
$inbox->setUserId($cases->USR_ID);
|
$inbox->setUserUid($cases['USR_UID']);
|
||||||
|
$inbox->setUserId($cases['USR_ID']);
|
||||||
// Set the title
|
// Set the title
|
||||||
$inbox->setCaseTitle($cases->DEL_TITLE);
|
$inbox->setCaseTitle($cases['DEL_TITLE']);
|
||||||
// Get the data
|
// Get the data
|
||||||
$res = $inbox->getData();
|
$res = $inbox->getData();
|
||||||
// Asserts
|
// Asserts
|
||||||
@@ -194,4 +216,31 @@ class InboxTest extends TestCase
|
|||||||
$res = $inbox->getData();
|
$res = $inbox->getData();
|
||||||
$this->assertNotEmpty($res);
|
$this->assertNotEmpty($res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* It tests the getPagingCounters() method
|
||||||
|
*
|
||||||
|
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getPagingCounters()
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_should_test_get_paging_counters_method()
|
||||||
|
{
|
||||||
|
$cases = $this->createMultipleInbox(3);
|
||||||
|
$inbox = new Inbox();
|
||||||
|
$inbox->setUserId($cases->USR_ID);
|
||||||
|
$inbox->setUserUid($cases->USR_UID);
|
||||||
|
|
||||||
|
$res = $inbox->getPagingCounters();
|
||||||
|
$this->assertEquals(3, $res);
|
||||||
|
|
||||||
|
$delegation = Delegation::select()->where('USR_ID', $cases->USR_ID)->first();
|
||||||
|
|
||||||
|
$inbox->setCaseNumber($delegation->APP_NUMBER);
|
||||||
|
$inbox->setProcessId($delegation->PRO_ID);
|
||||||
|
$inbox->setTaskId($delegation->TAS_ID);
|
||||||
|
$inbox->setCaseUid($delegation->APP_UID);
|
||||||
|
|
||||||
|
$res = $inbox->getPagingCounters();
|
||||||
|
$this->assertEquals(1, $res);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -45,6 +45,37 @@ class ParticipatedTest extends TestCase
|
|||||||
return $delegation2;
|
return $delegation2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create many participated cases for one user
|
||||||
|
*
|
||||||
|
* @param int
|
||||||
|
* @return object
|
||||||
|
*/
|
||||||
|
public function createMultipleParticipated($cases)
|
||||||
|
{
|
||||||
|
$user = factory(\ProcessMaker\Model\User::class)->create();
|
||||||
|
|
||||||
|
for ($i = 0; $i < $cases; $i = $i + 1) {
|
||||||
|
$delegation = factory(Delegation::class)->states('foreign_keys')->create([
|
||||||
|
'DEL_THREAD_STATUS' => 'CLOSED',
|
||||||
|
'DEL_INDEX' => 1,
|
||||||
|
'USR_UID' => $user->USR_UID,
|
||||||
|
'USR_ID' => $user->USR_ID,
|
||||||
|
]);
|
||||||
|
factory(Delegation::class)->states('last_thread')->create([
|
||||||
|
'APP_UID' => $delegation->APP_UID,
|
||||||
|
'APP_NUMBER' => $delegation->APP_NUMBER,
|
||||||
|
'TAS_ID' => $delegation->TAS_ID,
|
||||||
|
'DEL_THREAD_STATUS' => 'OPEN',
|
||||||
|
'USR_UID' => $delegation->USR_UID,
|
||||||
|
'USR_ID' => $delegation->USR_ID,
|
||||||
|
'PRO_ID' => $delegation->PRO_ID,
|
||||||
|
'DEL_INDEX' => 2,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
return $user;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* It tests the getData method without filters
|
* It tests the getData method without filters
|
||||||
*
|
*
|
||||||
@@ -59,15 +90,15 @@ class ParticipatedTest extends TestCase
|
|||||||
// Create new Participated object
|
// Create new Participated object
|
||||||
$participated = new Participated();
|
$participated = new Participated();
|
||||||
// Set the user UID
|
// Set the user UID
|
||||||
$participated->setUserUid($cases->USR_UID);
|
$participated->setUserUid($cases['USR_UID']);
|
||||||
// Set the user ID
|
// Set the user ID
|
||||||
$participated->setUserId($cases->USR_ID);
|
$participated->setUserId($cases['USR_ID']);
|
||||||
// Set OrderBYColumn value
|
// Set OrderBYColumn value
|
||||||
$participated->setOrderByColumn('APP_NUMBER');
|
$participated->setOrderByColumn('APP_NUMBER');
|
||||||
// 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(1, count($res));
|
$this->assertEquals(2, count($res));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -143,17 +174,17 @@ class ParticipatedTest extends TestCase
|
|||||||
// Set the filter
|
// Set the filter
|
||||||
$participated->setFilterCases('STARTED');
|
$participated->setFilterCases('STARTED');
|
||||||
// Set the user UID
|
// Set the user UID
|
||||||
$participated->setUserUid($cases->USR_UID);
|
$participated->setUserUid($cases['USR_UID']);
|
||||||
// Set the user ID
|
// Set the user ID
|
||||||
$participated->setUserId($cases->USR_ID);
|
$participated->setUserId($cases['USR_ID']);
|
||||||
// Set the process ID
|
// Set the process ID
|
||||||
$participated->setProcessId($cases->PRO_ID);
|
$participated->setProcessId($cases['PRO_ID']);
|
||||||
// Set OrderBYColumn value
|
// Set OrderBYColumn value
|
||||||
$participated->setOrderByColumn('APP_NUMBER');
|
$participated->setOrderByColumn('APP_NUMBER');
|
||||||
// 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(1, count($res));
|
$this->assertEquals(2, count($res));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -209,4 +240,32 @@ class ParticipatedTest extends TestCase
|
|||||||
// Assert the result of getCounter method
|
// Assert the result of getCounter method
|
||||||
$this->assertEquals(1, $res);
|
$this->assertEquals(1, $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* It tests the getPagingCounters() method
|
||||||
|
*
|
||||||
|
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getPagingCounters()
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_should_test_get_paging_counters_method()
|
||||||
|
{
|
||||||
|
$cases = $this->createMultipleParticipated(3);
|
||||||
|
$participated = new Participated();
|
||||||
|
$participated->setUserId($cases->USR_ID);
|
||||||
|
$participated->setUserUid($cases->USR_UID);
|
||||||
|
$participated->setParticipatedStatus('STARTED');
|
||||||
|
|
||||||
|
$res = $participated->getPagingCounters();
|
||||||
|
$this->assertEquals(3, $res);
|
||||||
|
|
||||||
|
$delegation = Delegation::select()->where('USR_ID', $cases->USR_ID)->first();
|
||||||
|
|
||||||
|
$participated->setCaseNumber($delegation->APP_NUMBER);
|
||||||
|
$participated->setProcessId($delegation->PRO_ID);
|
||||||
|
$participated->setTaskId($delegation->TAS_ID);
|
||||||
|
$participated->setCaseUid($delegation->APP_UID);
|
||||||
|
|
||||||
|
$res = $participated->getPagingCounters();
|
||||||
|
$this->assertEquals(1, $res);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -122,6 +122,67 @@ class PausedTest extends TestCase
|
|||||||
return $delegation2;
|
return $delegation2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create many paused cases for one user
|
||||||
|
*
|
||||||
|
* @param int
|
||||||
|
* @return object
|
||||||
|
*/
|
||||||
|
public function createMultiplePaused($cases)
|
||||||
|
{
|
||||||
|
$user = factory(\ProcessMaker\Model\User::class)->create();
|
||||||
|
|
||||||
|
for ($i = 0; $i < $cases; $i = $i + 1) {
|
||||||
|
$process1 = factory(Process::class)->create(
|
||||||
|
['PRO_CATEGORY' => '1']
|
||||||
|
);
|
||||||
|
|
||||||
|
$task = factory(Task::class)->create([
|
||||||
|
'TAS_ASSIGN_TYPE' => '',
|
||||||
|
'TAS_GROUP_VARIABLE' => '',
|
||||||
|
'PRO_UID' => $process1->PRO_UID,
|
||||||
|
'TAS_TYPE' => 'NORMAL'
|
||||||
|
]);
|
||||||
|
|
||||||
|
$application1 = factory(Application::class)->create();
|
||||||
|
|
||||||
|
factory(Delegation::class)->create([
|
||||||
|
'APP_UID' => $application1->APP_UID,
|
||||||
|
'APP_NUMBER' => $application1->APP_NUMBER,
|
||||||
|
'TAS_ID' => $task->TAS_ID,
|
||||||
|
'DEL_THREAD_STATUS' => 'CLOSED',
|
||||||
|
'USR_UID' => $user->USR_UID,
|
||||||
|
'USR_ID' => $user->USR_ID,
|
||||||
|
'PRO_ID' => $process1->PRO_ID,
|
||||||
|
'PRO_UID' => $process1->PRO_UID,
|
||||||
|
'DEL_PREVIOUS' => 0,
|
||||||
|
'DEL_INDEX' => 1
|
||||||
|
]);
|
||||||
|
$delegation1 = factory(Delegation::class)->create([
|
||||||
|
'APP_UID' => $application1->APP_UID,
|
||||||
|
'APP_NUMBER' => $application1->APP_NUMBER,
|
||||||
|
'TAS_ID' => $task->TAS_ID,
|
||||||
|
'DEL_THREAD_STATUS' => 'OPEN',
|
||||||
|
'USR_UID' => $user->USR_UID,
|
||||||
|
'USR_ID' => $user->USR_ID,
|
||||||
|
'PRO_ID' => $process1->PRO_ID,
|
||||||
|
'PRO_UID' => $process1->PRO_UID,
|
||||||
|
'DEL_PREVIOUS' => 1,
|
||||||
|
'DEL_INDEX' => 2
|
||||||
|
]);
|
||||||
|
|
||||||
|
factory(AppDelay::class)->create([
|
||||||
|
'APP_DELEGATION_USER' => $user->USR_UID,
|
||||||
|
'PRO_UID' => $process1->PRO_UID,
|
||||||
|
'APP_NUMBER' => $delegation1->APP_NUMBER,
|
||||||
|
'APP_DEL_INDEX' => $delegation1->DEL_INDEX,
|
||||||
|
'APP_DISABLE_ACTION_USER' => 0,
|
||||||
|
'APP_TYPE' => 'PAUSE'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
return $user;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* It tests the getData method without filters
|
* It tests the getData method without filters
|
||||||
*
|
*
|
||||||
@@ -245,4 +306,31 @@ class PausedTest extends TestCase
|
|||||||
$res = $paused->getData();
|
$res = $paused->getData();
|
||||||
$this->assertNotEmpty($res);
|
$this->assertNotEmpty($res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* It tests the getPagingCounters() method
|
||||||
|
*
|
||||||
|
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getPagingCounters()
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_should_test_get_paging_counters_method()
|
||||||
|
{
|
||||||
|
$cases = $this->createMultiplePaused(3);
|
||||||
|
$paused = new Paused();
|
||||||
|
$paused->setUserId($cases->USR_ID);
|
||||||
|
$paused->setUserUid($cases->USR_UID);
|
||||||
|
|
||||||
|
$res = $paused->getPagingCounters();
|
||||||
|
$this->assertEquals(3, $res);
|
||||||
|
|
||||||
|
$delegation = Delegation::select()->where('USR_ID', $cases->USR_ID)->first();
|
||||||
|
|
||||||
|
$paused->setCaseNumber($delegation->APP_NUMBER);
|
||||||
|
$paused->setProcessId($delegation->PRO_ID);
|
||||||
|
$paused->setTaskId($delegation->TAS_ID);
|
||||||
|
$paused->setCaseUid($delegation->APP_UID);
|
||||||
|
|
||||||
|
$res = $paused->getPagingCounters();
|
||||||
|
$this->assertEquals(1, $res);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ class SupervisingTest extends TestCase
|
|||||||
'PRO_UID' => $process->PRO_UID,
|
'PRO_UID' => $process->PRO_UID,
|
||||||
'APP_NUMBER' => $app1['APP_NUMBER'],
|
'APP_NUMBER' => $app1['APP_NUMBER'],
|
||||||
'DEL_INDEX' => 1,
|
'DEL_INDEX' => 1,
|
||||||
'DEL_PREVIOUS' =>0
|
'DEL_PREVIOUS' => 0
|
||||||
]);
|
]);
|
||||||
factory(Delegation::class, 1)->create([
|
factory(Delegation::class, 1)->create([
|
||||||
"APP_UID" => $app1['APP_UID'],
|
"APP_UID" => $app1['APP_UID'],
|
||||||
@@ -96,7 +96,7 @@ class SupervisingTest extends TestCase
|
|||||||
'PRO_UID' => $process->PRO_UID,
|
'PRO_UID' => $process->PRO_UID,
|
||||||
'APP_NUMBER' => $app1['APP_NUMBER'],
|
'APP_NUMBER' => $app1['APP_NUMBER'],
|
||||||
'DEL_INDEX' => 2,
|
'DEL_INDEX' => 2,
|
||||||
'DEL_PREVIOUS' =>1
|
'DEL_PREVIOUS' => 1
|
||||||
]);
|
]);
|
||||||
|
|
||||||
factory(Delegation::class, 1)->create([
|
factory(Delegation::class, 1)->create([
|
||||||
@@ -110,7 +110,7 @@ class SupervisingTest extends TestCase
|
|||||||
'PRO_UID' => $process->PRO_UID,
|
'PRO_UID' => $process->PRO_UID,
|
||||||
'APP_NUMBER' => $app2['APP_NUMBER'],
|
'APP_NUMBER' => $app2['APP_NUMBER'],
|
||||||
'DEL_INDEX' => 1,
|
'DEL_INDEX' => 1,
|
||||||
'DEL_PREVIOUS' =>0
|
'DEL_PREVIOUS' => 0
|
||||||
]);
|
]);
|
||||||
factory(Delegation::class, 1)->create([
|
factory(Delegation::class, 1)->create([
|
||||||
"APP_UID" => $app2['APP_UID'],
|
"APP_UID" => $app2['APP_UID'],
|
||||||
@@ -123,7 +123,7 @@ class SupervisingTest extends TestCase
|
|||||||
'PRO_UID' => $process->PRO_UID,
|
'PRO_UID' => $process->PRO_UID,
|
||||||
'APP_NUMBER' => $app2['APP_NUMBER'],
|
'APP_NUMBER' => $app2['APP_NUMBER'],
|
||||||
'DEL_INDEX' => 2,
|
'DEL_INDEX' => 2,
|
||||||
'DEL_PREVIOUS' =>1
|
'DEL_PREVIOUS' => 1
|
||||||
]);
|
]);
|
||||||
|
|
||||||
factory(Delegation::class, 1)->create([
|
factory(Delegation::class, 1)->create([
|
||||||
@@ -137,7 +137,7 @@ class SupervisingTest extends TestCase
|
|||||||
'PRO_UID' => $process->PRO_UID,
|
'PRO_UID' => $process->PRO_UID,
|
||||||
'APP_NUMBER' => $app3['APP_NUMBER'],
|
'APP_NUMBER' => $app3['APP_NUMBER'],
|
||||||
'DEL_INDEX' => 1,
|
'DEL_INDEX' => 1,
|
||||||
'DEL_PREVIOUS' =>0
|
'DEL_PREVIOUS' => 0
|
||||||
]);
|
]);
|
||||||
$delegation = factory(Delegation::class)->create([
|
$delegation = factory(Delegation::class)->create([
|
||||||
"APP_UID" => $app3['APP_UID'],
|
"APP_UID" => $app3['APP_UID'],
|
||||||
@@ -150,7 +150,7 @@ class SupervisingTest extends TestCase
|
|||||||
'PRO_UID' => $process->PRO_UID,
|
'PRO_UID' => $process->PRO_UID,
|
||||||
'APP_NUMBER' => $app3['APP_NUMBER'],
|
'APP_NUMBER' => $app3['APP_NUMBER'],
|
||||||
'DEL_INDEX' => 2,
|
'DEL_INDEX' => 2,
|
||||||
'DEL_PREVIOUS' =>1
|
'DEL_PREVIOUS' => 1
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Create the register in the ProcessUser table
|
// Create the register in the ProcessUser table
|
||||||
@@ -165,6 +165,152 @@ class SupervisingTest extends TestCase
|
|||||||
return $delegation;
|
return $delegation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create many supervising cases for one user
|
||||||
|
*
|
||||||
|
* @param int
|
||||||
|
* @return object
|
||||||
|
*/
|
||||||
|
public function createMultipleSupervising($cases)
|
||||||
|
{
|
||||||
|
$user = factory(\ProcessMaker\Model\User::class)->create();
|
||||||
|
|
||||||
|
for ($i = 0; $i < $cases; $i = $i + 1) {
|
||||||
|
// Create process
|
||||||
|
$process = factory(Process::class)->create();
|
||||||
|
|
||||||
|
// Create user
|
||||||
|
$user = factory(User::class)->create();
|
||||||
|
|
||||||
|
// Create a task
|
||||||
|
$task = factory(Task::class)->create([
|
||||||
|
'TAS_ASSIGN_TYPE' => 'NORMAL',
|
||||||
|
'TAS_GROUP_VARIABLE' => '',
|
||||||
|
'PRO_UID' => $process->PRO_UID,
|
||||||
|
]);
|
||||||
|
$task2 = factory(Task::class)->create([
|
||||||
|
'TAS_ASSIGN_TYPE' => 'NORMAL',
|
||||||
|
'TAS_GROUP_VARIABLE' => '',
|
||||||
|
'PRO_UID' => $process->PRO_UID,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Create 3 cases
|
||||||
|
$app1 = factory(Application::class)->states('todo')->create([
|
||||||
|
'APP_STATUS' => 'TO_DO',
|
||||||
|
'APP_STATUS_ID' => 2,
|
||||||
|
'PRO_UID' => $process->PRO_UID,
|
||||||
|
'APP_INIT_USER' => $user->USR_UID,
|
||||||
|
'APP_CUR_USER' => $user->USR_UID,
|
||||||
|
]);
|
||||||
|
$app2 = factory(Application::class)->states('todo')->create([
|
||||||
|
'APP_STATUS' => 'TO_DO',
|
||||||
|
'APP_STATUS_ID' => 2,
|
||||||
|
'PRO_UID' => $process->PRO_UID,
|
||||||
|
'APP_INIT_USER' => $user->USR_UID,
|
||||||
|
'APP_CUR_USER' => $user->USR_UID,
|
||||||
|
]);
|
||||||
|
$app3 = factory(Application::class)->states('todo')->create([
|
||||||
|
'APP_STATUS' => 'TO_DO',
|
||||||
|
'APP_STATUS_ID' => 2,
|
||||||
|
'PRO_UID' => $process->PRO_UID,
|
||||||
|
'APP_INIT_USER' => $user->USR_UID,
|
||||||
|
'APP_CUR_USER' => $user->USR_UID,
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Create the registers in delegation
|
||||||
|
factory(Delegation::class)->create([
|
||||||
|
"APP_UID" => $app1['APP_UID'],
|
||||||
|
'TAS_ID' => $task->TAS_ID,
|
||||||
|
'TAS_UID' => $task->TAS_UID,
|
||||||
|
'DEL_THREAD_STATUS' => 'CLOSED',
|
||||||
|
'USR_UID' => $user->USR_UID,
|
||||||
|
'USR_ID' => $user->USR_ID,
|
||||||
|
'PRO_ID' => $process->PRO_ID,
|
||||||
|
'PRO_UID' => $process->PRO_UID,
|
||||||
|
'APP_NUMBER' => $app1['APP_NUMBER'],
|
||||||
|
'DEL_INDEX' => 1,
|
||||||
|
'DEL_PREVIOUS' => 0
|
||||||
|
]);
|
||||||
|
factory(Delegation::class, 1)->create([
|
||||||
|
"APP_UID" => $app1['APP_UID'],
|
||||||
|
'TAS_ID' => $task2->TAS_ID,
|
||||||
|
'TAS_UID' => $task2->TAS_UID,
|
||||||
|
'DEL_THREAD_STATUS' => 'OPEN',
|
||||||
|
'USR_UID' => $user->USR_UID,
|
||||||
|
'USR_ID' => $user->USR_ID,
|
||||||
|
'PRO_ID' => $process->PRO_ID,
|
||||||
|
'PRO_UID' => $process->PRO_UID,
|
||||||
|
'APP_NUMBER' => $app1['APP_NUMBER'],
|
||||||
|
'DEL_INDEX' => 2,
|
||||||
|
'DEL_PREVIOUS' => 1
|
||||||
|
]);
|
||||||
|
|
||||||
|
factory(Delegation::class, 1)->create([
|
||||||
|
"APP_UID" => $app2['APP_UID'],
|
||||||
|
'TAS_ID' => $task->TAS_ID,
|
||||||
|
'TAS_UID' => $task->TAS_UID,
|
||||||
|
'DEL_THREAD_STATUS' => 'CLOSED',
|
||||||
|
'USR_UID' => $user->USR_UID,
|
||||||
|
'USR_ID' => $user->USR_ID,
|
||||||
|
'PRO_ID' => $process->PRO_ID,
|
||||||
|
'PRO_UID' => $process->PRO_UID,
|
||||||
|
'APP_NUMBER' => $app2['APP_NUMBER'],
|
||||||
|
'DEL_INDEX' => 1,
|
||||||
|
'DEL_PREVIOUS' => 0
|
||||||
|
]);
|
||||||
|
factory(Delegation::class, 1)->create([
|
||||||
|
"APP_UID" => $app2['APP_UID'],
|
||||||
|
'TAS_ID' => $task2->TAS_ID,
|
||||||
|
'TAS_UID' => $task2->TAS_UID,
|
||||||
|
'DEL_THREAD_STATUS' => 'OPEN',
|
||||||
|
'USR_UID' => $user->USR_UID,
|
||||||
|
'USR_ID' => $user->USR_ID,
|
||||||
|
'PRO_ID' => $process->PRO_ID,
|
||||||
|
'PRO_UID' => $process->PRO_UID,
|
||||||
|
'APP_NUMBER' => $app2['APP_NUMBER'],
|
||||||
|
'DEL_INDEX' => 2,
|
||||||
|
'DEL_PREVIOUS' => 1
|
||||||
|
]);
|
||||||
|
|
||||||
|
factory(Delegation::class, 1)->create([
|
||||||
|
"APP_UID" => $app3['APP_UID'],
|
||||||
|
'TAS_ID' => $task->TAS_ID,
|
||||||
|
'TAS_UID' => $task->TAS_UID,
|
||||||
|
'DEL_THREAD_STATUS' => 'CLOSED',
|
||||||
|
'USR_UID' => $user->USR_UID,
|
||||||
|
'USR_ID' => $user->USR_ID,
|
||||||
|
'PRO_ID' => $process->PRO_ID,
|
||||||
|
'PRO_UID' => $process->PRO_UID,
|
||||||
|
'APP_NUMBER' => $app3['APP_NUMBER'],
|
||||||
|
'DEL_INDEX' => 1,
|
||||||
|
'DEL_PREVIOUS' => 0
|
||||||
|
]);
|
||||||
|
$delegation = factory(Delegation::class)->create([
|
||||||
|
"APP_UID" => $app3['APP_UID'],
|
||||||
|
'TAS_ID' => $task2->TAS_ID,
|
||||||
|
'TAS_UID' => $task2->TAS_UID,
|
||||||
|
'DEL_THREAD_STATUS' => 'OPEN',
|
||||||
|
'USR_UID' => $user->USR_UID,
|
||||||
|
'USR_ID' => $user->USR_ID,
|
||||||
|
'PRO_ID' => $process->PRO_ID,
|
||||||
|
'PRO_UID' => $process->PRO_UID,
|
||||||
|
'APP_NUMBER' => $app3['APP_NUMBER'],
|
||||||
|
'DEL_INDEX' => 2,
|
||||||
|
'DEL_PREVIOUS' => 1
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Create the register in the ProcessUser table
|
||||||
|
factory(ProcessUser::class)->create(
|
||||||
|
[
|
||||||
|
'PRO_UID' => $process->PRO_UID,
|
||||||
|
'USR_UID' => $user->USR_UID,
|
||||||
|
'PU_TYPE' => 'SUPERVISOR'
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return $user;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests the getData() method when the user is a supervisor of the process(es)
|
* Tests the getData() method when the user is a supervisor of the process(es)
|
||||||
*
|
*
|
||||||
@@ -290,14 +436,14 @@ class SupervisingTest extends TestCase
|
|||||||
// 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($cases['USR_UID']);
|
||||||
// Set the user ID
|
// Set the user ID
|
||||||
$Supervising->setUserId($cases->USR_ID);
|
$Supervising->setUserId($cases['USR_ID']);
|
||||||
// Set the process Id filter
|
// Set the process Id filter
|
||||||
$Supervising->setProcessId($cases->PRO_ID);
|
$Supervising->setProcessId($cases['PRO_ID']);
|
||||||
// Call the getData method
|
// Call the getData method
|
||||||
$res = $Supervising->getData();
|
$res = $Supervising->getData();
|
||||||
$this->assertCount(1, $res);
|
$this->assertCount(3, $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -314,14 +460,14 @@ class SupervisingTest extends TestCase
|
|||||||
// 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($cases['USR_UID']);
|
||||||
// Set the user ID
|
// Set the user ID
|
||||||
$Supervising->setUserId($cases->USR_ID);
|
$Supervising->setUserId($cases['USR_ID']);
|
||||||
// Set the process Id filter
|
// Set the process Id filter
|
||||||
$Supervising->setProcessId($cases->TAS_ID);
|
$Supervising->setTaskId($cases['TAS_ID']);
|
||||||
// Call the getData method
|
// Call the getData method
|
||||||
$res = $Supervising->getData();
|
$res = $Supervising->getData();
|
||||||
$this->assertCount(1, $res);
|
$this->assertCount(3, $res);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -376,9 +522,9 @@ class SupervisingTest extends TestCase
|
|||||||
// 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($cases['USR_UID']);
|
||||||
//Set the user ID
|
//Set the user ID
|
||||||
$Supervising->setUserId($cases->USR_ID);
|
$Supervising->setUserId($cases['USR_ID']);
|
||||||
//Set the order by value
|
//Set the order by value
|
||||||
$Supervising->setOrderByColumn($columnsView[$index]);
|
$Supervising->setOrderByColumn($columnsView[$index]);
|
||||||
//Call the getData method
|
//Call the getData method
|
||||||
@@ -386,4 +532,31 @@ class SupervisingTest extends TestCase
|
|||||||
$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']);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
* It tests the getPagingCounters() method
|
||||||
|
*
|
||||||
|
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::getPagingCounters()
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_should_test_get_paging_counters_method()
|
||||||
|
{
|
||||||
|
$cases = $this->createMultipleSupervising(3);
|
||||||
|
$supervising = new Supervising();
|
||||||
|
$supervising->setUserId($cases->USR_ID);
|
||||||
|
$supervising->setUserUid($cases->USR_UID);
|
||||||
|
|
||||||
|
$res = $supervising->getPagingCounters();
|
||||||
|
$this->assertEquals(3, $res);
|
||||||
|
|
||||||
|
$delegation = Delegation::select()->where('USR_ID', $cases->USR_ID)->first();
|
||||||
|
|
||||||
|
$supervising->setCaseNumber($delegation->APP_NUMBER);
|
||||||
|
$supervising->setProcessId($delegation->PRO_ID);
|
||||||
|
$supervising->setTaskId($delegation->TAS_ID);
|
||||||
|
$supervising->setCaseUid($delegation->APP_UID);
|
||||||
|
|
||||||
|
$res = $supervising->getPagingCounters();
|
||||||
|
$this->assertEquals(1, $res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -74,6 +74,45 @@ class UnassignedTest extends TestCase
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create many unassigned cases for one user
|
||||||
|
*
|
||||||
|
* @param int
|
||||||
|
* @return object
|
||||||
|
*/
|
||||||
|
public function createMultipleUnassigned($cases)
|
||||||
|
{
|
||||||
|
$user = factory(\ProcessMaker\Model\User::class)->create();
|
||||||
|
|
||||||
|
for ($i = 0; $i < $cases; $i = $i + 1) {
|
||||||
|
$process = factory(Process::class)->create();
|
||||||
|
$application = factory(Application::class)->create([
|
||||||
|
'APP_STATUS_ID' => 2
|
||||||
|
]);
|
||||||
|
$task = factory(Task::class)->create([
|
||||||
|
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
|
||||||
|
'TAS_GROUP_VARIABLE' => '',
|
||||||
|
'PRO_UID' => $process->PRO_UID,
|
||||||
|
'PRO_ID' => $process->PRO_ID,
|
||||||
|
]);
|
||||||
|
factory(TaskUser::class)->create([
|
||||||
|
'TAS_UID' => $task->TAS_UID,
|
||||||
|
'USR_UID' => $user->USR_UID,
|
||||||
|
'TU_RELATION' => 1, //Related to the user
|
||||||
|
'TU_TYPE' => 1
|
||||||
|
]);
|
||||||
|
factory(Delegation::class)->create([
|
||||||
|
'APP_NUMBER' => $application->APP_NUMBER,
|
||||||
|
'TAS_ID' => $task->TAS_ID,
|
||||||
|
'PRO_ID' => $process->PRO_ID,
|
||||||
|
'DEL_THREAD_STATUS' => 'OPEN',
|
||||||
|
'USR_ID' => 0,
|
||||||
|
'DEL_DELEGATE_DATE' => date('Y-m-d H:m:s', strtotime("-$i year"))
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
return $user;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This checks the counters is working properly in self-service user assigned
|
* This checks the counters is working properly in self-service user assigned
|
||||||
*
|
*
|
||||||
@@ -906,4 +945,32 @@ class UnassignedTest extends TestCase
|
|||||||
// Asserts
|
// Asserts
|
||||||
$this->assertNotEmpty($res);
|
$this->assertNotEmpty($res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* It tests the getPagingCounters() method
|
||||||
|
*
|
||||||
|
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getPagingCounters()
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_should_test_get_paging_counters_method()
|
||||||
|
{
|
||||||
|
$cases = $this->createMultipleUnassigned(3);
|
||||||
|
$unassigned = new Unassigned();
|
||||||
|
$unassigned->setUserId($cases->USR_ID);
|
||||||
|
$unassigned->setUserUid($cases->USR_UID);
|
||||||
|
|
||||||
|
$res = $unassigned->getPagingCounters();
|
||||||
|
|
||||||
|
$this->assertEquals(3, $res);
|
||||||
|
|
||||||
|
$delegation = Delegation::select()->where('USR_ID', 0)->first();
|
||||||
|
|
||||||
|
$unassigned->setCaseNumber($delegation->APP_NUMBER);
|
||||||
|
$unassigned->setProcessId($delegation->PRO_ID);
|
||||||
|
$unassigned->setTaskId($delegation->TAS_ID);
|
||||||
|
$unassigned->setCaseUid($delegation->APP_UID);
|
||||||
|
|
||||||
|
$res = $unassigned->getPagingCounters();
|
||||||
|
$this->assertEquals(1, $res);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1256,4 +1256,14 @@ class AbstractCases implements CasesInterface
|
|||||||
{
|
{
|
||||||
throw new Exception("Method '" . __FUNCTION__ . "' should be implemented in the extended class '" . get_class($this) . "'.");
|
throw new Exception("Method '" . __FUNCTION__ . "' should be implemented in the extended class '" . get_class($this) . "'.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the list counter
|
||||||
|
*
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function getPagingCounters()
|
||||||
|
{
|
||||||
|
throw new Exception("Method '" . __FUNCTION__ . "' should be implemented in the extended class '" . get_class($this) . "'.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ class Draft extends AbstractCases
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Count the self-services cases by user
|
* Count how many cases the user has in DRAFT, does not apply filters
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
@@ -119,8 +119,23 @@ class Draft extends AbstractCases
|
|||||||
$query = Delegation::query()->select();
|
$query = Delegation::query()->select();
|
||||||
// Add the initial scope for draft cases
|
// Add the initial scope for draft cases
|
||||||
$query->draft($this->getUserId());
|
$query->draft($this->getUserId());
|
||||||
$this->filters($query);
|
// Return the number of rows
|
||||||
|
return $query->count(['APP_DELEGATION.APP_NUMBER']);
|
||||||
|
}
|
||||||
|
|
||||||
return $query->count();
|
/**
|
||||||
|
* Count how many cases the user has in DRAFT, needs to apply filters
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getPagingCounters()
|
||||||
|
{
|
||||||
|
$query = Delegation::query()->select();
|
||||||
|
// Add the initial scope for draft cases
|
||||||
|
$query->draft($this->getUserId());
|
||||||
|
// Apply filters
|
||||||
|
$this->filters($query);
|
||||||
|
// Return the number of rows
|
||||||
|
return $query->count(['APP_DELEGATION.APP_NUMBER']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,18 +114,32 @@ class Inbox extends AbstractCases
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the number of rows corresponding to the List Inbox
|
* Count how many cases the user has in TO_DO, does not apply filters
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getCounter()
|
public function getCounter()
|
||||||
{
|
{
|
||||||
$query = Delegation::query()->select();
|
$query = Delegation::query()->select();
|
||||||
|
|
||||||
// Scope that sets the queries for List Inbox
|
// Scope that sets the queries for List Inbox
|
||||||
$query->inbox($this->getUserId());
|
$query->inbox($this->getUserId());
|
||||||
|
|
||||||
// Return the number of rows
|
// Return the number of rows
|
||||||
return $query->count();
|
return $query->count(['APP_DELEGATION.APP_NUMBER']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Count how many cases the user has in TO_DO, needs to apply filters
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getPagingCounters()
|
||||||
|
{
|
||||||
|
$query = Delegation::query()->select();
|
||||||
|
// Scope that sets the queries for List Inbox
|
||||||
|
$query->inbox($this->getUserId());
|
||||||
|
// Apply filters
|
||||||
|
$this->filters($query);
|
||||||
|
// Return the number of rows
|
||||||
|
return $query->count(['APP_DELEGATION.APP_NUMBER']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ class Participated extends AbstractCases
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the number of rows corresponding to the Participated
|
* Get the number of rows corresponding has Participation, does not apply filters
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
@@ -249,4 +249,43 @@ class Participated extends AbstractCases
|
|||||||
// Return the number of rows
|
// Return the number of rows
|
||||||
return $query->count(['APP_DELEGATION.APP_NUMBER']);
|
return $query->count(['APP_DELEGATION.APP_NUMBER']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Count how many cases the user has Participation, needs to apply filters
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getPagingCounters()
|
||||||
|
{
|
||||||
|
// Get base query
|
||||||
|
$query = Delegation::query()->select();
|
||||||
|
// Join with application
|
||||||
|
$query->joinApplication();
|
||||||
|
// Scope that sets the queries for Participated
|
||||||
|
$query->participated($this->getUserId());
|
||||||
|
// Get filter
|
||||||
|
$filter = $this->getParticipatedStatus();
|
||||||
|
switch ($filter) {
|
||||||
|
case 'STARTED':
|
||||||
|
// Scope that search for the STARTED by user
|
||||||
|
$query->caseStarted();
|
||||||
|
break;
|
||||||
|
case 'IN_PROGRESS':
|
||||||
|
// Only distinct APP_NUMBER
|
||||||
|
$query->distinct();
|
||||||
|
// Scope for in progress cases
|
||||||
|
$query->statusIds([self::STATUS_DRAFT, self::STATUS_TODO]);
|
||||||
|
break;
|
||||||
|
case 'COMPLETED':
|
||||||
|
// Scope that search for the COMPLETED
|
||||||
|
$query->caseCompleted();
|
||||||
|
// Scope to set the last thread
|
||||||
|
$query->lastThread();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// Apply filters
|
||||||
|
$this->filters($query);
|
||||||
|
// Return the number of rows
|
||||||
|
return $query->count(['APP_DELEGATION.APP_NUMBER']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ class Paused extends AbstractCases
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the total for the paused cases list
|
* Count how many cases the user has in PAUSED, does not apply filters
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
@@ -118,7 +118,23 @@ class Paused extends AbstractCases
|
|||||||
$query = Delegation::query()->select();
|
$query = Delegation::query()->select();
|
||||||
// Scope that set the paused cases
|
// Scope that set the paused cases
|
||||||
$query->paused($this->getUserId(), $this->getTaskId(), $this->getCaseNumber());
|
$query->paused($this->getUserId(), $this->getTaskId(), $this->getCaseNumber());
|
||||||
|
// Return the number of rows
|
||||||
|
return $query->count(['APP_DELEGATION.APP_NUMBER']);
|
||||||
|
}
|
||||||
|
|
||||||
return $query->count();
|
/**
|
||||||
|
* Count how many cases the user has in PAUSED, needs to apply filters
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getPagingCounters()
|
||||||
|
{
|
||||||
|
$query = Delegation::query()->select();
|
||||||
|
// Scope that set the paused cases
|
||||||
|
$query->paused($this->getUserId(), $this->getTaskId(), $this->getCaseNumber());
|
||||||
|
// Apply filters
|
||||||
|
$this->filters($query);
|
||||||
|
// Return the number of rows
|
||||||
|
return $query->count(['APP_DELEGATION.APP_NUMBER']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -177,15 +177,24 @@ class Search extends AbstractCases
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the number of rows corresponding to the advanced search
|
* Count how many cases the user has in the advanced search, does not apply filters
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getCounter()
|
public function getCounter()
|
||||||
{
|
{
|
||||||
$query = Delegation::query()->select();
|
// The search does not have a counters
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Return the number of rows
|
/**
|
||||||
return $query->count();
|
* Get the number of rows corresponding to the advanced search, needs to apply filters
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getPagingCounters()
|
||||||
|
{
|
||||||
|
// The search always will enable the pagination
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -169,7 +169,7 @@ class Supervising extends AbstractCases
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the total of Review cases
|
* Count how many cases the user has in Supervising, does not apply filters
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
@@ -186,4 +186,25 @@ class Supervising extends AbstractCases
|
|||||||
// Return the number of rows
|
// Return the number of rows
|
||||||
return $query->count(['APP_DELEGATION.APP_NUMBER']);
|
return $query->count(['APP_DELEGATION.APP_NUMBER']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Count how many cases the user has in Supervising, needs to apply filters
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getPagingCounters()
|
||||||
|
{
|
||||||
|
// Get base query
|
||||||
|
$query = Delegation::query()->select();
|
||||||
|
// Only distinct APP_NUMBER
|
||||||
|
$query->distinct();
|
||||||
|
// Get the list of processes of the supervisor
|
||||||
|
$processes = ProcessUser::getProcessesOfSupervisor($this->getUserUid());
|
||||||
|
// Scope the specific array of processes supervising
|
||||||
|
$query->processInList($processes);
|
||||||
|
// Apply filters
|
||||||
|
$this->filters($query);
|
||||||
|
// Return the number of rows
|
||||||
|
return $query->count(['APP_DELEGATION.APP_NUMBER']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,15 +119,32 @@ class Unassigned extends AbstractCases
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Count the self-services cases by user
|
* Count how many cases the user has in SELF_SERVICE, does not apply filters
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getCounter()
|
public function getCounter()
|
||||||
{
|
{
|
||||||
$query = Delegation::query()->select();
|
$query = Delegation::query()->select();
|
||||||
|
// Add the initial scope for self-service cases
|
||||||
$query->selfService($this->getUserUid());
|
$query->selfService($this->getUserUid());
|
||||||
|
// Return the number of rows
|
||||||
|
return $query->count(['APP_DELEGATION.APP_NUMBER']);
|
||||||
|
}
|
||||||
|
|
||||||
return $query->count();
|
/**
|
||||||
|
* Count how many cases the user has in SELF_SERVICE, needs to apply filters
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getPagingCounters()
|
||||||
|
{
|
||||||
|
$query = Delegation::query()->select();
|
||||||
|
// Add the initial scope for self-service cases
|
||||||
|
$query->selfService($this->getUserUid());
|
||||||
|
// Apply filters
|
||||||
|
$this->filters($query);
|
||||||
|
// Return the number of rows
|
||||||
|
return $query->count(['APP_DELEGATION.APP_NUMBER']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ class Home extends Api
|
|||||||
$list->setProperties($properties);
|
$list->setProperties($properties);
|
||||||
$result = [];
|
$result = [];
|
||||||
$result['data'] = $list->getData();
|
$result['data'] = $list->getData();
|
||||||
$result['total'] = $list->getCounter();
|
$result['total'] = $list->getPagingCounters();
|
||||||
return $result;
|
return $result;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||||
@@ -141,7 +141,7 @@ class Home extends Api
|
|||||||
$list->setProperties($properties);
|
$list->setProperties($properties);
|
||||||
$result = [];
|
$result = [];
|
||||||
$result['data'] = $list->getData();
|
$result['data'] = $list->getData();
|
||||||
$result['total'] = $list->getCounter();
|
$result['total'] = $list->getPagingCounters();
|
||||||
return $result;
|
return $result;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||||
@@ -198,7 +198,7 @@ class Home extends Api
|
|||||||
$list->setProperties($properties);
|
$list->setProperties($properties);
|
||||||
$result = [];
|
$result = [];
|
||||||
$result['data'] = $list->getData();
|
$result['data'] = $list->getData();
|
||||||
$result['total'] = $list->getCounter();
|
$result['total'] = $list->getPagingCounters();
|
||||||
return $result;
|
return $result;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||||
@@ -253,7 +253,7 @@ class Home extends Api
|
|||||||
$list->setProperties($properties);
|
$list->setProperties($properties);
|
||||||
$result = [];
|
$result = [];
|
||||||
$result['data'] = $list->getData();
|
$result['data'] = $list->getData();
|
||||||
$result['total'] = $list->getCounter();
|
$result['total'] = $list->getPagingCounters();
|
||||||
return $result;
|
return $result;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||||
@@ -329,14 +329,14 @@ class Home extends Api
|
|||||||
$list->setParticipatedStatus($filter);
|
$list->setParticipatedStatus($filter);
|
||||||
$list->setProperties($properties);
|
$list->setProperties($properties);
|
||||||
$result['data'] = $list->getData();
|
$result['data'] = $list->getData();
|
||||||
$result['total'] = $list->getCounter();
|
$result['total'] = $list->getPagingCounters();
|
||||||
break;
|
break;
|
||||||
case 'SUPERVISING':
|
case 'SUPERVISING':
|
||||||
// Scope that search for the SUPERVISING cases by specific user
|
// Scope that search for the SUPERVISING cases by specific user
|
||||||
$list = new Supervising();
|
$list = new Supervising();
|
||||||
$list->setProperties($properties);
|
$list->setProperties($properties);
|
||||||
$result['data'] = $list->getData();
|
$result['data'] = $list->getData();
|
||||||
$result['total'] = $list->getCounter();
|
$result['total'] = $list->getPagingCounters();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user