Files
luos/tests/unit/workflow/engine/src/ProcessMaker/Model/DelegationTest.php

2579 lines
100 KiB
PHP
Raw Normal View History

<?php
2019-09-03 12:39:37 -04:00
namespace Tests\unit\workflow\src\ProcessMaker\Model;
2019-05-20 13:23:31 -04:00
use G;
use Illuminate\Foundation\Testing\DatabaseTransactions;
2019-07-29 12:46:55 -04:00
use Illuminate\Support\Facades\DB;
2019-05-13 16:44:40 -04:00
use ProcessMaker\Model\AppAssignSelfServiceValue;
use ProcessMaker\Model\AppAssignSelfServiceValueGroup;
2019-05-02 10:53:43 -04:00
use ProcessMaker\Model\Application;
use ProcessMaker\Model\Delegation;
2019-05-13 16:44:40 -04:00
use ProcessMaker\Model\GroupUser;
use ProcessMaker\Model\Groupwf;
2019-05-02 10:53:43 -04:00
use ProcessMaker\Model\Process;
2019-05-02 14:48:50 -04:00
use ProcessMaker\Model\ProcessCategory;
2021-03-23 15:13:52 -04:00
use ProcessMaker\Model\SubProcess;
2019-05-02 13:23:23 -04:00
use ProcessMaker\Model\Task;
2019-05-13 16:44:40 -04:00
use ProcessMaker\Model\TaskUser;
2019-05-02 10:53:43 -04:00
use ProcessMaker\Model\User;
use Tests\TestCase;
2019-09-03 12:39:37 -04:00
/**
* Class DelegationTest
*
* @coversDefaultClass \ProcessMaker\Model\Delegation
*/
class DelegationTest extends TestCase
{
use DatabaseTransactions;
2019-09-03 12:39:37 -04:00
/**
* Set up function.
*/
public function setUp()
{
parent::setUp();
Delegation::truncate();
}
2020-11-11 10:38:08 -04:00
/**
* This test scopePriority
*
* @covers \ProcessMaker\Model\Delegation::scopePriority()
* @test
*/
public function it_return_scope_priority()
{
$table = factory(Delegation::class)->states('foreign_keys')->create();
$this->assertCount(1, $table->priority($table->DEL_PRIORITY)->get());
}
/**
* This test scopeIndex
*
* @covers \ProcessMaker\Model\Delegation::scopeIndex()
* @test
*/
public function it_return_scope_index()
{
$table = factory(Delegation::class)->states('foreign_keys')->create();
$this->assertCount(1, $table->index($table->DEL_INDEX)->get());
}
/**
* This test scopeCaseStarted
*
* @covers \ProcessMaker\Model\Delegation::scopeCaseStarted()
* @test
*/
public function it_return_scope_case_started()
{
$table = factory(Delegation::class)->states('foreign_keys')->create();
$this->assertCount(1, $table->caseStarted($table->DEL_INDEX)->get());
}
/**
* This test scopeCaseInProgress
*
* @covers \ProcessMaker\Model\Delegation::scopeCaseInProgress()
* @test
*/
public function it_return_scope_case_in_progress()
{
$table = factory(Delegation::class)->states('foreign_keys')->create();
2020-11-25 18:11:22 -04:00
$this->assertCount(1, $table->joinApplication()->caseInProgress()->get());
2020-11-11 10:38:08 -04:00
}
/**
* This test scopeCaseCompleted
*
* @covers \ProcessMaker\Model\Delegation::scopeCaseCompleted()
* @test
*/
public function it_return_scope_case_in_completed()
{
$application = factory(Application::class)->states('completed')->create();
$table = factory(Delegation::class)->states('foreign_keys')->create([
'APP_NUMBER' => $application->APP_NUMBER,
'APP_UID' => $application->APP_UID,
]);
2020-11-25 18:11:22 -04:00
$this->assertCount(1, $table->joinApplication()->caseCompleted()->get());
2020-11-11 10:38:08 -04:00
}
/**
* This test scopeDelegateDateFrom
*
* @covers \ProcessMaker\Model\Delegation::scopeDelegateDateFrom()
* @test
*/
public function it_return_scope_delegate_date_from()
{
$table = factory(Delegation::class)->states('foreign_keys')->create();
2020-12-18 10:10:49 -04:00
$this->assertCount(1, $table->delegateDateFrom($table->DEL_DELEGATE_DATE->format("Y-m-d H:i:s"))->get());
2020-11-11 10:38:08 -04:00
}
/**
* This test scopeDelegateDateTo
*
* @covers \ProcessMaker\Model\Delegation::scopeDelegateDateTo()
* @test
*/
public function it_return_scope_delegate_date_to()
{
$table = factory(Delegation::class)->states('foreign_keys')->create();
2020-12-18 10:10:49 -04:00
$this->assertCount(1, $table->delegateDateTo($table->DEL_DELEGATE_DATE->format("Y-m-d H:i:s"))->get());
2020-11-11 10:38:08 -04:00
}
/**
* This test scopeSpecificCases
*
* @covers \ProcessMaker\Model\Delegation::scopeSpecificCases()
* @test
*/
public function it_return_scope_specific_cases()
{
$table = factory(Delegation::class)->states('foreign_keys')->create();
$this->assertCount(1, $table->specificCases([$table->APP_NUMBER])->get());
}
/**
* This test scopeWithoutUserId
*
* @covers \ProcessMaker\Model\Delegation::scopeWithoutUserId()
* @test
*/
public function it_return_scope_without_user_id()
{
$table = factory(Delegation::class)->states('foreign_keys')->create([
'USR_ID' => 0
]);
$this->assertCount(1, $table->withoutUserId($table->TAS_ID)->get());
}
/**
* This test scopeTask
*
* @covers \ProcessMaker\Model\Delegation::scopeTask()
* @test
*/
public function it_return_scope_task()
{
$table = factory(Delegation::class)->states('foreign_keys')->create();
$this->assertCount(1, $table->task()->get());
}
/**
* This test scopeSpecificTasks
*
* @covers \ProcessMaker\Model\Delegation::scopeSpecificTasks()
* @test
*/
public function it_return_scope_specific_tasks()
{
$table = factory(Delegation::class)->states('foreign_keys')->create();
$this->assertCount(1, $table->specificTasks([$table->TAS_ID])->get());
}
/**
* This checks to make sure pagination is working properly
2019-09-03 12:39:37 -04:00
*
2019-09-03 16:06:15 -04:00
* @covers \ProcessMaker\Model\Delegation::search()
* @test
*/
public function it_should_return_pages_of_data()
{
2019-09-03 16:06:15 -04:00
factory(Delegation::class, 51)->states('foreign_keys')->create();
// Get first page, which is 25
2019-09-03 16:06:15 -04:00
$results = Delegation::search(null, 0, 25, null, null, null, null, null, null, null, null, 'APP_NUMBER');
$this->assertCount(25, $results['data']);
// Get second page, which is 25 results
2019-09-03 16:06:15 -04:00
$results = Delegation::search(null, 25, 25, null, null, null, null, null, null, null, null, 'APP_NUMBER');
$this->assertCount(25, $results['data']);
// Get third page, which is only 1 result
2019-09-03 16:06:15 -04:00
$results = Delegation::search(null, 50, 25, null, null, null, null, null, null, null, null, 'APP_NUMBER');
$this->assertCount(1, $results['data']);
}
/**
* This checks to make sure pagination is working properly
2019-09-03 12:39:37 -04:00
*
2019-09-03 16:06:15 -04:00
* @covers \ProcessMaker\Model\Delegation::search()
* @test
*/
public function it_should_return_pages_of_data_unassigned()
{
2019-09-03 16:06:15 -04:00
factory(Delegation::class, 50)->states('foreign_keys')->create();
factory(Delegation::class, 1)->states('foreign_keys')->create([
'USR_ID' => 0 // A self service delegation
]);
// Get first page, which is 25
$results = Delegation::search(null, 0, 25);
$this->assertCount(25, $results['data']);
// Get second page, which is 25 results
$results = Delegation::search(null, 25, 25);
$this->assertCount(25, $results['data']);
// Get third page, which is only 1 result
$results = Delegation::search(null, 50, 25);
$this->assertCount(1, $results['data']);
}
2019-05-01 18:10:46 -04:00
/**
2019-05-02 10:53:43 -04:00
* This checks to make sure filter by process is working properly
2019-09-03 12:39:37 -04:00
*
2019-09-03 16:06:15 -04:00
* @covers \ProcessMaker\Model\Delegation::search()
2019-05-01 18:10:46 -04:00
* @test
*/
2019-05-02 10:53:43 -04:00
public function it_should_return_process_of_data()
2019-05-01 18:10:46 -04:00
{
2019-09-03 16:06:15 -04:00
2019-05-22 10:27:00 -04:00
$process = factory(Process::class)->create();
2019-09-03 16:06:15 -04:00
factory(Delegation::class, 51)->states('foreign_keys')->create([
2019-10-22 11:15:57 -04:00
'PRO_ID' => $process->PRO_ID
2019-05-02 10:53:43 -04:00
]);
2019-05-01 18:10:46 -04:00
// Get first page, which is 25
2019-10-22 11:15:57 -04:00
$results = Delegation::search(null, 0, 25, null, $process->PRO_ID);
2019-05-02 10:53:43 -04:00
$this->assertCount(25, $results['data']);
2019-05-01 18:10:46 -04:00
// Get second page, which is 25 results
2019-10-22 11:15:57 -04:00
$results = Delegation::search(null, 25, 25, null, $process->PRO_ID);
2019-05-02 10:53:43 -04:00
$this->assertCount(25, $results['data']);
2019-05-01 18:10:46 -04:00
// Get third page, which is only 1 result
2019-10-22 11:15:57 -04:00
$results = Delegation::search(null, 50, 25, null, $process->PRO_ID);
2019-05-01 18:10:46 -04:00
$this->assertCount(1, $results['data']);
}
/**
2019-05-02 10:53:43 -04:00
* This checks to make sure filter by status is working properly
* Review status filter by a specific status, such as Draft
2019-09-03 12:39:37 -04:00
*
2019-09-03 16:06:15 -04:00
* @covers \ProcessMaker\Model\Delegation::search()
2019-05-01 18:10:46 -04:00
* @test
*/
2019-05-02 10:53:43 -04:00
public function it_should_return_status_draft_of_data()
2019-05-01 18:10:46 -04:00
{
2019-05-22 10:27:00 -04:00
$application = factory(Application::class)->create([
2019-05-02 13:23:23 -04:00
'APP_STATUS_ID' => 1,
'APP_STATUS' => 'DRAFT'
]);
2019-09-03 16:06:15 -04:00
factory(Delegation::class, 51)->states('foreign_keys')->create([
2019-05-22 10:27:00 -04:00
'APP_NUMBER' => $application->APP_NUMBER
2019-05-02 10:53:43 -04:00
]);
// Review the filter by status DRAFT
2019-05-01 18:10:46 -04:00
// Get first page, which is 25
2019-05-22 10:27:00 -04:00
$results = Delegation::search(null, 0, 25, null, null, $application->APP_STATUS_ID);
2019-05-02 10:53:43 -04:00
$this->assertCount(25, $results['data']);
2019-05-01 18:10:46 -04:00
// Get second page, which is 25 results
2019-05-22 10:27:00 -04:00
$results = Delegation::search(null, 25, 25, null, null, $application->APP_STATUS_ID);
2019-05-02 10:53:43 -04:00
$this->assertCount(25, $results['data']);
2019-05-01 18:10:46 -04:00
// Get third page, which is only 1 result
2019-05-22 10:27:00 -04:00
$results = Delegation::search(null, 50, 25, null, null, $application->APP_STATUS_ID);
2019-05-01 18:10:46 -04:00
$this->assertCount(1, $results['data']);
}
/**
2019-05-02 10:53:43 -04:00
* This checks to make sure filter by status is working properly
* Review status filter by a specific status, such as To Do
2019-09-03 12:39:37 -04:00
*
2019-09-03 16:06:15 -04:00
* @covers \ProcessMaker\Model\Delegation::search()
2019-05-01 18:10:46 -04:00
* @test
*/
2019-05-02 10:53:43 -04:00
public function it_should_return_status_todo_of_data()
2019-05-01 18:10:46 -04:00
{
2019-05-22 10:27:00 -04:00
$application = factory(Application::class)->create([
2019-05-02 13:23:23 -04:00
'APP_STATUS_ID' => 2,
'APP_STATUS' => 'TO_DO'
]);
2019-09-03 16:06:15 -04:00
factory(Delegation::class, 51)->states('foreign_keys')->create([
2019-05-22 10:27:00 -04:00
'APP_NUMBER' => $application->APP_NUMBER
2019-05-02 10:53:43 -04:00
]);
// Review the filter by status TO_DO
2019-05-01 18:10:46 -04:00
// Get first page, which is 25
2019-05-22 10:27:00 -04:00
$results = Delegation::search(null, 0, 25, null, null, $application->APP_STATUS_ID);
2019-05-02 10:53:43 -04:00
$this->assertCount(25, $results['data']);
2019-05-01 18:10:46 -04:00
// Get second page, which is 25 results
2019-05-22 10:27:00 -04:00
$results = Delegation::search(null, 25, 25, null, null, $application->APP_STATUS_ID);
2019-05-02 10:53:43 -04:00
$this->assertCount(25, $results['data']);
2019-05-01 18:10:46 -04:00
// Get third page, which is only 1 result
2019-05-22 10:27:00 -04:00
$results = Delegation::search(null, 50, 25, null, null, $application->APP_STATUS_ID);
2019-05-01 18:10:46 -04:00
$this->assertCount(1, $results['data']);
}
/**
2019-05-02 10:53:43 -04:00
* This checks to make sure filter by status is working properly
* Review status filter by a specific status, such as Completed
2019-09-03 12:39:37 -04:00
*
2019-09-03 16:06:15 -04:00
* @covers \ProcessMaker\Model\Delegation::search()
2019-05-01 18:10:46 -04:00
* @test
*/
2019-05-02 10:53:43 -04:00
public function it_should_return_status_completed_of_data()
2019-05-01 18:10:46 -04:00
{
2019-05-22 10:27:00 -04:00
$application = factory(Application::class)->create([
2019-05-02 13:23:23 -04:00
'APP_STATUS_ID' => 3,
'APP_STATUS' => 'COMPLETED',
]);
2019-09-03 16:06:15 -04:00
factory(Delegation::class, 51)->states('foreign_keys')->create([
2019-05-22 10:27:00 -04:00
'APP_NUMBER' => $application->APP_NUMBER,
2019-05-02 13:23:23 -04:00
'DEL_LAST_INDEX' => 1
2019-05-02 10:53:43 -04:00
]);
2019-05-02 13:23:23 -04:00
// Review the filter by status COMPLETED
2019-05-02 10:53:43 -04:00
// Get first page, which is 25
2019-05-22 10:27:00 -04:00
$results = Delegation::search(null, 0, 25, null, null, $application->APP_STATUS_ID);
2019-05-02 10:53:43 -04:00
$this->assertCount(25, $results['data']);
// Get second page, which is 25 results
2019-05-22 10:27:00 -04:00
$results = Delegation::search(null, 25, 25, null, null, $application->APP_STATUS_ID);
2019-05-02 10:53:43 -04:00
$this->assertCount(25, $results['data']);
// Get third page, which is only 1 result
2019-05-22 10:27:00 -04:00
$results = Delegation::search(null, 50, 25, null, null, $application->APP_STATUS_ID);
2019-05-02 10:53:43 -04:00
$this->assertCount(1, $results['data']);
}
/**
* This checks to make sure filter by status is working properly
* Review status filter by a specific status, such as Cancelled
2019-09-03 12:39:37 -04:00
*
2019-09-03 16:06:15 -04:00
* @covers \ProcessMaker\Model\Delegation::search()
2019-05-02 10:53:43 -04:00
* @test
*/
public function it_should_return_status_cancelled_of_data()
{
2019-05-22 10:27:00 -04:00
$application = factory(Application::class)->create([
2019-05-02 13:23:23 -04:00
'APP_STATUS_ID' => 4,
'APP_STATUS' => 'CANCELLED'
]);
2019-09-03 16:06:15 -04:00
factory(Delegation::class, 51)->states('foreign_keys')->create([
2019-05-22 10:27:00 -04:00
'APP_NUMBER' => $application->APP_NUMBER,
2019-05-02 13:23:23 -04:00
'DEL_LAST_INDEX' => 1
2019-05-02 10:53:43 -04:00
]);
2019-05-02 13:23:23 -04:00
// Review the filter by status CANCELLED
2019-05-01 18:10:46 -04:00
// Get first page, which is 25
2019-05-22 10:27:00 -04:00
$results = Delegation::search(null, 0, 25, null, null, $application->APP_STATUS_ID);
2019-05-02 10:53:43 -04:00
$this->assertCount(25, $results['data']);
2019-05-01 18:10:46 -04:00
// Get second page, which is 25 results
2019-05-22 10:27:00 -04:00
$results = Delegation::search(null, 25, 25, null, null, $application->APP_STATUS_ID);
2019-05-02 10:53:43 -04:00
$this->assertCount(25, $results['data']);
2019-05-01 18:10:46 -04:00
// Get third page, which is only 1 result
2019-05-22 10:27:00 -04:00
$results = Delegation::search(null, 50, 25, null, null, $application->APP_STATUS_ID);
2019-05-01 18:10:46 -04:00
$this->assertCount(1, $results['data']);
}
/**
* This ensures searching for a valid user works
2019-09-03 12:39:37 -04:00
*
2019-09-03 16:06:15 -04:00
* @covers \ProcessMaker\Model\Delegation::search()
* @test
*/
public function it_should_return_one_result_for_specified_user()
{
// Create our unique user, with a unique username
2019-09-03 16:06:15 -04:00
$user = factory(User::class)->create();
// Create a new delegation, but for this specific user
2019-09-03 16:06:15 -04:00
factory(Delegation::class)->states('foreign_keys')->create([
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->USR_ID
]);
// Now fetch results, and assume delegation count is 1 and the user points to our user
$results = Delegation::search($user->USR_ID);
$this->assertCount(1, $results['data']);
2019-09-03 16:06:15 -04:00
$this->assertEquals($user->USR_USERNAME, $results['data'][0]['USRCR_USR_USERNAME']);
}
2019-05-02 17:12:35 -04:00
/**
2019-07-29 12:46:55 -04:00
* This ensures searching by case number and review the order
2019-09-03 12:39:37 -04:00
*
2019-09-03 16:06:15 -04:00
* @covers \ProcessMaker\Model\Delegation::search()
2019-05-02 17:12:35 -04:00
* @test
*/
2019-09-03 16:06:15 -04:00
public function it_should_search_and_filter_by_app_number()
2019-05-02 17:12:35 -04:00
{
2019-09-03 16:06:15 -04:00
for ($x = 1; $x <= 10; $x++) {
$application = factory(Application::class)->create();
factory(Delegation::class)->states('foreign_keys')->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_THREAD_STATUS' => 'OPEN'
]);
}
// Searching by a existent case number, result ordered by APP_NUMBER, filter by APP_NUMBER in DESC mode
$results = Delegation::search(null, 0, 25, $application->APP_NUMBER, null, null, 'DESC',
2019-05-02 17:12:35 -04:00
'APP_NUMBER', null, null, null, 'APP_NUMBER');
2019-07-29 12:46:55 -04:00
$this->assertCount(1, $results['data']);
2019-09-03 16:06:15 -04:00
$this->assertEquals($application->APP_NUMBER, $results['data'][0]['APP_NUMBER']);
// Searching by a existent case number, result ordered by APP_NUMBER, filter by APP_NUMBER in ASC mode
$results = Delegation::search(null, 0, 25, $application->APP_NUMBER, null, null, 'ASC',
2019-05-02 17:12:35 -04:00
'APP_NUMBER', null, null, null, 'APP_NUMBER');
2019-07-29 12:46:55 -04:00
$this->assertCount(1, $results['data']);
2019-09-03 16:06:15 -04:00
$this->assertEquals($application->APP_NUMBER, $results['data'][0]['APP_NUMBER']);
2019-05-02 17:12:35 -04:00
}
2019-05-02 17:12:35 -04:00
/**
2019-09-03 16:06:15 -04:00
* This ensures searching by case number and review the order
2019-09-03 12:39:37 -04:00
*
2019-09-03 16:06:15 -04:00
* @covers \ProcessMaker\Model\Delegation::search()
2019-05-02 17:12:35 -04:00
* @test
*/
2019-09-03 16:06:15 -04:00
public function it_should_search_and_filter_by_app_title()
2019-05-02 17:12:35 -04:00
{
$delegations = factory(Delegation::class, 1)
->states('foreign_keys')
->create();
$title = $delegations->last()
2020-12-07 09:21:51 -04:00
->DEL_TITLE;
2019-07-29 12:46:55 -04:00
// We need to commit the records inserted because is needed for the "fulltext" index
DB::commit();
2019-09-03 16:06:15 -04:00
// Searching by a existent case title, result ordered by APP_NUMBER, filter by APP_NUMBER in DESC mode
$results = Delegation::search(null, 0, 10, $title, null, null, 'DESC',
'APP_NUMBER', null, null, null, 'APP_TITLE');
2019-09-03 16:06:15 -04:00
$this->assertCount(1, $results['data']);
$this->assertEquals($title, $results['data'][0]['APP_TITLE']);
// Searching by a existent case title, result ordered by APP_NUMBER, filter by APP_NUMBER in ASC mode
$results = Delegation::search(null, 0, 10, $title, null, null, 'ASC',
'APP_NUMBER', null, null, null, 'APP_TITLE');
2019-05-02 17:19:10 -04:00
$this->assertCount(1, $results['data']);
2019-09-03 16:06:15 -04:00
$this->assertEquals($title, $results['data'][0]['APP_TITLE']);
2019-05-02 17:19:10 -04:00
}
/**
* This ensures searching by task title and review the page
2019-09-03 12:39:37 -04:00
*
2019-09-03 16:06:15 -04:00
* @covers \ProcessMaker\Model\Delegation::search()
* @test
*/
2019-09-03 16:06:15 -04:00
public function it_should_search_and_order_by_task_title()
{
2019-09-03 16:06:15 -04:00
factory(Delegation::class, 5)->states('foreign_keys')->create([
'TAS_ID' => function () {
return factory(Task::class)->create()->TAS_ID;
}
]);
2019-09-03 16:06:15 -04:00
$task = factory(Task::class)->create();
factory(Delegation::class)->states('foreign_keys')->create([
2019-05-22 10:27:00 -04:00
'TAS_ID' => $task->TAS_ID
]);
2019-09-03 16:06:15 -04:00
// Get the order taskTitle in ASC mode
$results = Delegation::search(null, 0, 10, $task->TAS_TITLE, null, null, 'ASC',
'TAS_TITLE', null, null, null, 'TAS_TITLE');
2019-09-03 16:06:15 -04:00
$this->assertCount(1, $results['data']);
$this->assertEquals($task->TAS_TITLE, $results['data'][0]['APP_TAS_TITLE']);
$results = Delegation::search(null, 0, 10, null, null, null, 'ASC',
'TAS_TITLE', null, null, null, 'TAS_TITLE');
2019-09-03 16:06:15 -04:00
$this->assertGreaterThan($results['data'][0]['APP_TAS_TITLE'], $results['data'][1]['APP_TAS_TITLE']);
2019-09-03 16:06:15 -04:00
// Get the order taskTitle in DESC mode
$results = Delegation::search(null, 0, 10, $task->TAS_TITLE, null, null, 'DESC',
'TAS_TITLE', null, null, null, 'TAS_TITLE');
2019-05-02 17:12:35 -04:00
$this->assertCount(1, $results['data']);
2019-09-03 16:06:15 -04:00
$this->assertEquals($task->TAS_TITLE, $results['data'][0]['APP_TAS_TITLE']);
$results = Delegation::search(null, 0, 10, null, null, null, 'DESC',
'TAS_TITLE', null, null, null, 'TAS_TITLE');
$this->assertLessThan($results['data'][0]['APP_TAS_TITLE'], $results['data'][1]['APP_TAS_TITLE']);
2019-05-02 17:12:35 -04:00
}
/**
* This ensures ordering ascending and descending works by case number APP_NUMBER
2019-09-03 12:39:37 -04:00
*
2019-09-03 16:06:15 -04:00
* @covers \ProcessMaker\Model\Delegation::search()
* @test
*/
public function it_should_sort_by_case_id()
{
2019-09-03 16:06:15 -04:00
factory(Delegation::class, 2)->states('foreign_keys')->create();
2019-05-02 11:43:38 -04:00
// Get first page, the minor case id
2019-09-03 16:06:15 -04:00
$results = Delegation::search(null, 0, 2, null, null, null, 'ASC', 'APP_NUMBER');
2019-05-02 11:43:38 -04:00
$this->assertCount(2, $results['data']);
2019-09-03 16:06:15 -04:00
$this->assertGreaterThan($results['data'][0]['APP_NUMBER'], $results['data'][1]['APP_NUMBER']);
2019-05-02 11:43:38 -04:00
// Get first page, the major case id
2019-09-03 16:06:15 -04:00
$results = Delegation::search(null, 0, 2, null, null, null, 'DESC', 'APP_NUMBER');
2019-05-02 11:43:38 -04:00
$this->assertCount(2, $results['data']);
2019-09-03 16:06:15 -04:00
$this->assertLessThan($results['data'][0]['APP_NUMBER'], $results['data'][1]['APP_NUMBER']);
}
/**
* This ensures ordering ascending and descending works by case title APP_TITLE
2019-09-03 12:39:37 -04:00
*
2019-09-03 16:06:15 -04:00
* @covers \ProcessMaker\Model\Delegation::search()
2019-05-02 13:23:23 -04:00
* @test
*/
public function it_should_sort_by_case_title()
{
2019-09-03 16:06:15 -04:00
factory(Delegation::class, 2)->states('foreign_keys')->create();
// Get first page, the minor case title
$results = Delegation::search(null, 0, 2, null, null, null, 'ASC', 'APP_TITLE');
2019-05-02 13:23:23 -04:00
$this->assertCount(2, $results['data']);
2020-12-18 10:10:49 -04:00
$this->assertGreaterThanOrEqual($results['data'][0]['APP_TITLE'], $results['data'][1]['APP_TITLE']);
2019-09-03 16:06:15 -04:00
// Get first page, the major case title
$results = Delegation::search(null, 0, 2, null, null, null, 'DESC', 'APP_TITLE');
2019-05-02 13:23:23 -04:00
$this->assertCount(2, $results['data']);
2019-09-03 16:06:15 -04:00
$this->assertLessThan($results['data'][0]['APP_TITLE'], $results['data'][1]['APP_TITLE']);
2019-05-02 13:23:23 -04:00
}
/**
* This ensures ordering ascending and descending works by case title APP_PRO_TITLE
2019-09-03 12:39:37 -04:00
*
2019-09-03 16:06:15 -04:00
* @covers \ProcessMaker\Model\Delegation::search()
* @test
*/
public function it_should_sort_by_process()
{
2019-09-03 16:06:15 -04:00
factory(Delegation::class, 3)->states('foreign_keys')->create([
'PRO_ID' => function () {
2019-10-22 11:15:57 -04:00
return factory(Process::class)->create()->PRO_ID;
2019-09-03 16:06:15 -04:00
}
]);
2019-09-03 16:06:15 -04:00
// Get first page, all process ordering ASC
$results = Delegation::search(null, 0, 3, null, null, null, 'ASC', 'APP_PRO_TITLE');
$this->assertCount(3, $results['data']);
2019-09-03 16:06:15 -04:00
$this->assertGreaterThan($results['data'][0]['APP_PRO_TITLE'], $results['data'][1]['APP_PRO_TITLE']);
// Get first page, all process ordering DESC
$results = Delegation::search(null, 0, 3, null, null, null, 'DESC', 'APP_PRO_TITLE');
$this->assertCount(3, $results['data']);
2019-09-03 16:06:15 -04:00
$this->assertLessThan($results['data'][0]['APP_PRO_TITLE'], $results['data'][1]['APP_PRO_TITLE']);
}
/**
* This ensures ordering ascending and descending works by task title APP_TAS_TITLE
2019-09-03 12:39:37 -04:00
*
2019-09-03 16:06:15 -04:00
* @covers \ProcessMaker\Model\Delegation::search()
* @test
*/
public function it_should_sort_by_task_title()
{
2019-09-03 16:06:15 -04:00
factory(Delegation::class, 2)->states('foreign_keys')->create([
'TAS_ID' => function () {
return factory(Task::class)->create()->TAS_ID;
}
]);
2019-09-03 16:06:15 -04:00
// Get first page, all titles ordering ASC
$results = Delegation::search(null, 0, 2, null, null, null, 'ASC', 'APP_TAS_TITLE');
$this->assertCount(2, $results['data']);
2019-09-03 16:06:15 -04:00
$this->assertGreaterThan($results['data'][0]['APP_TAS_TITLE'], $results['data'][1]['APP_TAS_TITLE']);
// Get first page, all titles ordering DESC
$results = Delegation::search(null, 0, 2, null, null, null, 'DESC', 'APP_TAS_TITLE');
$this->assertCount(2, $results['data']);
2019-09-03 16:06:15 -04:00
$this->assertLessThan($results['data'][0]['APP_TAS_TITLE'], $results['data'][1]['APP_TAS_TITLE']);
}
2019-05-02 13:23:23 -04:00
/**
* This ensures ordering ascending and descending works by current user
2019-09-03 12:39:37 -04:00
*
2019-09-03 16:06:15 -04:00
* @covers \ProcessMaker\Model\Delegation::search()
* @test
*/
public function it_should_sort_by_user()
{
2019-09-03 16:06:15 -04:00
factory(Delegation::class, 2)->states('foreign_keys')->create([
'USR_ID' => function () {
return factory(User::class)->create()->USR_ID;
}
2019-05-02 11:43:38 -04:00
]);
2019-09-03 16:06:15 -04:00
// Get first page, order by User ordering ASC
$results = Delegation::search(null, 0, 2, null, null, null, 'ASC', 'APP_CURRENT_USER');
2019-05-02 11:43:38 -04:00
$this->assertCount(2, $results['data']);
2019-09-03 16:06:15 -04:00
$this->assertGreaterThan($results['data'][0]['APP_CURRENT_USER'], $results['data'][1]['APP_CURRENT_USER']);
// Get first page, order by User ordering ASC
$results = Delegation::search(null, 0, 2, null, null, null, 'DESC', 'APP_CURRENT_USER');
2019-05-02 11:43:38 -04:00
$this->assertCount(2, $results['data']);
2019-09-03 16:06:15 -04:00
$this->assertLessThan($results['data'][0]['APP_CURRENT_USER'], $results['data'][1]['APP_CURRENT_USER']);
}
2019-05-02 12:46:53 -04:00
2019-05-02 13:23:23 -04:00
/**
* This ensures ordering ordering ascending and descending works by last modified APP_UPDATE_DATE
2019-09-03 12:39:37 -04:00
*
2019-09-03 16:06:15 -04:00
* @covers \ProcessMaker\Model\Delegation::search()
2019-05-02 13:23:23 -04:00
* @test
*/
public function it_should_sort_by_last_modified()
2019-05-02 13:23:23 -04:00
{
2019-09-03 16:06:15 -04:00
factory(Delegation::class, 2)->states('foreign_keys')->create([
'APP_NUMBER' => function () {
return factory(Application::class)->create()->APP_NUMBER;
}
2019-05-02 13:23:23 -04:00
]);
// Get first page, the minor last modified
2019-09-03 16:06:15 -04:00
$results = Delegation::search(null, 0, 2, null, null, null, 'ASC', 'APP_UPDATE_DATE');
$this->assertCount(2, $results['data']);
$this->assertGreaterThan($results['data'][0]['APP_UPDATE_DATE'], $results['data'][1]['APP_UPDATE_DATE']);
// Get first page, the major last modified
$results = Delegation::search(null, 0, 2, null, null, null, 'DESC', 'APP_UPDATE_DATE');
$this->assertCount(2, $results['data']);
$this->assertLessThan($results['data'][0]['APP_UPDATE_DATE'], $results['data'][1]['APP_UPDATE_DATE']);
}
/**
* This ensures ordering ascending and descending works by due date DEL_TASK_DUE_DATE
2019-09-03 12:39:37 -04:00
*
2019-09-03 16:06:15 -04:00
* @covers \ProcessMaker\Model\Delegation::search()
* @test
*/
public function it_should_sort_by_due_date()
{
2019-09-03 16:06:15 -04:00
factory(Delegation::class, 10)->states('foreign_keys')->create();
// Get first page, the minor due date
$results = Delegation::search(null, 0, 10, null, null, null, 'ASC', 'DEL_TASK_DUE_DATE');
$this->assertCount(10, $results['data']);
2019-09-03 16:06:15 -04:00
$this->assertGreaterThan($results['data'][0]['DEL_TASK_DUE_DATE'], $results['data'][1]['DEL_TASK_DUE_DATE']);
// Get first page, the major due date
$results = Delegation::search(null, 0, 10, null, null, null, 'DESC', 'DEL_TASK_DUE_DATE');
$this->assertCount(10, $results['data']);
2019-09-03 16:06:15 -04:00
$this->assertLessThan($results['data'][0]['DEL_TASK_DUE_DATE'], $results['data'][1]['DEL_TASK_DUE_DATE']);
}
/**
* This ensures ordering ascending and descending works by status APP_STATUS
2019-09-03 12:39:37 -04:00
*
2019-09-03 16:06:15 -04:00
* @covers \ProcessMaker\Model\Delegation::search()
* @test
*/
public function it_should_sort_by_status()
{
2019-09-03 16:06:15 -04:00
factory(Delegation::class)->states('foreign_keys')->create([
'APP_NUMBER' => function () {
return factory(Application::class)->create(['APP_STATUS' => 'DRAFT', 'APP_STATUS_ID' => 1])->APP_NUMBER;
}
]);
factory(Delegation::class)->states('foreign_keys')->create([
'APP_NUMBER' => function () {
return factory(Application::class)->create(['APP_STATUS' => 'TO_DO', 'APP_STATUS_ID' => 2])->APP_NUMBER;
}
]);
factory(Delegation::class)->states('foreign_keys')->create([
'APP_NUMBER' => function () {
return factory(Application::class)->create([
'APP_STATUS' => 'COMPLETED',
'APP_STATUS_ID' => 3
])->APP_NUMBER;
}
]);
factory(Delegation::class)->states('foreign_keys')->create([
'APP_NUMBER' => function () {
return factory(Application::class)->create([
'APP_STATUS' => 'CANCELLED',
'APP_STATUS_ID' => 4
])->APP_NUMBER;
}
2019-05-02 13:23:23 -04:00
]);
// Get first page, the minor status label
2019-09-03 16:06:15 -04:00
$results = Delegation::search(null, 0, 5, null, null, null, 'ASC', 'APP_STATUS_LABEL');
$this->assertGreaterThanOrEqual($results['data'][0]['APP_STATUS'], $results['data'][1]['APP_STATUS']);
// Get first page, the major status label
2019-09-03 16:06:15 -04:00
$results = Delegation::search(null, 0, 5, null, null, null, 'DESC', 'APP_STATUS_LABEL');
$this->assertLessThanOrEqual($results['data'][0]['APP_STATUS'], $results['data'][1]['APP_STATUS']);
2019-05-02 12:46:53 -04:00
}
2019-05-02 14:48:50 -04:00
/**
* This checks to make sure filter by category is working properly
2019-09-03 12:39:37 -04:00
*
2019-09-03 16:06:15 -04:00
* @covers \ProcessMaker\Model\Delegation::search()
2019-05-02 14:48:50 -04:00
* @test
*/
public function it_should_return_data_filtered_by_process_category()
2019-05-02 14:48:50 -04:00
{
// Dummy Processes
factory(ProcessCategory::class, 4)->create();
factory(Process::class, 4)->create([
'PRO_CATEGORY' => ProcessCategory::all()->random()->CATEGORY_UID
2019-05-02 14:48:50 -04:00
]);
// Dummy Delegations
factory(Delegation::class, 100)->create([
'PRO_ID' => Process::all()->random()->PRO_ID
2019-05-02 14:48:50 -04:00
]);
// Process with the category to search
2019-09-03 16:06:15 -04:00
$category = factory(ProcessCategory::class)->create();
$processSearch = factory(Process::class)->create([
'PRO_CATEGORY' => $category->CATEGORY_UID
2019-05-02 14:48:50 -04:00
]);
// Delegations to found
2019-09-03 16:06:15 -04:00
factory(Delegation::class, 51)->states('foreign_keys')->create([
2019-10-22 11:15:57 -04:00
'PRO_ID' => $processSearch->PRO_ID
2019-05-02 14:48:50 -04:00
]);
// Get first page, which is 25
2019-09-03 16:06:15 -04:00
$results = Delegation::search(null, 0, 25, null, null, null, null, null, $category->CATEGORY_UID);
2019-05-02 14:48:50 -04:00
$this->assertCount(25, $results['data']);
// Get second page, which is 25 results
2019-09-03 16:06:15 -04:00
$results = Delegation::search(null, 25, 25, null, null, null, null, null, $category->CATEGORY_UID);
2019-05-02 14:48:50 -04:00
$this->assertCount(25, $results['data']);
// Get third page, which is only 1 result
2019-09-03 16:06:15 -04:00
$results = Delegation::search(null, 50, 25, null, null, null, null, null, $category->CATEGORY_UID);
2019-05-02 14:48:50 -04:00
$this->assertCount(1, $results['data']);
}
/**
* This ensure the result is right when you search between two given dates
2019-09-03 12:39:37 -04:00
*
2019-09-03 16:06:15 -04:00
* @covers \ProcessMaker\Model\Delegation::search()
* @test
*/
public function it_should_return_right_data_between_two_dates()
{
2019-09-03 16:06:15 -04:00
factory(Delegation::class, 10)->states('foreign_keys')->create([
'DEL_DELEGATE_DATE' => '2019-01-02 00:00:00'
]);
factory(Delegation::class, 10)->states('foreign_keys')->create([
'DEL_DELEGATE_DATE' => '2019-01-03 00:00:00'
]);
factory(Delegation::class, 10)->states('foreign_keys')->create([
'DEL_DELEGATE_DATE' => '2019-01-04 00:00:00'
]);
factory(Delegation::class, 10)->states('foreign_keys')->create([
'DEL_DELEGATE_DATE' => '2019-01-05 00:00:00'
]);
$results = Delegation::search(null, 0, 25, null, null, null, null, null, null, '2019-01-02 00:00:00',
'2019-01-03 00:00:00');
$this->assertCount(20, $results['data']);
foreach ($results['data'] as $value) {
$this->assertGreaterThanOrEqual('2019-01-02 00:00:00', $value['DEL_DELEGATE_DATE']);
$this->assertLessThanOrEqual('2019-01-03 00:00:00', $value['DEL_DELEGATE_DATE']);
$this->assertRegExp('(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}) ', $value['DEL_DELEGATE_DATE']);
}
}
/**
* This ensure the result is right when you search from a given date
2019-09-03 12:39:37 -04:00
*
2019-09-03 16:06:15 -04:00
* @covers \ProcessMaker\Model\Delegation::search()
* @test
*/
2019-09-03 16:06:15 -04:00
public function it_should_return_right_data_with_filters_dates_parameter()
{
2019-09-03 16:06:15 -04:00
factory(Delegation::class, 10)->states('foreign_keys')->create([
'DEL_DELEGATE_DATE' => '2019-01-02 00:00:00'
]);
factory(Delegation::class, 10)->states('foreign_keys')->create([
'DEL_DELEGATE_DATE' => '2019-01-03 00:00:00'
]);
factory(Delegation::class, 10)->states('foreign_keys')->create([
'DEL_DELEGATE_DATE' => '2019-01-04 00:00:00'
]);
factory(Delegation::class, 10)->states('foreign_keys')->create([
'DEL_DELEGATE_DATE' => '2019-01-05 00:00:00'
]);
// Search setting only from
$results = Delegation::search(
null, 0, 40, null, null, null, null, null, null, '2019-01-02 00:00:00'
);
$this->assertCount(40, $results['data']);
foreach ($results['data'] as $value) {
$this->assertGreaterThanOrEqual('2019-01-02 00:00:00', $value['DEL_DELEGATE_DATE']);
$this->assertRegExp('(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}) ', $value['DEL_DELEGATE_DATE']);
}
2019-09-03 16:06:15 -04:00
// Search setting only to
$results = Delegation::search(
null, 0, 40, null, null, null, null, null, null, null, '2019-01-04 00:00:00'
);
foreach ($results['data'] as $value) {
$this->assertLessThanOrEqual('2019-01-04 00:00:00', $value['DEL_DELEGATE_DATE']);
$this->assertRegExp('(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}) ', $value['DEL_DELEGATE_DATE']);
}
}
/**
2019-09-03 16:06:15 -04:00
* This ensures return the correct data by parallel task all threads CLOSED
2019-09-03 12:39:37 -04:00
*
2019-09-03 16:06:15 -04:00
* @covers \ProcessMaker\Model\Delegation::search()
* @test
*/
2019-09-03 16:06:15 -04:00
public function it_should_return_empty_when_parallel_tasks_has_threads_closed()
{
2019-05-07 12:32:34 -04:00
// Create a process
2019-05-22 10:27:00 -04:00
$process = factory(Process::class)->create();
2019-09-03 16:06:15 -04:00
// Create a task
$parallelTask = factory(Task::class)->create();
// Create a case
2019-05-22 10:27:00 -04:00
$application = factory(Application::class)->create();
2019-09-03 16:06:15 -04:00
// Create the threads for a parallel process
factory(Delegation::class, 5)->states('foreign_keys')->create([
2019-10-22 11:15:57 -04:00
'PRO_ID' => $process->PRO_ID,
2019-09-03 16:06:15 -04:00
'TAS_ID' => $parallelTask->TAS_ID,
2019-05-22 10:27:00 -04:00
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_THREAD_STATUS' => 'CLOSED'
]);
2019-09-03 16:06:15 -04:00
// Get first page, searching for threads are closed
$results = Delegation::search(null, 0, 5, $application->APP_NUMBER, null, null, null,
2019-05-07 12:32:34 -04:00
'TAS_TITLE', null, null, null, 'TAS_TITLE');
$this->assertCount(0, $results['data']);
}
/**
* This ensures return the correct data by parallel task all threads OPEN
2019-09-03 12:39:37 -04:00
*
2019-09-03 16:06:15 -04:00
* @covers \ProcessMaker\Model\Delegation::search()
* @test
*/
2019-09-03 16:06:15 -04:00
public function it_should_return_data_when_parallel_tasks_has_threads_open()
{
2019-09-03 16:06:15 -04:00
// Create a process
$process = factory(Process::class)->create();
// Create a task
$parallelTask = factory(Task::class)->create();
// Create a case
$application = factory(Application::class)->create();
// Create the threads for a parallel process
factory(Delegation::class, 5)->states('foreign_keys')->create([
2019-10-22 11:15:57 -04:00
'PRO_ID' => $process->PRO_ID,
2019-09-03 16:06:15 -04:00
'TAS_ID' => $parallelTask->TAS_ID,
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_THREAD_STATUS' => 'OPEN'
]);
// Get first page, all the open status
$results = Delegation::search(null, 0, 5, null, null, null);
$this->assertCount(5, $results['data']);
2019-09-03 16:06:15 -04:00
$this->assertEquals('OPEN', $results['data'][rand(0, 4)]['DEL_THREAD_STATUS']);
}
/**
* This ensures return the correct data by sequential
*
* @covers \ProcessMaker\Model\Delegation::search()
* @test
*/
public function it_should_return_data_in_sequential_tasks_with_intermediate_dummy_task()
{
// Create a process
$process = factory(Process::class)->create();
// Create a task
$parallelTask = factory(Task::class)->create();
// Create a case
$application = factory(Application::class)->create(['APP_STATUS_ID' => 2]);
// Create the threads for a parallel process closed
factory(Delegation::class)->states('closed')->create([
2019-10-22 11:15:57 -04:00
'PRO_ID' => $process->PRO_ID,
2019-09-03 16:06:15 -04:00
'PRO_UID' => $process->PRO_UID,
'TAS_ID' => $parallelTask->TAS_ID,
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => 1
]);
// Create the threads for a parallel process closed
factory(Delegation::class)->states('open')->create([
2019-10-22 11:15:57 -04:00
'PRO_ID' => $process->PRO_ID,
2019-09-03 16:06:15 -04:00
'PRO_UID' => $process->PRO_UID,
'TAS_ID' => $parallelTask->TAS_ID,
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => 2
]);
// Get first page, searching for threads are open
$results = Delegation::search(null, 0, 5, $application->APP_NUMBER, null, null, null, null, null, null, null,
'APP_NUMBER');
$this->assertCount(1, $results['data']);
2019-05-07 12:32:34 -04:00
}
2019-05-07 12:32:34 -04:00
/**
* Review when the status is empty
2019-09-03 12:39:37 -04:00
*
2019-09-03 16:06:15 -04:00
* @covers \ProcessMaker\Model\Delegation::search()
2019-05-07 12:32:34 -04:00
* @test
*/
public function it_should_return_status_empty()
{
2019-09-03 16:06:15 -04:00
factory(Delegation::class, 5)->states('foreign_keys')->create([
'APP_NUMBER' => function () {
return factory(Application::class)->create(['APP_STATUS' => ''])->APP_NUMBER;
}
2019-05-07 12:32:34 -04:00
]);
// Review the filter by status empty
2019-09-03 16:06:15 -04:00
$results = Delegation::search(null, 0, 5, null, null, null, 'ASC', 'APP_STATUS_LABEL');
2019-05-22 10:27:00 -04:00
$this->assertEmpty($results['data'][0]['APP_STATUS']);
}
/**
* Review when filter when the process and category does not have a relation
2019-09-03 12:39:37 -04:00
*
2019-09-03 16:06:15 -04:00
* @covers \ProcessMaker\Model\Delegation::search()
2019-05-22 10:27:00 -04:00
* @test
*/
2019-09-03 16:06:15 -04:00
public function it_should_return_empty_when_process_and_category_does_not_have_a_relation()
2019-05-22 10:27:00 -04:00
{
2019-09-03 16:06:15 -04:00
// Create a categories
2019-05-22 10:27:00 -04:00
$category = factory(ProcessCategory::class, 2)->create();
2019-09-03 16:06:15 -04:00
//Create a process with category
$processWithCat = factory(Process::class)->create(['PRO_CATEGORY' => $category[0]->CATEGORY_UID]);
factory(Delegation::class)->states('foreign_keys')->create([
2019-10-22 11:15:57 -04:00
'PRO_ID' => $processWithCat->PRO_ID
2019-05-22 10:27:00 -04:00
]);
2019-09-03 16:06:15 -04:00
// Create a process without category
$processWithoutCat = factory(Process::class)->create(['PRO_CATEGORY' => '']);
factory(Delegation::class, 5)->states('foreign_keys')->create([
2019-10-22 11:15:57 -04:00
'PRO_ID' => $processWithoutCat->PRO_ID
2019-05-22 10:27:00 -04:00
]);
2019-09-03 16:06:15 -04:00
// Search the cases when the process has related to the category and search by another category
2019-10-22 11:15:57 -04:00
$results = Delegation::search(null, 0, 25, null, $processWithCat->PRO_ID, null, null, null,
2019-09-03 12:39:37 -04:00
$category[1]->CATEGORY_UID);
2019-05-22 10:27:00 -04:00
$this->assertCount(0, $results['data']);
2019-09-03 16:06:15 -04:00
// Search the cases when the process has related to the category and search by this relation
2019-10-22 11:15:57 -04:00
$results = Delegation::search(null, 0, 25, null, $processWithCat->PRO_ID, null, null, null,
2019-09-03 12:39:37 -04:00
$category[0]->CATEGORY_UID);
2019-09-03 16:06:15 -04:00
$this->assertCount(1, $results['data']);
// Search the cases when the process does not have relation with category and search by a category
2019-10-22 11:15:57 -04:00
$results = Delegation::search(null, 0, 25, null, $processWithoutCat->PRO_ID, null, null, null,
2019-09-03 16:06:15 -04:00
$category[1]->CATEGORY_UID);
2019-05-22 10:27:00 -04:00
$this->assertCount(0, $results['data']);
2019-09-03 16:06:15 -04:00
// Search the cases when the process does not have relation with category empty
2019-10-22 11:15:57 -04:00
$results = Delegation::search(null, 0, 25, null, $processWithoutCat->PRO_ID, null, null, null,
2019-09-03 16:06:15 -04:00
'');
$this->assertCount(5, $results['data']);
2019-05-22 10:27:00 -04:00
}
/**
* Review when filter when the process and category does have a relation
2019-09-03 12:39:37 -04:00
*
2019-09-03 16:06:15 -04:00
* @covers \ProcessMaker\Model\Delegation::search()
2019-05-22 10:27:00 -04:00
* @test
*/
2019-09-03 16:06:15 -04:00
public function it_should_return_data_when_process_and_category_does_have_a_relation()
2019-05-22 10:27:00 -04:00
{
//Create a category
$category = factory(ProcessCategory::class)->create();
//Define a process related with he previous category
$processWithCat = factory(Process::class)->create([
'PRO_CATEGORY' => $category->CATEGORY_UID
]);
//Create a delegation related to this process
factory(Delegation::class)->create([
2019-10-22 11:15:57 -04:00
'PRO_ID' => $processWithCat->PRO_ID
2019-05-22 10:27:00 -04:00
]);
//Define a process related with he previous category
$process = factory(Process::class)->create([
'PRO_CATEGORY' => ''
]);
//Create a delegation related to other process
factory(Delegation::class, 5)->create([
2019-10-22 11:15:57 -04:00
'PRO_ID' => $process->PRO_ID,
2019-05-22 10:27:00 -04:00
]);
2019-09-03 16:06:15 -04:00
}
2019-05-20 13:23:31 -04:00
/**
* Check if return participation information
2019-09-03 12:39:37 -04:00
*
2019-09-03 16:06:15 -04:00
* @covers \ProcessMaker\Model\Delegation::getParticipatedInfo()
2019-05-20 13:23:31 -04:00
* @test
*/
public function it_should_return_participation_info()
{
// Creating one application with two delegations
factory(User::class, 100)->create();
$process = factory(Process::class)->create();
$application = factory(Application::class)->create([
'PRO_UID' => $process->PRO_UID,
2019-05-20 13:23:31 -04:00
'APP_UID' => G::generateUniqueID()
]);
2019-05-24 12:45:10 -04:00
factory(Delegation::class)->states('closed')->create([
'PRO_UID' => $process->PRO_UID,
2019-05-24 12:45:10 -04:00
'APP_UID' => $application->APP_UID
2019-05-20 13:23:31 -04:00
]);
2019-05-24 12:45:10 -04:00
factory(Delegation::class)->states('open')->create([
'PRO_UID' => $process->PRO_UID,
2019-05-20 13:23:31 -04:00
'APP_UID' => $application->APP_UID,
2019-05-24 12:45:10 -04:00
'DEL_INDEX' => 2
2019-05-20 13:23:31 -04:00
]);
// Check the information returned
$results = Delegation::getParticipatedInfo($application->APP_UID);
$this->assertEquals('PARTICIPATED', $results['APP_STATUS']);
$this->assertCount(2, $results['DEL_INDEX']);
$this->assertEquals($process->PRO_UID, $results['PRO_UID']);
}
/**
* Check if return an empty participation information
2019-09-03 12:39:37 -04:00
*
2019-09-03 16:06:15 -04:00
* @covers \ProcessMaker\Model\Delegation::getParticipatedInfo()
2019-05-20 13:23:31 -04:00
* @test
*/
public function it_should_return_empty_participation_info()
{
// Try to get the participation information from a case that not exists
$results = Delegation::getParticipatedInfo(G::generateUniqueID());
// Check the information returned
$this->assertEmpty($results);
}
2019-05-13 16:44:40 -04:00
2020-02-06 16:30:46 -04:00
/**
* This checks if get the query is working properly in self-service user assigned
*
* @covers \ProcessMaker\Model\Delegation::getSelfServiceQuery()
* @test
*/
public function it_should_get_query_cases_by_user_with_self_service_user_assigned()
{
//Create process
$process = factory(Process::class)->create();
//Create user
$user = factory(User::class)->create();
//Create a task self service
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create the register in delegation relate to self-service
factory(Delegation::class, 25)->create([
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the self-service query
$result = Delegation::getSelfServiceQuery($user->USR_UID);
$this->assertTrue(is_string($result));
}
/**
* This checks if get the query is working properly in self-service-value-based when the variable has a value related
* with the USR_UID When the value assigned in the variable @@ARRAY_OF_USERS = [USR_UID]
*
* @covers \ProcessMaker\Model\Delegation::getSelfServiceQuery()
* @test
*/
public function it_should_get_query_cases_by_user_with_self_service_value_based_usr_uid()
{
//Create process
$process = factory(Process::class)->create();
//Create a case
$application = factory(Application::class)->create();
//Create user
$user = factory(User::class)->create();
//Create a task self service value based
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
'PRO_UID' => $process->PRO_UID
]);
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => 2,
'TAS_ID' => $task->TAS_ID
]);
factory(AppAssignSelfServiceValueGroup::class)->create([
'ID' => $appSelfValue->ID,
'GRP_UID' => $user->USR_UID,
'ASSIGNEE_ID' => $user->USR_ID, //The usrId or grpId
'ASSIGNEE_TYPE' => 1 //Related to the user=1 related to the group=2
]);
//Create the register in self-service
factory(Delegation::class, 25)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => $appSelfValue->DEL_INDEX,
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the self-service query
$result = Delegation::getSelfServiceQuery($user->USR_UID);
$this->assertInstanceOf(\Illuminate\Database\Eloquent\Builder::class, $result);
}
/**
* This checks if get the query is working properly in self-service group assigned
*
* @covers \ProcessMaker\Model\Delegation::getSelfServiceQuery()
* @test
*/
public function it_should_get_query_cases_by_user_with_self_service_group_assigned()
{
//Create process
$process = factory(Process::class)->create();
//Create group
$group = factory(Groupwf::class)->create();
//Create user
$user = factory(User::class)->create();
//Assign a user in the group
factory(GroupUser::class)->create([
'GRP_UID' => $group->GRP_UID,
'GRP_ID' => $group->GRP_ID,
'USR_UID' => $user->USR_UID
]);
//Create a task self service
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 2, //Related to the group
'TU_TYPE' => 1
]);
//Create the register in self-service
factory(Delegation::class, 25)->create([
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the self-service query
$result = Delegation::getSelfServiceQuery($user->USR_UID);
$this->assertTrue(is_string($result));
}
/**
* This checks if get the query is working properly in self-service-value-based when the variable has a value related
* with the GRP_UID When the value assigned in the variable @@ARRAY_OF_USERS = [GRP_UID]
*
* @covers \ProcessMaker\Model\Delegation::getSelfServiceQuery()
* @test
*/
public function it_should_get_query_cases_by_user_with_self_service_value_based_grp_uid()
{
//Create process
$process = factory(Process::class)->create();
//Create a task self service value based
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
'PRO_UID' => $process->PRO_UID
]);
//Create a case
$application = factory(Application::class)->create();
//Create group
$group = factory(Groupwf::class)->create();
//Create user
$user = factory(User::class)->create([
'USR_USERNAME' => 'gary',
'USR_LASTNAME' => 'Gary',
'USR_FIRSTNAME' => 'Bailey',
]);
//Assign a user in the group
factory(GroupUser::class)->create([
'GRP_UID' => $group->GRP_UID,
'GRP_ID' => $group->GRP_ID,
'USR_UID' => $user->USR_UID,
]);
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'APP_UID' => $application->APP_UID,
'DEL_INDEX' => 2,
'TAS_ID' => $task->TAS_ID
]);
factory(AppAssignSelfServiceValueGroup::class)->create([
'ID' => $appSelfValue->ID,
'GRP_UID' => $group->GRP_UID,
'ASSIGNEE_ID' => $group->GRP_ID, //The usrId or grpId
'ASSIGNEE_TYPE' => 2 //Related to the user=1 related to the group=2
]);
//Create the register in self-service
factory(Delegation::class, 25)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => 2,
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the self-service query
$result = Delegation::getSelfServiceQuery($user->USR_UID);
$this->assertInstanceOf(\Illuminate\Database\Eloquent\Builder::class, $result);
}
/**
* This checks if get the query is working properly with self-service and self-service-value-based
*
* @covers \ProcessMaker\Model\Delegation::getSelfServiceQuery()
* @test
*/
public function it_should_get_query_cases_by_user_with_self_service_and_self_service_value_based()
{
//Create process
$process = factory(Process::class)->create();
//Create group
$group = factory(Groupwf::class)->create();
//Create user
$user = factory(User::class)->create();
//Assign a user in the group
factory(GroupUser::class)->create([
'GRP_UID' => $group->GRP_UID,
'GRP_ID' => $group->GRP_ID,
'USR_UID' => $user->USR_UID
]);
//Create a task self service
$taskSelfService = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $taskSelfService->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create the register in self service
factory(Delegation::class)->create([
'TAS_ID' => $taskSelfService->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Create a task self service value based
$taskSelfServiceByVariable = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $taskSelfServiceByVariable->TAS_UID,
'USR_UID' => $group->GRP_UID,
'TU_RELATION' => 2, //Related to the group
'TU_TYPE' => 1
]);
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
$appAssignSelfService = factory(AppAssignSelfServiceValue::class)->create([
'TAS_ID' => $taskSelfServiceByVariable->TAS_ID
]);
factory(AppAssignSelfServiceValueGroup::class)->create([
'ID' => $appAssignSelfService->ID,
'GRP_UID' => $group->GRP_UID,
'ASSIGNEE_ID' => $group->GRP_ID, //The usrId or grpId
'ASSIGNEE_TYPE' => 2 //Related to the user=1 related to the group=2
]);
//Create the register in self service value based
factory(Delegation::class)->create([
'APP_NUMBER' => $appAssignSelfService->APP_NUMBER,
'DEL_INDEX' => $appAssignSelfService->DEL_INDEX,
'TAS_ID' => $taskSelfServiceByVariable->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the self-service query
$result = Delegation::getSelfServiceQuery($user->USR_UID);
$this->assertTrue(is_string($result));
}
/**
* This checks if get the query is working properly in self-service user and group assigned in parallel task
*
* @covers \ProcessMaker\Model\Delegation::getSelfServiceQuery()
* @test
*/
public function it_should_get_query_cases_by_user_with_self_service_user_and_group_assigned_parallel_task()
{
//Create process
$process = factory(Process::class)->create();
//Create group
$group = factory(Groupwf::class)->create();
//Create user
$user = factory(User::class)->create();
//Assign a user in the group
factory(GroupUser::class)->create([
'GRP_UID' => $group->GRP_UID,
'GRP_ID' => $group->GRP_ID,
'USR_UID' => $user->USR_UID
]);
//Create a task self service
$task1 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task1
factory(TaskUser::class)->create([
'TAS_UID' => $task1->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create a task self service
$task2 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task2
factory(TaskUser::class)->create([
'TAS_UID' => $task2->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create a task self service
$task3 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $task3->TAS_UID,
'USR_UID' => $group->GRP_UID,
'TU_RELATION' => 2, //Related to the group
'TU_TYPE' => 1
]);
//Create a task self service
$task4 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $task4->TAS_UID,
'USR_UID' => $group->GRP_UID,
'TU_RELATION' => 2, //Related to the group
'TU_TYPE' => 1
]);
//Create the register in self-service related to the task1
factory(Delegation::class, 10)->create([
'TAS_ID' => $task1->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Create the register in self-service related to the task2
factory(Delegation::class, 10)->create([
'TAS_ID' => $task2->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Create the register in self-service related to the task3
factory(Delegation::class, 10)->create([
'TAS_ID' => $task3->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Create the register in self-service related to the task4
factory(Delegation::class, 10)->create([
'TAS_ID' => $task4->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the self-service query
$result = Delegation::getSelfServiceQuery($user->USR_UID);
$this->assertTrue(is_string($result));
}
/**
* This checks if get the query is working properly in self-service-value-based with GRP_UID and USR_UID in parallel
* task When the value assigned in the variable @@ARRAY_OF_USERS = [GRP_UID, USR_UID]
*
* @covers \ProcessMaker\Model\Delegation::getSelfServiceQuery()
* @test
*/
public function it_should_get_query_cases_by_user_with_self_service_value_based_usr_uid_and_grp_uid()
{
//Create process
$process = factory(Process::class)->create();
//Create a case
$application = factory(Application::class)->create();
//Create user
$user = factory(User::class)->create();
//Create a task1 self service value based
$task1 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
'PRO_UID' => $process->PRO_UID
]);
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'TAS_ID' => $task1->TAS_ID
]);
factory(AppAssignSelfServiceValueGroup::class)->create([
'ID' => $appSelfValue->ID,
'GRP_UID' => $user->USR_UID,
'ASSIGNEE_ID' => $user->USR_ID, //The usrId or grpId
'ASSIGNEE_TYPE' => 1 //Related to the user=1 related to the group=2
]);
//Create the register in self-service
factory(Delegation::class, 10)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => $appSelfValue->DEL_INDEX,
'TAS_ID' => $task1->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Create a task2 self service value based
$task2 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
'PRO_UID' => $process->PRO_UID
]);
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'TAS_ID' => $task2->TAS_ID
]);
factory(AppAssignSelfServiceValueGroup::class)->create([
'ID' => $appSelfValue->ID,
'GRP_UID' => $user->USR_UID,
'ASSIGNEE_ID' => $user->USR_ID, //The usrId or grpId
'ASSIGNEE_TYPE' => 1 //Related to the user=1 related to the group=2
]);
//Create the register in self-service
factory(Delegation::class, 15)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => $appSelfValue->DEL_INDEX,
'TAS_ID' => $task2->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the self-service query
$result = Delegation::getSelfServiceQuery($user->USR_UID);
$this->assertInstanceOf(\Illuminate\Database\Eloquent\Builder::class, $result);
}
/**
* This checks if get the records is working properly in self-service user assigned
*
* @covers \ProcessMaker\Model\Delegation::getSelfService()
* @test
*/
public function it_should_get_cases_by_user_with_self_service_user_assigned()
{
//Create process
$process = factory(Process::class)->create();
//Create user
$user = factory(User::class)->create();
//Create a task self service
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create the register in delegation relate to self-service
factory(Delegation::class, 25)->create([
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the self-service records
$result = Delegation::getSelfService($user->USR_UID);
$this->assertEquals(25, count($result));
}
/**
* This checks if get the records is working properly in self-service-value-based when the variable has a value related
* with the USR_UID When the value assigned in the variable @@ARRAY_OF_USERS = [USR_UID]
*
* @covers \ProcessMaker\Model\Delegation::getSelfService()
* @test
*/
public function it_should_get_cases_by_user_with_self_service_value_based_usr_uid()
{
//Create process
$process = factory(Process::class)->create();
//Create a case
$application = factory(Application::class)->create();
//Create user
$user = factory(User::class)->create();
//Create a task self service value based
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
'PRO_UID' => $process->PRO_UID
]);
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => 2,
'TAS_ID' => $task->TAS_ID
]);
factory(AppAssignSelfServiceValueGroup::class)->create([
'ID' => $appSelfValue->ID,
'GRP_UID' => $user->USR_UID,
'ASSIGNEE_ID' => $user->USR_ID, //The usrId or grpId
'ASSIGNEE_TYPE' => 1 //Related to the user=1 related to the group=2
]);
//Create the register in self-service
factory(Delegation::class, 25)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => $appSelfValue->DEL_INDEX,
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the self-service records
$result = Delegation::getSelfService($user->USR_UID);
$this->assertEquals(25, count($result));
}
/**
* This checks if get the records is working properly in self-service group assigned
*
* @covers \ProcessMaker\Model\Delegation::getSelfService()
* @test
*/
public function it_should_get_cases_by_user_with_self_service_group_assigned()
{
//Create process
$process = factory(Process::class)->create();
//Create group
$group = factory(Groupwf::class)->create();
//Create user
$user = factory(User::class)->create();
//Assign a user in the group
factory(GroupUser::class)->create([
'GRP_UID' => $group->GRP_UID,
'GRP_ID' => $group->GRP_ID,
'USR_UID' => $user->USR_UID
]);
//Create a task self service
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 2, //Related to the group
'TU_TYPE' => 1
]);
//Create the register in self-service
factory(Delegation::class, 25)->create([
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the self-service records
$result = Delegation::getSelfService($user->USR_UID);
$this->assertEquals(25, count($result));
}
/**
* This checks if get the records is working properly in self-service-value-based when the variable has a value related
* with the GRP_UID When the value assigned in the variable @@ARRAY_OF_USERS = [GRP_UID]
*
* @covers \ProcessMaker\Model\Delegation::getSelfService()
* @test
*/
public function it_should_get_cases_by_user_with_self_service_value_based_grp_uid()
{
//Create process
$process = factory(Process::class)->create();
//Create a task self service value based
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
'PRO_UID' => $process->PRO_UID
]);
//Create a case
$application = factory(Application::class)->create();
//Create group
$group = factory(Groupwf::class)->create();
//Create user
$user = factory(User::class)->create([
'USR_USERNAME' => 'gary',
'USR_LASTNAME' => 'Gary',
'USR_FIRSTNAME' => 'Bailey',
]);
//Assign a user in the group
factory(GroupUser::class)->create([
'GRP_UID' => $group->GRP_UID,
'GRP_ID' => $group->GRP_ID,
'USR_UID' => $user->USR_UID,
]);
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'APP_UID' => $application->APP_UID,
'DEL_INDEX' => 2,
'TAS_ID' => $task->TAS_ID
]);
factory(AppAssignSelfServiceValueGroup::class)->create([
'ID' => $appSelfValue->ID,
'GRP_UID' => $group->GRP_UID,
'ASSIGNEE_ID' => $group->GRP_ID, //The usrId or grpId
'ASSIGNEE_TYPE' => 2 //Related to the user=1 related to the group=2
]);
//Create the register in self-service
factory(Delegation::class, 25)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => 2,
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the self-service records
$result = Delegation::getSelfService($user->USR_UID);
$this->assertEquals(25, count($result));
}
/**
* This checks if get the records is working properly with self-service and self-service-value-based
*
* @covers \ProcessMaker\Model\Delegation::getSelfService()
* @test
*/
public function it_should_get_cases_by_user_with_self_service_and_self_service_value_based()
{
//Create process
$process = factory(Process::class)->create();
//Create group
$group = factory(Groupwf::class)->create();
//Create user
$user = factory(User::class)->create();
//Assign a user in the group
factory(GroupUser::class)->create([
'GRP_UID' => $group->GRP_UID,
'GRP_ID' => $group->GRP_ID,
'USR_UID' => $user->USR_UID
]);
//Create a task self service
$taskSelfService = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $taskSelfService->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create the register in self service
factory(Delegation::class)->create([
'TAS_ID' => $taskSelfService->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Create a task self service value based
$taskSelfServiceByVariable = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $taskSelfServiceByVariable->TAS_UID,
'USR_UID' => $group->GRP_UID,
'TU_RELATION' => 2, //Related to the group
'TU_TYPE' => 1
]);
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
$appAssignSelfService = factory(AppAssignSelfServiceValue::class)->create([
'TAS_ID' => $taskSelfServiceByVariable->TAS_ID
]);
factory(AppAssignSelfServiceValueGroup::class)->create([
'ID' => $appAssignSelfService->ID,
'GRP_UID' => $group->GRP_UID,
'ASSIGNEE_ID' => $group->GRP_ID, //The usrId or grpId
'ASSIGNEE_TYPE' => 2 //Related to the user=1 related to the group=2
]);
//Create the register in self service value based
factory(Delegation::class)->create([
'APP_NUMBER' => $appAssignSelfService->APP_NUMBER,
'DEL_INDEX' => $appAssignSelfService->DEL_INDEX,
'TAS_ID' => $taskSelfServiceByVariable->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the self-service records
$result = Delegation::getSelfService($user->USR_UID);
$this->assertEquals(2, count($result));
}
/**
* This checks if get the records is working properly in self-service user and group assigned in parallel task
*
* @covers \ProcessMaker\Model\Delegation::getSelfService()
* @test
*/
public function it_should_get_cases_by_user_with_self_service_user_and_group_assigned_parallel_task()
{
//Create process
$process = factory(Process::class)->create();
//Create group
$group = factory(Groupwf::class)->create();
//Create user
$user = factory(User::class)->create();
//Assign a user in the group
factory(GroupUser::class)->create([
'GRP_UID' => $group->GRP_UID,
'GRP_ID' => $group->GRP_ID,
'USR_UID' => $user->USR_UID
]);
//Create a task self service
$task1 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task1
factory(TaskUser::class)->create([
'TAS_UID' => $task1->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create a task self service
$task2 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task2
factory(TaskUser::class)->create([
'TAS_UID' => $task2->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create a task self service
$task3 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $task3->TAS_UID,
'USR_UID' => $group->GRP_UID,
'TU_RELATION' => 2, //Related to the group
'TU_TYPE' => 1
]);
//Create a task self service
$task4 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $task4->TAS_UID,
'USR_UID' => $group->GRP_UID,
'TU_RELATION' => 2, //Related to the group
'TU_TYPE' => 1
]);
//Create the register in self-service related to the task1
factory(Delegation::class, 10)->create([
'TAS_ID' => $task1->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Create the register in self-service related to the task2
factory(Delegation::class, 10)->create([
'TAS_ID' => $task2->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Create the register in self-service related to the task3
factory(Delegation::class, 10)->create([
'TAS_ID' => $task3->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Create the register in self-service related to the task4
factory(Delegation::class, 10)->create([
'TAS_ID' => $task4->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the self-service records
$result = Delegation::getSelfService($user->USR_UID);
$this->assertEquals(40, count($result));
}
/**
* This checks if get the records is working properly in self-service-value-based with GRP_UID and USR_UID in parallel
* task When the value assigned in the variable @@ARRAY_OF_USERS = [GRP_UID, USR_UID]
*
* @covers \ProcessMaker\Model\Delegation::getSelfService()
* @test
*/
public function it_should_get_cases_by_user_with_self_service_value_based_usr_uid_and_grp_uid()
{
//Create process
$process = factory(Process::class)->create();
//Create a case
$application = factory(Application::class)->create();
//Create user
$user = factory(User::class)->create();
//Create a task1 self service value based
$task1 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
'PRO_UID' => $process->PRO_UID
]);
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'TAS_ID' => $task1->TAS_ID
]);
factory(AppAssignSelfServiceValueGroup::class)->create([
'ID' => $appSelfValue->ID,
'GRP_UID' => $user->USR_UID,
'ASSIGNEE_ID' => $user->USR_ID, //The usrId or grpId
'ASSIGNEE_TYPE' => 1 //Related to the user=1 related to the group=2
]);
//Create the register in self-service
factory(Delegation::class, 10)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => $appSelfValue->DEL_INDEX,
'TAS_ID' => $task1->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Create a task2 self service value based
$task2 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
'PRO_UID' => $process->PRO_UID
]);
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'TAS_ID' => $task2->TAS_ID
]);
factory(AppAssignSelfServiceValueGroup::class)->create([
'ID' => $appSelfValue->ID,
'GRP_UID' => $user->USR_UID,
'ASSIGNEE_ID' => $user->USR_ID, //The usrId or grpId
'ASSIGNEE_TYPE' => 1 //Related to the user=1 related to the group=2
]);
//Create the register in self-service
factory(Delegation::class, 15)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => $appSelfValue->DEL_INDEX,
'TAS_ID' => $task2->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the self-service records
$result = Delegation::getSelfService($user->USR_UID);
$this->assertEquals(25, count($result));
}
2019-05-13 16:44:40 -04:00
/**
* This checks the counters is working properly in self-service user assigned
2019-09-03 12:39:37 -04:00
*
2019-09-03 16:06:15 -04:00
* @covers \ProcessMaker\Model\Delegation::countSelfService()
2019-05-13 16:44:40 -04:00
* @test
*/
public function it_should_count_cases_by_user_with_self_service_user_assigned()
{
//Create process
$process = factory(Process::class)->create();
//Create user
$user = factory(User::class)->create();
//Create a task self service
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create the register in delegation relate to self-service
factory(Delegation::class, 25)->create([
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the count self-service
$result = Delegation::countSelfService($user->USR_UID);
$this->assertEquals(25, $result);
}
/**
2019-09-03 12:39:37 -04:00
* This checks the counters is working properly in self-service-value-based when the variable has a value related
* with the USR_UID When the value assigned in the variable @@ARRAY_OF_USERS = [USR_UID]
*
2019-09-03 16:06:15 -04:00
* @covers \ProcessMaker\Model\Delegation::countSelfService()
2019-05-13 16:44:40 -04:00
* @test
*/
public function it_should_count_cases_by_user_with_self_service_value_based_usr_uid()
{
//Create process
$process = factory(Process::class)->create();
//Create a case
$application = factory(Application::class)->create();
//Create user
$user = factory(User::class)->create();
//Create a task self service value based
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
'PRO_UID' => $process->PRO_UID
]);
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => 2,
'TAS_ID' => $task->TAS_ID
]);
factory(AppAssignSelfServiceValueGroup::class)->create([
'ID' => $appSelfValue->ID,
'GRP_UID' => $user->USR_UID,
'ASSIGNEE_ID' => $user->USR_ID, //The usrId or grpId
'ASSIGNEE_TYPE' => 1 //Related to the user=1 related to the group=2
]);
//Create the register in self-service
factory(Delegation::class, 25)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => $appSelfValue->DEL_INDEX,
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the count self-service
$result = Delegation::countSelfService($user->USR_UID);
$this->assertEquals(25, $result);
}
/**
* This checks the counters is working properly in self-service group assigned
2019-09-03 12:39:37 -04:00
*
2019-09-03 16:06:15 -04:00
* @covers \ProcessMaker\Model\Delegation::countSelfService()
2019-05-13 16:44:40 -04:00
* @test
*/
public function it_should_count_cases_by_user_with_self_service_group_assigned()
{
//Create process
$process = factory(Process::class)->create();
//Create group
$group = factory(Groupwf::class)->create();
//Create user
$user = factory(User::class)->create();
//Assign a user in the group
factory(GroupUser::class)->create([
'GRP_UID' => $group->GRP_UID,
'GRP_ID' => $group->GRP_ID,
'USR_UID' => $user->USR_UID
]);
//Create a task self service
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 2, //Related to the group
'TU_TYPE' => 1
]);
//Create the register in self-service
factory(Delegation::class, 25)->create([
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the count self-service
$result = Delegation::countSelfService($user->USR_UID);
$this->assertEquals(25, $result);
}
/**
2019-09-03 12:39:37 -04:00
* This checks the counters is working properly in self-service-value-based when the variable has a value related
* with the GRP_UID When the value assigned in the variable @@ARRAY_OF_USERS = [GRP_UID]
*
2019-09-03 16:06:15 -04:00
* @covers \ProcessMaker\Model\Delegation::countSelfService()
2019-05-13 16:44:40 -04:00
* @test
*/
public function it_should_count_cases_by_user_with_self_service_value_based_grp_uid()
{
//Create process
$process = factory(Process::class)->create();
//Create a task self service value based
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
'PRO_UID' => $process->PRO_UID
]);
//Create a case
$application = factory(Application::class)->create();
//Create group
$group = factory(Groupwf::class)->create();
//Create user
$user = factory(User::class)->create([
'USR_USERNAME' => 'gary',
'USR_LASTNAME' => 'Gary',
'USR_FIRSTNAME' => 'Bailey',
]);
//Assign a user in the group
factory(GroupUser::class)->create([
'GRP_UID' => $group->GRP_UID,
'GRP_ID' => $group->GRP_ID,
'USR_UID' => $user->USR_UID,
]);
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'APP_UID' => $application->APP_UID,
'DEL_INDEX' => 2,
'TAS_ID' => $task->TAS_ID
]);
factory(AppAssignSelfServiceValueGroup::class)->create([
'ID' => $appSelfValue->ID,
'GRP_UID' => $group->GRP_UID,
'ASSIGNEE_ID' => $group->GRP_ID, //The usrId or grpId
'ASSIGNEE_TYPE' => 2 //Related to the user=1 related to the group=2
]);
//Create the register in self-service
factory(Delegation::class, 25)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => 2,
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the count self-service
$result = Delegation::countSelfService($user->USR_UID);
$this->assertEquals(25, $result);
}
2020-01-30 11:24:53 -04:00
/**
* This checks the counters is working properly with self-service and self-service-value-based
*
* @covers \ProcessMaker\Model\Delegation::countSelfService()
* @test
*/
public function it_should_count_cases_by_user_with_self_service_and_self_service_value_based()
{
//Create process
$process = factory(Process::class)->create();
//Create group
$group = factory(Groupwf::class)->create();
//Create user
$user = factory(User::class)->create();
//Assign a user in the group
factory(GroupUser::class)->create([
'GRP_UID' => $group->GRP_UID,
'GRP_ID' => $group->GRP_ID,
'USR_UID' => $user->USR_UID
]);
//Create a task self service
$taskSelfService = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $taskSelfService->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create the register in self service
factory(Delegation::class)->create([
'TAS_ID' => $taskSelfService->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Create a task self service value based
$taskSelfServiceByVariable = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $taskSelfServiceByVariable->TAS_UID,
'USR_UID' => $group->GRP_UID,
'TU_RELATION' => 2, //Related to the group
'TU_TYPE' => 1
]);
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
$appAssignSelfService = factory(AppAssignSelfServiceValue::class)->create([
'TAS_ID' => $taskSelfServiceByVariable->TAS_ID
]);
factory(AppAssignSelfServiceValueGroup::class)->create([
'ID' => $appAssignSelfService->ID,
'GRP_UID' => $group->GRP_UID,
'ASSIGNEE_ID' => $group->GRP_ID, //The usrId or grpId
'ASSIGNEE_TYPE' => 2 //Related to the user=1 related to the group=2
]);
//Create the register in self service value based
factory(Delegation::class)->create([
'APP_NUMBER' => $appAssignSelfService->APP_NUMBER,
'DEL_INDEX' => $appAssignSelfService->DEL_INDEX,
'TAS_ID' => $taskSelfServiceByVariable->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the count self-service
$result = Delegation::countSelfService($user->USR_UID);
$this->assertEquals(2, $result);
}
2019-05-13 16:44:40 -04:00
/**
* This checks the counters is working properly in self-service user and group assigned in parallel task
2019-09-03 12:39:37 -04:00
*
2019-09-03 16:06:15 -04:00
* @covers \ProcessMaker\Model\Delegation::countSelfService()
2019-05-13 16:44:40 -04:00
* @test
*/
public function it_should_count_cases_by_user_with_self_service_user_and_group_assigned_parallel_task()
{
//Create process
$process = factory(Process::class)->create();
//Create group
$group = factory(Groupwf::class)->create();
//Create user
$user = factory(User::class)->create();
//Assign a user in the group
factory(GroupUser::class)->create([
'GRP_UID' => $group->GRP_UID,
'GRP_ID' => $group->GRP_ID,
'USR_UID' => $user->USR_UID
]);
//Create a task self service
$task1 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task1
factory(TaskUser::class)->create([
'TAS_UID' => $task1->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create a task self service
$task2 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task2
factory(TaskUser::class)->create([
'TAS_UID' => $task2->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create a task self service
$task3 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $task3->TAS_UID,
'USR_UID' => $group->GRP_UID,
'TU_RELATION' => 2, //Related to the group
'TU_TYPE' => 1
]);
//Create a task self service
$task4 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $task4->TAS_UID,
'USR_UID' => $group->GRP_UID,
'TU_RELATION' => 2, //Related to the group
'TU_TYPE' => 1
]);
//Create the register in self-service related to the task1
factory(Delegation::class, 10)->create([
'TAS_ID' => $task1->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Create the register in self-service related to the task2
factory(Delegation::class, 10)->create([
'TAS_ID' => $task2->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Create the register in self-service related to the task3
factory(Delegation::class, 10)->create([
'TAS_ID' => $task3->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Create the register in self-service related to the task4
factory(Delegation::class, 10)->create([
'TAS_ID' => $task4->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the count self-service
$result = Delegation::countSelfService($user->USR_UID);
$this->assertEquals(40, $result);
}
/**
2019-09-03 12:39:37 -04:00
* This checks the counters is working properly in self-service-value-based with GRP_UID and USR_UID in parallel
* task When the value assigned in the variable @@ARRAY_OF_USERS = [GRP_UID, USR_UID]
*
2019-09-03 16:06:15 -04:00
* @covers \ProcessMaker\Model\Delegation::countSelfService()
2019-05-13 16:44:40 -04:00
* @test
*/
public function it_should_count_cases_by_user_with_self_service_value_based_usr_uid_and_grp_uid()
{
//Create process
$process = factory(Process::class)->create();
//Create a case
$application = factory(Application::class)->create();
//Create user
$user = factory(User::class)->create();
//Create a task1 self service value based
$task1 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
'PRO_UID' => $process->PRO_UID
]);
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'TAS_ID' => $task1->TAS_ID
]);
factory(AppAssignSelfServiceValueGroup::class)->create([
'ID' => $appSelfValue->ID,
'GRP_UID' => $user->USR_UID,
'ASSIGNEE_ID' => $user->USR_ID, //The usrId or grpId
'ASSIGNEE_TYPE' => 1 //Related to the user=1 related to the group=2
]);
//Create the register in self-service
factory(Delegation::class, 10)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => $appSelfValue->DEL_INDEX,
'TAS_ID' => $task1->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Create a task2 self service value based
$task2 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
'PRO_UID' => $process->PRO_UID
]);
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'TAS_ID' => $task2->TAS_ID
]);
factory(AppAssignSelfServiceValueGroup::class)->create([
'ID' => $appSelfValue->ID,
'GRP_UID' => $user->USR_UID,
'ASSIGNEE_ID' => $user->USR_ID, //The usrId or grpId
'ASSIGNEE_TYPE' => 1 //Related to the user=1 related to the group=2
]);
//Create the register in self-service
factory(Delegation::class, 15)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => $appSelfValue->DEL_INDEX,
'TAS_ID' => $task2->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the count self-service
$result = Delegation::countSelfService($user->USR_UID);
$this->assertEquals(25, $result);
}
2019-07-25 16:12:48 -04:00
/**
* This check if return the USR_UID assigned in the thread OPEN
*
2019-09-03 16:06:15 -04:00
* @covers \ProcessMaker\Model\Delegation::getCurrentUser()
2019-07-25 16:12:48 -04:00
* @test
*/
public function it_should_return_current_user_for_thread_open()
{
//Create process
$process = factory(Process::class)->create();
//Create a case
$application = factory(Application::class)->create();
//Create user
$user = factory(User::class)->create();
//Create a delegation
factory(Delegation::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 2,
'USR_UID' => $user->USR_UID,
]);
factory(Delegation::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_THREAD_STATUS' => 'CLOSED',
'DEL_INDEX' => 1,
'USR_UID' => $user->USR_UID,
]);
//Get the current user assigned in the open thread
$result = Delegation::getCurrentUser($application->APP_NUMBER, 2, 'OPEN');
$this->assertEquals($user->USR_UID, $result);
}
/**
* This check if return the USR_UID assigned in the thread CLOSED
*
2019-09-03 16:06:15 -04:00
* @covers \ProcessMaker\Model\Delegation::getCurrentUser()
2019-07-25 16:12:48 -04:00
* @test
*/
public function it_should_return_current_user_for_thread_closed()
{
//Create process
$process = factory(Process::class)->create();
//Create a case
$application = factory(Application::class)->create();
//Create user
$user = factory(User::class)->create();
//Create a delegation
factory(Delegation::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_THREAD_STATUS' => 'CLOSED',
'DEL_INDEX' => 1,
'USR_UID' => $user->USR_UID,
]);
factory(Delegation::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 2,
'USR_UID' => $user->USR_UID,
]);
//Get the current user assigned in the open thread
$result = Delegation::getCurrentUser($application->APP_NUMBER, 1, 'CLOSED');
$this->assertEquals($user->USR_UID, $result);
}
/**
* This check if return empty when the data does not exits
*
2019-09-03 16:06:15 -04:00
* @covers \ProcessMaker\Model\Delegation::getCurrentUser()
2019-07-25 16:12:48 -04:00
* @test
*/
public function it_should_return_empty_when_row_does_not_exist()
{
//Create process
$process = factory(Process::class)->create();
//Create a case
$application = factory(Application::class)->create();
//Create user
$user = factory(User::class)->create();
//Create a delegation
factory(Delegation::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_THREAD_STATUS' => 'CLOSED',
'DEL_INDEX' => 1,
'USR_UID' => $user->USR_UID,
]);
factory(Delegation::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_INDEX' => 2,
'USR_UID' => $user->USR_UID,
]);
//Get the current user assigned in the open thread
$result = Delegation::getCurrentUser($application->APP_NUMBER, 3, 'CLOSED');
$this->assertEmpty($result);
$result = Delegation::getCurrentUser($application->APP_NUMBER, 3, 'OPEN');
$this->assertEmpty($result);
}
/**
* This checks if return the open thread
*
2019-09-03 16:06:15 -04:00
* @covers \ProcessMaker\Model\Delegation::getOpenThreads()
2019-07-25 16:12:48 -04:00
* @test
*/
public function it_should_return_thread_open()
{
//Create process
$process = factory(Process::class)->create();
//Create a case
$application = factory(Application::class)->create();
//Create user
$user = factory(User::class)->create();
//Create task
$task = factory(Task::class)->create();
//Create a delegation
factory(Delegation::class)->create([
'DEL_THREAD_STATUS' => 'OPEN',
'DEL_FINISH_DATE' => null,
'APP_NUMBER' => $application->APP_NUMBER,
'TAS_UID' => $task->TAS_UID,
]);
$result = Delegation::getOpenThreads($application->APP_NUMBER, $task->TAS_UID);
$this->assertEquals($application->APP_NUMBER, $result['APP_NUMBER']);
}
/**
* This checks if return empty when the thread is CLOSED
*
2019-09-03 16:06:15 -04:00
* @covers \ProcessMaker\Model\Delegation::getOpenThreads()
2019-07-25 16:12:48 -04:00
* @test
*/
public function it_should_return_empty_when_thread_is_closed()
{
//Create process
$process = factory(Process::class)->create();
//Create a case
$application = factory(Application::class)->create();
//Create task
$task = factory(Task::class)->create();
//Create a delegation
factory(Delegation::class)->create([
'DEL_THREAD_STATUS' => 'CLOSED',
'APP_NUMBER' => $application->APP_NUMBER,
'TAS_UID' => $task->TAS_UID,
]);
$result = Delegation::getOpenThreads($application->APP_NUMBER, $task->TAS_UID);
$this->assertEmpty($result);
}
/**
* This checks if return empty when the data is not null
*
2019-09-03 16:06:15 -04:00
* @covers \ProcessMaker\Model\Delegation::getOpenThreads()
2019-07-25 16:12:48 -04:00
* @test
*/
public function it_should_return_empty_when_thread_finish_date_is_not_null()
{
//Create process
$process = factory(Process::class)->create();
//Create a case
$application = factory(Application::class)->create();
//Create user
$user = factory(User::class)->create();
//Create task
$task = factory(Task::class)->create();
//Create a delegation
factory(Delegation::class)->create([
'DEL_THREAD_STATUS' => 'CLOSED',
'APP_NUMBER' => $application->APP_NUMBER,
'TAS_UID' => $task->TAS_UID,
]);
$result = Delegation::getOpenThreads($application->APP_NUMBER, $task->TAS_UID);
$this->assertEmpty($result);
}
2019-09-03 12:39:37 -04:00
/**
* This checks if return the participation when the user does have participation
*
* @covers \ProcessMaker\Model\Delegation::participation()
* @test
*/
public function it_when_the_user_does_have_participation()
{
factory(Process::class)->create();
//Create user
$user = factory(User::class)->create();
$application = factory(Application::class)->create();
//Create a delegation
factory(Delegation::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'APP_UID' => $application->APP_UID,
'USR_ID' => $user->USR_ID,
'USR_UID' => $user->USR_UID
]);
$result = Delegation::participation($application->APP_UID, $user->USR_UID);
$this->assertTrue($result);
}
/**
* This checks if return the participation of the user when the user does not have participation
*
* @covers \ProcessMaker\Model\Delegation::participation()
* @test
*/
public function it_when_the_user_does_not_have_participation()
{
factory(Process::class)->create();
//Create user
$user = factory(User::class)->create();
$application = factory(Application::class)->create();
//Create a delegation
factory(Delegation::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'APP_UID' => $application->APP_UID
]);
$result = Delegation::participation($application->APP_UID, $user->USR_UID);
$this->assertFalse($result);
}
2020-11-19 17:21:05 -04:00
/**
* This check the return of thread title
*
* @covers \ProcessMaker\Model\Delegation::getThreadTitle()
* @test
*/
public function it_get_thread_title()
{
$delegation = factory(Delegation::class)->states('foreign_keys')->create();
$result = Delegation::getThreadTitle($delegation->TAS_UID, $delegation->APP_NUMBER, $delegation->DEL_INDEX, []);
$this->assertNotEmpty($result);
}
2020-12-07 09:21:51 -04:00
/**
* This tests the getDeltitle() method
*
* @covers \ProcessMaker\Model\Delegation::getDeltitle()
* @test
*/
public function it_should_test_the_get_del_title_method()
{
$delegation = factory(Delegation::class)->create([
'DEL_TITLE' => "test"
]);
$result = Delegation::getDeltitle($delegation->APP_NUMBER, $delegation->DEL_INDEX);
$this->assertNotEmpty($result);
$this->assertEquals($result, $delegation->DEL_TITLE);
}
2021-03-23 15:13:52 -04:00
/**
* It should test the hasActiveParentsCases() method
*
* @covers \ProcessMaker\Model\Delegation::hasActiveParentsCases()
* @test
*/
public function it_should_test_the_has_active_parents_cases_method()
{
$process = factory(Process::class)->create();
$processParent = factory(Process::class, 3)->create();
factory(SubProcess::class)->create([
'PRO_UID' => $process['PRO_UID'],
'PRO_PARENT' => $processParent[0]['PRO_UID']
]);
factory(SubProcess::class)->create([
'PRO_UID' => $process['PRO_UID'],
'PRO_PARENT' => $processParent[1]['PRO_UID']
]);
factory(SubProcess::class)->create([
'PRO_UID' => $process['PRO_UID'],
'PRO_PARENT' => $processParent[2]['PRO_UID']
]);
$parents = SubProcess::getProParents($process['PRO_UID']);
factory(Delegation::class)->create([
'PRO_UID' => $parents[0]['PRO_PARENT'],
'TAS_UID' => $parents[0]['TAS_PARENT'],
'DEL_THREAD_STATUS' => 'OPEN'
]);
$res = Delegation::hasActiveParentsCases($parents);
// Assert the result is true
$this->assertTrue($res);
}
}