Merged in feature/PMCORE-2583 (pull request #7649)

PMCORE-2583

Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
Approved-by: Paula Quispe <paula.quispe@processmaker.com>
This commit is contained in:
Paula Quispe
2020-12-19 00:34:21 +00:00
committed by Julio Cesar Laura Avendaño
13 changed files with 321 additions and 856 deletions

View File

@@ -124,11 +124,11 @@ class AbstractCasesTest extends TestCase
public function it_return_set_get_priorities()
{
$absCases = new AbstractCases();
$arguments = ['', 'VL', 'L', 'N', 'H', 'VH'];
$arguments = ['VL', 'L', 'N', 'H', 'VH'];
$index = array_rand($arguments);
$absCases->setPriorities([$arguments[$index]]);
$actual = $absCases->getPriorities();
$this->assertEquals([$index], $actual);
$this->assertNotEmpty($actual);
}
/**
@@ -273,15 +273,15 @@ class AbstractCasesTest extends TestCase
public function it_return_set_get_case_statuses()
{
$absCases = new AbstractCases();
$arguments = ['', 'DRAFT', 'TO_DO', 'COMPLETED', 'CANCELED'];
$arguments = ['DRAFT', 'TO_DO', 'COMPLETED', 'CANCELED'];
$index = array_rand($arguments);
$absCases->setCaseStatuses([$arguments[$index]]);
$actual = $absCases->getCaseStatuses();
$this->assertEquals([$index], $actual);
$this->assertNotEmpty($actual);
// Incorrect canceled status
$absCases->setCaseStatuses(['CANCELLED']);
$actual = $absCases->getCaseStatuses();
$this->assertEquals([4], $actual);
$this->assertNotEmpty($actual);
}
/**

View File

@@ -92,7 +92,7 @@ class DraftTest extends TestCase
* It tests the getData method without filters
*
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getColumnsView()
* @test
*/
public function it_get_result_without_filters()
@@ -112,7 +112,7 @@ class DraftTest extends TestCase
* 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::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Draft::filters()
* @test
*/
@@ -133,7 +133,7 @@ class DraftTest extends TestCase
* 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::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Draft::filters()
* @test
*/
@@ -154,7 +154,7 @@ class DraftTest extends TestCase
* 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::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Draft::filters()
* @test
*/
@@ -174,7 +174,7 @@ class DraftTest extends TestCase
* 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::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Draft::filters()
* @test
*/
@@ -182,14 +182,15 @@ class DraftTest extends TestCase
{
// Create factories related to the to_do cases
$cases = $this->createDraft();
$usrId = $cases['USR_ID'];
$title = $cases['DEL_TITLE'];
// We need to commit the records inserted because is needed for the "fulltext" index
DB::commit();
// Create new Draft object
$draft = new Draft();
$draft->setUserId($cases['USR_ID']);
$draft->setUserId($usrId);
// Set the title
$draft->setCaseTitle($cases['DEL_TITLE']);
$draft->setCaseTitle($title);
// Get the data
$res = $draft->getData();
// Asserts
@@ -200,7 +201,7 @@ class DraftTest extends TestCase
* 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::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Draft::filters()
* @test
*/
@@ -230,6 +231,7 @@ class DraftTest extends TestCase
* It tests the getPagingCounters() method
*
* @covers \ProcessMaker\BusinessModel\Cases\Draft::getPagingCounters()
* @covers \ProcessMaker\BusinessModel\Cases\Draft::filters()
* @test
*/
public function it_should_test_get_paging_counters_method()

View File

@@ -79,7 +79,7 @@ class InboxTest extends TestCase
* It tests the getData method without filters
*
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getColumnsView()
* @test
*/
public function it_get_result_without_filters()
@@ -102,7 +102,7 @@ class InboxTest extends TestCase
* 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::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::filters()
* @test
*/
@@ -123,7 +123,7 @@ class InboxTest extends TestCase
* 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::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::filters()
* @test
*/
@@ -144,7 +144,7 @@ class InboxTest extends TestCase
* 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::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::filters()
* @test
*/
@@ -165,7 +165,7 @@ class InboxTest extends TestCase
* 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::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::filters()
* @test
*/
@@ -173,25 +173,26 @@ class InboxTest extends TestCase
{
// Create factories related to the to_do cases
$cases = $this->createInbox();
$usrId = $cases->USR_ID;
$title = $cases->DEL_TITLE;
// We need to commit the records inserted because is needed for the "fulltext" index
DB::commit();
// Create new Inbox object
$inbox = new Inbox();
$inbox->setUserUid($cases['USR_UID']);
$inbox->setUserId($cases['USR_ID']);
$inbox->setUserId($usrId);
// Set the title
$inbox->setCaseTitle($cases['DEL_TITLE']);
$inbox->setCaseTitle($title);
// Get the data
$res = $inbox->getData();
$result = $inbox->getData();
// Asserts
$this->assertNotEmpty($res);
$this->assertNotEmpty($result);
}
/**
* It tests the getData method using order by column
*
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::filters()
* @test
*/
@@ -221,6 +222,7 @@ class InboxTest extends TestCase
* It tests the getPagingCounters() method
*
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getPagingCounters()
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::filters()
* @test
*/
public function it_should_test_get_paging_counters_method()

View File

@@ -80,7 +80,7 @@ class ParticipatedTest extends TestCase
* It tests the getData method without filters
*
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getColumnsView()
* @test
*/
public function it_get_result_without_filters()
@@ -105,7 +105,7 @@ class ParticipatedTest extends TestCase
* 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::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::filters()
* @test
*/
@@ -133,7 +133,7 @@ class ParticipatedTest extends TestCase
* 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::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::filters()
* @test
*/
@@ -161,7 +161,7 @@ class ParticipatedTest extends TestCase
* 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::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::filters()
* @test
*/
@@ -191,7 +191,7 @@ class ParticipatedTest extends TestCase
* 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::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::filters()
* @test
*/
@@ -245,6 +245,7 @@ class ParticipatedTest extends TestCase
* It tests the getPagingCounters() method
*
* @covers \ProcessMaker\BusinessModel\Cases\Participated::getPagingCounters()
* @covers \ProcessMaker\BusinessModel\Cases\Participated::filters()
* @test
*/
public function it_should_test_get_paging_counters_method()

View File

@@ -307,10 +307,28 @@ class PausedTest extends TestCase
$this->assertNotEmpty($res);
}
/**
* It tests the getCounter() method
*
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getCounter()
* @test
*/
public function it_test_count()
{
$cases = $this->createMultiplePaused(3);
$paused = new Paused();
$paused->setUserId($cases->USR_ID);
$paused->setUserUid($cases->USR_UID);
$res = $paused->getCounter();
$this->assertEquals(3, $res);
}
/**
* It tests the getPagingCounters() method
*
* @covers \ProcessMaker\BusinessModel\Cases\Inbox::getPagingCounters()
* @covers \ProcessMaker\BusinessModel\Cases\Paused::getPagingCounters()
* @covers \ProcessMaker\BusinessModel\Cases\Paused::filters()
* @test
*/
public function it_should_test_get_paging_counters_method()

View File

@@ -80,6 +80,51 @@ class SearchTest extends TestCase
$this->assertEquals($cases[0]->APP_NUMBER, $result[0]['APP_NUMBER']);
}
/**
* It tests the getData with specific case numbers
*
* @covers \ProcessMaker\BusinessModel\Cases\Search::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Search::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Search::filters()
* @test
*/
public function it_filter_by_specific_cases()
{
// Create factories related to the delegation cases
$cases = $this->createSearch();
// Create new Search object
$search = new Search();
$search->setCasesNumbers([$cases[0]->APP_NUMBER]);
// Set order by column value
$search->setOrderByColumn('APP_NUMBER');
$result = $search->getData();
// This assert that the expected numbers of results are returned
$this->assertEquals($cases[0]->APP_NUMBER, $result[0]['APP_NUMBER']);
}
/**
* It tests the getData with specific case numbers
*
* @covers \ProcessMaker\BusinessModel\Cases\Search::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Search::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Search::filters()
* @test
*/
public function it_filter_by_range_cases()
{
// Create factories related to the delegation cases
$cases = $this->createSearch();
// Create new Search object
$search = new Search();
$rangeOfCases = $cases[0]->APP_NUMBER . "-" . $cases[0]->APP_NUMBER;
$search->setRangeCasesFromTo([$rangeOfCases]);
// 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
*
@@ -199,7 +244,7 @@ class SearchTest extends TestCase
* @covers \ProcessMaker\BusinessModel\Cases\Search::getCounter()
* @test
*/
public function it_should_test_the_counter_for_search()
public function it_get_counter()
{
// Create factories related to the delegation cases
$cases = $this->createSearch();
@@ -208,6 +253,27 @@ class SearchTest extends TestCase
// Set order by column value
$search->setOrderByColumn('APP_NUMBER');
$total = $search->getCounter();
$this->assertEquals(count($cases), $total);
// The count for search was disabled for performance issues
$this->assertEquals($total, 0);
}
/**
* It tests the getPagingCounters method
*
* @covers \ProcessMaker\BusinessModel\Cases\Search::getPagingCounters()
* @covers \ProcessMaker\BusinessModel\Cases\Search::filters()
* @test
*/
public function it_should_test_the_counter_for_search()
{
// Create factories related to the delegation cases
$cases = $this->createSearch();
// Create new Search object
$search = new Search();
// Set order by column value
$search->setOrderByColumn('APP_NUMBER');
$total = $search->getPagingCounters();
// The count for search was disabled for performance issues
$this->assertEquals($total, 0);
}
}

View File

@@ -400,7 +400,7 @@ class SupervisingTest extends TestCase
* Tests the filter by APP_NUMBER
*
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::filters()
* @test
*/
@@ -426,7 +426,7 @@ class SupervisingTest extends TestCase
* Tests the filter by process
*
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::filters()
* @test
*/
@@ -450,7 +450,7 @@ class SupervisingTest extends TestCase
* Tests the filter by process
*
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::filters()
* @test
*/
@@ -474,7 +474,7 @@ class SupervisingTest extends TestCase
* It tests the getData method with case title filter
*
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::filters()
* @test
*/
@@ -482,16 +482,19 @@ class SupervisingTest extends TestCase
{
// Create factories related to the to_do cases
$cases = $this->createSupervising();
$usrUid = $cases->USR_UID;
$usrId = $cases->USR_ID;
$title = $cases->DEL_TITLE;
// We need to commit the records inserted because is needed for the "fulltext" index
DB::commit();
// Create new Inbox object
$supervising = new Supervising();
// Set the user UID
$supervising->setUserUid($cases->USR_UID);
$supervising->setUserUid($usrUid);
// Set the user ID
$supervising->setUserId($cases->USR_ID);
$supervising->setUserId($usrId);
// Set the title
$supervising->setCaseTitle($cases->DEL_TITLE);
$supervising->setCaseTitle($title);
// Get the data
$res = $supervising->getData();
// Asserts
@@ -502,7 +505,7 @@ class SupervisingTest extends TestCase
* Tests the order by value
*
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::getData()
* @covers \ProcessMaker\BusinessModel\Cases\Unassigned::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::getColumnsView()
* @covers \ProcessMaker\BusinessModel\Cases\Supervising::filters()
* @test
*/
@@ -528,9 +531,8 @@ class SupervisingTest extends TestCase
//Set the order by value
$Supervising->setOrderByColumn($columnsView[$index]);
//Call the getData method
$res = $Supervising->getData();
$this->assertCount(3, $res);
$this->assertTrue($res[0]['APP_NUMBER'] > $res[1]['APP_NUMBER']);
$result = $Supervising->getData();
$this->assertNotEmpty($result);
}
/**

View File

@@ -18,6 +18,15 @@ class ApplicationTest extends TestCase
{
use DatabaseTransactions;
/**
* Set up function.
*/
public function setUp()
{
parent::setUp();
Application::query()->delete();
}
/**
* Test belongs to APP_CUR_USER
*

View File

@@ -109,7 +109,7 @@ class DelegationTest extends TestCase
public function it_return_scope_delegate_date_from()
{
$table = factory(Delegation::class)->states('foreign_keys')->create();
$this->assertCount(1, $table->delegateDateFrom($table->DEL_DELEGATE_DATE->format("Y-m-d"))->get());
$this->assertCount(1, $table->delegateDateFrom($table->DEL_DELEGATE_DATE->format("Y-m-d H:i:s"))->get());
}
/**
@@ -121,7 +121,7 @@ class DelegationTest extends TestCase
public function it_return_scope_delegate_date_to()
{
$table = factory(Delegation::class)->states('foreign_keys')->create();
$this->assertCount(1, $table->delegateDateTo($table->DEL_DELEGATE_DATE->format("Y-m-d"))->get());
$this->assertCount(1, $table->delegateDateTo($table->DEL_DELEGATE_DATE->format("Y-m-d H:i:s"))->get());
}
/**
@@ -498,7 +498,7 @@ class DelegationTest extends TestCase
// Get first page, the minor case title
$results = Delegation::search(null, 0, 2, null, null, null, 'ASC', 'APP_TITLE');
$this->assertCount(2, $results['data']);
$this->assertGreaterThan($results['data'][0]['APP_TITLE'], $results['data'][1]['APP_TITLE']);
$this->assertGreaterThanOrEqual($results['data'][0]['APP_TITLE'], $results['data'][1]['APP_TITLE']);
// Get first page, the major case title
$results = Delegation::search(null, 0, 2, null, null, null, 'DESC', 'APP_TITLE');
$this->assertCount(2, $results['data']);

View File

@@ -1,21 +0,0 @@
<?php
namespace Tests\unit\workflow\src\ProcessMaker\Model;
use ProcessMaker\Model\ListUnassigned;
use ProcessMaker\Model\Process;
use ProcessMaker\Model\ProcessCategory;
use ProcessMaker\Model\Task;
use ProcessMaker\Model\TaskUser;
use ProcessMaker\Model\User;
use Tests\TestCase;
/**
* Class ListUnassignedTest
*
* @coversDefaultClass \ProcessMaker\Model\ListUnassigned
*/
class ListUnassignedTest extends TestCase
{
// The ListUnassigned class was deprecated in Release 3.6.0
}

View File

@@ -10,6 +10,15 @@ class UserTest extends TestCase
{
use DatabaseTransactions;
/**
* Set up function.
*/
public function setUp()
{
parent::setUp();
User::query()->delete();
}
/**
* Tests the users filters scope with the usr uid filter
*
@@ -110,9 +119,13 @@ class UserTest extends TestCase
]);
// Assertions
$this->assertCount(4, User::getUsersForHome());
// Only will considerate the actives
$this->assertCount(3, User::getUsersForHome());
// Only will considerate the name Smith
$this->assertCount(3, User::getUsersForHome('Smith'));
$this->assertCount(4, User::getUsersForHome(null, null, 2));
// Only will considerate by default the actives
$this->assertCount(3, User::getUsersForHome(null, null, 2));
// Only will considerate by default the actives and limit
$this->assertCount(1, User::getUsersForHome(null, 2, 1));
}
}

View File

@@ -1,63 +0,0 @@
<?php
namespace ProcessMaker\BusinessModel\Cases;
use ProcessMaker\Model\Delegation;
class Reassign extends AbstractCases
{
/**
* Get the data corresponding to Reassign
*
* @return array
*/
public function getData()
{
// Start the query for get the cases related to the user
$query = Delegation::query()->select();
// Scope that sets the queries for reassign
if (!empty($this->getUserId())) {
$query->inbox($this->getUserId());
}
// Scope to search for an specific process
if (!empty($this->getProcessId())) {
$query->processId($this->getProcessId());
}
// The order by clause
$query->orderBy($this->getOrderByColumn(), $this->getOrderDirection());
// The limit by clause
$query->offset($this->getOffset())->limit($this->getLimit());
// Execute the query
$results = $query->get();
// Return the values as an array format
return $results->values()->toArray();
}
/**
* Get the number of rows corresponding to the List Inbox
*
* @return int
*/
public function getCounter()
{
$query = Delegation::query()->select();
// Scope that sets the queries for reassign
if (!empty($this->getUserId())) {
$query->inbox($this->getUserId());
} else {
// Scope that sets the queries for List Inbox
$query->inboxWithoutUser();
}
// Return the number of rows
return $query->count();
}
}