PMCORE-2397

This commit is contained in:
Paula Quispe
2020-12-09 19:04:05 -04:00
parent bb38e8acd8
commit 9565312ca9
20 changed files with 806 additions and 1431 deletions

View File

@@ -6,7 +6,7 @@ use Faker\Generator as Faker;
$factory->define(\ProcessMaker\Model\AppAssignSelfServiceValue::class, function(Faker $faker) {
return [
'ID' => $faker->unique()->numberBetween(1, 2000),
'ID' => $faker->unique()->numberBetween(5000),
'APP_UID' => G::generateUniqueID(),
'DEL_INDEX' => 2,
'PRO_UID' => G::generateUniqueID(),

View File

@@ -6,7 +6,7 @@ use Faker\Generator as Faker;
$factory->define(\ProcessMaker\Model\AppAssignSelfServiceValueGroup::class, function(Faker $faker) {
return [
'ID' => $faker->unique()->numberBetween(1, 2000),
'ID' => $faker->unique()->numberBetween(5000),
'GRP_UID' => G::generateUniqueID(),
'ASSIGNEE_ID' => $faker->unique()->numberBetween(1, 2000),
'ASSIGNEE_TYPE' => $faker->unique()->numberBetween(1, 2000),

View File

@@ -16,9 +16,9 @@ $factory->define(\ProcessMaker\Model\Delegation::class, function(Faker $faker) {
]);
// Return with default values
return [
'DELEGATION_ID' => $faker->unique()->numberBetween(5000),
'APP_UID' => $application->APP_UID,
'DEL_INDEX' => 1,
'DELEGATION_ID' => $faker->unique()->randomNumber,
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_PREVIOUS' => 0,
'PRO_UID' => $process->PRO_UID,
@@ -62,6 +62,7 @@ $factory->state(\ProcessMaker\Model\Delegation::class, 'foreign_keys', function
// Return with default values
return [
'DELEGATION_ID' => $faker->unique()->numberBetween(5000),
'APP_UID' => $application->APP_UID,
'DEL_INDEX' => 1,
'APP_NUMBER' => $application->APP_NUMBER,

View File

@@ -3,6 +3,7 @@
namespace Tests\unit\workflow\src\ProcessMaker\BusinessModel\Cases;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\BusinessModel\Cases\Draft;
use ProcessMaker\Model\Application;
use ProcessMaker\Model\Delegation;
@@ -65,92 +66,138 @@ class DraftTest extends TestCase
* It tests the getData method without filters
*
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @test
*/
public function it_should_test_get_data_method_without_filters()
public function it_get_result_without_filters()
{
// Create factories related to the draft cases
$cases = $this->createDraft();
// Create new Draft object
$inbox = new Inbox();
$draft = new Inbox();
// Set the user ID
$inbox->setUserId($cases->USR_ID);
$inbox->setOrderByColumn('APP_NUMBER');
$res = $inbox->getData();
$draft->setUserId($cases->USR_ID);
$draft->setOrderByColumn('APP_NUMBER');
$res = $draft->getData();
$this->assertNotEmpty($res);
}
/**
* It tests the getData method with Process Filter
* It tests the getData method with processId filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Draft::filters()
* @test
*/
public function it_should_test_get_data_by_process_filter()
public function it_filter_by_process()
{
// Create factories related to the draft cases
$cases = $this->createDraft();
// Create new Draft object
$inbox = new Draft();
$inbox->setUserId($cases->USR_ID);
$inbox->setProcessId($cases->PRO_ID);
$inbox->setOrderByColumn('APP_NUMBER');
$res = $inbox->getData();
$draft = new Draft();
$draft->setUserId($cases->USR_ID);
$draft->setProcessId($cases->PRO_ID);
$draft->setOrderByColumn('APP_NUMBER');
$res = $draft->getData();
$this->assertNotEmpty($res);
}
/**
* It tests the getData method using OrderBy
* It tests the getData method with case number filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Draft::filters()
* @test
*/
public function it_should_test_get_data_by_case_number()
public function it_filter_by_app_number()
{
// Create factories related to the draft cases
$cases = $this->createDraft();
// Create new Draft object
$inbox = new Draft();
$inbox->setUserId($cases->USR_ID);
$inbox->setCaseNumber($cases->APP_NUMBER);
$inbox->setOrderByColumn('APP_NUMBER');
$res = $inbox->getData();
$draft = new Draft();
$draft->setUserId($cases->USR_ID);
$draft->setCaseNumber($cases->APP_NUMBER);
$draft->setOrderByColumn('APP_NUMBER');
$res = $draft->getData();
$this->assertNotEmpty($res);
}
/**
* It tests the getData method using OrderBy
* It tests the getData method with taskId filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Draft::filters()
* @test
*/
public function it_should_test_get_data_by_task_filter()
public function it_filter_by_task()
{
// Create factories related to the draft cases
$cases = $this->createDraft();
// Create new Draft object
$inbox = new Draft();
$inbox->setUserId($cases->USR_ID);
$inbox->setTaskId($cases->TAS_ID);
$res = $inbox->getData();
$draft = new Draft();
$draft->setUserId($cases->USR_ID);
$draft->setTaskId($cases->TAS_ID);
$res = $draft->getData();
$this->assertNotEmpty($res);
}
/**
* It tests the getData method using OrderBy
* It tests the getData method with case title filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Draft::filters()
* @test
*/
public function it_should_test_get_data_by_case_title()
public function it_filter_by_thread_title()
{
// Create factories related to the to_do cases
$cases = $this->createDraft();
$title = $cases->last()->DEL_TITLE;
// We need to commit the records inserted because is needed for the "fulltext" index
DB::commit();
// Create new Draft object
$inbox = new Draft();
$inbox->setUserId($cases->USR_ID);
$res = $inbox->getData();
$draft = new Draft();
$draft->setUserId($cases->USR_ID);
// Set the title
$draft->setCaseTitle($cases->DEL_TITLE);
// Get the data
$res = $draft->getData();
// Asserts
$this->assertNotEmpty($res);
}
/**
* It tests the getData method using order by column
*
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Draft::filters()
* @test
*/
public function it_order_by_column()
{
// Create factories related to the to_do cases
$cases = $this->createDraft();
$columnsView = [
'APP_NUMBER',
'DEL_TITLE',
'PRO_TITLE',
'TAS_TITLE',
'DEL_TASK_DUE_DATE',
'DEL_DELEGATE_DATE'
];
$index = array_rand($columnsView);
// Create new Inbox object
$draft = new Draft();
$draft->setUserId($cases->USR_ID);
// Define the column to order
$draft->setOrderByColumn($columnsView[$index]);
$res = $draft->getData();
$this->assertNotEmpty($res);
}
}

View File

@@ -3,6 +3,7 @@
namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\BusinessModel\Cases\Inbox;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\Process;
@@ -36,13 +37,31 @@ class InboxTest extends TestCase
return $delegation;
}
/**
* It tests the getCounter method
*
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getCounter()
* @test
*/
public function it_get_counter()
{
// Create factories related to the to_do cases
$cases = $this->createInbox();
// Create the Inbox object
$inbox = new Inbox();
$inbox->setUserId($cases->USR_ID);
$res = $inbox->getCounter();
$this->assertTrue($res > 0);
}
/**
* It tests the getData method without filters
*
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @test
*/
public function it_should_test_get_data_method_without_filters()
public function it_get_result_without_filters()
{
// Create factories related to the to_do cases
$cases = $this->createInbox();
@@ -59,12 +78,14 @@ class InboxTest extends TestCase
}
/**
* It tests the getData method with Process Filter
* It tests the getData method with processId filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::filters()
* @test
*/
public function it_should_test_get_data_by_process_filter()
public function it_filter_by_process()
{
// Create factories related to the to_do cases
$cases = $this->createInbox();
@@ -78,12 +99,14 @@ class InboxTest extends TestCase
}
/**
* It tests the getData method using OrderBy
* It tests the getData method with case number filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::filters()
* @test
*/
public function it_should_test_get_data_by_case_number()
public function it_filter_by_app_number()
{
// Create factories related to the to_do cases
$cases = $this->createInbox();
@@ -97,12 +120,14 @@ class InboxTest extends TestCase
}
/**
* It tests the getData method using OrderBy
* It tests the getData method with taskId filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::filters()
* @test
*/
public function it_should_test_get_data_by_task_filter()
public function it_filter_by_task()
{
// Create factories related to the to_do cases
$cases = $this->createInbox();
@@ -116,36 +141,57 @@ class InboxTest extends TestCase
}
/**
* It tests the getData method using OrderBy
* It tests the getData method with case title filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::filters()
* @test
*/
public function it_should_test_get_data_by_case_title()
public function it_filter_by_thread_title()
{
// Create factories related to the to_do cases
$cases = $this->createInbox();
// We need to commit the records inserted because is needed for the "fulltext" index
DB::commit();
// Create new Inbox object
$inbox = new Inbox();
$inbox->setUserId($cases->USR_ID);
// Set the title
$inbox->setCaseTitle($cases->DEL_TITLE);
// Get the data
$res = $inbox->getData();
// Asserts
$this->assertNotEmpty($res);
}
/**
* It tests the getCounter method
* It tests the getData method using order by column
*
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getCounter()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::filters()
* @test
*/
public function it_should_test_the_counter_for_inbox()
public function it_order_by_column()
{
// Create factories related to the to_do cases
$cases = $this->createInbox();
// Create the Inbox object
$columnsView = [
'APP_NUMBER',
'DEL_TITLE',
'PRO_TITLE',
'TAS_TITLE',
'DEL_TASK_DUE_DATE',
'DEL_DELEGATE_DATE'
];
$index = array_rand($columnsView);
// Create new Inbox object
$inbox = new Inbox();
$inbox->setUserId($cases->USR_ID);
$res = $inbox->getCounter();
$this->assertTrue($res > 0);
// Define the column to order
$inbox->setOrderByColumn($columnsView[$index]);
$res = $inbox->getData();
$this->assertNotEmpty($res);
}
}

View File

@@ -3,6 +3,7 @@
namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\BusinessModel\Cases\Participated;
use ProcessMaker\Model\Application;
use ProcessMaker\Model\Delegation;
@@ -48,9 +49,10 @@ class ParticipatedTest extends TestCase
* It tests the getData method without filters
*
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @test
*/
public function it_should_test_get_data_method_without_filters()
public function it_get_result_without_filters()
{
// Create factories related to the participated cases
$cases = $this->createParticipated();
@@ -68,95 +70,15 @@ class ParticipatedTest extends TestCase
$this->assertEquals(1, count($res));
}
/**
* It tests the getData method with process
*
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getData()
* @test
*/
public function it_should_test_get_data_method_with_specific_process()
{
// Create factories related to the participated cases
$cases = $this->createParticipated();
// Create new Participated object
$participated = new Participated();
// Set the user UID
$participated->setUserUid($cases->USR_UID);
// Set the user ID
$participated->setUserId($cases->USR_ID);
// Set the process ID
$participated->setProcessId($cases->PRO_ID);
// Set OrderBYColumn value
$participated->setOrderByColumn('APP_NUMBER');
// Call to getData method
$res = $participated->getData();
// This assert that the expected numbers of results are returned
$this->assertEquals(1, count($res));
}
/**
* It tests the getData method with process category
*
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getData()
* @test
*/
public function it_should_test_get_data_method_with_specific_process_category()
{
// Create factories related to the participated cases
$cases = $this->createParticipated();
$process = Process::query()->where('PRO_ID', $cases->PRO_ID)->get()->toArray();
$process = head($process);
// Create new Participated object
$participated = new Participated();
// Set the user UID
$participated->setUserUid($cases->USR_UID);
// Set the user ID
$participated->setUserId($cases->USR_ID);
// Set the process ID
$participated->setProcessId($cases->PRO_ID);
// Set the category
$participated->setCategoryUid($process['PRO_CATEGORY']);
// Set OrderBYColumn value
$participated->setOrderByColumn('APP_NUMBER');
// Call to getData method
$res = $participated->getData();
// This assert that the expected numbers of results are returned
$this->assertEquals(1, count($res));
}
/**
* It tests the getData method with specific TO_DO status
*
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getData()
* @test
*/
public function it_should_test_get_data_method_with_case_to_do()
{
// Create factories related to the participated cases
$cases = $this->createParticipated();
// Create new Participated object
$participated = new Participated();
// Set the user UID
$participated->setUserUid($cases->USR_UID);
// Set the user ID
$participated->setUserId($cases->USR_ID);
// Set the case status
$participated->setCaseStatus('TO_DO');
// Set OrderBYColumn value
$participated->setOrderByColumn('APP_NUMBER');
// Call to getData method
$res = $participated->getData();
// This assert that the expected numbers of results are returned
$this->assertEquals(1, count($res));
}
/**
* It tests the getData method with specific filter StartedByMe
*
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::filters()
* @test
*/
public function it_should_test_get_data_method_started_by_me_filter()
public function it_filter_by_started_by_me()
{
// Create factories related to the participated cases
$cases = $this->createParticipated();
@@ -173,16 +95,18 @@ class ParticipatedTest extends TestCase
// Call to getData method
$res = $participated->getData();
// This assert that the expected numbers of results are returned
$this->assertEquals(0, count($res));
$this->assertEquals(1, count($res));
}
/**
* It tests the getData method with specific filter CompletedByMe
*
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::filters()
* @test
*/
public function it_should_test_get_data_method_completed_by_me_filter()
public function it_filter_by_completed_by_me()
{
// Create factories related to the participated cases
$cases = $this->createParticipated();
@@ -202,13 +126,73 @@ class ParticipatedTest extends TestCase
$this->assertEquals(0, count($res));
}
/**
* It tests the getData method with processId filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::filters()
* @test
*/
public function it_filter_by_process()
{
// Create factories related to the participated cases
$cases = $this->createParticipated();
// Create new Participated object
$participated = new Participated();
// Set the filter
$participated->setFilterCases('STARTED');
// Set the user UID
$participated->setUserUid($cases->USR_UID);
// Set the user ID
$participated->setUserId($cases->USR_ID);
// Set the process ID
$participated->setProcessId($cases->PRO_ID);
// Set OrderBYColumn value
$participated->setOrderByColumn('APP_NUMBER');
// Call to getData method
$res = $participated->getData();
// This assert that the expected numbers of results are returned
$this->assertEquals(1, count($res));
}
/**
* It tests the getData method with processId filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::filters()
* @test
*/
public function it_filter_by_thread_title()
{
// Create factories related to the participated cases
$cases = $this->createParticipated();
// We need to commit the records inserted because is needed for the "fulltext" index
DB::commit();
// Create new Participated object
$participated = new Participated();
// Set the filter
$participated->setFilterCases('STARTED');
// Set the user UID
$participated->setUserUid($cases->USR_UID);
// Set the user ID
$participated->setUserId($cases->USR_ID);
// Set the title
$participated->setCaseTitle($cases->DEL_TITLE);
// Get the data
$res = $participated->getData();
// Asserts
$this->assertCount(1, $res);
}
/**
* It tests the getCounter method
*
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getCounter()
* @test
*/
public function it_should_test_the_counter_for_participated()
public function it_get_counter()
{
// Create factories related to the participated cases
$cases = $this->createParticipated();

View File

@@ -3,6 +3,7 @@
namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\BusinessModel\Cases\Paused;
use ProcessMaker\Model\Application;
use ProcessMaker\Model\AppDelay;
@@ -15,8 +16,7 @@ use Tests\TestCase;
/**
* Class PausedTest
*
* @coversDefaultClass ProcessMaker\BusinessModel\Cases\Paused
* @package Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases
* @coversDefaultClass \ProcessMaker\BusinessModel\Cases\Paused
*/
class PausedTest extends TestCase
{
@@ -126,12 +126,12 @@ class PausedTest extends TestCase
* It tests the getData method without filters
*
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @test
*/
public function it_should_test_get_data_method_without_filters()
public function it_get_result_without_filters()
{
// Create factories related to the to_do cases
// Create factories related to the paused cases
$cases = $this->createPaused();
// Create new Paused object
$paused = new Paused();
@@ -146,14 +146,16 @@ class PausedTest extends TestCase
}
/**
* It tests the getData method with app number filter
* It tests the getData method with case number filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Paused::filters()
* @test
*/
public function it_should_test_get_data_by_case_number()
public function it_filter_by_app_number()
{
// Create factories related to the to_do cases
// Create factories related to the paused cases
$cases = $this->createPaused();
//Create new Paused object
$paused = new Paused();
@@ -173,11 +175,13 @@ class PausedTest extends TestCase
* It tests the getData method with taskId filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Paused::filters()
* @test
*/
public function it_should_test_get_data_by_task_filter()
public function it_filter_by_task()
{
// Create factories related to the to_do cases
// Create factories related to the paused cases
$cases = $this->createPaused();
// Create new Paused object
$paused = new Paused();
@@ -194,14 +198,16 @@ class PausedTest extends TestCase
}
/**
* It tests the getData method using OrderBy Case Number
* It tests the getData method with processId filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Paused::filters()
* @test
*/
public function it_should_test_get_data_by_process_filter()
public function it_filter_by_process()
{
// Create factories related to the to_do cases
// Create factories related to the paused cases
$cases = $this->createPaused();
// Create new Paused object
$paused = new Paused();
@@ -210,25 +216,32 @@ class PausedTest extends TestCase
// Set the user ID
$paused->setUserId($cases->USR_ID);
$paused->setProcessId($cases->PRO_ID);
// Call to getData method
// Get the data
$res = $paused->getData();
// Asserts
$this->assertNotEmpty($res);
}
/**
* It tests the getData method using OrderBy
* It tests the getData method with case title filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Paused::filters()
* @test
*/
public function it_should_test_get_data_by_case_title()
public function it_filter_by_thread_title()
{
// Create factories related to the to_do cases
// Create factories related to the paused cases
$cases = $this->createPaused();
// Create new Inbox object
// We need to commit the records inserted because is needed for the "fulltext" index
DB::commit();
// Create new Paused object
$paused = new Paused();
$paused->setUserUid($cases->USR_UID);
$paused->setUserId($cases->USR_ID);
// Set the title
$paused->setCaseTitle($cases->DEL_TITLE);
$res = $paused->getData();
$this->assertNotEmpty($res);
}

View File

@@ -3,6 +3,7 @@
namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\DB;
use ProcessMaker\BusinessModel\Cases\Search;
use ProcessMaker\Model\Delegation;
use Tests\TestCase;
@@ -43,9 +44,10 @@ class SearchTest extends TestCase
* It tests the getData method without filters
*
* @covers \ProcessMaker\BusinessModel\Cases\Search::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @test
*/
public function it_should_test_get_data_method_without_filters()
public function it_get_result_without_filters()
{
// Create factories related to the delegation cases
$cases = $this->createSearch();
@@ -60,9 +62,11 @@ class SearchTest extends TestCase
* It tests the getData with case number
*
* @covers \ProcessMaker\BusinessModel\Cases\Search::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Search::filters()
* @test
*/
public function it_should_test_get_data_method_with_specific_case_number()
public function it_filter_by_app_number()
{
// Create factories related to the delegation cases
$cases = $this->createSearch();
@@ -76,33 +80,15 @@ class SearchTest extends TestCase
$this->assertEquals($cases[0]->APP_NUMBER, $result[0]['APP_NUMBER']);
}
/**
* It tests the getData with priority
*
* @covers \ProcessMaker\BusinessModel\Cases\Search::getData()
* @test
*/
public function it_should_test_get_data_method_with_specific_priority()
{
// Create factories related to the delegation cases
$cases = $this->createSearch();
// Create new Search object
$search = new Search();
$search->setPriority('N');
// Set order by column value
$search->setOrderByColumn('APP_NUMBER');
$result = $search->getData();
// This assert that the expected numbers of results are returned
$this->assertNotEmpty($result);
}
/**
* It tests the getData with process
*
* @covers \ProcessMaker\BusinessModel\Cases\Search::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Search::filters()
* @test
*/
public function it_should_test_get_data_method_with_specific_process()
public function it_filter_by_process()
{
// Create factories related to the delegation cases
$cases = $this->createSearch();
@@ -120,9 +106,11 @@ class SearchTest extends TestCase
* It tests the getData with task
*
* @covers \ProcessMaker\BusinessModel\Cases\Search::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Search::filters()
* @test
*/
public function it_should_test_get_data_method_with_specific_task()
public function it_filter_by_task()
{
// Create factories related to the delegation cases
$cases = $this->createSearch();
@@ -136,13 +124,40 @@ class SearchTest extends TestCase
$this->assertNotEmpty($result);
}
/**
* It tests the getData method with case title filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Search::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Search::filters()
* @test
*/
public function it_filter_by_thread_title()
{
// Create factories related to the to_do cases
$cases = $this->createSearch();
$title = $cases->last()->DEL_TITLE;
// We need to commit the records inserted because is needed for the "fulltext" index
DB::commit();
// Create new Draft object
$search = new Search();
// Set the title
$search->setCaseTitle($title);
// Get the data
$res = $search->getData();
// Asserts
$this->assertNotEmpty($res);
}
/**
* It tests the getData with user
*
* @covers \ProcessMaker\BusinessModel\Cases\Search::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Search::filters()
* @test
*/
public function it_should_test_get_data_method_with_specific_user()
public function it_filter_by_user()
{
// Create factories related to the delegation cases
$cases = $this->createSearch();
@@ -156,6 +171,28 @@ class SearchTest extends TestCase
$this->assertNotEmpty($result);
}
/**
* It tests the getData with priority
*
* @covers \ProcessMaker\BusinessModel\Cases\Search::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Search::filters()
* @test
*/
public function it_filter_by_priority()
{
// Create factories related to the delegation cases
$cases = $this->createSearch();
// Create new Search object
$search = new Search();
$search->setPriority('N');
// Set order by column value
$search->setOrderByColumn('APP_NUMBER');
$result = $search->getData();
// This assert that the expected numbers of results are returned
$this->assertNotEmpty($result);
}
/**
* It tests the getCounter method
*

View File

@@ -12,20 +12,26 @@ use ProcessMaker\Model\User;
class AbstractCases implements CasesInterface
{
// Constants for validate values
const INBOX_STATUSES = ['ALL', 'READ', 'UNREAD'];
const PARTICIPATED_STATUSES = ['ALL', 'STARTED', 'IN_PROGRESS', 'COMPLETED', 'SUPERVISING'];
const RISK_STATUSES = ['ALL', 'ON_TIME', 'AT_RISK', 'OVERDUE'];
const INBOX_STATUSES = ['READ', 'UNREAD'];
const PARTICIPATED_STATUSES = ['STARTED', 'IN_PROGRESS', 'COMPLETED', 'SUPERVISING'];
const RISK_STATUSES = ['ON_TIME', 'AT_RISK', 'OVERDUE'];
const CASE_STATUSES = [1 => 'DRAFT', 2 => 'TO_DO', 3 => 'COMPLETED', 4 => 'CANCELED'];
const ORDER_DIRECTIONS = ['DESC', 'ASC'];
const CORRECT_CANCELED_STATUS = 'CANCELED';
const INCORRECT_CANCELED_STATUS = 'CANCELLED';
const PRIORITIES = [1 => 'VL', 2 => 'L', 3 => 'N', 4 => 'H', 5 => 'VH'];
// Task Colors
const TASK_COLORS = [1 => 'green', 2 => 'red', 3 => 'orange', 4 => 'blue', 5 => 'gray'];
const COLOR_OVERDUE = 1;
const COLOR_ON_TIME = 2;
const COLOR_DRAFT = 3;
const COLOR_PAUSED = 4;
const COLOR_UNASSIGNED = 5;
// Status values
const STATUS_DRAFT = 1;
const STATUS_TODO = 2;
const STATUS_COMPLETED = 3;
const STATUS_CANCELED = 4;
// Filter by category from a process, know as "$category" in the old lists classes
private $categoryUid = '';
@@ -286,11 +292,6 @@ class AbstractCases implements CasesInterface
throw new Exception("Inbox status '{$inboxStatus}' is not valid.");
}
// If empty string is sent, use value 'ALL'
if ($inboxStatus === '') {
$inboxStatus = 'ALL';
}
$this->inboxStatus = $inboxStatus;
}
@@ -321,11 +322,6 @@ class AbstractCases implements CasesInterface
throw new Exception("Participated status '{$participatedStatus}' is not valid.");
}
// If empty string will not apply the filter
if ($participatedStatus === 'ALL') {
$participatedStatus = '';
}
$this->participatedStatus = $participatedStatus;
}
@@ -356,11 +352,6 @@ class AbstractCases implements CasesInterface
throw new Exception("Risk status '{$riskStatus}' is not valid.");
}
// If empty string will not apply the filter
if ($riskStatus === 'ALL') {
$riskStatus = '';
}
$this->riskStatus = $riskStatus;
}

View File

@@ -11,7 +11,7 @@ class Draft extends AbstractCases
public $columnsView = [
// Columns view in the cases list
'APP_DELEGATION.APP_NUMBER', // Case #
'APP_DELEGATION.APP_NUMBER AS APP_TITLE', // Case Title @todo: Filter by case title, pending from other PRD
'APP_DELEGATION.DEL_TITLE', // Case Title
'PROCESS.PRO_TITLE', // Process
'TASK.TAS_TITLE', // Task
'APP_DELEGATION.DEL_TASK_DUE_DATE', // Due Date
@@ -48,7 +48,7 @@ class Draft extends AbstractCases
}
// Specific case title
if (!empty($this->getCaseTitle())) {
// @todo: Filter by case title, pending from other PRD
$query->title($this->getCaseTitle());
}
// Specific process
if ($this->getProcessId()) {

View File

@@ -11,7 +11,7 @@ class Inbox extends AbstractCases
public $columnsView = [
// Columns view in the cases list
'APP_DELEGATION.APP_NUMBER', // Case #
'APP_DELEGATION.APP_NUMBER AS APP_TITLE', // Case Title @todo: Filter by case title, pending from other PRD
'APP_DELEGATION.DEL_TITLE', // Case Title
'PROCESS.PRO_TITLE', // Process
'TASK.TAS_TITLE', // Task
'USERS.USR_USERNAME', // Current UserName
@@ -51,7 +51,7 @@ class Inbox extends AbstractCases
}
// Specific case title
if (!empty($this->getCaseTitle())) {
// @todo: Filter by case title, pending from other PRD
$query->title($this->getCaseTitle());
}
// Specific process
if ($this->getProcessId()) {

View File

@@ -12,7 +12,7 @@ class Participated extends AbstractCases
public $columnsView = [
// Columns view in the cases list
'APP_DELEGATION.APP_NUMBER', // Case #
'APP_DELEGATION.APP_NUMBER AS APP_TITLE', // Case Title @todo: Filter by case title, pending from other PRD
'APP_DELEGATION.DEL_TITLE', // Case Title
'PROCESS.PRO_TITLE', // Process Name
'TASK.TAS_TITLE', // Pending Task
'APPLICATION.APP_STATUS', // Status
@@ -51,7 +51,7 @@ class Participated extends AbstractCases
}
// Specific case title
if (!empty($this->getCaseTitle())) {
// @todo: Filter by case title, pending from other PRD
$query->title($this->getCaseTitle());
}
// Scope to search for an specific process
if ($this->getProcessId()) {
@@ -164,10 +164,6 @@ class Participated extends AbstractCases
$startDate = (string)$item['APP_CREATE_DATE'];
$endDate = !empty($item['APP_FINISH_DATE']) ? $item['APP_FINISH_DATE'] : date("Y-m-d H:i:s");
$item['DURATION'] = getDiffBetweenDates($startDate, $endDate);
// Get the detail related to the open thread
if (!empty($item['PENDING'])) {
$item['PENDING'] = $this->prepareTaskPending($item['PENDING']);
}
switch ($filter) {
case 'STARTED':
$result = [];
@@ -194,7 +190,10 @@ class Participated extends AbstractCases
}
break;
case 'IN_PROGRESS':
$item['PENDING'] = $this->prepareTaskPending($item['PENDING']);
// Get the detail related to the open thread
if (!empty($item['PENDING'])) {
$item['PENDING'] = $this->prepareTaskPending($item['PENDING']);
}
break;
case 'COMPLETED':
$result = [];
@@ -238,7 +237,7 @@ class Participated extends AbstractCases
// Only distinct APP_NUMBER
$query->distinct();
// Scope for in progress cases
$query->statusIds([Application::STATUS_DRAFT, Application::STATUS_TODO]);
$query->statusIds([self::STATUS_DRAFT, self::STATUS_TODO]);
break;
case 'COMPLETED':
// Scope that search for the COMPLETED

View File

@@ -11,7 +11,7 @@ class Paused extends AbstractCases
public $columnsView = [
// Columns view in the cases list
'APP_DELEGATION.APP_NUMBER', // Case #
'APP_DELEGATION.APP_NUMBER AS APP_TITLE', // Case Title @todo: Filter by case title, pending from other PRD
'APP_DELEGATION.DEL_TITLE', // Case Title
'PROCESS.PRO_TITLE', // Process
'TASK.TAS_TITLE', // Task
'USERS.USR_USERNAME', // Current UserName
@@ -51,7 +51,7 @@ class Paused extends AbstractCases
}
// Specific case title
if (!empty($this->getCaseTitle())) {
// @todo: Filter by case title, pending from other PRD
$query->title($this->getCaseTitle());
}
// Specific process
if ($this->getProcessId()) {

View File

@@ -12,7 +12,7 @@ class Search extends AbstractCases
public $columnsView = [
// Columns view in the cases list
'APP_DELEGATION.APP_NUMBER', // Case #
'APP_DELEGATION.APP_NUMBER AS APP_TITLE', // Case Title @todo: Filter by case title, pending from other PRD
'APP_DELEGATION.DEL_TITLE', // Case Title
'PROCESS.PRO_TITLE', // Process
'TASK.TAS_TITLE', // Task
'APPLICATION.APP_STATUS', // Status
@@ -61,7 +61,7 @@ class Search extends AbstractCases
}
// Specific case title
if (!empty($this->getCaseTitle())) {
// @todo: Filter by case title, pending from other PRD
$query->title($this->getCaseTitle());
}
// Filter by process
if ($this->getProcessId()) {
@@ -103,7 +103,7 @@ class Search extends AbstractCases
$casesOpen = [];
$casesClosed = [];
foreach ($statuses as $row) {
if ($row === Application::STATUS_DRAFT or $row === Application::STATUS_TODO) {
if ($row === self::STATUS_DRAFT or $row === self::STATUS_TODO) {
$casesOpen[] = $row;
} else {
$casesClosed[] = $row;

View File

@@ -11,7 +11,7 @@ class Supervising extends AbstractCases
public $columnsView = [
// Columns view in the cases list
'APP_DELEGATION.APP_NUMBER', // Case #
'APP_DELEGATION.APP_NUMBER AS APP_TITLE', // Case Title @todo: Filter by case title, pending from other PRD
'APP_DELEGATION.DEL_TITLE', // Case Title
'PROCESS.PRO_TITLE', // Process Name
'TASK.TAS_TITLE', // Pending Task
'APPLICATION.APP_STATUS', // Status
@@ -49,7 +49,7 @@ class Supervising extends AbstractCases
}
// Specific case title
if (!empty($this->getCaseTitle())) {
// @todo: Filter by case title, pending from other PRD
$query->title($this->getCaseTitle());
}
// Scope to search for an specific process
if ($this->getProcessId()) {
@@ -125,8 +125,8 @@ class Supervising extends AbstractCases
$query->joinUser();
// Join with application
$query->joinApplication();
// Only cases in progress
$query->caseInProgress();
// Only cases in to_do
$query->caseTodo();
// Scope that return the results for an specific user
$query->userId($this->getUserId());
// Scope the specific array of processes supervising

View File

@@ -12,7 +12,7 @@ class Unassigned extends AbstractCases
public $columnsView = [
// Columns view in the cases list
'APP_DELEGATION.APP_NUMBER', // Case #
'APP_DELEGATION.APP_NUMBER AS APP_TITLE', // Case Title @todo: Filter by case title, pending from other PRD
'APP_DELEGATION.DEL_TITLE', // Case Title
'PROCESS.PRO_TITLE', // Process
'TASK.TAS_TITLE', // Task
'USERS.USR_USERNAME', // Current UserName
@@ -52,7 +52,7 @@ class Unassigned extends AbstractCases
}
// Specific case title
if ($this->getCaseTitle()) {
// @todo: Filter by case title, pending from other PRD
$query->title($this->getCaseTitle());
}
// Specific process
if ($this->getProcessId()) {
@@ -88,7 +88,7 @@ class Unassigned extends AbstractCases
}
// Add join for application, for get the case title when the case status is TO_DO
$query->joinApplication();
$query->status(Application::STATUS_TODO);
$query->status(self::STATUS_TODO);
/** Apply filters */
$this->filters($query);
/** Apply order and pagination */

View File

@@ -153,7 +153,19 @@ class Delegation extends Model
*/
public function scopeCaseInProgress($query)
{
return $query->where('APPLICATION.APP_STATUS_ID', 2);
return $query->statusIds([Application::STATUS_DRAFT, Application::STATUS_TODO]);
}
/**
* Scope a query to get the to_do cases
*
* @param \Illuminate\Database\Eloquent\Builder $query
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeCaseTodo($query)
{
return $query->where('APPLICATION.APP_STATUS_ID', Application::STATUS_TODO);
}
/**
@@ -165,7 +177,7 @@ class Delegation extends Model
*/
public function scopeCaseCompleted($query)
{
return $query->where('APPLICATION.APP_STATUS_ID', 3);
return $query->where('APPLICATION.APP_STATUS_ID', Application::STATUS_COMPLETED);
}
/**
@@ -373,6 +385,37 @@ class Delegation extends Model
return $query->where('APP_DELEGATION.APP_NUMBER', '=', $appNumber);
}
/**
* Scope a query to only include a specific case title
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param string $search
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeTitle($query, string $search)
{
$config = System::getSystemConfiguration();
if ((int)$config['disable_advanced_search_case_title_fulltext'] === 0) {
// Cleaning "fulltext" operators in order to avoid unexpected results
$search = str_replace(
['-', '+', '<', '>', '(', ')', '~', '*', '"'],
['', '', '', '', '', '', '', '', ''],
$search
);
// Build the "fulltext" expression
$search = '+"' . preg_replace('/\s+/', '" +"', addslashes($search)) . '"';
// Searching using "fulltext" index
$query->whereRaw("MATCH(APP_DELEGATION.DEL_TITLE) AGAINST('{$search}' IN BOOLEAN MODE)");
} else {
// Searching using "like" operator
$query->where('APP_DELEGATION.DEL_TITLE', 'LIKE', "%${$search}%");
}
return $query;
}
/**
* Scope a query to only include specific cases
*