2019-05-01 13:49:05 -07:00
|
|
|
<?php
|
|
|
|
|
namespace Tests\unit\workflow\src\ProcessMaker\Model;
|
|
|
|
|
|
2019-05-20 13:23:31 -04:00
|
|
|
use G;
|
|
|
|
|
use Faker;
|
2019-05-01 13:49:05 -07:00
|
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
2019-05-02 10:53:43 -04:00
|
|
|
use ProcessMaker\Model\Application;
|
2019-05-01 13:49:05 -07:00
|
|
|
use ProcessMaker\Model\Delegation;
|
2019-05-02 10:53:43 -04:00
|
|
|
use ProcessMaker\Model\Process;
|
2019-05-02 14:48:50 -04:00
|
|
|
use ProcessMaker\Model\ProcessCategory;
|
2019-05-02 13:23:23 -04:00
|
|
|
use ProcessMaker\Model\Task;
|
2019-05-02 10:53:43 -04:00
|
|
|
use ProcessMaker\Model\User;
|
2019-05-01 13:49:05 -07:00
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
|
|
class DelegationTest extends TestCase
|
|
|
|
|
{
|
|
|
|
|
use DatabaseTransactions;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This checks to make sure pagination is working properly
|
|
|
|
|
* @test
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_return_pages_of_data()
|
2019-05-02 16:51:47 -04:00
|
|
|
{
|
2019-05-03 08:03:56 -04:00
|
|
|
factory(User::class, 100)->create();
|
|
|
|
|
factory(Process::class, 10)->create();
|
2019-05-02 16:51:47 -04:00
|
|
|
factory(Delegation::class, 51)->create();
|
|
|
|
|
// 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-03 08:03:56 -04:00
|
|
|
|
2019-05-02 16:51:47 -04:00
|
|
|
/**
|
|
|
|
|
* This checks to make sure pagination is working properly
|
|
|
|
|
* @test
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_return_pages_of_data_unassigned()
|
2019-05-01 13:49:05 -07:00
|
|
|
{
|
2019-05-03 08:03:56 -04:00
|
|
|
factory(User::class, 100)->create();
|
|
|
|
|
factory(Process::class, 10)->create();
|
2019-05-02 14:06:55 -07:00
|
|
|
|
2019-05-02 16:30:07 -04:00
|
|
|
factory(Delegation::class, 50)->create();
|
|
|
|
|
factory(Delegation::class, 1)->create([
|
|
|
|
|
'USR_ID' => 0 // A self service delegation
|
|
|
|
|
]);
|
2019-05-01 13:49:05 -07:00
|
|
|
// 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-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-05-03 08:03:56 -04:00
|
|
|
factory(User::class, 100)->create();
|
2019-05-02 10:53:43 -04:00
|
|
|
$process = factory(Process::class, 1)->create([
|
|
|
|
|
'PRO_ID' => 1
|
|
|
|
|
]);
|
|
|
|
|
factory(Delegation::class, 51)->create([
|
|
|
|
|
'PRO_ID' => $process[0]->id
|
|
|
|
|
]);
|
2019-05-01 18:10:46 -04:00
|
|
|
// Get first page, which is 25
|
2019-05-02 10:53:43 -04:00
|
|
|
$results = Delegation::search(null, 0, 25, null, $process[0]->id);
|
|
|
|
|
$this->assertCount(25, $results['data']);
|
2019-05-01 18:10:46 -04:00
|
|
|
// Get second page, which is 25 results
|
2019-05-03 08:03:56 -04:00
|
|
|
$results = Delegation::search(null, 25, 25, null, $process[0]->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-03 08:03:56 -04:00
|
|
|
$results = Delegation::search(null, 50, 25, null, $process[0]->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-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-03 08:03:56 -04:00
|
|
|
factory(User::class, 100)->create();
|
|
|
|
|
factory(Process::class, 1)->create();
|
2019-05-02 10:53:43 -04:00
|
|
|
$application = factory(Application::class, 1)->create([
|
|
|
|
|
'APP_NUMBER' => 2001,
|
2019-05-02 13:23:23 -04:00
|
|
|
'APP_STATUS_ID' => 1,
|
|
|
|
|
'APP_STATUS' => 'DRAFT'
|
|
|
|
|
]);
|
2019-05-02 10:53:43 -04:00
|
|
|
factory(Delegation::class, 51)->create([
|
|
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER
|
|
|
|
|
]);
|
|
|
|
|
// Review the filter by status DRAFT
|
2019-05-01 18:10:46 -04:00
|
|
|
// Get first page, which is 25
|
2019-05-02 10:53:43 -04:00
|
|
|
$results = Delegation::search(null, 0, 25, null, null, $application[0]->APP_STATUS_ID);
|
|
|
|
|
$this->assertCount(25, $results['data']);
|
2019-05-01 18:10:46 -04:00
|
|
|
// Get second page, which is 25 results
|
2019-05-03 08:03:56 -04:00
|
|
|
$results = Delegation::search(null, 25, 25, null, null, $application[0]->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-03 08:03:56 -04:00
|
|
|
$results = Delegation::search(null, 50, 25, null, null, $application[0]->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-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-03 08:03:56 -04:00
|
|
|
factory(User::class, 100)->create();
|
|
|
|
|
factory(Process::class, 1)->create();
|
2019-05-02 10:53:43 -04:00
|
|
|
$application = factory(Application::class, 1)->create([
|
|
|
|
|
'APP_NUMBER' => 2001,
|
2019-05-02 13:23:23 -04:00
|
|
|
'APP_STATUS_ID' => 2,
|
|
|
|
|
'APP_STATUS' => 'TO_DO'
|
|
|
|
|
]);
|
2019-05-02 10:53:43 -04:00
|
|
|
factory(Delegation::class, 51)->create([
|
|
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER
|
|
|
|
|
]);
|
|
|
|
|
// Review the filter by status TO_DO
|
2019-05-01 18:10:46 -04:00
|
|
|
// Get first page, which is 25
|
2019-05-02 10:53:43 -04:00
|
|
|
$results = Delegation::search(null, 0, 25, null, null, $application[0]->APP_STATUS_ID);
|
|
|
|
|
$this->assertCount(25, $results['data']);
|
2019-05-01 18:10:46 -04:00
|
|
|
// Get second page, which is 25 results
|
2019-05-03 08:03:56 -04:00
|
|
|
$results = Delegation::search(null, 25, 25, null, null, $application[0]->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-03 08:03:56 -04:00
|
|
|
$results = Delegation::search(null, 50, 25, null, null, $application[0]->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-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-03 08:03:56 -04:00
|
|
|
factory(User::class, 100)->create();
|
|
|
|
|
factory(Process::class, 1)->create();
|
2019-05-02 10:53:43 -04:00
|
|
|
$application = factory(Application::class, 1)->create([
|
|
|
|
|
'APP_NUMBER' => 2001,
|
2019-05-02 13:23:23 -04:00
|
|
|
'APP_STATUS_ID' => 3,
|
|
|
|
|
'APP_STATUS' => 'COMPLETED',
|
|
|
|
|
]);
|
2019-05-02 10:53:43 -04:00
|
|
|
|
|
|
|
|
factory(Delegation::class, 51)->create([
|
2019-05-02 13:23:23 -04:00
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER,
|
|
|
|
|
'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
|
|
|
|
|
$results = Delegation::search(null, 0, 25, null, null, $application[0]->APP_STATUS_ID);
|
|
|
|
|
$this->assertCount(25, $results['data']);
|
|
|
|
|
// Get second page, which is 25 results
|
2019-05-03 08:03:56 -04:00
|
|
|
$results = Delegation::search(null, 25, 25, null, null, $application[0]->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-03 08:03:56 -04:00
|
|
|
$results = Delegation::search(null, 50, 25, null, null, $application[0]->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
|
|
|
|
|
* @test
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_return_status_cancelled_of_data()
|
|
|
|
|
{
|
2019-05-03 08:03:56 -04:00
|
|
|
factory(User::class, 100)->create();
|
|
|
|
|
factory(Process::class, 1)->create();
|
2019-05-02 10:53:43 -04:00
|
|
|
$application = factory(Application::class, 1)->create([
|
|
|
|
|
'APP_NUMBER' => 2001,
|
2019-05-02 13:23:23 -04:00
|
|
|
'APP_STATUS_ID' => 4,
|
|
|
|
|
'APP_STATUS' => 'CANCELLED'
|
|
|
|
|
]);
|
2019-05-02 10:53:43 -04:00
|
|
|
|
|
|
|
|
factory(Delegation::class, 51)->create([
|
2019-05-02 13:23:23 -04:00
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER,
|
|
|
|
|
'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-02 10:53:43 -04:00
|
|
|
$results = Delegation::search(null, 0, 25, null, null, $application[0]->APP_STATUS_ID);
|
|
|
|
|
$this->assertCount(25, $results['data']);
|
2019-05-01 18:10:46 -04:00
|
|
|
// Get second page, which is 25 results
|
2019-05-03 08:03:56 -04:00
|
|
|
$results = Delegation::search(null, 25, 25, null, null, $application[0]->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-03 08:03:56 -04:00
|
|
|
$results = Delegation::search(null, 50, 25, null, null, $application[0]->APP_STATUS_ID);
|
2019-05-01 18:10:46 -04:00
|
|
|
$this->assertCount(1, $results['data']);
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-01 13:49:05 -07:00
|
|
|
/**
|
|
|
|
|
* This ensures searching for a valid user works
|
|
|
|
|
* @test
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_return_one_result_for_specified_user()
|
|
|
|
|
{
|
2019-05-03 08:03:56 -04:00
|
|
|
factory(User::class, 100)->create();
|
|
|
|
|
factory(Process::class, 10)->create();
|
2019-05-01 13:49:05 -07:00
|
|
|
// Create our unique user, with a unique username
|
2019-05-02 10:53:43 -04:00
|
|
|
$user = factory(User::class)->create([
|
2019-05-01 13:49:05 -07:00
|
|
|
'USR_USERNAME' => 'testcaseuser'
|
|
|
|
|
]);
|
|
|
|
|
// Create a new delegation, but for this specific user
|
|
|
|
|
factory(Delegation::class)->create([
|
|
|
|
|
'USR_UID' => $user->USR_UID,
|
|
|
|
|
'USR_ID' => $user->id
|
|
|
|
|
]);
|
|
|
|
|
// Now fetch results, and assume delegation count is 1 and the user points to our user
|
|
|
|
|
$results = Delegation::search($user->id);
|
|
|
|
|
$this->assertCount(1, $results['data']);
|
|
|
|
|
$this->assertEquals('testcaseuser', $results['data'][0]['USRCR_USR_USERNAME']);
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-02 17:12:35 -04:00
|
|
|
/**
|
|
|
|
|
* This ensures searching by case number and review the page
|
|
|
|
|
* @test
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_search_by_case_id_and_pages_of_data()
|
|
|
|
|
{
|
2019-05-03 08:03:56 -04:00
|
|
|
factory(User::class, 100)->create();
|
|
|
|
|
factory(Process::class, 1)->create();
|
2019-05-02 17:12:35 -04:00
|
|
|
$application = factory(Application::class, 1)->create([
|
|
|
|
|
'APP_NUMBER' => 2001
|
|
|
|
|
]);
|
|
|
|
|
factory(Delegation::class)->create([
|
|
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER
|
|
|
|
|
]);
|
|
|
|
|
$application = factory(Application::class, 1)->create([
|
|
|
|
|
'APP_NUMBER' => 2010
|
|
|
|
|
]);
|
|
|
|
|
factory(Delegation::class)->create([
|
|
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER
|
|
|
|
|
]);
|
|
|
|
|
$application = factory(Application::class, 1)->create([
|
|
|
|
|
'APP_NUMBER' => 2011
|
|
|
|
|
]);
|
|
|
|
|
factory(Delegation::class)->create([
|
|
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER
|
|
|
|
|
]);
|
|
|
|
|
$application = factory(Application::class, 1)->create([
|
|
|
|
|
'APP_NUMBER' => 2012
|
|
|
|
|
]);
|
|
|
|
|
factory(Delegation::class)->create([
|
|
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER
|
|
|
|
|
]);
|
|
|
|
|
$application = factory(Application::class, 1)->create([
|
|
|
|
|
'APP_NUMBER' => 2013
|
|
|
|
|
]);
|
|
|
|
|
factory(Delegation::class)->create([
|
|
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER
|
|
|
|
|
]);
|
|
|
|
|
$application = factory(Application::class, 1)->create([
|
|
|
|
|
'APP_NUMBER' => 2014
|
|
|
|
|
]);
|
|
|
|
|
factory(Delegation::class)->create([
|
|
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER
|
|
|
|
|
]);
|
|
|
|
|
$application = factory(Application::class, 1)->create([
|
|
|
|
|
'APP_NUMBER' => 2015
|
|
|
|
|
]);
|
|
|
|
|
factory(Delegation::class)->create([
|
|
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER
|
|
|
|
|
]);
|
|
|
|
|
// Get first page, the major case id
|
|
|
|
|
$results = Delegation::search(null, 0, 10, 1, null, null, 'DESC',
|
2019-05-03 08:03:56 -04:00
|
|
|
'APP_NUMBER', null, null, null, 'APP_NUMBER');
|
2019-05-02 17:12:35 -04:00
|
|
|
$this->assertCount(7, $results['data']);
|
|
|
|
|
$this->assertEquals(2015, $results['data'][0]['APP_NUMBER']);
|
|
|
|
|
// Get first page, the minor case id
|
|
|
|
|
$results = Delegation::search(null, 0, 10, 1, null, null, 'ASC',
|
|
|
|
|
'APP_NUMBER', null, null, null, 'APP_NUMBER');
|
|
|
|
|
$this->assertCount(7, $results['data']);
|
|
|
|
|
$this->assertEquals(2001, $results['data'][0]['APP_NUMBER']);
|
|
|
|
|
//Check the pagination
|
|
|
|
|
$results = Delegation::search(null, 0, 5, 1, null, null, 'DESC',
|
|
|
|
|
'APP_NUMBER', null, null, null, 'APP_NUMBER');
|
|
|
|
|
$this->assertCount(5, $results['data']);
|
|
|
|
|
$results = Delegation::search(null, 5, 2, 1, null, null, 'DESC',
|
|
|
|
|
'APP_NUMBER', null, null, null, 'APP_NUMBER');
|
|
|
|
|
$this->assertCount(2, $results['data']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This ensures searching by case title and review the page
|
|
|
|
|
* case title contain the case number, ex: APP_TITLE = 'Request # @=APP_NUMBER'
|
|
|
|
|
* @test
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_search_by_case_title_and_pages_of_data_app_number_matches_case_title()
|
|
|
|
|
{
|
2019-05-03 08:03:56 -04:00
|
|
|
factory(User::class, 100)->create();
|
|
|
|
|
factory(Process::class, 1)->create();
|
2019-05-02 17:12:35 -04:00
|
|
|
$application = factory(Application::class, 1)->create([
|
|
|
|
|
'APP_NUMBER' => 3001,
|
|
|
|
|
'APP_TITLE' => 'Request # 3001'
|
|
|
|
|
]);
|
|
|
|
|
factory(Delegation::class)->create([
|
|
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER
|
|
|
|
|
]);
|
|
|
|
|
$application = factory(Application::class, 1)->create([
|
|
|
|
|
'APP_NUMBER' => 3010,
|
|
|
|
|
'APP_TITLE' => 'Request # 3010'
|
|
|
|
|
]);
|
|
|
|
|
factory(Delegation::class)->create([
|
|
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER
|
|
|
|
|
]);
|
|
|
|
|
$application = factory(Application::class, 1)->create([
|
|
|
|
|
'APP_NUMBER' => 3011,
|
|
|
|
|
'APP_TITLE' => 'Request # 3011'
|
|
|
|
|
]);
|
|
|
|
|
factory(Delegation::class)->create([
|
|
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER
|
|
|
|
|
]);
|
|
|
|
|
$application = factory(Application::class, 1)->create([
|
|
|
|
|
'APP_NUMBER' => 3012,
|
|
|
|
|
'APP_TITLE' => 'Request # 3012'
|
|
|
|
|
]);
|
|
|
|
|
factory(Delegation::class)->create([
|
|
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER
|
|
|
|
|
]);
|
|
|
|
|
$application = factory(Application::class, 1)->create([
|
|
|
|
|
'APP_NUMBER' => 3013,
|
|
|
|
|
'APP_TITLE' => 'Request # 3013'
|
|
|
|
|
]);
|
|
|
|
|
factory(Delegation::class)->create([
|
|
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER
|
|
|
|
|
]);
|
|
|
|
|
$application = factory(Application::class, 1)->create([
|
|
|
|
|
'APP_TITLE' => 3014,
|
|
|
|
|
'APP_TITLE' => 'Request # 3014'
|
|
|
|
|
]);
|
|
|
|
|
factory(Delegation::class)->create([
|
|
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
// Get first page, the major case id
|
|
|
|
|
$results = Delegation::search(null, 0, 10, '1', null, null, 'DESC',
|
|
|
|
|
'APP_NUMBER', null, null, null, 'APP_TITLE');
|
|
|
|
|
$this->assertCount(6, $results['data']);
|
|
|
|
|
$this->assertEquals('Request # 3014', $results['data'][0]['APP_TITLE']);
|
|
|
|
|
|
|
|
|
|
// Get first page, the minor case id
|
|
|
|
|
$results = Delegation::search(null, 0, 10, '1', null, null, 'ASC',
|
2019-05-03 08:03:56 -04:00
|
|
|
'APP_NUMBER', null, null, null, 'APP_TITLE');
|
2019-05-02 17:12:35 -04:00
|
|
|
$this->assertCount(6, $results['data']);
|
|
|
|
|
$this->assertEquals(3001, $results['data'][0]['APP_NUMBER']);
|
|
|
|
|
$this->assertEquals('Request # 3001', $results['data'][0]['APP_TITLE']);
|
|
|
|
|
//Check the pagination
|
2019-05-02 17:19:10 -04:00
|
|
|
$results = Delegation::search(null, 0, 5, '1', null, null, 'ASC',
|
2019-05-03 08:03:56 -04:00
|
|
|
'APP_NUMBER', null, null, null, 'APP_TITLE');
|
2019-05-02 17:19:10 -04:00
|
|
|
$this->assertCount(5, $results['data']);
|
|
|
|
|
$results = Delegation::search(null, 5, 2, '1', null, null, 'ASC',
|
2019-05-03 08:03:56 -04:00
|
|
|
'APP_NUMBER', null, null, null, 'APP_TITLE');
|
2019-05-02 17:19:10 -04:00
|
|
|
$this->assertCount(1, $results['data']);
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-03 08:03:56 -04:00
|
|
|
/**
|
|
|
|
|
* This ensures searching by task title and review the page
|
|
|
|
|
* @test
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_search_by_task_title_and_pages_of_data()
|
|
|
|
|
{
|
|
|
|
|
factory(User::class, 100)->create();
|
|
|
|
|
factory(Process::class, 1)->create();
|
|
|
|
|
$task = factory(Task::class, 1)->create([
|
|
|
|
|
'TAS_ID' => 1,
|
|
|
|
|
'TAS_TITLE' => 'Request task'
|
|
|
|
|
]);
|
|
|
|
|
factory(Delegation::class, 5)->create([
|
|
|
|
|
'TAS_ID' => $task[0]->TAS_ID
|
|
|
|
|
]);
|
|
|
|
|
$task = factory(Task::class, 1)->create([
|
|
|
|
|
'TAS_ID' => 2,
|
|
|
|
|
'TAS_TITLE' => 'Account task'
|
|
|
|
|
]);
|
|
|
|
|
factory(Delegation::class, 5)->create([
|
|
|
|
|
'TAS_ID' => $task[0]->TAS_ID
|
|
|
|
|
]);
|
|
|
|
|
// Get first page, the order taskTitle
|
|
|
|
|
$results = Delegation::search(null, 0, 6, 'task', null, null, 'ASC',
|
|
|
|
|
'TAS_TITLE', null, null, null, 'TAS_TITLE');
|
|
|
|
|
$this->assertCount(6, $results['data']);
|
|
|
|
|
$this->assertEquals('Account task', $results['data'][0]['APP_TAS_TITLE']);
|
|
|
|
|
$results = Delegation::search(null, 6, 6, 'task', null, null, 'ASC',
|
|
|
|
|
'TAS_TITLE', null, null, null, 'TAS_TITLE');
|
|
|
|
|
$this->assertEquals('Request task', $results['data'][0]['APP_TAS_TITLE']);
|
|
|
|
|
|
|
|
|
|
// Get first page, the order taskTitle
|
|
|
|
|
$results = Delegation::search(null, 0, 6, 'task', null, null, 'DESC',
|
|
|
|
|
'TAS_TITLE', null, null, null, 'TAS_TITLE');
|
|
|
|
|
$this->assertCount(6, $results['data']);
|
|
|
|
|
$this->assertEquals('Request task', $results['data'][0]['APP_TAS_TITLE']);
|
|
|
|
|
$results = Delegation::search(null, 6, 6, 'task', null, null, 'DESC',
|
|
|
|
|
'TAS_TITLE', null, null, null, 'TAS_TITLE');
|
|
|
|
|
$this->assertEquals('Account task', $results['data'][0]['APP_TAS_TITLE']);
|
|
|
|
|
//Check the pagination
|
|
|
|
|
$results = Delegation::search(null, 0, 6, 'task', null, null, 'DESC',
|
|
|
|
|
'TAS_TITLE', null, null, null, 'TAS_TITLE');
|
|
|
|
|
$this->assertCount(6, $results['data']);
|
|
|
|
|
$results = Delegation::search(null, 6, 6, 'task', null, null, 'DESC',
|
|
|
|
|
'TAS_TITLE', null, null, null, 'TAS_TITLE');
|
|
|
|
|
$this->assertCount(4, $results['data']);
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-02 17:19:10 -04:00
|
|
|
/**
|
|
|
|
|
* This ensures searching by case title and review the page
|
|
|
|
|
* case title does not match with case number (hertland use case)
|
|
|
|
|
* @test
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_search_by_case_title_and_pages_of_data_app_number_no_matches_case_title()
|
|
|
|
|
{
|
2019-05-03 08:03:56 -04:00
|
|
|
factory(User::class, 100)->create();
|
|
|
|
|
factory(Process::class, 1)->create();
|
2019-05-02 17:19:10 -04:00
|
|
|
$application = factory(Application::class, 1)->create([
|
|
|
|
|
'APP_NUMBER' => 2001,
|
|
|
|
|
'APP_TITLE' => 'Request from Abigail check nro 25001'
|
|
|
|
|
]);
|
|
|
|
|
factory(Delegation::class)->create([
|
|
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER
|
|
|
|
|
]);
|
|
|
|
|
$application = factory(Application::class, 1)->create([
|
|
|
|
|
'APP_NUMBER' => 2010,
|
|
|
|
|
'APP_TITLE' => 'Request from Abigail check nro 12'
|
|
|
|
|
]);
|
|
|
|
|
factory(Delegation::class)->create([
|
|
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER
|
|
|
|
|
]);
|
|
|
|
|
$application = factory(Application::class, 1)->create([
|
|
|
|
|
'APP_NUMBER' => 2011,
|
|
|
|
|
'APP_TITLE' => 'Request from Abigail check nro 1000'
|
|
|
|
|
]);
|
|
|
|
|
factory(Delegation::class)->create([
|
|
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER
|
|
|
|
|
]);
|
|
|
|
|
$application = factory(Application::class, 1)->create([
|
|
|
|
|
'APP_NUMBER' => 2012,
|
|
|
|
|
'APP_TITLE' => 'Request from Abigail check nro 11000'
|
|
|
|
|
]);
|
|
|
|
|
factory(Delegation::class)->create([
|
|
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER
|
|
|
|
|
]);
|
|
|
|
|
$application = factory(Application::class, 1)->create([
|
|
|
|
|
'APP_NUMBER' => 2013,
|
|
|
|
|
'APP_TITLE' => 'Request from Abigail check nro 12000'
|
|
|
|
|
]);
|
|
|
|
|
factory(Delegation::class)->create([
|
|
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER
|
|
|
|
|
]);
|
|
|
|
|
$application = factory(Application::class, 1)->create([
|
|
|
|
|
'APP_TITLE' => 2014,
|
|
|
|
|
'APP_TITLE' => 'Request from Abigail check nro 111'
|
|
|
|
|
]);
|
|
|
|
|
factory(Delegation::class)->create([
|
|
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER
|
|
|
|
|
]);
|
|
|
|
|
// Get first page, the major case title
|
|
|
|
|
$results = Delegation::search(null, 0, 10, '1', null, null, 'ASC',
|
|
|
|
|
'APP_NUMBER', null, null, null, 'APP_TITLE');
|
|
|
|
|
$this->assertCount(6, $results['data']);
|
|
|
|
|
$this->assertEquals(2001, $results['data'][0]['APP_NUMBER']);
|
|
|
|
|
$this->assertEquals('Request from Abigail check nro 25001', $results['data'][0]['APP_TITLE']);
|
|
|
|
|
|
|
|
|
|
//Check the pagination
|
2019-05-02 17:12:35 -04:00
|
|
|
$results = Delegation::search(null, 0, 5, '1', null, null, 'ASC',
|
2019-05-03 08:03:56 -04:00
|
|
|
'APP_NUMBER', null, null, null, 'APP_TITLE');
|
2019-05-02 17:12:35 -04:00
|
|
|
$this->assertCount(5, $results['data']);
|
|
|
|
|
$results = Delegation::search(null, 5, 2, '1', null, null, 'ASC',
|
2019-05-03 08:03:56 -04:00
|
|
|
'APP_NUMBER', null, null, null, 'APP_TITLE');
|
2019-05-02 17:12:35 -04:00
|
|
|
$this->assertCount(1, $results['data']);
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-01 13:49:05 -07:00
|
|
|
/**
|
2019-05-03 08:03:56 -04:00
|
|
|
* This ensures ordering ascending and descending works by case number APP_NUMBER
|
2019-05-01 13:49:05 -07:00
|
|
|
* @test
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_sort_by_case_id()
|
|
|
|
|
{
|
2019-05-03 08:03:56 -04:00
|
|
|
factory(User::class, 100)->create();
|
|
|
|
|
factory(Process::class, 1)->create();
|
2019-05-02 11:43:38 -04:00
|
|
|
$application = factory(Application::class, 1)->create([
|
|
|
|
|
'APP_NUMBER' => 2001
|
|
|
|
|
]);
|
|
|
|
|
factory(Delegation::class)->create([
|
|
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER
|
|
|
|
|
]);
|
|
|
|
|
$application = factory(Application::class, 1)->create([
|
|
|
|
|
'APP_NUMBER' => 30002
|
|
|
|
|
]);
|
|
|
|
|
factory(Delegation::class)->create([
|
|
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER
|
|
|
|
|
]);
|
|
|
|
|
// Get first page, the minor case id
|
|
|
|
|
$results = Delegation::search(null, 0, 25, null, null, null, 'ASC', 'APP_NUMBER');
|
|
|
|
|
$this->assertCount(2, $results['data']);
|
|
|
|
|
$this->assertEquals(2001, $results['data'][0]['APP_NUMBER']);
|
|
|
|
|
$this->assertEquals(30002, $results['data'][1]['APP_NUMBER']);
|
|
|
|
|
// Get first page, the major case id
|
|
|
|
|
$results = Delegation::search(null, 0, 25, null, null, null, 'DESC', 'APP_NUMBER');
|
|
|
|
|
$this->assertCount(2, $results['data']);
|
|
|
|
|
$this->assertEquals(30002, $results['data'][0]['APP_NUMBER']);
|
|
|
|
|
$this->assertEquals(2001, $results['data'][1]['APP_NUMBER']);
|
2019-05-01 13:49:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2019-05-03 08:03:56 -04:00
|
|
|
* This ensures ordering ascending and descending works by case title APP_TITLE
|
2019-05-02 13:23:23 -04:00
|
|
|
* @test
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_sort_by_case_title()
|
|
|
|
|
{
|
2019-05-03 08:03:56 -04:00
|
|
|
factory(User::class, 100)->create();
|
|
|
|
|
factory(Process::class, 1)->create();
|
2019-05-02 13:23:23 -04:00
|
|
|
$application = factory(Application::class, 1)->create([
|
|
|
|
|
'APP_NUMBER' => 2001,
|
|
|
|
|
'APP_TITLE' => 'Request by Thomas'
|
|
|
|
|
]);
|
|
|
|
|
factory(Delegation::class)->create([
|
|
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER
|
|
|
|
|
]);
|
|
|
|
|
$application = factory(Application::class, 1)->create([
|
|
|
|
|
'APP_NUMBER' => 30002,
|
|
|
|
|
'APP_TITLE' => 'Request by Ariel'
|
|
|
|
|
]);
|
|
|
|
|
factory(Delegation::class)->create([
|
|
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER
|
|
|
|
|
]);
|
|
|
|
|
// Get first page, the minor case id
|
|
|
|
|
$results = Delegation::search(null, 0, 25, null, null, null, 'ASC', 'APP_TITLE');
|
|
|
|
|
$this->assertCount(2, $results['data']);
|
|
|
|
|
$this->assertEquals('Request by Ariel', $results['data'][0]['APP_TITLE']);
|
|
|
|
|
$this->assertEquals('Request by Thomas', $results['data'][1]['APP_TITLE']);
|
|
|
|
|
// Get first page, the major case id
|
|
|
|
|
$results = Delegation::search(null, 0, 25, null, null, null, 'DESC', 'APP_TITLE');
|
|
|
|
|
$this->assertCount(2, $results['data']);
|
|
|
|
|
$this->assertEquals('Request by Thomas', $results['data'][0]['APP_TITLE']);
|
|
|
|
|
$this->assertEquals('Request by Ariel', $results['data'][1]['APP_TITLE']);
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-03 08:03:56 -04:00
|
|
|
/**
|
|
|
|
|
* This ensures ordering ascending and descending works by case title APP_PRO_TITLE
|
|
|
|
|
* @test
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_sort_by_process()
|
|
|
|
|
{
|
|
|
|
|
factory(User::class, 100)->create();
|
|
|
|
|
$process = factory(Process::class, 1)->create([
|
|
|
|
|
'PRO_ID' => 2,
|
|
|
|
|
'PRO_TITLE' => 'Egypt Supplier Payment Proposal'
|
|
|
|
|
]);
|
|
|
|
|
factory(Delegation::class, 1)->create([
|
|
|
|
|
'PRO_ID' => $process[0]->id
|
|
|
|
|
]);
|
|
|
|
|
$process = factory(Process::class, 1)->create([
|
|
|
|
|
'PRO_ID' => 1,
|
|
|
|
|
'PRO_TITLE' => 'China Supplier Payment Proposal'
|
|
|
|
|
]);
|
|
|
|
|
factory(Delegation::class, 1)->create([
|
|
|
|
|
'PRO_ID' => $process[0]->id
|
|
|
|
|
]);
|
|
|
|
|
$process = factory(Process::class, 1)->create([
|
|
|
|
|
'PRO_ID' => 3,
|
|
|
|
|
'PRO_TITLE' => 'Russia Supplier Payment Proposal'
|
|
|
|
|
]);
|
|
|
|
|
factory(Delegation::class, 1)->create([
|
|
|
|
|
'PRO_ID' => $process[0]->id
|
|
|
|
|
]);
|
|
|
|
|
// Get first page, all process ordering ascending
|
|
|
|
|
$results = Delegation::search(null, 0, 3, null, null, null, 'ASC', 'APP_PRO_TITLE');
|
|
|
|
|
$this->assertCount(3, $results['data']);
|
|
|
|
|
$this->assertEquals('China Supplier Payment Proposal', $results['data'][0]['APP_PRO_TITLE']);
|
|
|
|
|
$this->assertEquals('Egypt Supplier Payment Proposal', $results['data'][1]['APP_PRO_TITLE']);
|
|
|
|
|
$this->assertEquals('Russia Supplier Payment Proposal', $results['data'][2]['APP_PRO_TITLE']);
|
|
|
|
|
// Get first page, all process ordering descending
|
|
|
|
|
$results = Delegation::search(null, 0, 3, null, null, null, 'DESC', 'APP_PRO_TITLE');
|
|
|
|
|
$this->assertCount(3, $results['data']);
|
|
|
|
|
$this->assertEquals('Russia Supplier Payment Proposal', $results['data'][0]['APP_PRO_TITLE']);
|
|
|
|
|
$this->assertEquals('Egypt Supplier Payment Proposal', $results['data'][1]['APP_PRO_TITLE']);
|
|
|
|
|
$this->assertEquals('China Supplier Payment Proposal', $results['data'][2]['APP_PRO_TITLE']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This ensures ordering ascending and descending works by task title APP_TAS_TITLE
|
|
|
|
|
* @test
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_sort_by_task_title()
|
|
|
|
|
{
|
|
|
|
|
factory(User::class, 100)->create();
|
|
|
|
|
factory(Process::class, 1)->create();
|
|
|
|
|
|
|
|
|
|
$task = factory(Task::class, 1)->create([
|
|
|
|
|
'TAS_ID' => 1000,
|
|
|
|
|
'TAS_TITLE' => 'Initiate Request'
|
|
|
|
|
]);
|
|
|
|
|
factory(Delegation::class, 1)->create([
|
|
|
|
|
'TAS_ID' => $task[0]->TAS_ID
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$task = factory(Task::class, 1)->create([
|
|
|
|
|
'TAS_ID' => 4000,
|
|
|
|
|
'TAS_TITLE' => 'Waiting for AP Manager Validation'
|
|
|
|
|
]);
|
|
|
|
|
factory(Delegation::class, 1)->create([
|
|
|
|
|
'TAS_ID' => $task[0]->TAS_ID
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$results = Delegation::search(null, 0, 25, null, null, null, 'ASC', 'APP_TAS_TITLE');
|
|
|
|
|
$this->assertCount(2, $results['data']);
|
|
|
|
|
$this->assertEquals('Initiate Request', $results['data'][0]['APP_TAS_TITLE']);
|
|
|
|
|
$this->assertEquals('Waiting for AP Manager Validation', $results['data'][1]['APP_TAS_TITLE']);
|
|
|
|
|
|
|
|
|
|
$results = Delegation::search(null, 0, 25, null, null, null, 'DESC', 'APP_TAS_TITLE');
|
|
|
|
|
$this->assertCount(2, $results['data']);
|
|
|
|
|
$this->assertEquals('Waiting for AP Manager Validation', $results['data'][0]['APP_TAS_TITLE']);
|
|
|
|
|
$this->assertEquals('Initiate Request', $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-05-01 13:49:05 -07:00
|
|
|
* @test
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_sort_by_user()
|
|
|
|
|
{
|
2019-05-03 08:03:56 -04:00
|
|
|
factory(User::class, 100)->create();
|
|
|
|
|
factory(Process::class, 10)->create();
|
2019-05-02 11:43:38 -04:00
|
|
|
// Create our unique user, with a unique username
|
|
|
|
|
$user = factory(User::class)->create([
|
|
|
|
|
'USR_USERNAME' => 'gary',
|
|
|
|
|
'USR_LASTNAME' => 'Gary',
|
|
|
|
|
'USR_FIRSTNAME' => 'Bailey',
|
|
|
|
|
]);
|
|
|
|
|
// Create a new delegation, but for this specific user
|
|
|
|
|
factory(Delegation::class)->create([
|
|
|
|
|
'USR_UID' => $user->USR_UID,
|
|
|
|
|
'USR_ID' => $user->id
|
|
|
|
|
]);
|
|
|
|
|
$user = factory(User::class)->create([
|
|
|
|
|
'USR_USERNAME' => 'paul',
|
|
|
|
|
'USR_LASTNAME' => 'Paul',
|
|
|
|
|
'USR_FIRSTNAME' => 'Griffis',
|
|
|
|
|
]);
|
|
|
|
|
// Create a new delegation, but for this specific user
|
|
|
|
|
factory(Delegation::class)->create([
|
|
|
|
|
'USR_UID' => $user->USR_UID,
|
|
|
|
|
'USR_ID' => $user->id
|
|
|
|
|
]);
|
|
|
|
|
// Now fetch results, and assume delegation count is 2 and the ordering ascending return Gary
|
|
|
|
|
$results = Delegation::search(null, 0, 25, null, null, null, 'ASC', 'APP_CURRENT_USER');
|
|
|
|
|
$this->assertCount(2, $results['data']);
|
|
|
|
|
$this->assertEquals('Gary Bailey', $results['data'][0]['APP_CURRENT_USER']);
|
|
|
|
|
|
|
|
|
|
// Now fetch results, and assume delegation count is 2 and the ordering descending return Gary
|
|
|
|
|
$results = Delegation::search(null, 0, 25, null, null, null, 'DESC', 'APP_CURRENT_USER');
|
|
|
|
|
$this->assertCount(2, $results['data']);
|
|
|
|
|
$this->assertEquals('Paul Griffis', $results['data'][0]['APP_CURRENT_USER']);
|
2019-05-01 13:49:05 -07:00
|
|
|
}
|
2019-05-02 12:46:53 -04:00
|
|
|
|
2019-05-02 13:23:23 -04:00
|
|
|
/**
|
2019-05-03 08:03:56 -04:00
|
|
|
* This ensures ordering ordering ascending and descending works by last modified APP_UPDATE_DATE
|
2019-05-02 13:23:23 -04:00
|
|
|
* @test
|
|
|
|
|
*/
|
2019-05-03 08:03:56 -04:00
|
|
|
public function it_should_sort_by_last_modified()
|
2019-05-02 13:23:23 -04:00
|
|
|
{
|
|
|
|
|
factory(User::class,100)->create();
|
2019-05-03 08:03:56 -04:00
|
|
|
factory(Process::class,1)->create();
|
|
|
|
|
$application = factory(Application::class, 1)->create([
|
|
|
|
|
'APP_UPDATE_DATE' => '2019-01-02 00:00:00'
|
|
|
|
|
]);
|
|
|
|
|
factory(Delegation::class)->create([
|
|
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER
|
2019-05-02 12:46:53 -04:00
|
|
|
]);
|
2019-05-02 13:23:23 -04:00
|
|
|
$application = factory(Application::class, 1)->create([
|
2019-05-03 08:03:56 -04:00
|
|
|
'APP_UPDATE_DATE' => '2019-01-03 00:00:00'
|
2019-05-02 13:23:23 -04:00
|
|
|
]);
|
2019-05-03 08:03:56 -04:00
|
|
|
factory(Delegation::class)->create([
|
|
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER
|
2019-05-02 13:23:23 -04:00
|
|
|
]);
|
2019-05-03 08:03:56 -04:00
|
|
|
$application = factory(Application::class, 1)->create([
|
|
|
|
|
'APP_UPDATE_DATE' => '2019-01-04 00:00:00'
|
|
|
|
|
]);
|
|
|
|
|
factory(Delegation::class)->create([
|
2019-05-02 13:23:23 -04:00
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER
|
|
|
|
|
]);
|
2019-05-03 08:03:56 -04:00
|
|
|
// Get first page, the minor last modified
|
|
|
|
|
$results = Delegation::search(null, 0, 1, null, null, null, 'ASC', 'APP_UPDATE_DATE');
|
|
|
|
|
$this->assertCount(1, $results['data']);
|
|
|
|
|
$this->assertEquals('2019-01-02 00:00:00', $results['data'][0]['APP_UPDATE_DATE']);
|
2019-05-02 13:23:23 -04:00
|
|
|
|
2019-05-03 08:03:56 -04:00
|
|
|
$results = Delegation::search(null, 1, 1, null, null, null, 'ASC', 'APP_UPDATE_DATE');
|
|
|
|
|
$this->assertCount(1, $results['data']);
|
|
|
|
|
$this->assertEquals('2019-01-03 00:00:00', $results['data'][0]['APP_UPDATE_DATE']);
|
|
|
|
|
|
|
|
|
|
$results = Delegation::search(null, 2, 1, null, null, null, 'ASC', 'APP_UPDATE_DATE');
|
|
|
|
|
$this->assertCount(1, $results['data']);
|
|
|
|
|
$this->assertEquals('2019-01-04 00:00:00', $results['data'][0]['APP_UPDATE_DATE']);
|
|
|
|
|
|
|
|
|
|
$results = Delegation::search(null, 0, 1, null, null, null, 'DESC', 'APP_UPDATE_DATE');
|
|
|
|
|
$this->assertCount(1, $results['data']);
|
|
|
|
|
$this->assertEquals('2019-01-04 00:00:00', $results['data'][0]['APP_UPDATE_DATE']);
|
|
|
|
|
|
|
|
|
|
$results = Delegation::search(null, 1, 1, null, null, null, 'DESC', 'APP_UPDATE_DATE');
|
|
|
|
|
$this->assertCount(1, $results['data']);
|
|
|
|
|
$this->assertEquals('2019-01-03 00:00:00', $results['data'][0]['APP_UPDATE_DATE']);
|
|
|
|
|
|
|
|
|
|
$results = Delegation::search(null, 2, 1, null, null, null, 'DESC', 'APP_UPDATE_DATE');
|
|
|
|
|
$this->assertCount(1, $results['data']);
|
|
|
|
|
$this->assertEquals('2019-01-02 00:00:00', $results['data'][0]['APP_UPDATE_DATE']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This ensures ordering ascending and descending works by due date DEL_TASK_DUE_DATE
|
|
|
|
|
* @test
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_sort_by_due_date()
|
|
|
|
|
{
|
|
|
|
|
factory(User::class,100)->create();
|
|
|
|
|
factory(Process::class,1)->create();
|
|
|
|
|
factory(Delegation::class, 10)->create([
|
|
|
|
|
'DEL_TASK_DUE_DATE' => '2019-01-02 00:00:00'
|
2019-05-02 13:23:23 -04:00
|
|
|
]);
|
2019-05-03 08:03:56 -04:00
|
|
|
factory(Delegation::class, 10)->create([
|
|
|
|
|
'DEL_TASK_DUE_DATE' => '2019-01-03 00:00:00'
|
|
|
|
|
]);
|
|
|
|
|
factory(Delegation::class, 9)->create([
|
|
|
|
|
'DEL_TASK_DUE_DATE' => '2019-01-04 00:00:00'
|
|
|
|
|
]);
|
|
|
|
|
// Get first page, the minor last modified
|
|
|
|
|
$results = Delegation::search(null, 0, 10, null, null, null, 'ASC', 'DEL_TASK_DUE_DATE');
|
|
|
|
|
$this->assertCount(10, $results['data']);
|
|
|
|
|
$this->assertEquals('2019-01-02 00:00:00', $results['data'][0]['DEL_TASK_DUE_DATE']);
|
|
|
|
|
|
|
|
|
|
$results = Delegation::search(null, 10, 10, null, null, null, 'ASC', 'DEL_TASK_DUE_DATE');
|
|
|
|
|
$this->assertCount(10, $results['data']);
|
|
|
|
|
$this->assertEquals('2019-01-03 00:00:00', $results['data'][0]['DEL_TASK_DUE_DATE']);
|
|
|
|
|
|
|
|
|
|
$results = Delegation::search(null, 20, 10, null, null, null, 'ASC', 'DEL_TASK_DUE_DATE');
|
|
|
|
|
$this->assertCount(9, $results['data']);
|
|
|
|
|
$this->assertEquals('2019-01-04 00:00:00', $results['data'][0]['DEL_TASK_DUE_DATE']);
|
|
|
|
|
|
|
|
|
|
$results = Delegation::search(null, 0, 10, null, null, null, 'DESC', 'DEL_TASK_DUE_DATE');
|
|
|
|
|
$this->assertCount(10, $results['data']);
|
|
|
|
|
$this->assertEquals('2019-01-04 00:00:00', $results['data'][0]['DEL_TASK_DUE_DATE']);
|
|
|
|
|
|
|
|
|
|
$results = Delegation::search(null, 10, 10, null, null, null, 'DESC', 'DEL_TASK_DUE_DATE');
|
|
|
|
|
$this->assertCount(10, $results['data']);
|
|
|
|
|
$this->assertEquals('2019-01-03 00:00:00', $results['data'][0]['DEL_TASK_DUE_DATE']);
|
|
|
|
|
|
|
|
|
|
$results = Delegation::search(null, 20, 10, null, null, null, 'DESC', 'DEL_TASK_DUE_DATE');
|
|
|
|
|
$this->assertCount(9, $results['data']);
|
|
|
|
|
$this->assertEquals('2019-01-02 00:00:00', $results['data'][0]['DEL_TASK_DUE_DATE']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This ensures ordering ascending and descending works by status APP_STATUS
|
|
|
|
|
* @test
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_sort_by_status()
|
|
|
|
|
{
|
|
|
|
|
factory(User::class,100)->create();
|
|
|
|
|
factory(Process::class,1)->create();
|
|
|
|
|
$application = factory(Application::class, 1)->create([
|
|
|
|
|
'APP_STATUS' => 'DRAFT'
|
|
|
|
|
]);
|
|
|
|
|
factory(Delegation::class, 25)->create([
|
2019-05-02 13:23:23 -04:00
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER
|
|
|
|
|
]);
|
2019-05-03 08:03:56 -04:00
|
|
|
$application = factory(Application::class, 1)->create([
|
|
|
|
|
'APP_STATUS' => 'TO_DO'
|
2019-05-02 13:23:23 -04:00
|
|
|
]);
|
2019-05-03 08:03:56 -04:00
|
|
|
factory(Delegation::class, 25)->create([
|
2019-05-02 13:23:23 -04:00
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER
|
|
|
|
|
]);
|
2019-05-03 08:03:56 -04:00
|
|
|
$application = factory(Application::class, 1)->create([
|
|
|
|
|
'APP_STATUS' => 'COMPLETED'
|
2019-05-02 12:46:53 -04:00
|
|
|
]);
|
2019-05-03 08:03:56 -04:00
|
|
|
factory(Delegation::class, 25)->create([
|
|
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER
|
|
|
|
|
]);
|
|
|
|
|
$application = factory(Application::class, 1)->create([
|
|
|
|
|
'APP_STATUS' => 'CANCELLED'
|
|
|
|
|
]);
|
|
|
|
|
factory(Delegation::class, 25)->create([
|
|
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
// Get first page, the minor status label
|
|
|
|
|
$results = Delegation::search(null, 0, 25, null, null, null, 'ASC', 'APP_STATUS');
|
|
|
|
|
$this->assertEquals('CANCELLED', $results['data'][0]['APP_STATUS']);
|
|
|
|
|
$results = Delegation::search(null, 25, 25, null, null, null, 'ASC', 'APP_STATUS');
|
|
|
|
|
$this->assertEquals('COMPLETED', $results['data'][0]['APP_STATUS']);
|
|
|
|
|
$results = Delegation::search(null, 50, 25, null, null, null, 'ASC', 'APP_STATUS');
|
|
|
|
|
$this->assertEquals('DRAFT', $results['data'][0]['APP_STATUS']);
|
|
|
|
|
$results = Delegation::search(null, 75, 25, null, null, null, 'ASC', 'APP_STATUS');
|
|
|
|
|
$this->assertEquals('TO_DO', $results['data'][0]['APP_STATUS']);
|
|
|
|
|
// Get first page, the major status label
|
|
|
|
|
$results = Delegation::search(null, 0, 25, null, null, null, 'DESC', 'APP_STATUS');
|
|
|
|
|
$this->assertEquals('TO_DO', $results['data'][0]['APP_STATUS']);
|
|
|
|
|
$results = Delegation::search(null, 25, 25, null, null, null, 'DESC', 'APP_STATUS');
|
|
|
|
|
$this->assertEquals('DRAFT', $results['data'][0]['APP_STATUS']);
|
|
|
|
|
$results = Delegation::search(null, 50, 25, null, null, null, 'DESC', 'APP_STATUS');
|
|
|
|
|
$this->assertEquals('COMPLETED', $results['data'][0]['APP_STATUS']);
|
|
|
|
|
$results = Delegation::search(null, 75, 25, null, null, null, 'DESC', 'APP_STATUS');
|
|
|
|
|
$this->assertEquals('CANCELLED', $results['data'][0]['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
|
|
|
|
|
* @test
|
|
|
|
|
*/
|
2019-05-02 15:02:20 -04:00
|
|
|
public function it_should_return_data_filtered_by_process_category()
|
2019-05-02 14:48:50 -04:00
|
|
|
{
|
|
|
|
|
factory(User::class, 100)->create();
|
|
|
|
|
// Dummy Processes
|
|
|
|
|
factory(ProcessCategory::class, 4)->create();
|
|
|
|
|
factory(Process::class, 4)->create([
|
2019-05-02 16:51:47 -04:00
|
|
|
'PRO_CATEGORY' => ProcessCategory::all()->random()->CATEGORY_UID
|
2019-05-02 14:48:50 -04:00
|
|
|
]);
|
|
|
|
|
// Dummy Delegations
|
|
|
|
|
factory(Delegation::class, 100)->create([
|
2019-05-02 16:51:47 -04:00
|
|
|
'PRO_ID' => Process::all()->random()->PRO_ID
|
2019-05-02 14:48:50 -04:00
|
|
|
]);
|
|
|
|
|
// Process with the category to search
|
|
|
|
|
$processCategorySearch = factory(ProcessCategory::class, 1)->create();
|
|
|
|
|
$categoryUid = $processCategorySearch[0]->CATEGORY_UID;
|
|
|
|
|
$processSearch = factory(Process::class, 1)->create([
|
|
|
|
|
'PRO_ID' => 5,
|
|
|
|
|
'PRO_CATEGORY' => $categoryUid
|
|
|
|
|
]);
|
|
|
|
|
// Delegations to found
|
|
|
|
|
factory(Delegation::class, 51)->create([
|
|
|
|
|
'PRO_ID' => $processSearch[0]->id
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
// Get first page, which is 25
|
|
|
|
|
$results = Delegation::search(null, 0, 25, null, null, null, null, null, $categoryUid);
|
|
|
|
|
$this->assertCount(25, $results['data']);
|
|
|
|
|
// Get second page, which is 25 results
|
|
|
|
|
$results = Delegation::search(null, 25, 25, null, null, null, null, null, $categoryUid);
|
|
|
|
|
$this->assertCount(25, $results['data']);
|
|
|
|
|
// Get third page, which is only 1 result
|
|
|
|
|
$results = Delegation::search(null, 50, 25, null, null, null, null, null, $categoryUid);
|
|
|
|
|
$this->assertCount(1, $results['data']);
|
|
|
|
|
}
|
2019-05-02 16:51:47 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This ensure the result is right when you search between two given dates
|
|
|
|
|
* @test
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_return_right_data_between_two_dates()
|
|
|
|
|
{
|
|
|
|
|
factory(User::class, 10)->create();
|
|
|
|
|
factory(Process::class, 10)->create();
|
|
|
|
|
factory(Delegation::class, 10)->create(['DEL_DELEGATE_DATE' => '2019-01-02 00:00:00']);
|
|
|
|
|
factory(Delegation::class, 10)->create(['DEL_DELEGATE_DATE' => '2019-01-03 00:00:00']);
|
|
|
|
|
factory(Delegation::class, 10)->create(['DEL_DELEGATE_DATE' => '2019-01-04 00:00:00']);
|
|
|
|
|
factory(Delegation::class, 10)->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
|
|
|
|
|
* @test
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_return_right_data_when_you_send_only_dateFrom_parameter()
|
|
|
|
|
{
|
|
|
|
|
factory(User::class, 10)->create();
|
|
|
|
|
factory(Process::class, 10)->create();
|
|
|
|
|
factory(Delegation::class, 10)->create(['DEL_DELEGATE_DATE' => '2019-01-02 00:00:00']);
|
|
|
|
|
factory(Delegation::class, 10)->create(['DEL_DELEGATE_DATE' => '2019-01-03 00:00:00']);
|
|
|
|
|
factory(Delegation::class, 10)->create(['DEL_DELEGATE_DATE' => '2019-01-04 00:00:00']);
|
|
|
|
|
factory(Delegation::class, 10)->create(['DEL_DELEGATE_DATE' => '2019-01-05 00:00:00']);
|
|
|
|
|
$results = Delegation::search(null, 0, 50, null, null, null, null, null, null, '2019-01-02 00:00:00',
|
|
|
|
|
null);
|
|
|
|
|
$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']);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This ensure the result is right when you search to a given date
|
|
|
|
|
* @test
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_return_right_data_when_you_send_only_dateTo_parameter()
|
|
|
|
|
{
|
|
|
|
|
factory(User::class, 10)->create();
|
|
|
|
|
factory(Process::class, 10)->create();
|
|
|
|
|
factory(Delegation::class, 10)->create(['DEL_DELEGATE_DATE' => '2019-01-02 00:00:00']);
|
|
|
|
|
factory(Delegation::class, 10)->create(['DEL_DELEGATE_DATE' => '2019-01-03 00:00:00']);
|
|
|
|
|
factory(Delegation::class, 10)->create(['DEL_DELEGATE_DATE' => '2019-01-04 00:00:00']);
|
|
|
|
|
factory(Delegation::class, 10)->create(['DEL_DELEGATE_DATE' => '2019-01-05 00:00:00']);
|
|
|
|
|
$results = Delegation::search(null, 0, 50, null, null, null, null, null, null, null,
|
|
|
|
|
'2019-01-04 00:00:00');
|
|
|
|
|
$this->assertCount(30, $results['data']);
|
|
|
|
|
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-05-03 08:03:56 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This ensures return the correct data by sequential
|
|
|
|
|
* @test
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_return_by_sequential_tasks_pages_of_data()
|
|
|
|
|
{
|
|
|
|
|
factory(User::class, 100)->create();
|
2019-05-07 12:32:34 -04:00
|
|
|
// Create a process
|
2019-05-03 08:03:56 -04:00
|
|
|
$process = factory(Process::class, 1)->create([
|
2019-05-07 12:32:34 -04:00
|
|
|
'PRO_ID' => 1000
|
2019-05-03 08:03:56 -04:00
|
|
|
]);
|
|
|
|
|
$application = factory(Application::class, 1)->create([
|
2019-05-07 12:32:34 -04:00
|
|
|
'APP_NUMBER' => 5000,
|
2019-05-03 08:03:56 -04:00
|
|
|
'APP_TITLE' => 'Request by Thomas',
|
|
|
|
|
]);
|
2019-05-07 12:32:34 -04:00
|
|
|
// Create task
|
|
|
|
|
$task = factory(Task::class, 1)->create([
|
|
|
|
|
'TAS_TYPE' => 'NORMAL'
|
2019-05-03 08:03:56 -04:00
|
|
|
]);
|
2019-05-07 12:32:34 -04:00
|
|
|
// Create a thread with the user, process and application defined before
|
|
|
|
|
factory(Delegation::class)->create([
|
2019-05-03 08:03:56 -04:00
|
|
|
'PRO_ID' => $process[0]->id,
|
2019-05-07 12:32:34 -04:00
|
|
|
'TAS_ID' => $task[0]->id,
|
2019-05-03 08:03:56 -04:00
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER,
|
|
|
|
|
'DEL_THREAD_STATUS' => 'CLOSED'
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
// Define a dummy task
|
|
|
|
|
$task = factory(Task::class, 1)->create([
|
|
|
|
|
'TAS_TYPE' => 'INTERMEDIATE-THROW'
|
|
|
|
|
]);
|
|
|
|
|
// Create a thread with the dummy task this does not need a user
|
2019-05-07 12:32:34 -04:00
|
|
|
factory(Delegation::class)->create([
|
2019-05-03 08:03:56 -04:00
|
|
|
'PRO_ID' => $process[0]->id,
|
|
|
|
|
'USR_ID' => 0,
|
|
|
|
|
'TAS_ID' => $task[0]->id,
|
|
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER
|
|
|
|
|
]);
|
2019-05-07 12:32:34 -04:00
|
|
|
// Create task
|
|
|
|
|
$task = factory(Task::class, 1)->create([
|
|
|
|
|
'TAS_TYPE' => 'NORMAL'
|
2019-05-03 08:03:56 -04:00
|
|
|
]);
|
2019-05-07 12:32:34 -04:00
|
|
|
// Create a thread with the user, process and application defined before
|
|
|
|
|
factory(Delegation::class)->create([
|
2019-05-03 08:03:56 -04:00
|
|
|
'PRO_ID' => $process[0]->id,
|
2019-05-07 12:32:34 -04:00
|
|
|
'TAS_ID' => $task[0]->id,
|
2019-05-03 08:03:56 -04:00
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER,
|
|
|
|
|
'DEL_THREAD_STATUS' => 'OPEN'
|
|
|
|
|
]);
|
2019-05-07 12:32:34 -04:00
|
|
|
// Review if the thread OPEN is showed
|
|
|
|
|
$results = Delegation::search(null, 0, 10, null);
|
2019-05-03 08:03:56 -04:00
|
|
|
$this->assertCount(1, $results['data']);
|
2019-05-07 12:32:34 -04:00
|
|
|
$this->assertEquals('OPEN', $results['data'][0]['DEL_THREAD_STATUS']);
|
2019-05-03 08:03:56 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This ensures return the correct data by parallel task all threads CLOSED
|
|
|
|
|
* @test
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_return_by_parallel_tasks_threads_closed()
|
|
|
|
|
{
|
2019-05-07 12:32:34 -04:00
|
|
|
factory(User::class, 100)->create();
|
|
|
|
|
factory(Process::class, 1)->create();
|
|
|
|
|
$task = factory(Task::class, 1)->create([
|
2019-05-03 08:03:56 -04:00
|
|
|
'TAS_TITLE' => 'Parallel task 1'
|
|
|
|
|
]);
|
|
|
|
|
factory(Delegation::class, 5)->create([
|
|
|
|
|
'TAS_ID' => $task[0]->TAS_ID,
|
|
|
|
|
'DEL_THREAD_STATUS' => 'CLOSED'
|
|
|
|
|
]);
|
2019-05-07 12:32:34 -04:00
|
|
|
$task = factory(Task::class, 1)->create([
|
2019-05-03 08:03:56 -04:00
|
|
|
'TAS_TITLE' => 'Parallel task 2'
|
|
|
|
|
]);
|
|
|
|
|
factory(Delegation::class, 5)->create([
|
|
|
|
|
'TAS_ID' => $task[0]->TAS_ID,
|
|
|
|
|
'DEL_THREAD_STATUS' => 'CLOSED'
|
|
|
|
|
]);
|
|
|
|
|
// Get first page, the order taskTitle
|
|
|
|
|
$results = Delegation::search(null, 0, 2, null, null, null, 'ASC',
|
2019-05-07 12:32:34 -04:00
|
|
|
'TAS_TITLE', null, null, null, 'TAS_TITLE');
|
2019-05-03 08:03:56 -04:00
|
|
|
$this->assertCount(0, $results['data']);
|
|
|
|
|
|
|
|
|
|
// Get first page, the order taskTitle
|
|
|
|
|
$results = Delegation::search(null, 0, 2, null, null, null, 'DESC',
|
2019-05-07 12:32:34 -04:00
|
|
|
'TAS_TITLE', null, null, null, 'TAS_TITLE');
|
2019-05-03 08:03:56 -04:00
|
|
|
$this->assertCount(0, $results['data']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This ensures return the correct data by parallel task all threads OPEN
|
|
|
|
|
* @test
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_return_by_parallel_tasks_threads_open()
|
|
|
|
|
{
|
2019-05-07 12:32:34 -04:00
|
|
|
factory(User::class, 100)->create();
|
|
|
|
|
factory(Process::class, 1)->create();
|
2019-05-03 08:03:56 -04:00
|
|
|
//Create the threads
|
|
|
|
|
factory(Delegation::class, 5)->create([
|
|
|
|
|
'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']);
|
|
|
|
|
$this->assertEquals('OPEN', $results['data'][0]['DEL_THREAD_STATUS']);
|
|
|
|
|
$this->assertEquals('OPEN', $results['data'][4]['DEL_THREAD_STATUS']);
|
2019-05-07 12:32:34 -04:00
|
|
|
}
|
2019-05-03 08:03:56 -04:00
|
|
|
|
2019-05-07 12:32:34 -04:00
|
|
|
/**
|
|
|
|
|
* Review when the status is empty
|
|
|
|
|
* @test
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_return_status_empty()
|
|
|
|
|
{
|
|
|
|
|
factory(User::class, 100)->create();
|
|
|
|
|
factory(Process::class, 1)->create();
|
|
|
|
|
$application = factory(Application::class, 1)->create([
|
|
|
|
|
'APP_NUMBER' => 2001,
|
|
|
|
|
'APP_STATUS' => ''
|
|
|
|
|
]);
|
|
|
|
|
factory(Delegation::class, 1)->create([
|
|
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER
|
|
|
|
|
]);
|
|
|
|
|
// Review the filter by status empty
|
|
|
|
|
$results = Delegation::search(null, 0, 25);
|
|
|
|
|
$this->assertEquals('', $results['data'][0]['APP_STATUS']);
|
2019-05-03 08:03:56 -04:00
|
|
|
}
|
2019-05-20 13:23:31 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Check if return participation information
|
|
|
|
|
* @test
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_return_participation_info()
|
|
|
|
|
{
|
|
|
|
|
// Initializing Faker instance
|
|
|
|
|
$faker = Faker\Factory::create();
|
|
|
|
|
|
|
|
|
|
// Creating one application with two delegations
|
|
|
|
|
factory(User::class, 100)->create();
|
|
|
|
|
$process = factory(Process::class)->create();
|
|
|
|
|
$application = factory(Application::class)->create([
|
|
|
|
|
'APP_UID' => G::generateUniqueID()
|
|
|
|
|
]);
|
|
|
|
|
factory(Delegation::class)->create([
|
|
|
|
|
'APP_UID' => $application->APP_UID,
|
|
|
|
|
'DEL_THREAD_STATUS' => 'CLOSED',
|
|
|
|
|
'DEL_FINISH_DATE' => $faker->dateTime()
|
|
|
|
|
]);
|
|
|
|
|
factory(Delegation::class)->create([
|
|
|
|
|
'APP_UID' => $application->APP_UID,
|
|
|
|
|
'DEL_INDEX' => 2,
|
|
|
|
|
'DEL_THREAD_STATUS' => 'CLOSED',
|
|
|
|
|
'DEL_FINISH_DATE' => $faker->dateTime()
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
* @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-01 13:49:05 -07:00
|
|
|
}
|