PMCORE-2399
This commit is contained in:
@@ -23,5 +23,5 @@ return [
|
||||
| directory. However, as usual, you are free to change this value.
|
||||
|
|
||||
*/
|
||||
'compiled' => realpath(PATH_TRUNK . 'bootstrap/cache/views')
|
||||
'compiled' => realpath(dirname(__DIR__) . '/' . 'bootstrap/cache/views')
|
||||
];
|
||||
@@ -24,3 +24,62 @@ $factory->define(\ProcessMaker\Model\AppDelay::class, function (Faker $faker) {
|
||||
'PRO_ID' => $faker->unique()->numberBetween(1000),
|
||||
];
|
||||
});
|
||||
|
||||
// Create a delegation with the foreign keys
|
||||
$factory->state(\ProcessMaker\Model\AppDelay::class, 'paused_foreign_keys', function (Faker $faker) {
|
||||
// Create values in the foreign key relations
|
||||
$user = factory(\ProcessMaker\Model\User::class)->create();
|
||||
$process = factory(\ProcessMaker\Model\Process::class)->create();
|
||||
$task = factory(\ProcessMaker\Model\Task::class)->create([
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'PRO_ID' => $process->PRO_ID
|
||||
]);
|
||||
$application = factory(\ProcessMaker\Model\Application::class)->create([
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'APP_INIT_USER' => $user->USR_UID,
|
||||
'APP_CUR_USER' => $user->USR_UID
|
||||
]);
|
||||
$delegation1 = factory(\ProcessMaker\Model\Delegation::class)->create([
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'PRO_ID' => $process->PRO_ID,
|
||||
'TAS_UID' => $task->TAS_UID,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'APP_UID' => $application->APP_UID,
|
||||
'DEL_THREAD_STATUS' => 'CLOSED',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'DEL_PREVIOUS' => 0,
|
||||
'DEL_INDEX' => 1
|
||||
]);
|
||||
$delegation = factory(\ProcessMaker\Model\Delegation::class)->create([
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'PRO_ID' => $process->PRO_ID,
|
||||
'TAS_UID' => $task->TAS_UID,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'APP_UID' => $application->APP_UID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'DEL_PREVIOUS' => $delegation1->DEL_INDEX,
|
||||
'DEL_INDEX' => $delegation1->DEL_INDEX++
|
||||
]);
|
||||
|
||||
// Return with default values
|
||||
return [
|
||||
'APP_DELAY_UID' => G::generateUniqueID(),
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'PRO_ID' => $process->PRO_ID,
|
||||
'APP_UID' => $application->APP_UID,
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'APP_DEL_INDEX' => $delegation->DEL_INDEX,
|
||||
'APP_TYPE' => 'PAUSE',
|
||||
'APP_STATUS' => $application->APP_STATUS,
|
||||
'APP_DELEGATION_USER' => $user->USR_UID,
|
||||
'APP_DELEGATION_USER_ID' => $user->USR_ID,
|
||||
'APP_ENABLE_ACTION_USER' => G::generateUniqueID(),
|
||||
'APP_ENABLE_ACTION_DATE' => $faker->dateTime(),
|
||||
'APP_DISABLE_ACTION_USER' => 0,
|
||||
];
|
||||
});
|
||||
|
||||
@@ -103,7 +103,7 @@ class AbstractCasesTest extends TestCase
|
||||
public function it_return_set_get_priority()
|
||||
{
|
||||
$absCases = new AbstractCases();
|
||||
$arguments = ['ALL', 'VL', 'L', 'N', 'H', 'VH'];
|
||||
$arguments = ['VL', 'L', 'N', 'H', 'VH'];
|
||||
$index = array_rand($arguments);
|
||||
$absCases->setPriority($arguments[$index]);
|
||||
$actual = $absCases->getPriority();
|
||||
@@ -120,7 +120,7 @@ class AbstractCasesTest extends TestCase
|
||||
public function it_return_set_get_priorities()
|
||||
{
|
||||
$absCases = new AbstractCases();
|
||||
$arguments = ['ALL', 'VL', 'L', 'N', 'H', 'VH'];
|
||||
$arguments = ['VL', 'L', 'N', 'H', 'VH'];
|
||||
$index = array_rand($arguments);
|
||||
$absCases->setPriorities([$arguments[$index]]);
|
||||
$actual = $absCases->getPriorities();
|
||||
@@ -276,16 +276,12 @@ class AbstractCasesTest extends TestCase
|
||||
public function it_return_set_get_case_statuses()
|
||||
{
|
||||
$absCases = new AbstractCases();
|
||||
$arguments = ['ALL', 'DRAFT', 'TO_DO', 'COMPLETED', 'CANCELED'];
|
||||
$arguments = ['DRAFT', 'TO_DO', 'COMPLETED', 'CANCELED'];
|
||||
$index = array_rand($arguments);
|
||||
$absCases->setCaseStatuses([$arguments[$index]]);
|
||||
$actual = $absCases->getCaseStatuses();
|
||||
if ($arguments[$index] === 'ALL') {
|
||||
$this->assertEquals([], $actual);
|
||||
} else {
|
||||
$this->assertEquals([$index], $actual);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This check the getter and setter related to the case
|
||||
@@ -407,11 +403,91 @@ class AbstractCasesTest extends TestCase
|
||||
$actual = $absCases->getLimit();
|
||||
$this->assertEquals($number, $actual);
|
||||
}
|
||||
/**
|
||||
* This check the setter by default related to the properties
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setProperties()
|
||||
* @test
|
||||
*/
|
||||
public function it_return_set_get_properties_default()
|
||||
{
|
||||
$absCases = new AbstractCases();
|
||||
$properties = [];
|
||||
$absCases->setProperties($properties);
|
||||
$actual = $absCases->getProcessId();
|
||||
$this->assertEquals(0, $actual);
|
||||
$actual = $absCases->getTaskId();
|
||||
$this->assertEquals(0, $actual);
|
||||
$actual = $absCases->getTaskId();
|
||||
$this->assertEquals(0, $actual);
|
||||
$actual = $absCases->getUserId();
|
||||
$this->assertEquals(0, $actual);
|
||||
$actual = $absCases->getCaseNumber();
|
||||
$this->assertEquals(0, $actual);
|
||||
$actual = $absCases->getOrderDirection();
|
||||
$this->assertEquals('DESC', $actual);
|
||||
$actual = $absCases->getOrderByColumn();
|
||||
$this->assertEquals('APP_NUMBER', $actual);
|
||||
$actual = $absCases->getOffset();
|
||||
$this->assertEquals(0, $actual);
|
||||
$actual = $absCases->getLimit();
|
||||
$this->assertEquals(15, $actual);
|
||||
// Home - Search
|
||||
$actual = $absCases->getPriorities();
|
||||
$this->assertEmpty($actual);
|
||||
$actual = $absCases->getCaseStatuses();
|
||||
$this->assertEmpty($actual);
|
||||
$actual = $absCases->getFilterCases();
|
||||
$this->assertEmpty($actual);
|
||||
$actual = $absCases->getDelegateFrom();
|
||||
$this->assertEmpty($actual);
|
||||
$actual = $absCases->getDelegateTo();
|
||||
$this->assertEmpty($actual);
|
||||
// Home - My cases
|
||||
$actual = $absCases->getParticipatedStatus();
|
||||
$this->assertEmpty($actual);
|
||||
$actual = $absCases->getCaseNumberFrom();
|
||||
$this->assertEmpty($actual);
|
||||
$actual = $absCases->getCaseNumberTo();
|
||||
$this->assertEmpty($actual);
|
||||
$actual = $absCases->getFinishCaseFrom();
|
||||
$this->assertEmpty($actual);
|
||||
$actual = $absCases->getFinishCaseTo();
|
||||
$this->assertEmpty($actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* This check the setter related all the properties
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setProperties()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setProcessId()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setTaskId()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setUserId()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCaseNumber()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCaseTitle()
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setParticipatedStatus()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCaseStatus()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setStartCaseFrom()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setStartCaseTo()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setFinishCaseFrom()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setFinishCaseTo()
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setFilterCases()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCaseStatuses()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setProperties()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setDelegateFrom()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setDelegateTo()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setDueFrom()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setDueTo()
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCaseUid()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setCasesUids()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setOrderByColumn()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setOrderDirection()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setPaged()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setOffset()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\AbstractCases::setLimit()
|
||||
* @test
|
||||
*/
|
||||
public function it_return_set_get_properties()
|
||||
@@ -431,7 +507,7 @@ class AbstractCasesTest extends TestCase
|
||||
'delegationDateFrom' => date('Y-m-d'),
|
||||
'delegationDateTo' => date('Y-m-d'),
|
||||
// Home - My cases
|
||||
'filter'=> 'ALL',
|
||||
'filter'=> 'STARTED',
|
||||
'caseStatus' => 'TO_DO',
|
||||
'startCaseFrom' => date('Y-m-d'),
|
||||
'startCaseTo' => date('Y-m-d'),
|
||||
@@ -461,9 +537,31 @@ class AbstractCasesTest extends TestCase
|
||||
// Home - Search
|
||||
$actual = $absCases->getPriorities();
|
||||
$this->assertNotEmpty($actual);
|
||||
$actual = $absCases->getCaseStatuses();
|
||||
$this->assertNotEmpty($actual);
|
||||
$actual = $absCases->getFilterCases();
|
||||
$this->assertEquals([1,8], $actual);
|
||||
$actual = $absCases->getCasesNumbers();
|
||||
$this->assertEquals(['3-5','10-15'], $actual);
|
||||
$actual = $absCases->getRangeCasesFromTo();
|
||||
$this->assertNotEmpty($actual);
|
||||
$actual = $absCases->getDelegateFrom();
|
||||
$this->assertEquals($properties['delegationDateFrom'], $actual);
|
||||
$actual = $absCases->getDelegateTo();
|
||||
$this->assertEquals($properties['delegationDateTo'], $actual);
|
||||
// Home - My cases
|
||||
$actual = $absCases->getParticipatedStatus();
|
||||
$this->assertEmpty($actual);
|
||||
$actual = $absCases->getCaseStatus();
|
||||
$this->assertEquals(2, $actual);
|
||||
$actual = $absCases->getStartCaseFrom();
|
||||
$this->assertEquals($properties['startCaseFrom'], $actual);
|
||||
$actual = $absCases->getStartCaseTo();
|
||||
$this->assertEquals($properties['startCaseTo'], $actual);
|
||||
$actual = $absCases->getFinishCaseFrom();
|
||||
$this->assertEquals($properties['finishCaseFrom'], $actual);
|
||||
$actual = $absCases->getFinishCaseTo();
|
||||
$this->assertEquals($properties['finishCaseTo'], $actual);
|
||||
// Other
|
||||
$actual = $absCases->getValueToSearch();
|
||||
$this->assertEquals($properties['search'], $actual);
|
||||
|
||||
@@ -6,9 +6,6 @@ use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use ProcessMaker\BusinessModel\Cases\Draft;
|
||||
use ProcessMaker\Model\Application;
|
||||
use ProcessMaker\Model\Delegation;
|
||||
use ProcessMaker\Model\Process;
|
||||
use ProcessMaker\Model\Task;
|
||||
use ProcessMaker\Model\User;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@@ -27,6 +24,26 @@ class DraftTest extends TestCase
|
||||
$this->markTestIncomplete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create draft cases factories
|
||||
*
|
||||
* @param string
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function createDraft()
|
||||
{
|
||||
$application = factory(Application::class)->states('draft')->create();
|
||||
$delegation = factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'DEL_INDEX' => 1,
|
||||
'APP_UID' => $application->APP_UID,
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
]);
|
||||
|
||||
return $delegation;
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks the counters is working properly in draft
|
||||
*
|
||||
@@ -35,416 +52,105 @@ class DraftTest extends TestCase
|
||||
*/
|
||||
public function it_should_count_cases()
|
||||
{
|
||||
//Create process
|
||||
$process = factory(Process::class)->create();
|
||||
//Create user
|
||||
$user = factory(User::class)->create();
|
||||
//Create a task related with the process
|
||||
$task = factory(Task::class)->create([
|
||||
'PRO_UID' => $process->PRO_UID
|
||||
]);
|
||||
//Create application and app_delegation related with DRAFT status
|
||||
$casesDraft = 25;
|
||||
for ($x = 1; $x <= $casesDraft; $x++) {
|
||||
$application = factory(Application::class)->states('draft')->create();
|
||||
factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
]);
|
||||
}
|
||||
|
||||
//Create application and app_delegation related with OTHER status
|
||||
$casesTodo = 25;
|
||||
for ($x = 1; $x <= $casesTodo; $x++) {
|
||||
$application = factory(Application::class)->states('todo')->create();
|
||||
factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
]);
|
||||
}
|
||||
|
||||
//Review the count draft
|
||||
// Create factories related to the draft cases
|
||||
$cases = $this->createDraft();
|
||||
// Create new Draft object
|
||||
$draft = new Draft();
|
||||
$draft->setUserId($user->USR_ID);
|
||||
$draft->setUserId($cases->USR_ID);
|
||||
$result = $draft->getCounter();
|
||||
$this->assertEquals($casesDraft, $result);
|
||||
$this->assertTrue($result > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks to make sure pagination is working properly in draft
|
||||
* It tests the getData method without filters
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getData()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_return_draft_paged()
|
||||
public function it_should_test_get_data_method_without_filters()
|
||||
{
|
||||
//Create process
|
||||
$process = factory(Process::class)->create();
|
||||
//Create user
|
||||
$user = factory(User::class)->create();
|
||||
//Create a task
|
||||
$task = factory(Task::class)->create([
|
||||
'PRO_UID' => $process->PRO_UID
|
||||
]);
|
||||
//Create application and app_delegation related with DRAFT status
|
||||
$casesDraft = 51;
|
||||
for ($x = 1; $x <= $casesDraft; $x++) {
|
||||
$application = factory(Application::class)->states('draft')->create();
|
||||
factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
]);
|
||||
}
|
||||
|
||||
// Get first page
|
||||
$draft = new Draft();
|
||||
$draft->setUserId($user->USR_ID);
|
||||
$draft->setOrderByColumn('APP_NUMBER');
|
||||
$draft->setOffset(0);
|
||||
$draft->setLimit(25);
|
||||
$results = $draft->getData();
|
||||
$this->assertCount(25, $results);
|
||||
// Get second page
|
||||
$draft->setOffset(25);
|
||||
$draft->setLimit(25);
|
||||
$results = $draft->getData();
|
||||
$this->assertCount(25, $results);
|
||||
// Get third page
|
||||
$draft->setOffset(50);
|
||||
$draft->setLimit(25);
|
||||
$results = $draft->getData();
|
||||
$this->assertCount(1, $results);
|
||||
// Create factories related to the draft cases
|
||||
$cases = $this->createDraft();
|
||||
// Create new Draft object
|
||||
$inbox = new Inbox();
|
||||
// Set the user ID
|
||||
$inbox->setUserId($cases->USR_ID);
|
||||
$inbox->setOrderByColumn('APP_NUMBER');
|
||||
$res = $inbox->getData();
|
||||
$this->assertNotEmpty($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* This ensures ordering ascending and descending works by case number APP_NUMBER in draft
|
||||
* It tests the getData method with Process Filter
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getData()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_return_draft_sort_by_case_number()
|
||||
public function it_should_test_get_data_by_process_filter()
|
||||
{
|
||||
//Create process
|
||||
$process = factory(Process::class)->create();
|
||||
//Create user
|
||||
$user = factory(User::class)->create();
|
||||
//Create a task
|
||||
$task = factory(Task::class)->create([
|
||||
'PRO_UID' => $process->PRO_UID
|
||||
]);
|
||||
//Create application and app_delegation related with DRAFT status with a minor case number
|
||||
$application = factory(Application::class)->states('draft_minor_case')->create();
|
||||
factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
]);
|
||||
//Create application and app_delegation related with DRAFT status with a minor case number
|
||||
$application2 = factory(Application::class)->states('draft_major_case')->create();
|
||||
factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application2->APP_NUMBER,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
]);
|
||||
//Get the data ordered by APP_NUMBER
|
||||
$draft = new Draft();
|
||||
$draft->setUserId($user->USR_ID);
|
||||
$draft->setOrderByColumn('APP_NUMBER');
|
||||
// Get first page, the minor case id
|
||||
$draft->setOrderDirection('ASC');
|
||||
$results = $draft->getData();
|
||||
$this->assertGreaterThan($results[0]['APP_NUMBER'], $results[1]['APP_NUMBER']);
|
||||
// Get first page, the major case id
|
||||
$draft->setOrderDirection('DESC');
|
||||
$results = $draft->getData();
|
||||
$this->assertLessThan($results[0]['APP_NUMBER'], $results[1]['APP_NUMBER']);
|
||||
// Create factories related to the draft cases
|
||||
$cases = $this->createDraft();
|
||||
// Create new Draft object
|
||||
$inbox = new Draft();
|
||||
$inbox->setUserId($cases->USR_ID);
|
||||
$inbox->setProcessId($cases->PRO_ID);
|
||||
$inbox->setOrderByColumn('APP_NUMBER');
|
||||
$res = $inbox->getData();
|
||||
$this->assertNotEmpty($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* This ensures ordering ascending and descending works by case title APP_TITLE in draft
|
||||
* It tests the getData method using OrderBy
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getData()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_return_draft_sort_by_case_title()
|
||||
public function it_should_test_get_data_by_case_number()
|
||||
{
|
||||
$this->markTestIncomplete(
|
||||
'This test needs to write when the column DELEGATION.DEL_THREAD was added'
|
||||
);
|
||||
//Create process
|
||||
$process = factory(Process::class)->create();
|
||||
//Create user
|
||||
$user = factory(User::class)->create();
|
||||
//Create a task
|
||||
$task = factory(Task::class)->create([
|
||||
'PRO_UID' => $process->PRO_UID
|
||||
]);
|
||||
//Create application and app_delegation related with DRAFT status with a minor case title
|
||||
$application = factory(Application::class)->states('draft_minor_case')->create();
|
||||
factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
]);
|
||||
//Create application and app_delegation related with DRAFT status with a minor case title
|
||||
$application2 = factory(Application::class)->states('draft_major_case')->create();
|
||||
factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application2->APP_NUMBER,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
]);
|
||||
// Get first page
|
||||
$draft = new Draft();
|
||||
$draft->setUserId($user->USR_ID);
|
||||
$draft->setOrderByColumn('APPLICATION.APP_TITLE');
|
||||
// Get first page, the minor case title
|
||||
$draft->setOrderDirection('ASC');
|
||||
$results = $draft->getData();
|
||||
$this->assertGreaterThanOrEqual($results[0]['APP_TITLE'], $results[1]['APP_TITLE']);
|
||||
// Get first page, the major case title
|
||||
$draft->setOrderDirection('DESC');
|
||||
$results = $draft->getData();
|
||||
$this->assertLessThanOrEqual($results[0]['APP_TITLE'], $results[1]['APP_TITLE']);
|
||||
// Create factories related to the draft cases
|
||||
$cases = $this->createDraft();
|
||||
// Create new Draft object
|
||||
$inbox = new Draft();
|
||||
$inbox->setUserId($cases->USR_ID);
|
||||
$inbox->setCaseNumber($cases->APP_NUMBER);
|
||||
$inbox->setOrderByColumn('APP_NUMBER');
|
||||
$res = $inbox->getData();
|
||||
$this->assertNotEmpty($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* This ensures ordering ascending and descending works by case title PRO_TITLE in draft
|
||||
* It tests the getData method using OrderBy
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getData()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_return_draft_sort_by_process()
|
||||
public function it_should_test_get_data_by_task_filter()
|
||||
{
|
||||
// Create a user
|
||||
$user = factory(User::class)->create();
|
||||
// Create some cases
|
||||
for ($i = 1; $i <= 2; $i++) {
|
||||
$process = factory(Process::class)->create();
|
||||
$task = factory(Task::class)->create([
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'PRO_ID' => $process->PRO_ID,
|
||||
]);
|
||||
//Create application and app_delegation related with DRAFT status
|
||||
$application = factory(Application::class)->states('draft')->create();
|
||||
factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'PRO_ID' => $process->PRO_ID,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
]);
|
||||
}
|
||||
// Get first page
|
||||
$draft = new Draft();
|
||||
$draft->setUserId($user->USR_ID);
|
||||
$draft->setOrderByColumn('PRO_TITLE');
|
||||
// Get first page, the minor case title
|
||||
$draft->setOrderDirection('ASC');
|
||||
$results = $draft->getData();
|
||||
$this->assertGreaterThan($results[0]['PRO_TITLE'], $results[1]['PRO_TITLE']);
|
||||
// Get first page, the major case title
|
||||
$draft->setOrderDirection('DESC');
|
||||
$results = $draft->getData();
|
||||
$this->assertLessThan($results[0]['PRO_TITLE'], $results[1]['PRO_TITLE']);
|
||||
// Create factories related to the draft cases
|
||||
$cases = $this->createDraft();
|
||||
// Create new Draft object
|
||||
$inbox = new Draft();
|
||||
$inbox->setUserId($cases->USR_ID);
|
||||
$inbox->setTaskId($cases->TAS_ID);
|
||||
$res = $inbox->getData();
|
||||
$this->assertNotEmpty($res);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This ensures ordering ascending and descending works by task title TAS_TITLE in draft
|
||||
* It tests the getData method using OrderBy
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getData()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_return_draft_sort_by_task_title()
|
||||
public function it_should_test_get_data_by_case_title()
|
||||
{
|
||||
//Create process
|
||||
$process = factory(Process::class)->create();
|
||||
//Create user
|
||||
$user = factory(User::class)->create();
|
||||
//Create a task
|
||||
for ($i = 1; $i <= 2; $i++) {
|
||||
$task = factory(Task::class)->create([
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'TAS_TYPE' => 'NORMAL',
|
||||
]);
|
||||
$application = factory(Application::class)->states('draft')->create();
|
||||
factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
]);
|
||||
}
|
||||
// Get first page
|
||||
$draft = new Draft();
|
||||
$draft->setUserId($user->USR_ID);
|
||||
$draft->setOrderByColumn('TAS_TITLE');
|
||||
// Get first page, the minor case title
|
||||
$draft->setOrderDirection('ASC');
|
||||
$results = $draft->getData();
|
||||
$this->assertGreaterThan($results[0]['TAS_TITLE'], $results[1]['TAS_TITLE']);
|
||||
// Get first page, the major case title
|
||||
$draft->setOrderDirection('DESC');
|
||||
$results = $draft->getData();
|
||||
$this->assertLessThan($results[0]['TAS_TITLE'], $results[1]['TAS_TITLE']);
|
||||
}
|
||||
|
||||
/**
|
||||
* This ensures ordering ascending and descending works by due date DEL_TASK_DUE_DATE in draft
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getData()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_return_draft_sort_due_date()
|
||||
{
|
||||
$faker = \Faker\Factory::create();
|
||||
//Create process
|
||||
$process = factory(Process::class)->create();
|
||||
//Create user
|
||||
$user = factory(User::class)->create();
|
||||
//Create a task
|
||||
$task = factory(Task::class)->create([
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'TAS_TYPE' => 'NORMAL',
|
||||
]);
|
||||
//Create application and app_delegation related with DRAFT status
|
||||
$application = factory(Application::class)->states('draft')->create();
|
||||
factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'DEL_TASK_DUE_DATE' => $faker->dateTimeBetween('now', '+1 year')
|
||||
]);
|
||||
//Create the register in delegation related to draft
|
||||
factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'DEL_TASK_DUE_DATE' => $faker->dateTimeBetween('-2 year', '-1 year')
|
||||
]);
|
||||
// Get first page
|
||||
$draft = new Draft();
|
||||
$draft->setUserId($user->USR_ID);
|
||||
$draft->setOrderByColumn('DEL_TASK_DUE_DATE');
|
||||
// Get first page, the minor case title
|
||||
$draft->setOrderDirection('ASC');
|
||||
$results = $draft->getData();
|
||||
$this->assertGreaterThan($results[0]['DEL_TASK_DUE_DATE'], $results[1]['DEL_TASK_DUE_DATE']);
|
||||
// Get first page, the major case title
|
||||
$draft->setOrderDirection('DESC');
|
||||
$results = $draft->getData();
|
||||
$this->assertLessThan($results[0]['DEL_TASK_DUE_DATE'], $results[1]['DEL_TASK_DUE_DATE']);
|
||||
}
|
||||
|
||||
/**
|
||||
* This ensures searching specific cases and review the page in draft
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getData()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_search_draft_search_specific_case_uid()
|
||||
{
|
||||
//Create process
|
||||
$process = factory(Process::class)->create();
|
||||
//Create user
|
||||
$user = factory(User::class)->create();
|
||||
//Create a task
|
||||
$task = factory(Task::class)->create([
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
]);
|
||||
//Create application and app_delegation related with DRAFT status
|
||||
$application = factory(Application::class)->states('draft')->create();
|
||||
factory(Delegation::class)->create([
|
||||
'APP_UID' => $application->APP_UID,
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'USR_ID' => $user->USR_ID
|
||||
]);
|
||||
//Create other cases
|
||||
factory(Delegation::class, 5)->create([
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'USR_ID' => $user->USR_ID
|
||||
]);
|
||||
// Get first page
|
||||
$draft = new Draft();
|
||||
$draft->setUserId($user->USR_ID);
|
||||
$draft->setOrderByColumn('APP_NUMBER');
|
||||
// Get first page, the specific case
|
||||
$draft->setOrderDirection('ASC');
|
||||
$draft->setCaseUid($application->APP_UID);
|
||||
$results = $draft->getData();
|
||||
$this->assertEquals($application->APP_UID, $results[0]['APP_UID']);
|
||||
}
|
||||
|
||||
/**
|
||||
* This ensures searching specific cases and review the page in draft
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getData()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_search_draft_search_specific_cases_uid_array()
|
||||
{
|
||||
//Create process
|
||||
$process = factory(Process::class)->create();
|
||||
//Create user
|
||||
$user = factory(User::class)->create();
|
||||
//Create a task
|
||||
$task = factory(Task::class)->create([
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
]);
|
||||
//Create application and app_delegation related with DRAFT status
|
||||
$application = factory(Application::class)->states('draft')->create();
|
||||
factory(Delegation::class)->create([
|
||||
'APP_UID' => $application->APP_UID,
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'USR_ID' => $user->USR_ID
|
||||
]);
|
||||
// Get first page
|
||||
$draft = new Draft();
|
||||
$draft->setUserId($user->USR_ID);
|
||||
$draft->setOrderByColumn('APP_NUMBER');
|
||||
// Get first page, the specific case
|
||||
$draft->setOrderDirection('ASC');
|
||||
$draft->setCasesUids([$application->APP_UID]);
|
||||
$results = $draft->getData();
|
||||
$this->assertEquals($application->APP_UID, $results[0]['APP_UID']);
|
||||
}
|
||||
|
||||
/**
|
||||
* This ensures searching specific process and review the page in draft
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getData()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_search_draft_search_specific_process()
|
||||
{
|
||||
//Create user
|
||||
$user = factory(User::class)->create();
|
||||
for ($i = 1; $i <= 2; $i++) {
|
||||
//Create process
|
||||
$process = factory(Process::class)->create();
|
||||
$task = factory(Task::class)->create([
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'PRO_ID' => $process->PRO_ID,
|
||||
]);
|
||||
//Create application and app_delegation related with DRAFT status
|
||||
$application = factory(Application::class)->states('draft')->create();
|
||||
factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'PRO_ID' => $process->PRO_ID,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
]);
|
||||
}
|
||||
// Get first page
|
||||
$draft = new Draft();
|
||||
$draft->setUserId($user->USR_ID);
|
||||
$draft->setOrderByColumn('APP_NUMBER');
|
||||
$draft->setProcessId($process->PRO_ID);
|
||||
// Get first page, the minor case title
|
||||
$draft->setOrderDirection('ASC');
|
||||
$results = $draft->getData();
|
||||
$this->assertEquals($process->PRO_TITLE, $results[0]['PRO_TITLE']);
|
||||
// Create factories related to the to_do cases
|
||||
$cases = $this->createDraft();
|
||||
// Create new Draft object
|
||||
$inbox = new Draft();
|
||||
$inbox->setUserId($cases->USR_ID);
|
||||
$res = $inbox->getData();
|
||||
$this->assertNotEmpty($res);
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,23 @@ class InboxTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
/**
|
||||
* Create inbox cases factories
|
||||
*
|
||||
* @param string
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function createInbox()
|
||||
{
|
||||
$delegation = factory(Delegation::class)->states('foreign_keys')->create([
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'DEL_INDEX' => 2,
|
||||
]);
|
||||
|
||||
return $delegation;
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the getData method without filters
|
||||
*
|
||||
@@ -27,89 +44,18 @@ class InboxTest extends TestCase
|
||||
*/
|
||||
public function it_should_test_get_data_method_without_filters()
|
||||
{
|
||||
//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' => '',
|
||||
'TAS_GROUP_VARIABLE' => '',
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
]);
|
||||
//Create the register in delegation
|
||||
factory(Delegation::class, 10)->create([
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process->PRO_ID
|
||||
]);
|
||||
//Create new Inbox object
|
||||
// Create factories related to the to_do cases
|
||||
$cases = $this->createInbox();
|
||||
// Create new Inbox object
|
||||
$inbox = new Inbox();
|
||||
//Set the user UID
|
||||
$inbox->setUserUid($user->USR_UID);
|
||||
//Set the user ID
|
||||
$inbox->setUserId($user->USR_ID);
|
||||
//Set OrderBYColumn value
|
||||
// Set the user ID
|
||||
$inbox->setUserId($cases->USR_ID);
|
||||
// Set OrderBYColumn value
|
||||
$inbox->setOrderByColumn('APP_NUMBER');
|
||||
//Call to getData method
|
||||
// Call to getData method
|
||||
$res = $inbox->getData();
|
||||
//This assert that the expected numbers of results are returned
|
||||
$this->assertEquals(10, count($res));
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the getData method with Category Filter
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
|
||||
* @test
|
||||
*/
|
||||
public function it_it_should_test_get_data_method_with_Category_Filter()
|
||||
{
|
||||
//Create process
|
||||
$process = factory(Process::class)->create(
|
||||
['PRO_CATEGORY' => '248565910552bd7d6006458065223611']
|
||||
);
|
||||
|
||||
//Create user
|
||||
$user = factory(User::class)->create();
|
||||
|
||||
//Create a task
|
||||
$task = factory(Task::class)->create([
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'PRO_ID' => $process->PRO_ID
|
||||
]);
|
||||
|
||||
//Create the register in delegation
|
||||
factory(Delegation::class, 10)->create([
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process->PRO_ID
|
||||
]);
|
||||
|
||||
//Create new Inbox object
|
||||
$inbox = new Inbox();
|
||||
|
||||
//Set the user UID
|
||||
$inbox->setUserUid($user->USR_UID);
|
||||
|
||||
//Set the user ID
|
||||
$inbox->setUserId($user->USR_ID);
|
||||
|
||||
//Set OrderBYColumn value
|
||||
$inbox->setOrderByColumn('APP_NUMBER');
|
||||
|
||||
//Set Category value
|
||||
$inbox->setCategoryUid('248565910552bd7d6006458065223611');
|
||||
|
||||
//Call to getData method
|
||||
$res = $inbox->getData();
|
||||
|
||||
//
|
||||
$this->assertEquals(10, count($res));
|
||||
// This assert that the expected numbers of results are returned
|
||||
$this->assertNotEmpty($res);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -118,39 +64,17 @@ class InboxTest extends TestCase
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
|
||||
* @test
|
||||
*/
|
||||
public function it_it_should_test_get_data_method_with_Process_Filter()
|
||||
public function it_should_test_get_data_by_process_filter()
|
||||
{
|
||||
//Create process
|
||||
$process = factory(Process::class, 2)->create();
|
||||
|
||||
//Create user
|
||||
$user = factory(User::class)->create();
|
||||
|
||||
//Create a task
|
||||
$task = factory(Task::class)->create([
|
||||
'PRO_UID' => $process[0]->PRO_UID,
|
||||
'PRO_ID' => $process[0]->PRO_ID
|
||||
]);
|
||||
|
||||
//Create the register in delegation relate to self-service
|
||||
factory(Delegation::class, 10)->create([
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process[0]->PRO_ID
|
||||
]);
|
||||
|
||||
// Create factories related to the to_do cases
|
||||
$cases = $this->createInbox();
|
||||
// Create new Inbox object
|
||||
$inbox = new Inbox();
|
||||
$inbox->setUserUid($user->USR_UID);
|
||||
$inbox->setUserId($user->USR_ID);
|
||||
$inbox->setUserId($cases->USR_ID);
|
||||
$inbox->setProcessId($cases->PRO_ID);
|
||||
$inbox->setOrderByColumn('APP_NUMBER');
|
||||
$inbox->setProcessId($process[1]->PRO_ID);
|
||||
$res = $inbox->getData();
|
||||
$this->assertEmpty($res);
|
||||
$inbox->setProcessId($process[0]->PRO_ID);
|
||||
$res = $inbox->getData();
|
||||
$this->assertEquals(10, count($res));
|
||||
$this->assertNotEmpty($res);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,43 +83,17 @@ class InboxTest extends TestCase
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_return_inbox_sort_by_case_number()
|
||||
public function it_should_test_get_data_by_case_number()
|
||||
{
|
||||
//Create process
|
||||
$process = factory(Process::class)->create();
|
||||
|
||||
//Create user
|
||||
$user = factory(User::class)->create();
|
||||
|
||||
//Create tasks
|
||||
$task = factory(Task::class)->create([
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'PRO_ID' => $process->PRO_ID
|
||||
]);
|
||||
|
||||
//Create the register in delegation
|
||||
factory(Delegation::class, 10)->create([
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process->PRO_ID
|
||||
]);
|
||||
|
||||
// Create factories related to the to_do cases
|
||||
$cases = $this->createInbox();
|
||||
// Create new Inbox object
|
||||
$inbox = new Inbox();
|
||||
$inbox->setUserUid($user->USR_UID);
|
||||
$inbox->setUserId($user->USR_ID);
|
||||
$inbox->setUserId($cases->USR_ID);
|
||||
$inbox->setCaseNumber($cases->APP_NUMBER);
|
||||
$inbox->setOrderByColumn('APP_NUMBER');
|
||||
$inbox->setOrderDirection('DESC');
|
||||
$res = $inbox->getData();
|
||||
// This asserts the order is for APP_NUMBER from highest to lowest
|
||||
$this->assertLessThan($res[0]['APP_NUMBER'], $res[1]['APP_NUMBER']);
|
||||
|
||||
$inbox->setOrderByColumn('APP_NUMBER');
|
||||
$inbox->setOrderDirection('ASC');
|
||||
$res = $inbox->getData();
|
||||
// This asserts the order is for APP_NUMBER from highest to lowest
|
||||
$this->assertGreaterThan($res[0]['APP_NUMBER'], $res[1]['APP_NUMBER']);
|
||||
$this->assertNotEmpty($res);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -204,40 +102,17 @@ class InboxTest extends TestCase
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_return_inbox_sort_by_task_title()
|
||||
public function it_should_test_get_data_by_task_filter()
|
||||
{
|
||||
//Create process
|
||||
$process = factory(Process::class)->create();
|
||||
//Create user
|
||||
$user = factory(User::class)->create();
|
||||
for ($i = 1; $i <= 2; $i++) {
|
||||
//Create tasks
|
||||
$task = factory(Task::class)->create([
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'PRO_ID' => $process->PRO_ID
|
||||
]);
|
||||
//Create the register in delegation
|
||||
factory(Delegation::class, 10)->create([
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process->PRO_ID
|
||||
]);
|
||||
}
|
||||
|
||||
// Create factories related to the to_do cases
|
||||
$cases = $this->createInbox();
|
||||
// Create new Inbox object
|
||||
$inbox = new Inbox();
|
||||
$inbox->setUserUid($user->USR_UID);
|
||||
$inbox->setUserId($user->USR_ID);
|
||||
$inbox->setOrderByColumn('TASK.TAS_TITLE');
|
||||
$inbox->setOrderDirection('DESC');
|
||||
$inbox->setUserId($cases->USR_ID);
|
||||
$inbox->setTaskId($cases->TAS_ID);
|
||||
$res = $inbox->getData();
|
||||
$this->assertLessThanOrEqual($res[0]['TAS_TITLE'], $res[1]['TAS_TITLE']);
|
||||
$this->assertNotEmpty($res);
|
||||
|
||||
$inbox->setOrderByColumn('TASK.TAS_TITLE');
|
||||
$inbox->setOrderDirection('ASC');
|
||||
$res = $inbox->getData();
|
||||
$this->assertGreaterThanOrEqual($res[0]['TAS_TITLE'], $res[1]['TAS_TITLE']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -246,249 +121,15 @@ class InboxTest extends TestCase
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_return_inbox_sort_by_case_title()
|
||||
public function it_should_test_get_data_by_case_title()
|
||||
{
|
||||
//Create process
|
||||
$process = factory(Process::class)->create();
|
||||
|
||||
//Create user
|
||||
$user = factory(User::class)->create();
|
||||
|
||||
//Create tasks
|
||||
$task = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => '',
|
||||
'TAS_GROUP_VARIABLE' => '',
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
]);
|
||||
|
||||
//Create the register in delegation
|
||||
factory(Delegation::class, 20)->create([
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process->PRO_ID
|
||||
]);
|
||||
|
||||
// Create factories related to the to_do cases
|
||||
$cases = $this->createInbox();
|
||||
// Create new Inbox object
|
||||
$inbox = new Inbox();
|
||||
$inbox->setUserUid($user->USR_UID);
|
||||
$inbox->setUserId($user->USR_ID);
|
||||
$inbox->setOrderByColumn('APP_TITLE');
|
||||
$inbox->setOrderDirection('DESC');
|
||||
$inbox->setUserId($cases->USR_ID);
|
||||
$res = $inbox->getData();
|
||||
// This asserts the order is for APP_TITLE from highest to lowest
|
||||
$this->assertLessThan($res[0]['APP_TITLE'], $res[1]['APP_TITLE']);
|
||||
|
||||
$inbox->setOrderByColumn('APP_TITLE');
|
||||
$inbox->setOrderDirection('ASC');
|
||||
$res = $inbox->getData();
|
||||
// This asserts the order is for APP_TITLE from highest to lowest
|
||||
$this->assertGreaterThan($res[0]['APP_TITLE'], $res[1]['APP_TITLE']);
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the getData method using OrderBy
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_return_inbox_sort_by_process()
|
||||
{
|
||||
//Create process
|
||||
$process1 = factory(Process::class)->create();
|
||||
$process2 = factory(Process::class)->create();
|
||||
|
||||
//Create user
|
||||
$user = factory(User::class)->create();
|
||||
|
||||
//Create tasks
|
||||
$task = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => '',
|
||||
'TAS_GROUP_VARIABLE' => '',
|
||||
'PRO_UID' => $process1->PRO_UID,
|
||||
]);
|
||||
|
||||
//Create the register in delegation
|
||||
factory(Delegation::class, 10)->create([
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process1->PRO_ID
|
||||
]);
|
||||
factory(Delegation::class, 10)->create([
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process2->PRO_ID
|
||||
]);
|
||||
|
||||
$inbox = new Inbox();
|
||||
$inbox->setUserUid($user->USR_UID);
|
||||
$inbox->setUserId($user->USR_ID);
|
||||
$inbox->setOrderByColumn('PROCESS.PRO_TITLE');
|
||||
$inbox->setOrderDirection('DESC');
|
||||
$res = $inbox->getData();
|
||||
// This asserts the order is for PRO_ID from highest to lowest
|
||||
$this->assertLessThanOrEqual($res[0]['PRO_TITLE'], $res[1]['PRO_TITLE']);
|
||||
|
||||
$inbox->setOrderByColumn('PROCESS.PRO_ID');
|
||||
$inbox->setOrderDirection('ASC');
|
||||
$res = $inbox->getData();
|
||||
// This asserts the order is for PRO_ID from highest to lowest
|
||||
$this->assertGreaterThanOrEqual($res[0]['PRO_TITLE'], $res[1]['PRO_TITLE']);
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the getData method using OrderBy
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_return_inbox_sort_by_due_date()
|
||||
{
|
||||
//Create process
|
||||
$process1 = factory(Process::class)->create();
|
||||
$process2 = factory(Process::class)->create();
|
||||
|
||||
//Create user
|
||||
$user = factory(User::class)->create();
|
||||
|
||||
//Create tasks
|
||||
$task = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => '',
|
||||
'TAS_GROUP_VARIABLE' => '',
|
||||
'PRO_UID' => $process1->PRO_UID,
|
||||
]);
|
||||
|
||||
//Create the register in delegation
|
||||
factory(Delegation::class, 10)->create([
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process1->PRO_ID
|
||||
]);
|
||||
factory(Delegation::class, 10)->create([
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process2->PRO_ID
|
||||
]);
|
||||
|
||||
$inbox = new Inbox();
|
||||
$inbox->setUserUid($user->USR_UID);
|
||||
$inbox->setUserId($user->USR_ID);
|
||||
$inbox->setOrderByColumn('DEL_TASK_DUE_DATE');
|
||||
$inbox->setOrderDirection('DESC');
|
||||
$res = $inbox->getData();
|
||||
// This asserts the order is for DEL_TASK_DUE_DATE from highest to lowest
|
||||
$this->assertLessThanOrEqual($res[0]['DEL_TASK_DUE_DATE'], $res[1]['DEL_TASK_DUE_DATE']);
|
||||
|
||||
$inbox->setOrderByColumn('DEL_TASK_DUE_DATE');
|
||||
$inbox->setOrderDirection('ASC');
|
||||
$res = $inbox->getData();
|
||||
// This asserts the order is for DEL_TASK_DUE_DATE from highest to lowest
|
||||
$this->assertGreaterThanOrEqual($res[0]['DEL_TASK_DUE_DATE'], $res[1]['DEL_TASK_DUE_DATE']);
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the getData method using OrderBy
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_return_inbox_sort_by_delegate_date()
|
||||
{
|
||||
//Create process
|
||||
$process1 = factory(Process::class)->create();
|
||||
$process2 = factory(Process::class)->create();
|
||||
|
||||
//Create user
|
||||
$user = factory(User::class)->create();
|
||||
|
||||
//Create tasks
|
||||
$task = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => '',
|
||||
'TAS_GROUP_VARIABLE' => '',
|
||||
'PRO_UID' => $process1->PRO_UID,
|
||||
]);
|
||||
|
||||
//Create the register in delegation
|
||||
factory(Delegation::class, 10)->create([
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process1->PRO_ID
|
||||
]);
|
||||
factory(Delegation::class, 10)->create([
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process2->PRO_ID
|
||||
]);
|
||||
|
||||
$inbox = new Inbox();
|
||||
$inbox->setUserUid($user->USR_UID);
|
||||
$inbox->setUserId($user->USR_ID);
|
||||
$inbox->setOrderByColumn('DEL_DELEGATE_DATE');
|
||||
$inbox->setOrderDirection('DESC');
|
||||
$res = $inbox->getData();
|
||||
// This asserts the order is for APP_UPDATE_DATE from highest to lowest
|
||||
$this->assertLessThanOrEqual($res[0]['DEL_DELEGATE_DATE'], $res[1]['DEL_DELEGATE_DATE']);
|
||||
|
||||
$inbox->setOrderByColumn('DEL_DELEGATE_DATE');
|
||||
$inbox->setOrderDirection('ASC');
|
||||
$res = $inbox->getData();
|
||||
// This asserts the order is for APP_UPDATE_DATE from highest to lowest
|
||||
$this->assertGreaterThanOrEqual($res[0]['DEL_DELEGATE_DATE'], $res[1]['DEL_DELEGATE_DATE']);
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the getData method with pager
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
|
||||
* @test
|
||||
*/
|
||||
public function it_it_should_test_get_data_method_with_pager()
|
||||
{
|
||||
//Create process
|
||||
$process = factory(Process::class)->create(
|
||||
['PRO_CATEGORY' => '248565910552bd7d6006458065223611']
|
||||
);
|
||||
|
||||
//Create user
|
||||
$user = factory(User::class)->create();
|
||||
|
||||
//Create a task
|
||||
$task = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => '',
|
||||
'TAS_GROUP_VARIABLE' => '',
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
]);
|
||||
|
||||
//Create the register in delegation relate to self-service
|
||||
factory(Delegation::class, 50)->create([
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process->PRO_ID
|
||||
]);
|
||||
|
||||
$inbox = new Inbox();
|
||||
$inbox->setUserUid($user->USR_UID);
|
||||
$inbox->setUserId($user->USR_ID);
|
||||
$inbox->setOrderByColumn('APP_NUMBER');
|
||||
$inbox->setOffset(5);
|
||||
$inbox->setLimit(2);
|
||||
$res = $inbox->getData();
|
||||
|
||||
$this->assertEquals(2, count($res));
|
||||
$this->assertNotEmpty($res);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -499,34 +140,12 @@ class InboxTest extends TestCase
|
||||
*/
|
||||
public function it_should_test_the_counter_for_inbox()
|
||||
{
|
||||
//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' => '',
|
||||
'TAS_GROUP_VARIABLE' => '',
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
]);
|
||||
|
||||
//Create the register in delegation relate to self-service
|
||||
factory(Delegation::class, 10)->create([
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process->PRO_ID
|
||||
]);
|
||||
|
||||
//Create the Inbox object
|
||||
// Create factories related to the to_do cases
|
||||
$cases = $this->createInbox();
|
||||
// Create the Inbox object
|
||||
$inbox = new Inbox();
|
||||
$inbox->setUserId($user->USR_ID);
|
||||
$inbox->setUserId($cases->USR_ID);
|
||||
$res = $inbox->getCounter();
|
||||
|
||||
//Assert the result of getCounter method
|
||||
$this->assertEquals(10, $res);
|
||||
$this->assertTrue($res > 0);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases;
|
||||
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use ProcessMaker\BusinessModel\Cases\Paused;
|
||||
use ProcessMaker\Model\Application;
|
||||
use ProcessMaker\Model\AppDelay;
|
||||
@@ -19,96 +20,16 @@ use Tests\TestCase;
|
||||
*/
|
||||
class PausedTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* It tests the getData method without filters
|
||||
*
|
||||
* @covers ::getData()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_get_data_method_without_filters()
|
||||
{
|
||||
//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' => '',
|
||||
'TAS_GROUP_VARIABLE' => '',
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'TAS_TYPE' => 'NORMAL'
|
||||
]);
|
||||
|
||||
$application = factory(Application::class)->create();
|
||||
//Create the register in delegation
|
||||
$delegation1 = factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'CLOSED',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process->PRO_ID,
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'DEL_PREVIOUS' => 0,
|
||||
'DEL_INDEX' => 1
|
||||
]);
|
||||
|
||||
$delegation2 = factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process->PRO_ID,
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'DEL_PREVIOUS' => 1,
|
||||
'DEL_INDEX' => 2
|
||||
]);
|
||||
|
||||
//Create the registers in AppDelay
|
||||
factory(AppDelay::class, 5)->create([
|
||||
'APP_DELEGATION_USER' => $user->USR_UID,
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'APP_NUMBER' => $delegation1->APP_NUMBER,
|
||||
'APP_DEL_INDEX' => $delegation1->DEL_INDEX,
|
||||
'APP_DISABLE_ACTION_USER' => 0,
|
||||
'APP_TYPE' => 'PAUSE'
|
||||
]);
|
||||
//Create the registers in AppDelay
|
||||
factory(AppDelay::class, 5)->create([
|
||||
'APP_DELEGATION_USER' => $user->USR_UID,
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'APP_NUMBER' => $delegation2->APP_NUMBER,
|
||||
'APP_DEL_INDEX' => $delegation2->DEL_INDEX,
|
||||
'APP_DISABLE_ACTION_USER' => 0,
|
||||
'APP_TYPE' => 'PAUSE'
|
||||
]);
|
||||
|
||||
//Create new Paused object
|
||||
$paused = new Paused();
|
||||
|
||||
//Set the user UID
|
||||
$paused->setUserUid($user->USR_UID);
|
||||
|
||||
//Set the user ID
|
||||
$paused->setUserId($user->USR_ID);
|
||||
|
||||
//Call to getData method
|
||||
$res = $paused->getData();
|
||||
|
||||
//This assert that the expected numbers of results are returned with no filters
|
||||
$this->assertEquals(10, count($res));
|
||||
}
|
||||
use DatabaseTransactions;
|
||||
|
||||
/**
|
||||
* It tests the getData method with app number filter
|
||||
* Create paused cases factories
|
||||
*
|
||||
* @covers ::getData()
|
||||
* @test
|
||||
* @param string
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function it_should_test_get_data_method_with_app_number_filter()
|
||||
public function createPaused()
|
||||
{
|
||||
//Create processes
|
||||
$process1 = factory(Process::class)->create(
|
||||
@@ -198,416 +119,117 @@ class PausedTest extends TestCase
|
||||
'APP_TYPE' => 'PAUSE'
|
||||
]);
|
||||
|
||||
return $delegation2;
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the getData method without filters
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getData()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_get_data_method_without_filters()
|
||||
{
|
||||
|
||||
// Create factories related to the to_do cases
|
||||
$cases = $this->createPaused();
|
||||
// Create new Paused object
|
||||
$paused = new Paused();
|
||||
// Set the user UID
|
||||
$paused->setUserUid($cases->USR_UID);
|
||||
// Set the user ID
|
||||
$paused->setUserId($cases->USR_ID);
|
||||
// Call to getData method
|
||||
$res = $paused->getData();
|
||||
// This assert that the expected numbers of results are returned with no filters
|
||||
$this->assertEquals(10, count($res));
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the getData method with app number filter
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getData()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_get_data_by_case_number()
|
||||
{
|
||||
// Create factories related to the to_do cases
|
||||
$cases = $this->createPaused();
|
||||
//Create new Paused object
|
||||
$paused = new Paused();
|
||||
|
||||
//Set the user UID
|
||||
$paused->setUserUid($user->USR_UID);
|
||||
|
||||
$paused->setUserUid($cases->USR_UID);
|
||||
//Set the user ID
|
||||
$paused->setUserId($user->USR_ID);
|
||||
|
||||
$paused->setUserId($cases->USR_ID);
|
||||
//Set app number
|
||||
$paused->setCaseNumber($delegation1->APP_NUMBER);
|
||||
|
||||
$paused->setCaseNumber($cases->APP_NUMBER);
|
||||
//Call to getData method
|
||||
$res = $paused->getData();
|
||||
|
||||
//This asserts there are results for the filtered app number
|
||||
$this->assertCount(5, $res);
|
||||
|
||||
//This asserts the result corresponds to the app number filtered
|
||||
$this->assertEquals($delegation1->APP_NUMBER, $res[0]['APP_NUMBER']);
|
||||
|
||||
//Set app number
|
||||
$paused->setCaseNumber($delegation2->APP_NUMBER);
|
||||
|
||||
//Call to getData method
|
||||
$res = $paused->getData();
|
||||
|
||||
//This asserts there are results for the filtered app number
|
||||
$this->assertCount(5, $res);
|
||||
|
||||
//This asserts the result corresponds to the app number filtered
|
||||
$this->assertEquals($delegation2->APP_NUMBER, $res[0]['APP_NUMBER']);;
|
||||
$this->assertNotEmpty($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the getData method with taskId filter
|
||||
*
|
||||
* @covers ::getData()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getData()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_get_data_method_with_task_id_filter()
|
||||
public function it_should_test_get_data_by_task_filter()
|
||||
{
|
||||
//Create processes
|
||||
$process1 = factory(Process::class)->create();
|
||||
$process2 = factory(Process::class)->create();
|
||||
|
||||
//Create user
|
||||
$user = factory(User::class)->create();
|
||||
|
||||
//Create a task
|
||||
$task1 = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => '',
|
||||
'TAS_GROUP_VARIABLE' => '',
|
||||
'PRO_UID' => $process1->PRO_UID,
|
||||
]);
|
||||
|
||||
$task2 = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => '',
|
||||
'TAS_GROUP_VARIABLE' => '',
|
||||
'PRO_UID' => $process2->PRO_UID,
|
||||
]);
|
||||
|
||||
$application1 = factory(Application::class)->create();
|
||||
$application2 = factory(Application::class)->create();
|
||||
|
||||
//Create the register in delegation
|
||||
factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application1->APP_NUMBER,
|
||||
'TAS_ID' => $task1->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'CLOSED',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process1->PRO_ID,
|
||||
'PRO_UID' => $process1->PRO_UID,
|
||||
'DEL_PREVIOUS' => 0,
|
||||
'DEL_INDEX' => 1
|
||||
]);
|
||||
$delegation1 = factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application1->APP_NUMBER,
|
||||
'TAS_ID' => $task1->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'CLOSED',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process1->PRO_ID,
|
||||
'PRO_UID' => $process1->PRO_UID,
|
||||
'DEL_PREVIOUS' => 1,
|
||||
'DEL_INDEX' => 2
|
||||
]);
|
||||
|
||||
factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application2->APP_NUMBER,
|
||||
'TAS_ID' => $task2->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process2->PRO_ID,
|
||||
'PRO_UID' => $process2->PRO_UID,
|
||||
'DEL_PREVIOUS' => 0,
|
||||
'DEL_INDEX' => 1
|
||||
]);
|
||||
$delegation2 = factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application2->APP_NUMBER,
|
||||
'TAS_ID' => $task2->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process2->PRO_ID,
|
||||
'PRO_UID' => $process2->PRO_UID,
|
||||
'DEL_PREVIOUS' => 1,
|
||||
'DEL_INDEX' => 2
|
||||
]);
|
||||
|
||||
//Create the registers in AppDelay
|
||||
factory(AppDelay::class, 5)->create([
|
||||
'APP_DELEGATION_USER' => $user->USR_UID,
|
||||
'PRO_UID' => $process2->PRO_UID,
|
||||
'APP_NUMBER' => $delegation1->APP_NUMBER,
|
||||
'APP_DEL_INDEX' => $delegation1->DEL_INDEX,
|
||||
'APP_DISABLE_ACTION_USER' => 0,
|
||||
'APP_TYPE' => 'PAUSE'
|
||||
]);
|
||||
//Create the registers in AppDelay
|
||||
factory(AppDelay::class, 5)->create([
|
||||
'APP_DELEGATION_USER' => $user->USR_UID,
|
||||
'PRO_UID' => $process2->PRO_UID,
|
||||
'APP_NUMBER' => $delegation2->APP_NUMBER,
|
||||
'APP_DEL_INDEX' => $delegation2->DEL_INDEX,
|
||||
'APP_DISABLE_ACTION_USER' => 0,
|
||||
'APP_TYPE' => 'PAUSE'
|
||||
]);
|
||||
|
||||
//Create new Paused object
|
||||
// Create factories related to the to_do cases
|
||||
$cases = $this->createPaused();
|
||||
// Create new Paused object
|
||||
$paused = new Paused();
|
||||
|
||||
//Set the user UID
|
||||
$paused->setUserUid($user->USR_UID);
|
||||
|
||||
//Set the user ID
|
||||
$paused->setUserId($user->USR_ID);
|
||||
|
||||
//Set taskId
|
||||
$paused->setTaskId($task1->TAS_ID);
|
||||
|
||||
//Call to getData method
|
||||
// Set the user UID
|
||||
$paused->setUserUid($cases->USR_UID);
|
||||
// Set the user ID
|
||||
$paused->setUserId($cases->USR_ID);
|
||||
// Set taskId
|
||||
$paused->setTaskId($cases->TAS_ID);
|
||||
// Call to getData method
|
||||
$res = $paused->getData();
|
||||
|
||||
//This asserts there are results for the filtered task
|
||||
$this->assertCount(5, $res);
|
||||
|
||||
//This asserts the result corresponds to the task filtered
|
||||
$this->assertEquals($task1->TAS_TITLE, $res[0]['TAS_TITLE']);
|
||||
|
||||
//Set taskId
|
||||
$paused->setTaskId($task2->TAS_ID);
|
||||
|
||||
//Call to getData method
|
||||
$res = $paused->getData();
|
||||
|
||||
//This asserts there are results for the filtered task
|
||||
$this->assertCount(5, $res);
|
||||
|
||||
//This asserts the result corresponds to the task filtered
|
||||
$this->assertEquals($task2->TAS_TITLE, $res[0]['TAS_TITLE']);
|
||||
// This asserts there are results for the filtered task
|
||||
$this->assertNotEmpty($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the getData method using OrderBy Case Number
|
||||
*
|
||||
* @covers ::getData()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getData()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_return_inbox_sort_by_case_number()
|
||||
public function it_should_test_get_data_by_process_filter()
|
||||
{
|
||||
//Create processes
|
||||
$process1 = factory(Process::class)->create();
|
||||
$process2 = factory(Process::class)->create();
|
||||
|
||||
//Create user
|
||||
$user = factory(User::class)->create();
|
||||
|
||||
//Create a task
|
||||
$task1 = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => '',
|
||||
'TAS_GROUP_VARIABLE' => '',
|
||||
'PRO_UID' => $process1->PRO_UID,
|
||||
]);
|
||||
|
||||
$task2 = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => '',
|
||||
'TAS_GROUP_VARIABLE' => '',
|
||||
'PRO_UID' => $process2->PRO_UID,
|
||||
]);
|
||||
|
||||
$application1 = factory(Application::class)->create();
|
||||
$application2 = factory(Application::class)->create();
|
||||
|
||||
//Create the register in delegation
|
||||
factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application1->APP_NUMBER,
|
||||
'TAS_ID' => $task1->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'CLOSED',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process1->PRO_ID,
|
||||
'PRO_UID' => $process1->PRO_UID,
|
||||
'DEL_PREVIOUS' => 0,
|
||||
'DEL_INDEX' => 1
|
||||
]);
|
||||
$delegation1 = factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application1->APP_NUMBER,
|
||||
'TAS_ID' => $task1->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'CLOSED',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process1->PRO_ID,
|
||||
'PRO_UID' => $process1->PRO_UID,
|
||||
'DEL_PREVIOUS' => 1,
|
||||
'DEL_INDEX' => 2
|
||||
]);
|
||||
|
||||
factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application2->APP_NUMBER,
|
||||
'TAS_ID' => $task2->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process2->PRO_ID,
|
||||
'PRO_UID' => $process2->PRO_UID,
|
||||
'DEL_PREVIOUS' => 0,
|
||||
'DEL_INDEX' => 1
|
||||
]);
|
||||
$delegation2 = factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application2->APP_NUMBER,
|
||||
'TAS_ID' => $task2->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process2->PRO_ID,
|
||||
'PRO_UID' => $process2->PRO_UID,
|
||||
'DEL_PREVIOUS' => 1,
|
||||
'DEL_INDEX' => 2
|
||||
]);
|
||||
|
||||
//Create the registers in AppDelay
|
||||
factory(AppDelay::class, 5)->create([
|
||||
'APP_DELEGATION_USER' => $user->USR_UID,
|
||||
'PRO_UID' => $process2->PRO_UID,
|
||||
'APP_NUMBER' => $delegation1->APP_NUMBER,
|
||||
'APP_DEL_INDEX' => $delegation1->DEL_INDEX,
|
||||
'APP_DISABLE_ACTION_USER' => 0,
|
||||
'APP_TYPE' => 'PAUSE'
|
||||
]);
|
||||
//Create the registers in AppDelay
|
||||
factory(AppDelay::class, 5)->create([
|
||||
'APP_DELEGATION_USER' => $user->USR_UID,
|
||||
'PRO_UID' => $process2->PRO_UID,
|
||||
'APP_NUMBER' => $delegation2->APP_NUMBER,
|
||||
'APP_DEL_INDEX' => $delegation2->DEL_INDEX,
|
||||
'APP_DISABLE_ACTION_USER' => 0,
|
||||
'APP_TYPE' => 'PAUSE'
|
||||
]);
|
||||
|
||||
//Create new Paused object
|
||||
// Create factories related to the to_do cases
|
||||
$cases = $this->createPaused();
|
||||
// Create new Paused object
|
||||
$paused = new Paused();
|
||||
|
||||
//Set the user UID
|
||||
$paused->setUserUid($user->USR_UID);
|
||||
|
||||
//Set the user ID
|
||||
$paused->setUserId($user->USR_ID);
|
||||
|
||||
//Set OrderBYColumn value
|
||||
$paused->setOrderByColumn('APP_NUMBER');
|
||||
|
||||
//Set Order Direction value
|
||||
$paused->setOrderDirection('DESC');
|
||||
|
||||
//Call to getData method
|
||||
// Set the user UID
|
||||
$paused->setUserUid($cases->USR_UID);
|
||||
// Set the user ID
|
||||
$paused->setUserId($cases->USR_ID);
|
||||
$paused->setProcessId($cases->PRO_ID);
|
||||
// Call to getData method
|
||||
$res = $paused->getData();
|
||||
|
||||
//Asserts that the order is descending
|
||||
$this->assertGreaterThan($res[count($res) - 1]['APP_NUMBER'], $res[0]['APP_NUMBER']);
|
||||
|
||||
//Set Order Direction value
|
||||
$paused->setOrderDirection('ASC');
|
||||
|
||||
//Call to getData method
|
||||
$res = $paused->getData();
|
||||
|
||||
//Asserts that the order is ascending
|
||||
$this->assertLessThan($res[count($res) - 1]['APP_NUMBER'], $res[0]['APP_NUMBER']);
|
||||
$this->assertNotEmpty($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the limit
|
||||
* It tests the getData method using OrderBy
|
||||
*
|
||||
* @covers ::getData()
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getData()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_get_data_method_with_limit()
|
||||
public function it_should_test_get_data_by_case_title()
|
||||
{
|
||||
//Create processes
|
||||
$process1 = factory(Process::class)->create();
|
||||
$process2 = factory(Process::class)->create();
|
||||
|
||||
//Create user
|
||||
$user = factory(User::class)->create();
|
||||
|
||||
//Create a task
|
||||
$task1 = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => '',
|
||||
'TAS_GROUP_VARIABLE' => '',
|
||||
'PRO_UID' => $process1->PRO_UID,
|
||||
]);
|
||||
|
||||
$task2 = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => '',
|
||||
'TAS_GROUP_VARIABLE' => '',
|
||||
'PRO_UID' => $process2->PRO_UID,
|
||||
]);
|
||||
|
||||
$application1 = factory(Application::class)->create();
|
||||
$application2 = factory(Application::class)->create();
|
||||
|
||||
//Create the register in delegation
|
||||
factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application1->APP_NUMBER,
|
||||
'TAS_ID' => $task1->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'CLOSED',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process1->PRO_ID,
|
||||
'PRO_UID' => $process1->PRO_UID,
|
||||
'DEL_PREVIOUS' => 0,
|
||||
'DEL_INDEX' => 1
|
||||
]);
|
||||
$delegation1 = factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application1->APP_NUMBER,
|
||||
'TAS_ID' => $task1->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'CLOSED',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process1->PRO_ID,
|
||||
'PRO_UID' => $process1->PRO_UID,
|
||||
'DEL_PREVIOUS' => 1,
|
||||
'DEL_INDEX' => 2
|
||||
]);
|
||||
|
||||
factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application2->APP_NUMBER,
|
||||
'TAS_ID' => $task2->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process2->PRO_ID,
|
||||
'PRO_UID' => $process2->PRO_UID,
|
||||
'DEL_PREVIOUS' => 0,
|
||||
'DEL_INDEX' => 1
|
||||
]);
|
||||
$delegation2 = factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application2->APP_NUMBER,
|
||||
'TAS_ID' => $task2->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process2->PRO_ID,
|
||||
'PRO_UID' => $process2->PRO_UID,
|
||||
'DEL_PREVIOUS' => 1,
|
||||
'DEL_INDEX' => 2
|
||||
]);
|
||||
|
||||
//Create the registers in AppDelay
|
||||
factory(AppDelay::class, 5)->create([
|
||||
'APP_DELEGATION_USER' => $user->USR_UID,
|
||||
'PRO_UID' => $process2->PRO_UID,
|
||||
'APP_NUMBER' => $delegation1->APP_NUMBER,
|
||||
'APP_DEL_INDEX' => $delegation1->DEL_INDEX,
|
||||
'APP_DISABLE_ACTION_USER' => 0,
|
||||
'APP_TYPE' => 'PAUSE'
|
||||
]);
|
||||
//Create the registers in AppDelay
|
||||
factory(AppDelay::class, 5)->create([
|
||||
'APP_DELEGATION_USER' => $user->USR_UID,
|
||||
'PRO_UID' => $process2->PRO_UID,
|
||||
'APP_NUMBER' => $delegation2->APP_NUMBER,
|
||||
'APP_DEL_INDEX' => $delegation2->DEL_INDEX,
|
||||
'APP_DISABLE_ACTION_USER' => 0,
|
||||
'APP_TYPE' => 'PAUSE'
|
||||
]);
|
||||
|
||||
//Create new Paused object
|
||||
// Create factories related to the to_do cases
|
||||
$cases = $this->createPaused();
|
||||
// Create new Inbox object
|
||||
$paused = new Paused();
|
||||
|
||||
//Set the user UID
|
||||
$paused->setUserUid($user->USR_UID);
|
||||
|
||||
//Set the user ID
|
||||
$paused->setUserId($user->USR_ID);
|
||||
|
||||
//Set OrderBYColumn value
|
||||
$paused->setOrderByColumn('APP_NUMBER');
|
||||
|
||||
//Set offset and limit values
|
||||
$paused->setOffset(0);
|
||||
$paused->setLimit(2);
|
||||
|
||||
//Call to getData method
|
||||
$paused->setUserUid($cases->USR_UID);
|
||||
$paused->setUserId($cases->USR_ID);
|
||||
$res = $paused->getData();
|
||||
|
||||
//This assert that there are results with read inbox status
|
||||
$this->assertCount(2, $res);
|
||||
$this->assertNotEmpty($res);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases;
|
||||
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use ProcessMaker\BusinessModel\Cases\Supervising;
|
||||
use ProcessMaker\Model\Application;
|
||||
use ProcessMaker\Model\Delegation;
|
||||
@@ -17,14 +18,16 @@ use Tests\TestCase;
|
||||
*/
|
||||
class SupervisingTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
/**
|
||||
* Tests the getData() method when the user is a supervisor of the process(es)
|
||||
* Create supervising cases factories
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::getData()
|
||||
* @test
|
||||
* @param string
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function it_should_test_the_get_data_method_when_the_user_is_supervisor()
|
||||
public function createSupervising()
|
||||
{
|
||||
// Create process
|
||||
$process = factory(Process::class)->create();
|
||||
@@ -68,7 +71,7 @@ class SupervisingTest extends TestCase
|
||||
]);
|
||||
|
||||
// Create the registers in delegation
|
||||
factory(Delegation::class, 1)->create([
|
||||
factory(Delegation::class)->create([
|
||||
"APP_UID" => $app1['APP_UID'],
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'TAS_UID' => $task->TAS_UID,
|
||||
@@ -135,7 +138,7 @@ class SupervisingTest extends TestCase
|
||||
'DEL_INDEX' => 1,
|
||||
'DEL_PREVIOUS' =>0
|
||||
]);
|
||||
factory(Delegation::class, 1)->create([
|
||||
$delegation = factory(Delegation::class)->create([
|
||||
"APP_UID" => $app3['APP_UID'],
|
||||
'TAS_ID' => $task2->TAS_ID,
|
||||
'TAS_UID' => $task2->TAS_UID,
|
||||
@@ -158,18 +161,26 @@ class SupervisingTest extends TestCase
|
||||
]
|
||||
);
|
||||
|
||||
return $delegation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the getData() method when the user is a supervisor of the process(es)
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::getData()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_the_get_data_method_when_the_user_is_supervisor()
|
||||
{
|
||||
$cases = $this->createSupervising();
|
||||
// Instance the Supervising class
|
||||
$Supervising = new Supervising();
|
||||
|
||||
// Set the user UID
|
||||
$Supervising->setUserUid($user->USR_UID);
|
||||
|
||||
$Supervising->setUserUid($cases->USR_UID);
|
||||
// Set the user ID
|
||||
$Supervising->setUserId($user->USR_ID);
|
||||
|
||||
$Supervising->setUserId($cases->USR_ID);
|
||||
// Call the getData method
|
||||
$res = $Supervising->getData();
|
||||
|
||||
// Asserts the result contains 3 registers
|
||||
$this->assertCount(3, $res);
|
||||
}
|
||||
@@ -182,153 +193,15 @@ class SupervisingTest extends TestCase
|
||||
*/
|
||||
public function it_should_test_the_get_data_method_when_the_user_belong_to_a_group_supervisor()
|
||||
{
|
||||
//Create process
|
||||
$process = factory(Process::class)->create();
|
||||
|
||||
//Create user
|
||||
$user = factory(User::class)->create();
|
||||
|
||||
$groupUser = factory(GroupUser::class)->create([
|
||||
'USR_UID' => $user['USR_UID']
|
||||
]);
|
||||
|
||||
//Create a task
|
||||
$task = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => '',
|
||||
'TAS_GROUP_VARIABLE' => '',
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
]);
|
||||
$task2 = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => 'NORMAL',
|
||||
'TAS_GROUP_VARIABLE' => '',
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
]);
|
||||
|
||||
$app1 = factory(Application::class)->states('todo')->create([
|
||||
'APP_STATUS' => 'TO_DO',
|
||||
'APP_STATUS_ID' => 2,
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'APP_INIT_USER' => $user->USR_UID,
|
||||
'APP_CUR_USER' => $user->USR_UID,
|
||||
]);
|
||||
$app2 = factory(Application::class)->states('todo')->create([
|
||||
'APP_STATUS' => 'TO_DO',
|
||||
'APP_STATUS_ID' => 2,
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'APP_INIT_USER' => $user->USR_UID,
|
||||
'APP_CUR_USER' => $user->USR_UID,
|
||||
]);
|
||||
$app3 = factory(Application::class)->states('todo')->create([
|
||||
'APP_STATUS' => 'TO_DO',
|
||||
'APP_STATUS_ID' => 2,
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'APP_INIT_USER' => $user->USR_UID,
|
||||
'APP_CUR_USER' => $user->USR_UID,
|
||||
]);
|
||||
|
||||
//Create the register in delegation
|
||||
factory(Delegation::class, 1)->create([
|
||||
"APP_UID" => $app1['APP_UID'],
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'TAS_UID' => $task->TAS_UID,
|
||||
'DEL_THREAD_STATUS' => 'CLOSED',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process->PRO_ID,
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'APP_NUMBER' => $app1['APP_NUMBER'],
|
||||
'DEL_INDEX' => 1,
|
||||
'DEL_PREVIOUS' =>0
|
||||
]);
|
||||
factory(Delegation::class, 1)->create([
|
||||
"APP_UID" => $app1['APP_UID'],
|
||||
'TAS_ID' => $task2->TAS_ID,
|
||||
'TAS_UID' => $task2->TAS_UID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process->PRO_ID,
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'APP_NUMBER' => $app1['APP_NUMBER'],
|
||||
'DEL_INDEX' => 2,
|
||||
'DEL_PREVIOUS' =>1
|
||||
]);
|
||||
|
||||
factory(Delegation::class, 1)->create([
|
||||
"APP_UID" => $app2['APP_UID'],
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'TAS_UID' => $task->TAS_UID,
|
||||
'DEL_THREAD_STATUS' => 'CLOSED',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process->PRO_ID,
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'APP_NUMBER' => $app2['APP_NUMBER'],
|
||||
'DEL_INDEX' => 1,
|
||||
'DEL_PREVIOUS' =>0
|
||||
]);
|
||||
factory(Delegation::class, 1)->create([
|
||||
"APP_UID" => $app2['APP_UID'],
|
||||
'TAS_ID' => $task2->TAS_ID,
|
||||
'TAS_UID' => $task2->TAS_UID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process->PRO_ID,
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'APP_NUMBER' => $app2['APP_NUMBER'],
|
||||
'DEL_INDEX' => 2,
|
||||
'DEL_PREVIOUS' =>1
|
||||
]);
|
||||
|
||||
factory(Delegation::class, 1)->create([
|
||||
"APP_UID" => $app3['APP_UID'],
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'TAS_UID' => $task->TAS_UID,
|
||||
'DEL_THREAD_STATUS' => 'CLOSED',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process->PRO_ID,
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'APP_NUMBER' => $app3['APP_NUMBER'],
|
||||
'DEL_INDEX' => 1,
|
||||
'DEL_PREVIOUS' =>0
|
||||
]);
|
||||
factory(Delegation::class, 1)->create([
|
||||
"APP_UID" => $app3['APP_UID'],
|
||||
'TAS_ID' => $task2->TAS_ID,
|
||||
'TAS_UID' => $task2->TAS_UID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process->PRO_ID,
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'APP_NUMBER' => $app3['APP_NUMBER'],
|
||||
'DEL_INDEX' => 2,
|
||||
'DEL_PREVIOUS' =>1
|
||||
]);
|
||||
|
||||
//Create the register in the ProcessUser table
|
||||
factory(ProcessUser::class)->create(
|
||||
[
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'USR_UID' => $groupUser->USR_UID,
|
||||
'PU_TYPE' => 'SUPERVISOR'
|
||||
]
|
||||
);
|
||||
|
||||
$cases = $this->createSupervising();
|
||||
// Instance the Supervising object
|
||||
$Supervising = new Supervising();
|
||||
|
||||
//Set the user UID
|
||||
$Supervising->setUserUid($user->USR_UID);
|
||||
|
||||
$Supervising->setUserUid($cases->USR_UID);
|
||||
//Set the user ID
|
||||
$Supervising->setUserId($user->USR_ID);
|
||||
|
||||
$Supervising->setUserId($cases->USR_ID);
|
||||
//Call the getData method
|
||||
$res = $Supervising->getData();
|
||||
|
||||
// Asserts the result contains 3 registers
|
||||
$this->assertCount(3, $res);
|
||||
}
|
||||
@@ -341,65 +214,16 @@ class SupervisingTest extends TestCase
|
||||
*/
|
||||
public function it_should_test_the_get_data_method_when_the_user_is_not_supervisor()
|
||||
{
|
||||
//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' => '',
|
||||
'TAS_GROUP_VARIABLE' => '',
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
]);
|
||||
|
||||
$app1 = factory(Application::class)->states('todo')->create();
|
||||
$app2 = factory(Application::class)->states('todo')->create();
|
||||
$app3 = factory(Application::class)->states('todo')->create();
|
||||
|
||||
//Create the register in delegation
|
||||
factory(Delegation::class, 1)->create([
|
||||
"APP_UID" => $app1['APP_UID'],
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process->PRO_ID,
|
||||
'APP_NUMBER' => $app1['APP_NUMBER']
|
||||
]);
|
||||
factory(Delegation::class, 1)->create([
|
||||
"APP_UID" => $app2['APP_UID'],
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process->PRO_ID,
|
||||
'APP_NUMBER' => $app2['APP_NUMBER']
|
||||
]);
|
||||
factory(Delegation::class, 1)->create([
|
||||
"APP_UID" => $app3['APP_UID'],
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process->PRO_ID,
|
||||
'APP_NUMBER' => $app3['APP_NUMBER']
|
||||
]);
|
||||
|
||||
$cases = $this->createSupervising();
|
||||
// Instance the Supervising object
|
||||
$Supervising = new Supervising();
|
||||
|
||||
//Set the user UID
|
||||
$Supervising->setUserUid($user->USR_UID);
|
||||
|
||||
//Set the user ID
|
||||
$Supervising->setUserId($user->USR_ID);
|
||||
|
||||
//Call the getData method
|
||||
$res = $Supervising->getData();
|
||||
|
||||
|
||||
// Asserts the result
|
||||
$this->assertEmpty($res);
|
||||
}
|
||||
@@ -412,74 +236,15 @@ class SupervisingTest extends TestCase
|
||||
*/
|
||||
public function it_should_count_the_data()
|
||||
{
|
||||
//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' => '',
|
||||
'TAS_GROUP_VARIABLE' => '',
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
]);
|
||||
|
||||
//Create 3 cases
|
||||
$app1 = factory(Application::class)->states('todo')->create();
|
||||
$app2 = factory(Application::class)->states('todo')->create();
|
||||
$app3 = factory(Application::class)->states('todo')->create();
|
||||
|
||||
//Create the registers in delegation
|
||||
factory(Delegation::class, 1)->create([
|
||||
"APP_UID" => $app1['APP_UID'],
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process->PRO_ID,
|
||||
'APP_NUMBER' => $app1['APP_NUMBER']
|
||||
]);
|
||||
factory(Delegation::class, 1)->create([
|
||||
"APP_UID" => $app2['APP_UID'],
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process->PRO_ID,
|
||||
'APP_NUMBER' => $app2['APP_NUMBER']
|
||||
]);
|
||||
factory(Delegation::class, 1)->create([
|
||||
"APP_UID" => $app3['APP_UID'],
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->USR_ID,
|
||||
'PRO_ID' => $process->PRO_ID,
|
||||
'APP_NUMBER' => $app3['APP_NUMBER']
|
||||
]);
|
||||
|
||||
//Create the register in the ProcessUser table
|
||||
factory(ProcessUser::class)->create(
|
||||
[
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'PU_TYPE' => 'SUPERVISOR'
|
||||
]
|
||||
);
|
||||
|
||||
$cases = $this->createSupervising();
|
||||
// Instance the Supervising object
|
||||
$Supervising = new Supervising();
|
||||
|
||||
//Set the user UID
|
||||
$Supervising->setUserUid($user->USR_UID);
|
||||
|
||||
$Supervising->setUserUid($cases->USR_UID);
|
||||
//Set the user ID
|
||||
$Supervising->setUserId($user->USR_ID);
|
||||
|
||||
$Supervising->setUserId($cases->USR_ID);
|
||||
//Call the getCounter method
|
||||
$res = $Supervising->getCounter();
|
||||
|
||||
//Assert the counter
|
||||
$this->assertEquals(3, $res);
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ class DelegationTest extends TestCase
|
||||
public function it_return_scope_delegate_date_from()
|
||||
{
|
||||
$table = factory(Delegation::class)->states('foreign_keys')->create();
|
||||
$this->assertCount(1, $table->delegateDateFrom($table->DEL_DELEGATE_DATE)->get());
|
||||
$this->assertCount(1, $table->delegateDateFrom($table->DEL_DELEGATE_DATE->format("Y-m-d"))->get());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,7 +121,7 @@ class DelegationTest extends TestCase
|
||||
public function it_return_scope_delegate_date_to()
|
||||
{
|
||||
$table = factory(Delegation::class)->states('foreign_keys')->create();
|
||||
$this->assertCount(1, $table->delegateDateTo($table->DEL_DELEGATE_DATE)->get());
|
||||
$this->assertCount(1, $table->delegateDateTo($table->DEL_DELEGATE_DATE->format("Y-m-d"))->get());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,11 +15,11 @@ class AbstractCases implements CasesInterface
|
||||
const INBOX_STATUSES = ['ALL', 'READ', 'UNREAD'];
|
||||
const PARTICIPATED_STATUSES = ['ALL', 'STARTED', 'IN_PROGRESS', 'COMPLETED', 'SUPERVISING'];
|
||||
const RISK_STATUSES = ['ALL', 'ON_TIME', 'AT_RISK', 'OVERDUE'];
|
||||
const CASE_STATUSES = [0 => 'ALL', 1 => 'DRAFT', 2 => 'TO_DO', 3 => 'COMPLETED', 4 => 'CANCELED'];
|
||||
const CASE_STATUSES = [1 => 'DRAFT', 2 => 'TO_DO', 3 => 'COMPLETED', 4 => 'CANCELED'];
|
||||
const ORDER_DIRECTIONS = ['DESC', 'ASC'];
|
||||
const CORRECT_CANCELED_STATUS = 'CANCELED';
|
||||
const INCORRECT_CANCELED_STATUS = 'CANCELLED';
|
||||
const PRIORITIES = [0 => 'ALL', 1 => 'VL', 2 => 'L', 3 => 'N', 4 => 'H', 5 => 'VH'];
|
||||
const PRIORITIES = [1 => 'VL', 2 => 'L', 3 => 'N', 4 => 'H', 5 => 'VH'];
|
||||
const TASK_COLORS = [1 => 'green', 2 => 'red', 3 => 'orange', 4 => 'blue', 5 => 'gray'];
|
||||
const COLOR_OVERDUE = 1;
|
||||
const COLOR_ON_TIME = 2;
|
||||
@@ -1164,56 +1164,56 @@ class AbstractCases implements CasesInterface
|
||||
}
|
||||
/** Apply filters related to MY CASES */
|
||||
// My cases filter: started, in-progress, completed, supervising
|
||||
if (!empty($properties['filter']) && get_class($this) === Participated::class) {
|
||||
if (get_class($this) === Participated::class && !empty($properties['filter'])) {
|
||||
$this->setParticipatedStatus($properties['filter']);
|
||||
}
|
||||
// Filter by one case status
|
||||
if (!empty($properties['caseStatus']) && get_class($this) === Participated::class) {
|
||||
if (get_class($this) === Participated::class && !empty($properties['caseStatus'])) {
|
||||
$this->setCaseStatus($properties['caseStatus']);
|
||||
}
|
||||
// Filter date related to started date from
|
||||
if (!empty($properties['startCaseFrom'] && (get_class($this) === Participated::class || get_class($this) === Supervising::class))) {
|
||||
if ((get_class($this) === Participated::class || get_class($this) === Supervising::class) && !empty($properties['startCaseFrom'])) {
|
||||
$this->setStartCaseFrom($properties['startCaseFrom']);
|
||||
}
|
||||
// Filter date related to started date to
|
||||
if (!empty($properties['startCaseTo']) && (get_class($this) === Participated::class || get_class($this) === Supervising::class)) {
|
||||
if ((get_class($this) === Participated::class || get_class($this) === Supervising::class) && !empty($properties['startCaseTo'])) {
|
||||
$this->setStartCaseTo($properties['startCaseTo']);
|
||||
}
|
||||
// Filter date related to finish date from
|
||||
if (!empty($properties['finishCaseFrom']) && (get_class($this) === Participated::class || get_class($this) === Supervising::class)) {
|
||||
if ((get_class($this) === Participated::class || get_class($this) === Supervising::class) && !empty($properties['finishCaseFrom'])) {
|
||||
$this->setFinishCaseFrom($properties['finishCaseFrom']);
|
||||
}
|
||||
// Filter date related to finish date to
|
||||
if (!empty($properties['finishCaseTo']) && (get_class($this) === Participated::class || get_class($this) === Supervising::class)) {
|
||||
if ((get_class($this) === Participated::class || get_class($this) === Supervising::class) && !empty($properties['finishCaseTo'])) {
|
||||
$this->setFinishCaseTo($properties['finishCaseTo']);
|
||||
}
|
||||
/** Apply filters related to SEARCH */
|
||||
// Add a filter with specific cases or range of cases like '1, 3-5, 8, 10-15'
|
||||
if (!empty($properties['filterCases']) && get_class($this) === Search::class) {
|
||||
if (get_class($this) === Search::class && !empty($properties['filterCases'])) {
|
||||
$this->setFilterCases($properties['filterCases']);
|
||||
}
|
||||
// Filter by more than one case statuses like ['DRAFT', 'TO_DO']
|
||||
if (!empty($properties['caseStatuses']) && get_class($this) === Search::class) {
|
||||
if (get_class($this) === Search::class && !empty($properties['caseStatuses'])) {
|
||||
$this->setCaseStatuses($properties['caseStatuses']);
|
||||
}
|
||||
// Filter by more than one priorities like ['VL', 'L', 'N']
|
||||
if (!empty($properties['priorities']) && get_class($this) === Search::class) {
|
||||
if (get_class($this) === Search::class && !empty($properties['priorities'])) {
|
||||
$this->setProperties($properties['priorities']);
|
||||
}
|
||||
// Filter date newest related to delegation/started date
|
||||
if (!empty($properties['delegationDateFrom'] && get_class($this) === Search::class)) {
|
||||
if (get_class($this) === Search::class && !empty($properties['delegationDateFrom'])) {
|
||||
$this->setDelegateFrom($properties['delegationDateFrom']);
|
||||
}
|
||||
// Filter date oldest related to delegation/started date
|
||||
if (!empty($properties['delegationDateTo']) && get_class($this) === Search::class) {
|
||||
if (get_class($this) === Search::class && !empty($properties['delegationDateTo'])) {
|
||||
$this->setDelegateTo($properties['delegationDateTo']);
|
||||
}
|
||||
// Filter date newest related to due date
|
||||
if (!empty($properties['dueDateFrom']) && get_class($this) === Search::class) {
|
||||
if (get_class($this) === Search::class && !empty($properties['dueDateFrom'])) {
|
||||
$this->setDueFrom($properties['dueDateFrom']);
|
||||
}
|
||||
// Filter date oldest related to due date
|
||||
if (!empty($properties['dueDateTo']) && get_class($this) === Search::class) {
|
||||
if (get_class($this) === Search::class && !empty($properties['dueDateTo'])) {
|
||||
$this->setDueTo($properties['dueDateTo']);
|
||||
}
|
||||
// Filter by case uid
|
||||
|
||||
@@ -20,6 +20,8 @@ class Draft extends AbstractCases
|
||||
// Additional column for other functionalities
|
||||
'APP_DELEGATION.APP_UID', // Case Uid for Open case
|
||||
'APP_DELEGATION.DEL_INDEX', // Del Index for Open case
|
||||
'APP_DELEGATION.PRO_UID', // Process Uid for Case notes
|
||||
'APP_DELEGATION.TAS_UID', // Task Uid for Case notes
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,6 +23,8 @@ class Inbox extends AbstractCases
|
||||
// Additional column for other functionalities
|
||||
'APP_DELEGATION.APP_UID', // Case Uid for Open case
|
||||
'APP_DELEGATION.DEL_INDEX', // Del Index for Open case
|
||||
'APP_DELEGATION.PRO_UID', // Process Uid for Case notes
|
||||
'APP_DELEGATION.TAS_UID', // Task Uid for Case notes
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,6 +22,8 @@ class Participated extends AbstractCases
|
||||
// Additional column for other functionalities
|
||||
'APP_DELEGATION.APP_UID', // Case Uid for Open case
|
||||
'APP_DELEGATION.DEL_INDEX', // Del Index for Open case
|
||||
'APP_DELEGATION.PRO_UID', // Process Uid for Case notes
|
||||
'APP_DELEGATION.TAS_UID', // Task Uid for Case notes
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -107,7 +109,6 @@ class Participated extends AbstractCases
|
||||
$query->participated($this->getUserId());
|
||||
// Add filter
|
||||
$filter = $this->getParticipatedStatus();
|
||||
if (!empty($filter)) {
|
||||
switch ($filter) {
|
||||
case 'STARTED':
|
||||
// Scope that search for the STARTED by user
|
||||
@@ -132,7 +133,9 @@ class Participated extends AbstractCases
|
||||
\']\'
|
||||
) AS PENDING'
|
||||
);
|
||||
// Only cases in progress
|
||||
$query->caseInProgress();
|
||||
// Group by AppNumber
|
||||
$query->groupBy('APP_NUMBER');
|
||||
break;
|
||||
case 'COMPLETED':
|
||||
@@ -142,7 +145,6 @@ class Participated extends AbstractCases
|
||||
$query->lastThread();
|
||||
break;
|
||||
}
|
||||
}
|
||||
/** Apply filters */
|
||||
$this->filters($query);
|
||||
/** Apply order and pagination */
|
||||
|
||||
@@ -23,6 +23,8 @@ class Paused extends AbstractCases
|
||||
// Additional column for other functionalities
|
||||
'APP_DELEGATION.APP_UID', // Case Uid for Open case
|
||||
'APP_DELEGATION.DEL_INDEX', // Del Index for Open case
|
||||
'APP_DELEGATION.PRO_UID', // Process Uid for Case notes
|
||||
'APP_DELEGATION.TAS_UID', // Task Uid for Case notes
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,6 +25,8 @@ class Search extends AbstractCases
|
||||
// Additional column for other functionalities
|
||||
'APP_DELEGATION.APP_UID', // Case Uid for Open case
|
||||
'APP_DELEGATION.DEL_INDEX', // Del Index for Open case
|
||||
'APP_DELEGATION.PRO_UID', // Process Uid for Case notes
|
||||
'APP_DELEGATION.TAS_UID', // Task Uid for Case notes
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,6 +21,8 @@ class Supervising extends AbstractCases
|
||||
// Additional column for other functionalities
|
||||
'APP_DELEGATION.APP_UID', // Case Uid for Open case
|
||||
'APP_DELEGATION.DEL_INDEX', // Del Index for Open case
|
||||
'APP_DELEGATION.PRO_UID', // Process Uid for Case notes
|
||||
'APP_DELEGATION.TAS_UID', // Task Uid for Case notes
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -98,6 +100,23 @@ class Supervising extends AbstractCases
|
||||
if (!empty($processes)) {
|
||||
// Start the query for get the cases related to the user
|
||||
$query = Delegation::query()->select($this->getColumnsView());
|
||||
$query->selectRaw(
|
||||
'CONCAT(
|
||||
\'[\',
|
||||
GROUP_CONCAT(
|
||||
CONCAT(
|
||||
\'{"tas_id":\',
|
||||
APP_DELEGATION.TAS_ID,
|
||||
\', "user_id":\',
|
||||
APP_DELEGATION.USR_ID,
|
||||
\', "due_date":"\',
|
||||
APP_DELEGATION.DEL_TASK_DUE_DATE,
|
||||
\'"}\'
|
||||
)
|
||||
),
|
||||
\']\'
|
||||
) AS PENDING'
|
||||
);
|
||||
// Join with process
|
||||
$query->joinProcess();
|
||||
// Join with task
|
||||
@@ -112,6 +131,8 @@ class Supervising extends AbstractCases
|
||||
$query->userId($this->getUserId());
|
||||
// Scope the specific array of processes supervising
|
||||
$query->processInList($processes);
|
||||
// Group by appNumber
|
||||
$query->groupBy('APP_NUMBER');
|
||||
/** Apply filters */
|
||||
$this->filters($query);
|
||||
/** Apply order and pagination */
|
||||
@@ -133,6 +154,10 @@ class Supervising extends AbstractCases
|
||||
$startDate = (string)$item['APP_CREATE_DATE'];
|
||||
$endDate = !empty($item['APP_FINISH_DATE']) ? $item['APP_FINISH_DATE'] : date("Y-m-d H:i:s");
|
||||
$item['DURATION'] = getDiffBetweenDates($startDate, $endDate);
|
||||
// Get the detail related to the open thread
|
||||
if (!empty($item['PENDING'])) {
|
||||
$item['PENDING'] = $this->prepareTaskPending($item['PENDING']);
|
||||
}
|
||||
|
||||
return $item;
|
||||
});
|
||||
|
||||
@@ -24,6 +24,8 @@ class Unassigned extends AbstractCases
|
||||
// Additional column for other functionalities
|
||||
'APP_DELEGATION.APP_UID', // Case Uid for Open case
|
||||
'APP_DELEGATION.DEL_INDEX', // Del Index for Open case
|
||||
'APP_DELEGATION.PRO_UID', // Process Uid for Case notes
|
||||
'APP_DELEGATION.TAS_UID', // Task Uid for Case notes
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -457,7 +457,8 @@ class Home extends Api
|
||||
$list->setProperties($properties);
|
||||
$result = [];
|
||||
$result['data'] = $list->getData();
|
||||
$result['total'] = $list->getCounter();
|
||||
// We will to enable always the pagination
|
||||
$result['total'] = $list->getLimit() + 1;
|
||||
return $result;
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
|
||||
Reference in New Issue
Block a user