Merged in bugfix/PMCORE-659 (pull request #7404)
PMCORE-659 Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
committed by
Julio Cesar Laura Avendaño
commit
061d4531f1
90
tests/unit/workflow/engine/methods/cases/CasesOpenTest.php
Normal file
90
tests/unit/workflow/engine/methods/cases/CasesOpenTest.php
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\unit\workflow\engine\methods\cases;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
|
use ProcessMaker\Model\Application;
|
||||||
|
use ProcessMaker\Model\Delegation;
|
||||||
|
use ProcessMaker\Model\Dynaform;
|
||||||
|
use ProcessMaker\Model\Process;
|
||||||
|
use ProcessMaker\Model\Task;
|
||||||
|
use ProcessMaker\Model\User;
|
||||||
|
use Publisher;
|
||||||
|
use RBAC;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class CasesOpenTest extends TestCase
|
||||||
|
{
|
||||||
|
use DatabaseTransactions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* It test the cases_Open file when the jump action is set in the unassigned list
|
||||||
|
*
|
||||||
|
* @test
|
||||||
|
*/
|
||||||
|
public function it_should_test_the_jump_case()
|
||||||
|
{
|
||||||
|
global $RBAC;
|
||||||
|
global $G_PUBLISH;
|
||||||
|
|
||||||
|
$user = User::where('USR_ID', '=', 1)
|
||||||
|
->get()
|
||||||
|
->first();
|
||||||
|
|
||||||
|
$_SESSION['USER_LOGGED'] = $user['USR_UID'];
|
||||||
|
$_SESSION['USR_USERNAME'] = $user['USR_USERNAME'];
|
||||||
|
|
||||||
|
$G_PUBLISH = new Publisher();
|
||||||
|
|
||||||
|
$RBAC = RBAC::getSingleton(PATH_DATA, session_id());
|
||||||
|
$RBAC->initRBAC();
|
||||||
|
$RBAC->loadUserRolePermission('PROCESSMAKER', $_SESSION['USER_LOGGED']);
|
||||||
|
|
||||||
|
$task = factory(Task::class)->create();
|
||||||
|
$dynaform = factory(Dynaform::class)->create();
|
||||||
|
$process = factory(Process::class)->create([
|
||||||
|
'PRO_DYNAFORMS' => $dynaform['DYN_UID']
|
||||||
|
]);
|
||||||
|
$application = factory(Application::class)->create([
|
||||||
|
'PRO_UID' => $process['PRO_UID'],
|
||||||
|
'APP_STATUS' => 'COMPLETED'
|
||||||
|
]);
|
||||||
|
$delegation = factory(Delegation::class)->create([
|
||||||
|
'APP_UID' => $application['APP_UID'],
|
||||||
|
'TAS_UID' => $task['TAS_UID'],
|
||||||
|
'DEL_INDEX' => 1,
|
||||||
|
'DEL_THREAD_STATUS' => 'CLOSED'
|
||||||
|
]);
|
||||||
|
|
||||||
|
factory(Delegation::class)->create([
|
||||||
|
'APP_UID' => $application['APP_UID'],
|
||||||
|
'TAS_UID' => $task['TAS_UID'],
|
||||||
|
'DEL_INDEX' => 2,
|
||||||
|
'DEL_LAST_INDEX' => 1,
|
||||||
|
'DEL_THREAD_STATUS' => 'OPEN',
|
||||||
|
'DEL_DELEGATE_DATE' => $delegation['DEL_DELEGATE_DATE']
|
||||||
|
]);
|
||||||
|
|
||||||
|
$_GET['APP_UID'] = $application['APP_UID'];
|
||||||
|
$_GET['DEL_INDEX'] = $delegation['DEL_INDEX'];
|
||||||
|
$_GET['action'] = 'jump';
|
||||||
|
|
||||||
|
define("PATH_GULLIVER_HOME", PATH_TRUNK . "gulliver" . PATH_SEP);
|
||||||
|
define("PATH_TEMPLATE", PATH_GULLIVER_HOME . "templates" . PATH_SEP);
|
||||||
|
|
||||||
|
//Turn on output buffering
|
||||||
|
ob_start();
|
||||||
|
|
||||||
|
//Call the tested file
|
||||||
|
require_once PATH_METHODS . 'cases/cases_Open.php';
|
||||||
|
|
||||||
|
//Return the contents of the output buffer
|
||||||
|
$outputBuffer = ob_get_contents();
|
||||||
|
|
||||||
|
//Clean the output buffer and turn off output buffering
|
||||||
|
ob_end_clean();
|
||||||
|
|
||||||
|
$res = '<html>';
|
||||||
|
$this->assertContains($res, $outputBuffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cases_Open.php
|
* cases_Open.php
|
||||||
*
|
*
|
||||||
@@ -15,21 +16,21 @@
|
|||||||
* @link https://wiki.processmaker.com/3.2/Cases/Cases#Search_Criteria
|
* @link https://wiki.processmaker.com/3.2/Cases/Cases#Search_Criteria
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if(isset( $_GET['gmail']) && $_GET['gmail'] == 1){
|
if (isset($_GET['gmail']) && $_GET['gmail'] == 1) {
|
||||||
$_SESSION['gmail'] = 1;
|
$_SESSION['gmail'] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Permissions */
|
/* Permissions */
|
||||||
if ($RBAC->userCanAccess( 'PM_CASES' ) != 1) {
|
if ($RBAC->userCanAccess('PM_CASES') != 1) {
|
||||||
switch ($RBAC->userCanAccess( 'PM_CASES' )) {
|
switch ($RBAC->userCanAccess('PM_CASES')) {
|
||||||
case - 2:
|
case -2:
|
||||||
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels' );
|
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_SYSTEM', 'error', 'labels');
|
||||||
G::header( 'location: ../login/login' );
|
G::header('location: ../login/login');
|
||||||
break;
|
break;
|
||||||
case - 1:
|
case -1:
|
||||||
default:
|
default:
|
||||||
G::SendTemporalMessage( 'ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels' );
|
G::SendTemporalMessage('ID_USER_HAVENT_RIGHTS_PAGE', 'error', 'labels');
|
||||||
G::header( 'location: ../login/login' );
|
G::header('location: ../login/login');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -42,21 +43,30 @@ Cases::clearCaseSessionData();
|
|||||||
try {
|
try {
|
||||||
//Loading data for a Jump request
|
//Loading data for a Jump request
|
||||||
if (!isset($_GET['APP_UID']) && isset($_GET['APP_NUMBER'])) {
|
if (!isset($_GET['APP_UID']) && isset($_GET['APP_NUMBER'])) {
|
||||||
$_GET['APP_UID'] = $caseInstance->getApplicationUIDByNumber( $_GET['APP_NUMBER'] );
|
$_GET['APP_UID'] = $caseInstance->getApplicationUIDByNumber($_GET['APP_NUMBER']);
|
||||||
//Get the index related to the userLogged but this thread can be OPEN or CLOSED
|
//Get the index related to the userLogged but this thread can be OPEN or CLOSED
|
||||||
$_GET['DEL_INDEX'] = $caseInstance->getCurrentDelegation($_GET['APP_UID'], $_SESSION['USER_LOGGED']);
|
if (isset($_GET['actionFromList'])) {
|
||||||
|
if ($_GET['actionFromList'] == 'unassigned') {
|
||||||
|
$_SESSION['APPLICATION'] = $_GET['APP_UID'];
|
||||||
|
$_GET['DEL_INDEX'] = $caseInstance->getCurrentDelegation($_GET['APP_UID'], $_SESSION['USER_LOGGED'], true);
|
||||||
|
} else {
|
||||||
|
$_GET['DEL_INDEX'] = $caseInstance->getCurrentDelegation($_GET['APP_UID'], $_SESSION['USER_LOGGED']);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$_GET['DEL_INDEX'] = $caseInstance->getCurrentDelegation($_GET['APP_UID'], $_SESSION['USER_LOGGED']);
|
||||||
|
}
|
||||||
|
|
||||||
//if the application doesn't exist
|
//if the application doesn't exist
|
||||||
if (is_null($_GET['APP_UID'])) {
|
if (is_null($_GET['APP_UID'])) {
|
||||||
G::SendMessageText( G::LoadTranslation( 'ID_CASE_DOES_NOT_EXISTS' ), 'info' );
|
G::SendMessageText(G::LoadTranslation('ID_CASE_DOES_NOT_EXISTS'), 'info');
|
||||||
G::header( 'location: casesListExtJs' );
|
G::header('location: casesListExtJs');
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
//if the application exists but the
|
//if the application exists but the
|
||||||
if (is_null($_GET['DEL_INDEX'])) {
|
if (is_null($_GET['DEL_INDEX'])) {
|
||||||
G::SendMessageText( G::LoadTranslation( 'ID_CASE_IS_CURRENTLY_WITH_ANOTHER_USER' ), 'info' );
|
G::SendMessageText(G::LoadTranslation('ID_CASE_IS_CURRENTLY_WITH_ANOTHER_USER'), 'info');
|
||||||
G::header( 'location: casesListExtJs' );
|
G::header('location: casesListExtJs');
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -123,7 +133,6 @@ try {
|
|||||||
require_once(PATH_METHODS . 'cases' . PATH_SEP . 'cases_Resume.php');
|
require_once(PATH_METHODS . 'cases' . PATH_SEP . 'cases_Resume.php');
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Proceed and try to open the case
|
//Proceed and try to open the case
|
||||||
@@ -151,8 +160,8 @@ try {
|
|||||||
|
|
||||||
//If the current users is in the AppDelegation row and the thread is open will be open the case
|
//If the current users is in the AppDelegation row and the thread is open will be open the case
|
||||||
if (($delegationInfo['USR_UID'] == $_SESSION['USER_LOGGED'] && $delegationInfo['DEL_THREAD_STATUS'] === 'OPEN')
|
if (($delegationInfo['USR_UID'] == $_SESSION['USER_LOGGED'] && $delegationInfo['DEL_THREAD_STATUS'] === 'OPEN')
|
||||||
&& $action != 'sent')
|
&& $action != 'sent'
|
||||||
{
|
) {
|
||||||
$_SESSION['APPLICATION'] = $appUid;
|
$_SESSION['APPLICATION'] = $appUid;
|
||||||
$_SESSION['INDEX'] = $delIndex;
|
$_SESSION['INDEX'] = $delIndex;
|
||||||
|
|
||||||
@@ -180,7 +189,6 @@ try {
|
|||||||
$pageOpenCase = $nextStep['PAGE'];
|
$pageOpenCase = $nextStep['PAGE'];
|
||||||
|
|
||||||
G::header('location: ' . $pageOpenCase);
|
G::header('location: ' . $pageOpenCase);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$_SESSION['APPLICATION'] = $appUid;
|
$_SESSION['APPLICATION'] = $appUid;
|
||||||
$_SESSION['PROCESS'] = $fieldCase['PRO_UID'];
|
$_SESSION['PROCESS'] = $fieldCase['PRO_UID'];
|
||||||
@@ -210,7 +218,6 @@ try {
|
|||||||
$_SESSION['CURRENT_TASK'] = $fields['TAS_UID'];
|
$_SESSION['CURRENT_TASK'] = $fields['TAS_UID'];
|
||||||
|
|
||||||
require_once(PATH_METHODS . 'cases' . PATH_SEP . 'cases_Resume.php');
|
require_once(PATH_METHODS . 'cases' . PATH_SEP . 'cases_Resume.php');
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default: //APP_STATUS IS COMPLETED OR CANCELLED
|
default: //APP_STATUS IS COMPLETED OR CANCELLED
|
||||||
@@ -231,4 +238,3 @@ try {
|
|||||||
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $message);
|
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'login/showMessage', '', $message);
|
||||||
G::RenderPage('publishBlank', 'blank');
|
G::RenderPage('publishBlank', 'blank');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user