|
|
|
|
@@ -33,6 +33,7 @@ class DelegationTest extends TestCase
|
|
|
|
|
$results = Delegation::search(null, 50, 25);
|
|
|
|
|
$this->assertCount(1, $results['data']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This checks to make sure pagination is working properly
|
|
|
|
|
* @test
|
|
|
|
|
@@ -366,6 +367,54 @@ class DelegationTest extends TestCase
|
|
|
|
|
$this->assertCount(1, $results['data']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This ensures searching by case title and review the page
|
|
|
|
|
* case title does not match with case number (hertland use case)
|
|
|
|
|
@@ -434,7 +483,7 @@ class DelegationTest extends TestCase
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This ensures ordering ascending works by case number
|
|
|
|
|
* This ensures ordering ascending and descending works by case number APP_NUMBER
|
|
|
|
|
* @test
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_sort_by_case_id()
|
|
|
|
|
@@ -466,7 +515,7 @@ class DelegationTest extends TestCase
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This ensures ordering ascending works by case title
|
|
|
|
|
* This ensures ordering ascending and descending works by case title APP_TITLE
|
|
|
|
|
* @test
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_sort_by_case_title()
|
|
|
|
|
@@ -499,6 +548,84 @@ class DelegationTest extends TestCase
|
|
|
|
|
$this->assertEquals('Request by Ariel', $results['data'][1]['APP_TITLE']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This ensures ordering ascending and descending works by current user
|
|
|
|
|
* @test
|
|
|
|
|
@@ -540,66 +667,151 @@ class DelegationTest extends TestCase
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This checks to make sure filter by process is working properly
|
|
|
|
|
* This ensures ordering ordering ascending and descending works by last modified APP_UPDATE_DATE
|
|
|
|
|
* @test
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_return_data_issue()
|
|
|
|
|
public function it_should_sort_by_last_modified()
|
|
|
|
|
{
|
|
|
|
|
factory(User::class,100)->create();
|
|
|
|
|
// Create a threads over the process
|
|
|
|
|
$process = factory(Process::class, 1)->create([
|
|
|
|
|
'PRO_ID' => 1
|
|
|
|
|
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
|
|
|
|
|
]);
|
|
|
|
|
$application = factory(Application::class, 1)->create([
|
|
|
|
|
'APP_UPDATE_DATE' => '2019-01-03 00:00:00'
|
|
|
|
|
]);
|
|
|
|
|
factory(Delegation::class)->create([
|
|
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER
|
|
|
|
|
]);
|
|
|
|
|
$application = factory(Application::class, 1)->create([
|
|
|
|
|
'APP_UPDATE_DATE' => '2019-01-04 00:00:00'
|
|
|
|
|
]);
|
|
|
|
|
factory(Delegation::class)->create([
|
|
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER
|
|
|
|
|
]);
|
|
|
|
|
// 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']);
|
|
|
|
|
|
|
|
|
|
$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'
|
|
|
|
|
]);
|
|
|
|
|
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([
|
|
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER
|
|
|
|
|
]);
|
|
|
|
|
$application = factory(Application::class, 1)->create([
|
|
|
|
|
'APP_NUMBER' => 1,
|
|
|
|
|
'APP_TITLE' => 'Request by Thomas',
|
|
|
|
|
'APP_STATUS_ID' => 2,
|
|
|
|
|
'APP_STATUS' => 'TO_DO'
|
|
|
|
|
]);
|
|
|
|
|
// Create a user Gary in a thread
|
|
|
|
|
$user = factory(User::class)->create([
|
|
|
|
|
'USR_USERNAME' => 'gary',
|
|
|
|
|
'USR_LASTNAME' => 'Gary',
|
|
|
|
|
'USR_FIRSTNAME' => 'Bailey',
|
|
|
|
|
factory(Delegation::class, 25)->create([
|
|
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER
|
|
|
|
|
]);
|
|
|
|
|
// Create a thread with the user Gary
|
|
|
|
|
factory(Delegation::class, 1)->create([
|
|
|
|
|
'PRO_ID' => $process[0]->id,
|
|
|
|
|
'USR_ID' => $user->id,
|
|
|
|
|
$application = factory(Application::class, 1)->create([
|
|
|
|
|
'APP_STATUS' => 'COMPLETED'
|
|
|
|
|
]);
|
|
|
|
|
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
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
// Define a dummy task
|
|
|
|
|
$task = factory(Task::class, 1)->create([
|
|
|
|
|
'TAS_ID' => 1,
|
|
|
|
|
'TAS_TYPE' => 'INTERMEDIATE-THROW'
|
|
|
|
|
]);
|
|
|
|
|
// Create a thread with the dummy task this does not need a user
|
|
|
|
|
factory(Delegation::class, 1)->create([
|
|
|
|
|
'PRO_ID' => $process[0]->id,
|
|
|
|
|
'USR_ID' => 0,
|
|
|
|
|
'TAS_ID' => $task[0]->id,
|
|
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER
|
|
|
|
|
]);
|
|
|
|
|
// Create a user Paul in a thread
|
|
|
|
|
$user = factory(User::class)->create([
|
|
|
|
|
'USR_USERNAME' => 'Paul',
|
|
|
|
|
'USR_LASTNAME' => 'Griffis',
|
|
|
|
|
'USR_FIRSTNAME' => 'paul',
|
|
|
|
|
]);
|
|
|
|
|
// Create a thread with the user Paul
|
|
|
|
|
factory(Delegation::class, 1)->create([
|
|
|
|
|
'PRO_ID' => $process[0]->id,
|
|
|
|
|
'USR_ID' => $user->id,
|
|
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER
|
|
|
|
|
]);
|
|
|
|
|
// Create others delegations
|
|
|
|
|
factory(Delegation::class, 24)->create([
|
|
|
|
|
'PRO_ID' => $process[0]->id
|
|
|
|
|
]);
|
|
|
|
|
// Get first page, which is 25 of 26
|
|
|
|
|
$results = Delegation::search(null, 0, 10, null, $process[0]->id, null, 'ASC', 'APP_NUMBER');
|
|
|
|
|
$this->assertCount(10, $results['data']);
|
|
|
|
|
// 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']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@@ -704,4 +916,116 @@ class DelegationTest extends TestCase
|
|
|
|
|
$this->assertRegExp('(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}) ', $value['DEL_DELEGATE_DATE']);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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();
|
|
|
|
|
// Create a threads over the process
|
|
|
|
|
$process = factory(Process::class, 1)->create([
|
|
|
|
|
'PRO_ID' => 1
|
|
|
|
|
]);
|
|
|
|
|
$application = factory(Application::class, 1)->create([
|
|
|
|
|
'APP_NUMBER' => 1,
|
|
|
|
|
'APP_TITLE' => 'Request by Thomas',
|
|
|
|
|
]);
|
|
|
|
|
// Create a user Gary in a thread
|
|
|
|
|
$user = factory(User::class)->create([
|
|
|
|
|
'USR_USERNAME' => 'gary',
|
|
|
|
|
'USR_LASTNAME' => 'Bailey',
|
|
|
|
|
'USR_FIRSTNAME' => 'Gary',
|
|
|
|
|
]);
|
|
|
|
|
// Create a thread with the user Gary
|
|
|
|
|
factory(Delegation::class, 1)->create([
|
|
|
|
|
'PRO_ID' => $process[0]->id,
|
|
|
|
|
'USR_ID' => $user->id,
|
|
|
|
|
'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
|
|
|
|
|
factory(Delegation::class, 1)->create([
|
|
|
|
|
'PRO_ID' => $process[0]->id,
|
|
|
|
|
'USR_ID' => 0,
|
|
|
|
|
'TAS_ID' => $task[0]->id,
|
|
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER
|
|
|
|
|
]);
|
|
|
|
|
// Create a user Paul in a thread
|
|
|
|
|
$user = factory(User::class)->create([
|
|
|
|
|
'USR_USERNAME' => 'paul',
|
|
|
|
|
'USR_LASTNAME' => 'Griffis',
|
|
|
|
|
'USR_FIRSTNAME' => 'Paul',
|
|
|
|
|
]);
|
|
|
|
|
// Create a thread with the user Paul
|
|
|
|
|
factory(Delegation::class, 1)->create([
|
|
|
|
|
'PRO_ID' => $process[0]->id,
|
|
|
|
|
'USR_ID' => $user->id,
|
|
|
|
|
'APP_NUMBER' => $application[0]->APP_NUMBER,
|
|
|
|
|
'DEL_THREAD_STATUS' => 'OPEN'
|
|
|
|
|
]);
|
|
|
|
|
// Get first page, which is 25 of 26
|
|
|
|
|
$results = Delegation::search(null, 0, 10, null, $process[0]->id, null, 'ASC', 'APP_NUMBER');
|
|
|
|
|
$this->assertCount(1, $results['data']);
|
|
|
|
|
$this->assertEquals('Griffis Paul', $results['data'][0]['APP_CURRENT_USER']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This ensures return the correct data by parallel task all threads CLOSED
|
|
|
|
|
* @test
|
|
|
|
|
*/
|
|
|
|
|
public function it_should_return_by_parallel_tasks_threads_closed()
|
|
|
|
|
{
|
|
|
|
|
factory(User::class,100)->create();
|
|
|
|
|
factory(Process::class,1)->create();
|
|
|
|
|
$task = factory(Task::class,1)->create([
|
|
|
|
|
'TAS_TITLE' => 'Parallel task 1'
|
|
|
|
|
]);
|
|
|
|
|
factory(Delegation::class, 5)->create([
|
|
|
|
|
'TAS_ID' => $task[0]->TAS_ID,
|
|
|
|
|
'DEL_THREAD_STATUS' => 'CLOSED'
|
|
|
|
|
]);
|
|
|
|
|
$task = factory(Task::class,1)->create([
|
|
|
|
|
'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',
|
|
|
|
|
'TAS_TITLE', null, null, null,'TAS_TITLE');
|
|
|
|
|
$this->assertCount(0, $results['data']);
|
|
|
|
|
|
|
|
|
|
// Get first page, the order taskTitle
|
|
|
|
|
$results = Delegation::search(null, 0, 2, null, null, null, 'DESC',
|
|
|
|
|
'TAS_TITLE', null, null, null,'TAS_TITLE');
|
|
|
|
|
$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()
|
|
|
|
|
{
|
|
|
|
|
factory(User::class,100)->create();
|
|
|
|
|
factory(Process::class,1)->create();
|
|
|
|
|
//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']);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|