filter by task title and order by lastModified, dueDate, status, process and task
This commit is contained in:
@@ -21,9 +21,7 @@ return [
|
|||||||
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
|
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
|
||||||
Illuminate\Queue\QueueServiceProvider::class,
|
Illuminate\Queue\QueueServiceProvider::class,
|
||||||
Illuminate\Translation\TranslationServiceProvider::class,
|
Illuminate\Translation\TranslationServiceProvider::class,
|
||||||
|
|
||||||
Laravel\Tinker\TinkerServiceProvider::class,
|
Laravel\Tinker\TinkerServiceProvider::class,
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
'aliases' => [
|
'aliases' => [
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ use Faker\Generator as Faker;
|
|||||||
use ProcessMaker\BusinessModel\Cases as BmCases;
|
use ProcessMaker\BusinessModel\Cases as BmCases;
|
||||||
|
|
||||||
$factory->define(\ProcessMaker\Model\Application::class, function(Faker $faker) {
|
$factory->define(\ProcessMaker\Model\Application::class, function(Faker $faker) {
|
||||||
|
|
||||||
$process = \ProcessMaker\Model\Process::all()->random();
|
$process = \ProcessMaker\Model\Process::all()->random();
|
||||||
$statuses = ['DRAFT', 'TO_DO'];
|
$statuses = ['DRAFT', 'TO_DO'];
|
||||||
$status = $faker->randomElement($statuses);
|
$status = $faker->randomElement($statuses);
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ use Faker\Generator as Faker;
|
|||||||
use ProcessMaker\BusinessModel\Cases as BmCases;
|
use ProcessMaker\BusinessModel\Cases as BmCases;
|
||||||
|
|
||||||
$factory->define(\ProcessMaker\Model\Delegation::class, function(Faker $faker) {
|
$factory->define(\ProcessMaker\Model\Delegation::class, function(Faker $faker) {
|
||||||
|
|
||||||
$app = factory(\ProcessMaker\Model\Application::class)->create();
|
$app = factory(\ProcessMaker\Model\Application::class)->create();
|
||||||
$process = \ProcessMaker\Model\Process::where('PRO_UID', $app->PRO_UID)->first();
|
$process = \ProcessMaker\Model\Process::where('PRO_UID', $app->PRO_UID)->first();
|
||||||
$task = $process->tasks->first();
|
$task = $process->tasks->first();
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
use Faker\Generator as Faker;
|
use Faker\Generator as Faker;
|
||||||
|
|
||||||
$factory->define(\ProcessMaker\Model\Process::class, function(Faker $faker) {
|
$factory->define(\ProcessMaker\Model\Process::class, function(Faker $faker) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo Determine if we need more base columns populated
|
* @todo Determine if we need more base columns populated
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
use Faker\Generator as Faker;
|
use Faker\Generator as Faker;
|
||||||
|
|
||||||
$factory->define(\ProcessMaker\Model\Route::class, function(Faker $faker) {
|
$factory->define(\ProcessMaker\Model\Route::class, function(Faker $faker) {
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'PRO_UID' => function() {
|
'PRO_UID' => function() {
|
||||||
$process = factory(\ProcessMaker\Model\Process::class)->create();
|
$process = factory(\ProcessMaker\Model\Process::class)->create();
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
use Faker\Generator as Faker;
|
use Faker\Generator as Faker;
|
||||||
|
|
||||||
$factory->define(\ProcessMaker\Model\Task::class, function(Faker $faker) {
|
$factory->define(\ProcessMaker\Model\Task::class, function(Faker $faker) {
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'PRO_UID' => function() {
|
'PRO_UID' => function() {
|
||||||
$process = factory(\ProcessMaker\Model\Process::class)->create();
|
$process = factory(\ProcessMaker\Model\Process::class)->create();
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
use Faker\Generator as Faker;
|
use Faker\Generator as Faker;
|
||||||
|
|
||||||
$factory->define(\ProcessMaker\Model\TaskUser::class, function(Faker $faker) {
|
$factory->define(\ProcessMaker\Model\TaskUser::class, function(Faker $faker) {
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'TAS_UID' => function() {
|
'TAS_UID' => function() {
|
||||||
$task = factory(\ProcessMaker\Model\Task::class)->create();
|
$task = factory(\ProcessMaker\Model\Task::class)->create();
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
use Faker\Generator as Faker;
|
use Faker\Generator as Faker;
|
||||||
|
|
||||||
$factory->define(\ProcessMaker\Model\User::class, function(Faker $faker) {
|
$factory->define(\ProcessMaker\Model\User::class, function(Faker $faker) {
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'USR_UID' => G::generateUniqueID(),
|
'USR_UID' => G::generateUniqueID(),
|
||||||
'USR_USERNAME' => $faker->unique()->userName,
|
'USR_USERNAME' => $faker->unique()->userName,
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ class DelegationTest extends TestCase
|
|||||||
$results = Delegation::search(null, 50, 25);
|
$results = Delegation::search(null, 50, 25);
|
||||||
$this->assertCount(1, $results['data']);
|
$this->assertCount(1, $results['data']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This checks to make sure pagination is working properly
|
* This checks to make sure pagination is working properly
|
||||||
* @test
|
* @test
|
||||||
@@ -366,6 +367,54 @@ class DelegationTest extends TestCase
|
|||||||
$this->assertCount(1, $results['data']);
|
$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
|
* This ensures searching by case title and review the page
|
||||||
* case title does not match with case number (hertland use case)
|
* 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
|
* @test
|
||||||
*/
|
*/
|
||||||
public function it_should_sort_by_case_id()
|
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
|
* @test
|
||||||
*/
|
*/
|
||||||
public function it_should_sort_by_case_title()
|
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->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
|
* This ensures ordering ascending and descending works by current user
|
||||||
* @test
|
* @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
|
* @test
|
||||||
*/
|
*/
|
||||||
public function it_should_return_data_issue()
|
public function it_should_sort_by_last_modified()
|
||||||
{
|
{
|
||||||
factory(User::class,100)->create();
|
factory(User::class,100)->create();
|
||||||
// Create a threads over the process
|
factory(Process::class,1)->create();
|
||||||
$process = factory(Process::class, 1)->create([
|
$application = factory(Application::class, 1)->create([
|
||||||
'PRO_ID' => 1
|
'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([
|
$application = factory(Application::class, 1)->create([
|
||||||
'APP_NUMBER' => 1,
|
|
||||||
'APP_TITLE' => 'Request by Thomas',
|
|
||||||
'APP_STATUS_ID' => 2,
|
|
||||||
'APP_STATUS' => 'TO_DO'
|
'APP_STATUS' => 'TO_DO'
|
||||||
]);
|
]);
|
||||||
// Create a user Gary in a thread
|
factory(Delegation::class, 25)->create([
|
||||||
$user = factory(User::class)->create([
|
'APP_NUMBER' => $application[0]->APP_NUMBER
|
||||||
'USR_USERNAME' => 'gary',
|
|
||||||
'USR_LASTNAME' => 'Gary',
|
|
||||||
'USR_FIRSTNAME' => 'Bailey',
|
|
||||||
]);
|
]);
|
||||||
// Create a thread with the user Gary
|
$application = factory(Application::class, 1)->create([
|
||||||
factory(Delegation::class, 1)->create([
|
'APP_STATUS' => 'COMPLETED'
|
||||||
'PRO_ID' => $process[0]->id,
|
]);
|
||||||
'USR_ID' => $user->id,
|
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
|
'APP_NUMBER' => $application[0]->APP_NUMBER
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Define a dummy task
|
// Get first page, the minor status label
|
||||||
$task = factory(Task::class, 1)->create([
|
$results = Delegation::search(null, 0, 25, null, null, null, 'ASC', 'APP_STATUS');
|
||||||
'TAS_ID' => 1,
|
$this->assertEquals('CANCELLED', $results['data'][0]['APP_STATUS']);
|
||||||
'TAS_TYPE' => 'INTERMEDIATE-THROW'
|
$results = Delegation::search(null, 25, 25, null, null, null, 'ASC', 'APP_STATUS');
|
||||||
]);
|
$this->assertEquals('COMPLETED', $results['data'][0]['APP_STATUS']);
|
||||||
// Create a thread with the dummy task this does not need a user
|
$results = Delegation::search(null, 50, 25, null, null, null, 'ASC', 'APP_STATUS');
|
||||||
factory(Delegation::class, 1)->create([
|
$this->assertEquals('DRAFT', $results['data'][0]['APP_STATUS']);
|
||||||
'PRO_ID' => $process[0]->id,
|
$results = Delegation::search(null, 75, 25, null, null, null, 'ASC', 'APP_STATUS');
|
||||||
'USR_ID' => 0,
|
$this->assertEquals('TO_DO', $results['data'][0]['APP_STATUS']);
|
||||||
'TAS_ID' => $task[0]->id,
|
// Get first page, the major status label
|
||||||
'APP_NUMBER' => $application[0]->APP_NUMBER
|
$results = Delegation::search(null, 0, 25, null, null, null, 'DESC', 'APP_STATUS');
|
||||||
]);
|
$this->assertEquals('TO_DO', $results['data'][0]['APP_STATUS']);
|
||||||
// Create a user Paul in a thread
|
$results = Delegation::search(null, 25, 25, null, null, null, 'DESC', 'APP_STATUS');
|
||||||
$user = factory(User::class)->create([
|
$this->assertEquals('DRAFT', $results['data'][0]['APP_STATUS']);
|
||||||
'USR_USERNAME' => 'Paul',
|
$results = Delegation::search(null, 50, 25, null, null, null, 'DESC', 'APP_STATUS');
|
||||||
'USR_LASTNAME' => 'Griffis',
|
$this->assertEquals('COMPLETED', $results['data'][0]['APP_STATUS']);
|
||||||
'USR_FIRSTNAME' => 'paul',
|
$results = Delegation::search(null, 75, 25, null, null, null, 'DESC', 'APP_STATUS');
|
||||||
]);
|
$this->assertEquals('CANCELLED', $results['data'][0]['APP_STATUS']);
|
||||||
// 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']);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -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->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']);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -50,7 +50,7 @@ $filterStatus = isset($_REQUEST["filterStatus"]) ? strtoupper($_REQUEST["filterS
|
|||||||
// What user
|
// What user
|
||||||
$user = isset($_REQUEST["user"]) ? $_REQUEST["user"] : "";
|
$user = isset($_REQUEST["user"]) ? $_REQUEST["user"] : "";
|
||||||
|
|
||||||
// What search???
|
// What keywords to search
|
||||||
$search = isset($_REQUEST["search"]) ? $_REQUEST["search"] : "";
|
$search = isset($_REQUEST["search"]) ? $_REQUEST["search"] : "";
|
||||||
|
|
||||||
// What kind of action
|
// What kind of action
|
||||||
|
|||||||
@@ -24,5 +24,4 @@ class Application extends Model
|
|||||||
{
|
{
|
||||||
return $this->hasOne(User::class, 'APP_CUR_USER', 'USR_UID');
|
return $this->hasOne(User::class, 'APP_CUR_USER', 'USR_UID');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ class Process extends Model
|
|||||||
// Our custom timestamp columns
|
// Our custom timestamp columns
|
||||||
const CREATED_AT = 'PRO_CREATE_DATE';
|
const CREATED_AT = 'PRO_CREATE_DATE';
|
||||||
const UPDATED_AT = 'PRO_UPDATE_DATE';
|
const UPDATED_AT = 'PRO_UPDATE_DATE';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve all applications that belong to this process
|
* Retrieve all applications that belong to this process
|
||||||
*/
|
*/
|
||||||
@@ -26,7 +25,6 @@ class Process extends Model
|
|||||||
return $this->hasMany(Application::class, 'PRO_ID', 'PRO_ID');
|
return $this->hasMany(Application::class, 'PRO_ID', 'PRO_ID');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function tasks()
|
public function tasks()
|
||||||
{
|
{
|
||||||
return $this->hasMany(Task::class, 'PRO_UID', 'PRO_UID');
|
return $this->hasMany(Task::class, 'PRO_UID', 'PRO_UID');
|
||||||
|
|||||||
@@ -17,6 +17,5 @@ class User extends Model
|
|||||||
public function delegations()
|
public function delegations()
|
||||||
{
|
{
|
||||||
return $this->hasMany(Delegation::class, 'USR_ID', 'USR_ID');
|
return $this->hasMany(Delegation::class, 'USR_ID', 'USR_ID');
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user