Merged in bugfix/PMC-763-a (pull request #6884)

PMC-763

Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
Paula Quispe
2019-05-07 16:37:09 +00:00
committed by Julio Cesar Laura Avendaño
2 changed files with 49 additions and 34 deletions

View File

@@ -924,24 +924,22 @@ class DelegationTest extends TestCase
public function it_should_return_by_sequential_tasks_pages_of_data() public function it_should_return_by_sequential_tasks_pages_of_data()
{ {
factory(User::class, 100)->create(); factory(User::class, 100)->create();
// Create a threads over the process // Create a process
$process = factory(Process::class, 1)->create([ $process = factory(Process::class, 1)->create([
'PRO_ID' => 1 'PRO_ID' => 1000
]); ]);
$application = factory(Application::class, 1)->create([ $application = factory(Application::class, 1)->create([
'APP_NUMBER' => 1, 'APP_NUMBER' => 5000,
'APP_TITLE' => 'Request by Thomas', 'APP_TITLE' => 'Request by Thomas',
]); ]);
// Create a user Gary in a thread // Create task
$user = factory(User::class)->create([ $task = factory(Task::class, 1)->create([
'USR_USERNAME' => 'gary', 'TAS_TYPE' => 'NORMAL'
'USR_LASTNAME' => 'Bailey',
'USR_FIRSTNAME' => 'Gary',
]); ]);
// Create a thread with the user Gary // Create a thread with the user, process and application defined before
factory(Delegation::class, 1)->create([ factory(Delegation::class)->create([
'PRO_ID' => $process[0]->id, 'PRO_ID' => $process[0]->id,
'USR_ID' => $user->id, 'TAS_ID' => $task[0]->id,
'APP_NUMBER' => $application[0]->APP_NUMBER, 'APP_NUMBER' => $application[0]->APP_NUMBER,
'DEL_THREAD_STATUS' => 'CLOSED' 'DEL_THREAD_STATUS' => 'CLOSED'
]); ]);
@@ -951,29 +949,27 @@ class DelegationTest extends TestCase
'TAS_TYPE' => 'INTERMEDIATE-THROW' 'TAS_TYPE' => 'INTERMEDIATE-THROW'
]); ]);
// Create a thread with the dummy task this does not need a user // Create a thread with the dummy task this does not need a user
factory(Delegation::class, 1)->create([ factory(Delegation::class)->create([
'PRO_ID' => $process[0]->id, 'PRO_ID' => $process[0]->id,
'USR_ID' => 0, 'USR_ID' => 0,
'TAS_ID' => $task[0]->id, 'TAS_ID' => $task[0]->id,
'APP_NUMBER' => $application[0]->APP_NUMBER 'APP_NUMBER' => $application[0]->APP_NUMBER
]); ]);
// Create a user Paul in a thread // Create task
$user = factory(User::class)->create([ $task = factory(Task::class, 1)->create([
'USR_USERNAME' => 'paul', 'TAS_TYPE' => 'NORMAL'
'USR_LASTNAME' => 'Griffis',
'USR_FIRSTNAME' => 'Paul',
]); ]);
// Create a thread with the user Paul // Create a thread with the user, process and application defined before
factory(Delegation::class, 1)->create([ factory(Delegation::class)->create([
'PRO_ID' => $process[0]->id, 'PRO_ID' => $process[0]->id,
'USR_ID' => $user->id, 'TAS_ID' => $task[0]->id,
'APP_NUMBER' => $application[0]->APP_NUMBER, 'APP_NUMBER' => $application[0]->APP_NUMBER,
'DEL_THREAD_STATUS' => 'OPEN' 'DEL_THREAD_STATUS' => 'OPEN'
]); ]);
// Get first page, which is 25 of 26 // Review if the thread OPEN is showed
$results = Delegation::search(null, 0, 10, null, $process[0]->id, null, 'ASC', 'APP_NUMBER'); $results = Delegation::search(null, 0, 10, null);
$this->assertCount(1, $results['data']); $this->assertCount(1, $results['data']);
$this->assertEquals('Griffis Paul', $results['data'][0]['APP_CURRENT_USER']); $this->assertEquals('OPEN', $results['data'][0]['DEL_THREAD_STATUS']);
} }
/** /**
@@ -1026,6 +1022,25 @@ class DelegationTest extends TestCase
$this->assertCount(5, $results['data']); $this->assertCount(5, $results['data']);
$this->assertEquals('OPEN', $results['data'][0]['DEL_THREAD_STATUS']); $this->assertEquals('OPEN', $results['data'][0]['DEL_THREAD_STATUS']);
$this->assertEquals('OPEN', $results['data'][4]['DEL_THREAD_STATUS']); $this->assertEquals('OPEN', $results['data'][4]['DEL_THREAD_STATUS']);
}
/**
* 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']);
} }
} }

View File

@@ -282,14 +282,14 @@ class Delegation extends Model
// Rewrite priority string // Rewrite priority string
if ($item['DEL_PRIORITY']) { if ($item['DEL_PRIORITY']) {
$item['DEL_PRIORITY'] = G::LoadTranslation("ID_PRIORITY_{$priorities[$item['DEL_PRIORITY']]}", 'en'); $item['DEL_PRIORITY'] = G::LoadTranslation("ID_PRIORITY_{$priorities[$item['DEL_PRIORITY']]}");
} }
// Merge in desired application data // Merge in desired application data
if ($item['APP_STATUS']) { if ($item['APP_STATUS']) {
$item['APP_STATUS_LABEL'] = G::LoadTranslation("ID_${item['APP_STATUS']}", 'en'); $item['APP_STATUS_LABEL'] = G::LoadTranslation("ID_${item['APP_STATUS']}");
} else { } else {
$item['APP_STATUS_LABEL'] = $application->APP_STATUS; $item['APP_STATUS_LABEL'] = $item['APP_STATUS'];
} }
// Merge in desired process data // Merge in desired process data