Merged in bugfix/PMCORE-1221 (pull request #7909)

PMCORE-1221

Approved-by: Julio Cesar Laura Avendaño
This commit is contained in:
Andrea Adamczyk
2021-05-03 20:06:28 +00:00
committed by Julio Cesar Laura Avendaño
2 changed files with 216 additions and 86 deletions

View File

@@ -10,6 +10,7 @@ use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\EmailServerModel;
use ProcessMaker\Model\Process;
use ProcessMaker\Model\Task;
use ProcessMaker\Model\TaskUser;
use ProcessMaker\Model\User;
use ProcessMaker\Model\UserReporting;
use Tests\TestCase;
@@ -1122,4 +1123,140 @@ class WsBaseTest extends TestCase
$this->assertEquals($response->status_code, 100);
$this->assertContains($fakeApp, $response->message);
}
/**
* Test the unassigned case list method with unassigned cases
*
* @test
* @covers WsBase::unassignedCaseList()
*/
public function it_should_test_the_unassigned_case_list_method_with_unassigned_cases()
{
//Create process
$process1 = factory(Process::class)->create([
'PRO_TITLE' => 'China Supplier Payment Proposal'
]);
$process2 = factory(Process::class)->create([
'PRO_TITLE' => 'Egypt Supplier Payment Proposal'
]);
//Create application
$application1 = factory(Application::class)->create([
'APP_STATUS_ID' => 2
]);
//Create user
$user = factory(User::class)->create();
//Create a task self service
$task1 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process1->PRO_UID
]);
$task2 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process1->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $task1->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
factory(TaskUser::class)->create([
'TAS_UID' => $task2->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create the register in delegation relate to self-service
factory(Delegation::class, 2)->create([
'APP_NUMBER' => $application1->APP_NUMBER,
'TAS_ID' => $task1->TAS_ID,
'PRO_ID' => $process1->id,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
factory(Delegation::class, 2)->create([
'APP_NUMBER' => $application1->APP_NUMBER,
'TAS_ID' => $task2->TAS_ID,
'PRO_ID' => $process2->id,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
$wsBase = new WsBase();
$res = $wsBase->unassignedCaseList($user->USR_UID);
//Assert the expected number of unassigned cases
$this->assertCount(4, $res);
}
/**
* Test the unassigned case list method without unassigned cases
*
* @test
* @covers WsBase::unassignedCaseList()
*/
public function it_should_test_the_unassigned_case_list_method_without_unassigned_cases()
{
//Create process
$process1 = factory(Process::class)->create([
'PRO_TITLE' => 'China Supplier Payment Proposal'
]);
$process2 = factory(Process::class)->create([
'PRO_TITLE' => 'Egypt Supplier Payment Proposal'
]);
//Create application
$application1 = factory(Application::class)->create([
'APP_STATUS_ID' => 2
]);
//Create user
$user = factory(User::class)->create();
//Create a task self service
$task1 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process1->PRO_UID
]);
$task2 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process1->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $task1->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $task2->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create the register in delegation relate to self-service
factory(Delegation::class, 2)->create([
'APP_NUMBER' => $application1->APP_NUMBER,
'TAS_ID' => $task1->TAS_ID,
'PRO_ID' => $process1->id,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 5,
]);
factory(Delegation::class, 2)->create([
'APP_NUMBER' => $application1->APP_NUMBER,
'TAS_ID' => $task2->TAS_ID,
'PRO_ID' => $process2->id,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 3,
]);
$wsBase = new WsBase();
$res = $wsBase->unassignedCaseList($user->USR_UID);
//Assert the expected number of unassigned cases
$this->assertCount(0, $res);
}
}

View File

@@ -3,6 +3,7 @@
use App\Jobs\EmailEvent;
use Illuminate\Support\Facades\Crypt;
use ProcessMaker\BusinessModel\Cases as BmCases;
use ProcessMaker\BusinessModel\Cases\Unassigned;
use ProcessMaker\BusinessModel\EmailServer;
/*----------------------------------********---------------------------------*/
use ProcessMaker\ChangeLog\ChangeLog;
@@ -541,41 +542,33 @@ class WsBase
/**
* Get unassigned case list
*
* @param string $userId
* @param string $userUid
*
* @return $result will return an object
*/
public function unassignedCaseList($userId)
public function unassignedCaseList($userUid)
{
try {
$result = [];
$oAppCache = new AppCacheView();
$Criteria = $oAppCache->getUnassignedListCriteria($userId);
$oDataset = AppCacheViewPeer::doSelectRS($Criteria);
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataset->next();
while ($aRow = $oDataset->getRow()) {
$result[] = array(
'guid' => $aRow['APP_UID'],
'name' => $aRow['APP_NUMBER'],
'delIndex' => $aRow['DEL_INDEX'],
'processId' => $aRow['PRO_UID']
);
$oDataset->next();
$unassigned = new Unassigned();
$unassigned->setUserUid($userUid);
$data = $unassigned->getData();
foreach ($data as $var) {
array_push($result, [
'guid' => $var['APP_UID'],
'name' => $var['APP_NUMBER'],
'delIndex' => $var['DEL_INDEX'],
'processId' => $var['PRO_UID']
]);
}
return $result;
} catch (Exception $e) {
$result[] = array(
$result[] = [
'guid' => $e->getMessage(),
'name' => $e->getMessage(),
'status' => $e->getMessage(),
'status' => $e->getMessage(),
'processId' => $e->getMessage()
);
];
return $result;
}
}