Merged in darojas/processmaker (pull request #374)
Se agregan unit test para cases 7_12. Se resuelven conflictos de merge. Se agregan unit test para INPUT DOCUMENTS y se agregan validaciones.
This commit is contained in:
521
workflow/engine/src/BusinessModel/Cases.php
Normal file
521
workflow/engine/src/BusinessModel/Cases.php
Normal file
@@ -0,0 +1,521 @@
|
||||
<?php
|
||||
namespace BusinessModel;
|
||||
|
||||
use \G;
|
||||
use \UsersPeer;
|
||||
use \CasesPeer;
|
||||
|
||||
/**
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
class Cases
|
||||
{
|
||||
/**
|
||||
* Get list for Cases
|
||||
*
|
||||
* @access public
|
||||
* @param array $dataList, Data for list
|
||||
* @return array
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function getList($dataList = array())
|
||||
{
|
||||
Validator::isArray($dataList, '$dataList');
|
||||
if (!isset($dataList["userId"])) {
|
||||
throw (new \Exception("The user with userId: '' does not exist."));
|
||||
} else {
|
||||
Validator::usrUid($dataList["userId"], "userId");
|
||||
}
|
||||
|
||||
G::LoadClass("applications");
|
||||
$solrEnabled = false;
|
||||
$userUid = $dataList["userId"];
|
||||
$callback = isset( $dataList["callback"] ) ? $dataList["callback"] : "stcCallback1001";
|
||||
$dir = isset( $dataList["dir"] ) ? $dataList["dir"] : "DESC";
|
||||
$sort = isset( $dataList["sort"] ) ? $dataList["sort"] : "APP_CACHE_VIEW.APP_NUMBER";
|
||||
$start = isset( $dataList["start"] ) ? $dataList["start"] : "0";
|
||||
$limit = isset( $dataList["limit"] ) ? $dataList["limit"] : "25";
|
||||
$filter = isset( $dataList["filter"] ) ? $dataList["filter"] : "";
|
||||
$process = isset( $dataList["process"] ) ? $dataList["process"] : "";
|
||||
$category = isset( $dataList["category"] ) ? $dataList["category"] : "";
|
||||
$status = isset( $dataList["status"] ) ? strtoupper( $dataList["status"] ) : "";
|
||||
$user = isset( $dataList["user"] ) ? $dataList["user"] : "";
|
||||
$search = isset( $dataList["search"] ) ? $dataList["search"] : "";
|
||||
$action = isset( $dataList["action"] ) ? $dataList["action"] : "todo";
|
||||
$type = "extjs";
|
||||
$dateFrom = isset( $dataList["dateFrom"] ) ? substr( $dataList["dateFrom"], 0, 10 ) : "";
|
||||
$dateTo = isset( $dataList["dateTo"] ) ? substr( $dataList["dateTo"], 0, 10 ) : "";
|
||||
$first = isset( $dataList["first"] ) ? true :false;
|
||||
|
||||
$valuesCorrect = array('todo', 'draft', 'paused', 'sent', 'selfservice', 'unassigned', 'search');
|
||||
if (!in_array($action, $valuesCorrect)) {
|
||||
throw (new \Exception('The value for $action is incorrect.'));
|
||||
}
|
||||
|
||||
if ($action == 'search' || $action == 'to_reassign') {
|
||||
$userUid = ($user == "CURRENT_USER") ? $userUid : $user;
|
||||
if ($first) {
|
||||
$result = array();
|
||||
$result['totalCount'] = 0;
|
||||
$result['data'] = array();
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
if ((
|
||||
$action == "todo" || $action == "draft" || $action == "paused" || $action == "sent" ||
|
||||
$action == "selfservice" || $action == "unassigned" || $action == "search"
|
||||
) &&
|
||||
(($solrConf = \System::solrEnv()) !== false)
|
||||
) {
|
||||
G::LoadClass("AppSolr");
|
||||
|
||||
$ApplicationSolrIndex = new \AppSolr(
|
||||
$solrConf["solr_enabled"],
|
||||
$solrConf["solr_host"],
|
||||
$solrConf["solr_instance"]
|
||||
);
|
||||
|
||||
if ($ApplicationSolrIndex->isSolrEnabled() && $solrConf['solr_enabled'] == true) {
|
||||
//Check if there are missing records to reindex and reindex them
|
||||
$ApplicationSolrIndex->synchronizePendingApplications();
|
||||
$solrEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($solrEnabled) {
|
||||
$result = $ApplicationSolrIndex->getAppGridData(
|
||||
$userUid,
|
||||
$start,
|
||||
$limit,
|
||||
$action,
|
||||
$filter,
|
||||
$search,
|
||||
$process,
|
||||
$status,
|
||||
$type,
|
||||
$dateFrom,
|
||||
$dateTo,
|
||||
$callback,
|
||||
$dir,
|
||||
$sort,
|
||||
$category
|
||||
);
|
||||
} else {
|
||||
G::LoadClass("applications");
|
||||
$apps = new \Applications();
|
||||
$result = $apps->getAll(
|
||||
$userUid,
|
||||
$start,
|
||||
$limit,
|
||||
$action,
|
||||
$filter,
|
||||
$search,
|
||||
$process,
|
||||
$status,
|
||||
$type,
|
||||
$dateFrom,
|
||||
$dateTo,
|
||||
$callback,
|
||||
$dir,
|
||||
(strpos($sort, ".") !== false)? $sort : "APP_CACHE_VIEW." . $sort,
|
||||
$category
|
||||
);
|
||||
}
|
||||
if (!empty($result['data'])) {
|
||||
foreach ($result['data'] as &$value) {
|
||||
$value = array_change_key_case($value, CASE_LOWER);
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data of a Case
|
||||
*
|
||||
* @param string $caseUid Unique id of Case
|
||||
* @param string $userUid Unique id of User
|
||||
*
|
||||
* return array Return an array with data of Case Info
|
||||
*/
|
||||
public function getCaseInfo($caseUid, $userUid)
|
||||
{
|
||||
try {
|
||||
$solrEnabled = 0;
|
||||
if (($solrEnv = \System::solrEnv()) !== false) {
|
||||
\G::LoadClass("AppSolr");
|
||||
$appSolr = new \AppSolr(
|
||||
$solrEnv["solr_enabled"],
|
||||
$solrEnv["solr_host"],
|
||||
$solrEnv["solr_instance"]
|
||||
);
|
||||
if ($appSolr->isSolrEnabled() && $solrEnv["solr_enabled"] == true) {
|
||||
//Check if there are missing records to reindex and reindex them
|
||||
$appSolr->synchronizePendingApplications();
|
||||
$solrEnabled = 1;
|
||||
}
|
||||
}
|
||||
if ($solrEnabled == 1) {
|
||||
try {
|
||||
\G::LoadClass("searchIndex");
|
||||
$arrayData = array();
|
||||
$delegationIndexes = array();
|
||||
$columsToInclude = array("APP_UID");
|
||||
$solrSearchText = null;
|
||||
//Todo
|
||||
$solrSearchText = $solrSearchText . (($solrSearchText != null)? " OR " : null) . "(APP_STATUS:TO_DO AND APP_ASSIGNED_USERS:" . $userUid . ")";
|
||||
$delegationIndexes[] = "APP_ASSIGNED_USER_DEL_INDEX_" . $userUid . "_txt";
|
||||
//Draft
|
||||
$solrSearchText = $solrSearchText . (($solrSearchText != null)? " OR " : null) . "(APP_STATUS:DRAFT AND APP_DRAFT_USER:" . $userUid . ")";
|
||||
//Index is allways 1
|
||||
$solrSearchText = "($solrSearchText)";
|
||||
//Add del_index dynamic fields to list of resulting columns
|
||||
$columsToIncludeFinal = array_merge($columsToInclude, $delegationIndexes);
|
||||
$solrRequestData = \Entity_SolrRequestData::createForRequestPagination(
|
||||
array(
|
||||
"workspace" => $solrEnv["solr_instance"],
|
||||
"startAfter" => 0,
|
||||
"pageSize" => 1000,
|
||||
"searchText" => $solrSearchText,
|
||||
"numSortingCols" => 1,
|
||||
"sortCols" => array("APP_NUMBER"),
|
||||
"sortDir" => array(strtolower("DESC")),
|
||||
"includeCols" => $columsToIncludeFinal,
|
||||
"resultFormat" => "json"
|
||||
)
|
||||
);
|
||||
//Use search index to return list of cases
|
||||
$searchIndex = new \BpmnEngine_Services_SearchIndex($appSolr->isSolrEnabled(), $solrEnv["solr_host"]);
|
||||
//Execute query
|
||||
$solrQueryResult = $searchIndex->getDataTablePaginatedList($solrRequestData);
|
||||
//Get the missing data from database
|
||||
$arrayApplicationUid = array();
|
||||
foreach ($solrQueryResult->aaData as $i => $data) {
|
||||
$arrayApplicationUid[] = $data["APP_UID"];
|
||||
}
|
||||
$aaappsDBData = $appSolr->getListApplicationDelegationData($arrayApplicationUid);
|
||||
foreach ($solrQueryResult->aaData as $i => $data) {
|
||||
//Initialize array
|
||||
$delIndexes = array(); //Store all the delegation indexes
|
||||
//Complete empty values
|
||||
$applicationUid = $data["APP_UID"]; //APP_UID
|
||||
//Get all the indexes returned by Solr as columns
|
||||
for($i = count($columsToInclude); $i <= count($data) - 1; $i++) {
|
||||
if (is_array($data[$columsToIncludeFinal[$i]])) {
|
||||
foreach ($data[$columsToIncludeFinal[$i]] as $delIndex) {
|
||||
$delIndexes[] = $delIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
//Verify if the delindex is an array
|
||||
//if is not check different types of repositories
|
||||
//the delegation index must always be defined.
|
||||
if (count($delIndexes) == 0) {
|
||||
$delIndexes[] = 1; // the first default index
|
||||
}
|
||||
//Remove duplicated
|
||||
$delIndexes = array_unique($delIndexes);
|
||||
//Get records
|
||||
foreach ($delIndexes as $delIndex) {
|
||||
$aRow = array();
|
||||
//Copy result values to new row from Solr server
|
||||
$aRow["APP_UID"] = $data["APP_UID"];
|
||||
//Get delegation data from DB
|
||||
//Filter data from db
|
||||
$indexes = $appSolr->aaSearchRecords($aaappsDBData, array(
|
||||
"APP_UID" => $applicationUid,
|
||||
"DEL_INDEX" => $delIndex
|
||||
));
|
||||
foreach ($indexes as $index) {
|
||||
$row = $aaappsDBData[$index];
|
||||
}
|
||||
if(!isset($row))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$aRow["APP_NUMBER"] = $row["APP_NUMBER"];
|
||||
$aRow["APP_STATUS"] = $row["APP_STATUS"];
|
||||
$aRow["PRO_UID"] = $row["PRO_UID"];
|
||||
$aRow["DEL_INDEX"] = $row["DEL_INDEX"];
|
||||
$arrayData[] = array(
|
||||
"guid" => $aRow["APP_UID"],
|
||||
"name" => $aRow["APP_NUMBER"],
|
||||
"status" => $aRow["APP_STATUS"],
|
||||
"delIndex" => $aRow["DEL_INDEX"],
|
||||
"processId" => $aRow["PRO_UID"]
|
||||
);
|
||||
}
|
||||
}
|
||||
$case = array();
|
||||
for ($i = 0; $i<=count($arrayData)-1; $i++) {
|
||||
if ($arrayData[$i]["guid"] == $caseUid) {
|
||||
$case = $arrayData[$i];
|
||||
}
|
||||
}
|
||||
return $case;
|
||||
} catch (\InvalidIndexSearchTextException $e) {
|
||||
$arrayData = array();
|
||||
$arrayData[] = array (
|
||||
"guid" => $e->getMessage(),
|
||||
"name" => $e->getMessage(),
|
||||
"status" => $e->getMessage(),
|
||||
"delIndex" => $e->getMessage(),
|
||||
"processId" => $e->getMessage()
|
||||
);
|
||||
return $arrayData;
|
||||
}
|
||||
} else {
|
||||
$arrayData = array();
|
||||
$criteria = new \Criteria("workflow");
|
||||
$criteria->addSelectColumn(\AppCacheViewPeer::APP_UID);
|
||||
$criteria->addSelectColumn(\AppCacheViewPeer::DEL_INDEX);
|
||||
$criteria->addSelectColumn(\AppCacheViewPeer::APP_NUMBER);
|
||||
$criteria->addSelectColumn(\AppCacheViewPeer::APP_STATUS);
|
||||
$criteria->addSelectColumn(\AppCacheViewPeer::PRO_UID);
|
||||
$criteria->add(\AppCacheViewPeer::USR_UID, $userUid);
|
||||
$criteria->add(\AppCacheViewPeer::APP_UID, $caseUid);
|
||||
$criteria->add(
|
||||
//ToDo - getToDo()
|
||||
$criteria->getNewCriterion(\AppCacheViewPeer::APP_STATUS, "TO_DO", \CRITERIA::EQUAL)->addAnd(
|
||||
$criteria->getNewCriterion(\AppCacheViewPeer::DEL_FINISH_DATE, null, \Criteria::ISNULL))->addAnd(
|
||||
$criteria->getNewCriterion(\AppCacheViewPeer::APP_THREAD_STATUS, "OPEN"))->addAnd(
|
||||
$criteria->getNewCriterion(\AppCacheViewPeer::DEL_THREAD_STATUS, "OPEN"))
|
||||
)->addOr(
|
||||
//Draft - getDraft()
|
||||
$criteria->getNewCriterion(\AppCacheViewPeer::APP_STATUS, "DRAFT", \CRITERIA::EQUAL)->addAnd(
|
||||
$criteria->getNewCriterion(\AppCacheViewPeer::APP_THREAD_STATUS, "OPEN"))->addAnd(
|
||||
$criteria->getNewCriterion(\AppCacheViewPeer::DEL_THREAD_STATUS, "OPEN"))
|
||||
);
|
||||
$criteria->addDescendingOrderByColumn(\AppCacheViewPeer::APP_NUMBER);
|
||||
$rsCriteria = \AppCacheViewPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
while ($rsCriteria->next()) {
|
||||
$row = $rsCriteria->getRow();
|
||||
$arrayData[] = array(
|
||||
"guid" => $row["APP_UID"],
|
||||
"name" => $row["APP_NUMBER"],
|
||||
"status" => $row["APP_STATUS"],
|
||||
"delIndex" => $row["DEL_INDEX"],
|
||||
"processId" => $row["PRO_UID"]
|
||||
);
|
||||
}
|
||||
return $arrayData;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data Task Case
|
||||
*
|
||||
* @param string $caseUid Unique id of Case
|
||||
*
|
||||
* return array Return an array with Task Case
|
||||
*/
|
||||
public function getTaskCase($caseUid)
|
||||
{
|
||||
try {
|
||||
\G::LoadClass('wsBase');
|
||||
$ws = new \wsBase();
|
||||
$fields = $ws->taskCase($caseUid);
|
||||
//Return
|
||||
return $fields;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add New Case
|
||||
*
|
||||
* @param string $prjUid Unique id of Project
|
||||
* @param string $actUid Unique id of Activity
|
||||
* @param string $caseUid Unique id of Case
|
||||
* @param array $variables
|
||||
*
|
||||
* return array Return an array with Task Case
|
||||
*/
|
||||
public function addCase($prjUid, $actUid, $userUid, $variables)
|
||||
{
|
||||
try {
|
||||
\G::LoadClass('wsBase');
|
||||
$ws = new \wsBase();
|
||||
if ($variables) {
|
||||
$variables = array_shift($variables);
|
||||
}
|
||||
$fields = $ws->newCase($prjUid, $userUid, $actUid, $variables);
|
||||
//Return
|
||||
return $fields;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add New Case Impersonate
|
||||
*
|
||||
* @param string $prjUid Unique id of Project
|
||||
* @param string $usrUid Unique id of User
|
||||
* @param string $caseUid Unique id of Case
|
||||
* @param array $variables
|
||||
*
|
||||
* return array Return an array with Task Case
|
||||
*/
|
||||
public function addCaseImpersonate($prjUid, $usrUid, $caseUid, $variables)
|
||||
{
|
||||
try {
|
||||
\G::LoadClass('wsBase');
|
||||
$ws = new \wsBase();
|
||||
$fields = $ws->newCaseImpersonate($prjUid, $usrUid, $variables, '1352844695225ff5fe54de2005407079');
|
||||
//Return
|
||||
return $fields;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reassign Case
|
||||
*
|
||||
* @param string $caseUid Unique id of Case
|
||||
* @param string $userUid Unique id of User
|
||||
* @param string $delIndex
|
||||
* @param string $userUidSource Unique id of User Source
|
||||
* @param string $userUid $userUidTarget id of User Target
|
||||
*
|
||||
* return array Return an array with Task Case
|
||||
*/
|
||||
|
||||
public function updateReassignCase($caseUid, $userUid, $delIndex, $userUidSource, $userUidTarget)
|
||||
{
|
||||
try {
|
||||
\G::LoadClass('wsBase');
|
||||
$ws = new \wsBase();
|
||||
$fields = $ws->reassignCase($userUid, $caseUid, $delIndex, $userUidSource, $userUidTarget);
|
||||
//Return
|
||||
return $fields;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Put cancel case
|
||||
*
|
||||
* @access public
|
||||
* @param string $app_uid, Uid for case
|
||||
* @param string $usr_uid, Uid for user
|
||||
* @param string $del_index, Index for case
|
||||
* @return array
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function putCancelCase($app_uid, $usr_uid, $del_index = false) {
|
||||
Validator::appUid($app_uid, '$cas_uid');
|
||||
Validator::usrUid($usr_uid, '$usr_uid');
|
||||
|
||||
if ($del_index === false) {
|
||||
$del_index = \AppDelegation::getCurrentIndex($app_uid);
|
||||
}
|
||||
|
||||
$case = new \Cases();
|
||||
$case->cancelCase( $app_uid, $del_index, $usr_uid );
|
||||
}
|
||||
|
||||
/**
|
||||
* Put pause case
|
||||
*
|
||||
* @access public
|
||||
* @param string $app_uid , Uid for case
|
||||
* @param string $usr_uid , Uid for user
|
||||
* @param bool|string $del_index , Index for case
|
||||
* @param null|string $unpaused_date, Date for unpaused
|
||||
* @return array
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function putPauseCase($app_uid, $usr_uid, $del_index = false, $unpaused_date = null) {
|
||||
Validator::appUid($app_uid, '$cas_uid');
|
||||
Validator::usrUid($usr_uid, '$usr_uid');
|
||||
if ($unpaused_date != null) {
|
||||
Validator::isDate($unpaused_date, 'Y-m-d', '$unpaused_date');
|
||||
}
|
||||
|
||||
if ($del_index === false) {
|
||||
$del_index = \AppDelegation::getCurrentIndex($app_uid);
|
||||
}
|
||||
|
||||
$case = new \Cases();
|
||||
$case->pauseCase( $app_uid, $del_index, $usr_uid, $unpaused_date );
|
||||
}
|
||||
|
||||
/**
|
||||
* Put unpause case
|
||||
*
|
||||
* @access public
|
||||
* @param string $app_uid , Uid for case
|
||||
* @param string $usr_uid , Uid for user
|
||||
* @param bool|string $del_index , Index for case
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function putUnpauseCase($app_uid, $usr_uid, $del_index = false) {
|
||||
Validator::appUid($app_uid, '$cas_uid');
|
||||
Validator::usrUid($usr_uid, '$usr_uid');
|
||||
|
||||
if ($del_index === false) {
|
||||
$del_index = \AppDelegation::getCurrentIndex($app_uid);
|
||||
}
|
||||
|
||||
$case = new \Cases();
|
||||
$case->unpauseCase( $app_uid, $del_index, $usr_uid );
|
||||
}
|
||||
|
||||
/**
|
||||
* Put unpause case
|
||||
*
|
||||
* @access public
|
||||
* @param string $app_uid , Uid for case
|
||||
* @param string $usr_uid , Uid for user
|
||||
* @param bool|string $del_index , Index for case
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function putExecuteTriggerCase($app_uid, $tri_uid, $usr_uid, $del_index = false) {
|
||||
Validator::appUid($app_uid, '$cas_uid');
|
||||
Validator::triUid($tri_uid, '$tri_uid');
|
||||
Validator::usrUid($usr_uid, '$usr_uid');
|
||||
|
||||
if ($del_index === false) {
|
||||
$del_index = \AppDelegation::getCurrentIndex($app_uid);
|
||||
}
|
||||
|
||||
$case = new \wsBase();
|
||||
$case->executeTrigger( $usr_uid, $app_uid, $tri_uid, $del_index );
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete case
|
||||
*
|
||||
* @access public
|
||||
* @param string $app_uid, Uid for case
|
||||
* @return array
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function deleteCase($app_uid) {
|
||||
Validator::appUid($app_uid, '$cas_uid');
|
||||
$case = new \Cases();
|
||||
$case->removeCase( $app_uid );
|
||||
}
|
||||
}
|
||||
@@ -608,14 +608,18 @@ class Cases
|
||||
}
|
||||
\G::LoadClass('wsBase');
|
||||
$ws = new \wsBase();
|
||||
$fields = $ws->reassignCase($userUid, $applicationUid, $delIndex, $userUidSource, $userUidTarget);
|
||||
$fields = $ws->reassignCase($userUid, $applicationUid, $delIndex, $userUidTarget, $userUidSource);
|
||||
$array = json_decode(json_encode($fields), true);
|
||||
if ($array ["status_code"] != 0) {
|
||||
throw (new \Exception($array ["message"]));
|
||||
if (array_key_exists("status_code", $array)) {
|
||||
if ($array ["status_code"] != 0) {
|
||||
throw (new \Exception($array ["message"]));
|
||||
} else {
|
||||
unset($array['status_code']);
|
||||
unset($array['message']);
|
||||
unset($array['timestamp']);
|
||||
}
|
||||
} else {
|
||||
unset($array['status_code']);
|
||||
unset($array['message']);
|
||||
unset($array['timestamp']);
|
||||
throw (new \Exception('The Application with app_uid: '.$applicationUid.' doesn\'t exist'));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
|
||||
@@ -58,6 +58,10 @@ class InputDocument
|
||||
public function getCasesInputDocument($applicationUid, $userUid, $inputDocumentUid)
|
||||
{
|
||||
try {
|
||||
$oAppDocument = \AppDocumentPeer::retrieveByPK( $inputDocumentUid, 1 );
|
||||
if (is_null( $oAppDocument ) || $oAppDocument->getAppDocStatus() == 'DELETED') {
|
||||
throw (new \Exception('This input document with id: '.$inputDocumentUid.' doesn\'t exist!'));
|
||||
}
|
||||
$sApplicationUID = $applicationUid;
|
||||
$sUserUID = $userUid;
|
||||
\G::LoadClass('case');
|
||||
|
||||
@@ -28,14 +28,14 @@ class CasesTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
$this->oCases = new \ProcessMaker\BusinessModel\Cases();
|
||||
$this->oCases = new \BusinessModel\Cases();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for type in first field the function
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::getList
|
||||
* @covers \BusinessModel\Cases::getList
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid value for '$dataList' it must be an array.
|
||||
*
|
||||
@@ -50,7 +50,7 @@ class CasesTest extends \PHPUnit_Framework_TestCase
|
||||
/**
|
||||
* Test error for empty userId in array
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::getList
|
||||
* @covers \BusinessModel\Cases::getList
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The user with userId: '' does not exist.
|
||||
*
|
||||
@@ -65,150 +65,37 @@ class CasesTest extends \PHPUnit_Framework_TestCase
|
||||
/**
|
||||
* Test error for not exists userId in array
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::getList
|
||||
* @covers \BusinessModel\Cases::getList
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The user with userId: 'IdDoesNotExists' does not exist.
|
||||
* @expectedExceptionMessage The user with userId: 'UidInexistente' does not exist.
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testGetListCasesErrorNotExistsUserIdArray()
|
||||
{
|
||||
$this->oCases->getList(array('userId' => 'IdDoesNotExists'));
|
||||
$this->oCases->getList(array('userId' => 'UidInexistente'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for incorrect value $action in array
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::getList
|
||||
* @covers \BusinessModel\Cases::getList
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The value for $action is incorrect.
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testGetListCasesErrorIncorrectValueActionArray()
|
||||
public function testGetListCasesErrorIncorrectValueArray()
|
||||
{
|
||||
$this->oCases->getList(array('userId' => '00000000000000000000000000000001', 'action' => 'incorrect'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for incorrect value $process in array
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::getList
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The process with $pro_uid: 'IdDoesNotExists' does not exist.
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testGetListCasesErrorIncorrectValueProUidArray()
|
||||
{
|
||||
$this->oCases->getList(array(
|
||||
'userId' => '00000000000000000000000000000001',
|
||||
'process' => 'IdDoesNotExists'
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for incorrect value $process in array
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::getList
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The category with $cat_uid: 'IdDoesNotExists' does not exist.
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testGetListCasesErrorIncorrectValueCatUidArray()
|
||||
{
|
||||
$this->oCases->getList(array(
|
||||
'userId' => '00000000000000000000000000000001',
|
||||
'category' => 'IdDoesNotExists'
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for incorrect value $process in array
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::getList
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The user with $usr_uid: 'IdDoesNotExists' does not exist.
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testGetListCasesErrorIncorrectValueUserArray()
|
||||
{
|
||||
$this->oCases->getList(array(
|
||||
'userId' => '00000000000000000000000000000001',
|
||||
'user' => 'IdDoesNotExists'
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for incorrect value $process in array
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::getList
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The value '2014-44-44' is not a valid date for the format 'Y-m-d'.
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testGetListCasesErrorIncorrectValueDateToArray()
|
||||
{
|
||||
$this->oCases->getList(array(
|
||||
'userId' => '00000000000000000000000000000001',
|
||||
'dateTo' => '2014-44-44'
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for incorrect value $process in array
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::getList
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The value '2014-44-44' is not a valid date for the format 'Y-m-d'.
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testGetListCasesErrorIncorrectValueDateFromArray()
|
||||
{
|
||||
$this->oCases->getList(array(
|
||||
'userId' => '00000000000000000000000000000001',
|
||||
'dateFrom' => '2014-44-44'
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get list to do not paged
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::getList
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testGetListCasesToDoNotPaged()
|
||||
{
|
||||
$response = $this->oCases->getList(array('userId' => '00000000000000000000000000000001', 'paged' => false));
|
||||
$this->assertTrue(is_array($response));
|
||||
$this->assertFalse(isset($response['data']));
|
||||
$this->assertFalse(isset($response['total']));
|
||||
$this->assertFalse(isset($response['start']));
|
||||
$this->assertFalse(isset($response['limit']));
|
||||
$this->assertFalse(isset($response['sort']));
|
||||
$this->assertFalse(isset($response['dir']));
|
||||
$this->assertFalse(isset($response['cat_uid']));
|
||||
$this->assertFalse(isset($response['pro_uid']));
|
||||
$this->assertFalse(isset($response['search']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get list to do
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::getList
|
||||
* @covers \BusinessModel\Cases::getList
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
@@ -217,44 +104,14 @@ class CasesTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$response = $this->oCases->getList(array('userId' => '00000000000000000000000000000001'));
|
||||
$this->assertTrue(is_array($response));
|
||||
$this->assertTrue(is_numeric($response['totalCount']));
|
||||
$this->assertTrue(is_array($response['data']));
|
||||
$this->assertTrue(isset($response['total']));
|
||||
$this->assertTrue(isset($response['start']));
|
||||
$this->assertTrue(isset($response['limit']));
|
||||
$this->assertTrue(isset($response['sort']));
|
||||
$this->assertTrue(isset($response['dir']));
|
||||
$this->assertTrue(isset($response['cat_uid']));
|
||||
$this->assertTrue(isset($response['pro_uid']));
|
||||
$this->assertTrue(isset($response['search']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get list draft not paged
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::getList
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testGetListCasesDraftNotPaged()
|
||||
{
|
||||
$response = $this->oCases->getList(array('userId' => '00000000000000000000000000000001', 'action' => 'draft', 'paged' => false));
|
||||
$this->assertTrue(is_array($response));
|
||||
$this->assertFalse(isset($response['data']));
|
||||
$this->assertFalse(isset($response['total']));
|
||||
$this->assertFalse(isset($response['start']));
|
||||
$this->assertFalse(isset($response['limit']));
|
||||
$this->assertFalse(isset($response['sort']));
|
||||
$this->assertFalse(isset($response['dir']));
|
||||
$this->assertFalse(isset($response['cat_uid']));
|
||||
$this->assertFalse(isset($response['pro_uid']));
|
||||
$this->assertFalse(isset($response['search']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get list draft
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::getList
|
||||
* @covers \BusinessModel\Cases::getList
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
@@ -263,44 +120,14 @@ class CasesTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$response = $this->oCases->getList(array('userId' => '00000000000000000000000000000001', 'action' => 'draft'));
|
||||
$this->assertTrue(is_array($response));
|
||||
$this->assertTrue(is_numeric($response['totalCount']));
|
||||
$this->assertTrue(is_array($response['data']));
|
||||
$this->assertTrue(isset($response['total']));
|
||||
$this->assertTrue(isset($response['start']));
|
||||
$this->assertTrue(isset($response['limit']));
|
||||
$this->assertTrue(isset($response['sort']));
|
||||
$this->assertTrue(isset($response['dir']));
|
||||
$this->assertTrue(isset($response['cat_uid']));
|
||||
$this->assertTrue(isset($response['pro_uid']));
|
||||
$this->assertTrue(isset($response['search']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get list participated not paged
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::getList
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testGetListCasesParticipatedNotPaged()
|
||||
{
|
||||
$response = $this->oCases->getList(array('userId' => '00000000000000000000000000000001', 'action' => 'sent', 'paged' => false));
|
||||
$this->assertTrue(is_array($response));
|
||||
$this->assertFalse(isset($response['data']));
|
||||
$this->assertFalse(isset($response['total']));
|
||||
$this->assertFalse(isset($response['start']));
|
||||
$this->assertFalse(isset($response['limit']));
|
||||
$this->assertFalse(isset($response['sort']));
|
||||
$this->assertFalse(isset($response['dir']));
|
||||
$this->assertFalse(isset($response['cat_uid']));
|
||||
$this->assertFalse(isset($response['pro_uid']));
|
||||
$this->assertFalse(isset($response['search']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get list participated
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::getList
|
||||
* @covers \BusinessModel\Cases::getList
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
@@ -309,44 +136,14 @@ class CasesTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$response = $this->oCases->getList(array('userId' => '00000000000000000000000000000001', 'action' => 'sent'));
|
||||
$this->assertTrue(is_array($response));
|
||||
$this->assertTrue(is_numeric($response['totalCount']));
|
||||
$this->assertTrue(is_array($response['data']));
|
||||
$this->assertTrue(isset($response['total']));
|
||||
$this->assertTrue(isset($response['start']));
|
||||
$this->assertTrue(isset($response['limit']));
|
||||
$this->assertTrue(isset($response['sort']));
|
||||
$this->assertTrue(isset($response['dir']));
|
||||
$this->assertTrue(isset($response['cat_uid']));
|
||||
$this->assertTrue(isset($response['pro_uid']));
|
||||
$this->assertTrue(isset($response['search']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get list unassigned not paged
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::getList
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testGetListCasesUnassignedNotPaged()
|
||||
{
|
||||
$response = $this->oCases->getList(array('userId' => '00000000000000000000000000000001', 'action' => 'unassigned', 'paged' => false));
|
||||
$this->assertTrue(is_array($response));
|
||||
$this->assertFalse(isset($response['data']));
|
||||
$this->assertFalse(isset($response['total']));
|
||||
$this->assertFalse(isset($response['start']));
|
||||
$this->assertFalse(isset($response['limit']));
|
||||
$this->assertFalse(isset($response['sort']));
|
||||
$this->assertFalse(isset($response['dir']));
|
||||
$this->assertFalse(isset($response['cat_uid']));
|
||||
$this->assertFalse(isset($response['pro_uid']));
|
||||
$this->assertFalse(isset($response['search']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get list unassigned
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::getList
|
||||
* @covers \BusinessModel\Cases::getList
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
@@ -355,48 +152,14 @@ class CasesTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$response = $this->oCases->getList(array('userId' => '00000000000000000000000000000001', 'action' => 'unassigned'));
|
||||
$this->assertTrue(is_array($response));
|
||||
$this->assertTrue(is_numeric($response['totalCount']));
|
||||
$this->assertTrue(is_array($response['data']));
|
||||
$this->assertTrue(isset($response['total']));
|
||||
$this->assertTrue(isset($response['start']));
|
||||
$this->assertTrue(isset($response['limit']));
|
||||
$this->assertTrue(isset($response['sort']));
|
||||
$this->assertTrue(isset($response['dir']));
|
||||
$this->assertTrue(isset($response['cat_uid']));
|
||||
$this->assertTrue(isset($response['pro_uid']));
|
||||
$this->assertTrue(isset($response['search']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get list search not paged
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::getList
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testGetListCasesSearchNotPaged()
|
||||
{
|
||||
$response = $this->oCases->getList(array('userId' => '00000000000000000000000000000001', 'action' => 'search', 'paged' => false));
|
||||
$this->assertTrue(is_array($response));
|
||||
$this->assertFalse(isset($response['data']));
|
||||
$this->assertFalse(isset($response['total']));
|
||||
$this->assertFalse(isset($response['start']));
|
||||
$this->assertFalse(isset($response['limit']));
|
||||
$this->assertFalse(isset($response['sort']));
|
||||
$this->assertFalse(isset($response['dir']));
|
||||
$this->assertFalse(isset($response['cat_uid']));
|
||||
$this->assertFalse(isset($response['pro_uid']));
|
||||
$this->assertFalse(isset($response['search']));
|
||||
$this->assertFalse(isset($response['app_status']));
|
||||
$this->assertFalse(isset($response['usr_uid']));
|
||||
$this->assertFalse(isset($response['date_from']));
|
||||
$this->assertFalse(isset($response['date_to']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get list search
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::getList
|
||||
* @covers \BusinessModel\Cases::getList
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
@@ -405,19 +168,8 @@ class CasesTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$response = $this->oCases->getList(array('userId' => '00000000000000000000000000000001', 'action' => 'search'));
|
||||
$this->assertTrue(is_array($response));
|
||||
$this->assertTrue(is_numeric($response['totalCount']));
|
||||
$this->assertTrue(is_array($response['data']));
|
||||
$this->assertTrue(isset($response['total']));
|
||||
$this->assertTrue(isset($response['start']));
|
||||
$this->assertTrue(isset($response['limit']));
|
||||
$this->assertTrue(isset($response['sort']));
|
||||
$this->assertTrue(isset($response['dir']));
|
||||
$this->assertTrue(isset($response['cat_uid']));
|
||||
$this->assertTrue(isset($response['pro_uid']));
|
||||
$this->assertTrue(isset($response['search']));
|
||||
$this->assertTrue(isset($response['app_status']));
|
||||
$this->assertTrue(isset($response['usr_uid']));
|
||||
$this->assertTrue(isset($response['date_from']));
|
||||
$this->assertTrue(isset($response['date_to']));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -83,6 +83,34 @@ class CasesTest extends \PHPUnit_Framework_TestCase
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for incorrect value of process in array
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::addCase
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid process 12345678912345678912345678912345678
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testAddCaseErrorIncorrectProcessValueArray()
|
||||
{
|
||||
$this->oCases->addCase('12345678912345678912345678912345678', self::$tasUid, self::$usrUid, array());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for incorrect value of task in array
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::addCase
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Task invalid or the user is not assigned to the task
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testAddCaseErrorIncorrectTaskValueArray()
|
||||
{
|
||||
$this->oCases->addCase(self::$proUid, '12345678912345678912345678912345678', self::$usrUid, array());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test add Case
|
||||
*
|
||||
@@ -98,6 +126,20 @@ class CasesTest extends \PHPUnit_Framework_TestCase
|
||||
return $aResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for incorrect value of case in array
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::getTaskCase
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Incorrect or unavailable information about this case: 12345678912345678912345678912345678
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testGetTaskCaseErrorIncorrectCaseValueArray()
|
||||
{
|
||||
$this->oCases->getTaskCase('12345678912345678912345678912345678', self::$usrUid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get Task Case
|
||||
*
|
||||
@@ -113,6 +155,20 @@ class CasesTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertTrue(is_array($response));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for incorrect value of case in array
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::getCaseInfo
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The Application row '12345678912345678912345678912345678' doesn't exist!
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testGetCaseInfoErrorIncorrectCaseValueArray()
|
||||
{
|
||||
$this->oCases->getCaseInfo('12345678912345678912345678912345678', self::$usrUid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get Case Info
|
||||
*
|
||||
@@ -128,10 +184,40 @@ class CasesTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertTrue(is_object($response));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for incorrect value of user delegation in array
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::updateReassignCase
|
||||
* @depends testAddCase
|
||||
* @param array $aResponse
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid Case Delegation index for this user
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testUpdateReassignCaseErrorIncorrectUserValueArray(array $aResponse)
|
||||
{
|
||||
$this->oCases->updateReassignCase($aResponse['app_uid'], self::$usrUid, null, self::$usrUid, self::$usrUid2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for incorrect value of case in array
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::updateReassignCase
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The Application with app_uid: 12345678912345678912345678912345678 doesn't exist
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testUpdateReassignCaseErrorIncorrectCaseValueArray()
|
||||
{
|
||||
$this->oCases->updateReassignCase('12345678912345678912345678912345678', self::$usrUid, null, self::$usrUid2, self::$usrUid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test put reassign case
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::getCaseInfo
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::updateReassignCase
|
||||
* @depends testAddCase
|
||||
* @param array $aResponse
|
||||
*
|
||||
@@ -139,7 +225,7 @@ class CasesTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testUpdateReassignCase(array $aResponse)
|
||||
{
|
||||
$response = $this->oCases->updateReassignCase($aResponse['app_uid'], self::$usrUid, null, self::$usrUid, self::$usrUid2);
|
||||
$response = $this->oCases->updateReassignCase($aResponse['app_uid'], self::$usrUid, null, self::$usrUid2, self::$usrUid);
|
||||
$this->assertTrue(empty($response));
|
||||
}
|
||||
|
||||
@@ -158,6 +244,20 @@ class CasesTest extends \PHPUnit_Framework_TestCase
|
||||
return $aResponseRouteCase;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for incorrect value of case in array
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::updateRouteCase
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The row '12345678912345678912345678912345678, ' in table AppDelegation doesn't exist!
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testUpdateRouteCaseErrorIncorrectCaseValueArray()
|
||||
{
|
||||
$this->oCases->updateRouteCase('12345678912345678912345678912345678', self::$usrUid, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test put route case
|
||||
*
|
||||
@@ -173,6 +273,35 @@ class CasesTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertTrue(empty($response));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for incorrect value of process in array
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::addCase
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid process 12345678912345678912345678912345678
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testAddCaseImpersonateErrorIncorrectProcessValueArray()
|
||||
{
|
||||
$this->oCases->addCaseImpersonate('12345678912345678912345678912345678', self::$usrUid2, self::$tasUid, array());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for incorrect value of task in array
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::addCase
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage User not registered! 12345678912345678912345678912345678!!
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testAddCaseImpersonateErrorIncorrectTaskValueArray()
|
||||
{
|
||||
$this->oCases->addCaseImpersonate(self::$proUid, '12345678912345678912345678912345678', self::$tasUid, array());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test add Case impersonate
|
||||
*
|
||||
|
||||
@@ -18,6 +18,53 @@ class InputDocumentsCasesTest extends \PHPUnit_Framework_TestCase
|
||||
protected $oInputDocument;
|
||||
protected $idCase = '';
|
||||
|
||||
protected static $usrUid = "00000000000000000000000000000001";
|
||||
protected static $proUid = "00000000000000000000000000000002";
|
||||
protected static $tasUid = "00000000000000000000000000000003";
|
||||
protected static $inpUid = "00000000000000000000000000000004";
|
||||
protected static $steUid = "00000000000000000000000000000005";
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
$process = new \Process();
|
||||
$process->create(array("type"=>"classicProject", "PRO_TITLE"=> "NEW TEST PHP UNIT", "PRO_DESCRIPTION"=> "465",
|
||||
"PRO_CATEGORY"=> "", "PRO_CREATE_USER"=> "00000000000000000000000000000001",
|
||||
"PRO_UID"=> self::$proUid, "USR_UID"=> "00000000000000000000000000000001"), false);
|
||||
|
||||
$task = new \Task();
|
||||
$task->create(array("TAS_START"=>"TRUE", "TAS_UID"=> self::$tasUid, "PRO_UID"=> self::$proUid, "TAS_TITLE" => "NEW TASK TEST PHP UNIT",
|
||||
"TAS_POSX"=> 581, "TAS_POSY"=> 17, "TAS_WIDTH"=> 165, "TAS_HEIGHT"=> 40), false);
|
||||
|
||||
$inputDocument = new \InputDocument();
|
||||
$inputDocument->create(array("INP_DOC_UID"=> self::$inpUid, "PRO_UID"=> self::$proUid, "INP_DOC_TITLE"=> "INPUTDOCUMENT TEST UNIT", "INP_DOC_FORM_NEEDED"=> "VIRTUAL",
|
||||
"INP_DOC_ORIGINAL"=> "ORIGINAL", "INP_DOC_DESCRIPTION"=> "", "INP_DOC_VERSIONING"=> "",
|
||||
"INP_DOC_DESTINATION_PATH"=> "", "INP_DOC_TAGS"=> "INPUT", "ACCEPT"=> "Save", "BTN_CANCEL"=>"Cancel"));
|
||||
|
||||
$step = new \Step();
|
||||
$step->create(array( "PRO_UID"=> self::$proUid, "TAS_UID"=> self::$tasUid, "STEP_UID"=> self::$steUid, "STEP_TYPE_OBJ" => "INPUT_DOCUMENT", "STEP_UID_OBJ" =>self::$inpUid));
|
||||
|
||||
$assign = new \TaskUser();
|
||||
$assign->create(array("TAS_UID"=> self::$tasUid, "USR_UID"=> self::$usrUid, "TU_TYPE"=> "1", "TU_RELATION"=> 1));
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
$assign = new \TaskUser();
|
||||
$assign->remove(self::$tasUid, self::$usrUid, 1,1);
|
||||
|
||||
$step = new \Step();
|
||||
$step->remove(self::$steUid);
|
||||
|
||||
$inputDocument = new \InputDocument();
|
||||
$inputDocument->remove(self::$inpUid);
|
||||
|
||||
$task = new \Task();
|
||||
$task->remove(self::$tasUid);
|
||||
|
||||
$process = new \Process();
|
||||
$process->remove(self::$proUid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set class for test
|
||||
*
|
||||
@@ -39,19 +86,29 @@ class InputDocumentsCasesTest extends \PHPUnit_Framework_TestCase
|
||||
public function testAddInputDocument()
|
||||
{
|
||||
\G::loadClass('pmFunctions');
|
||||
\G::loadClass('pmFunctions');
|
||||
$usrUid = '00000000000000000000000000000001';//an user id valid
|
||||
$proUid = '1265557095225ff5c688f46031700471';//a process id valid
|
||||
$tasUid = '46941969352af5be2ab3f39001216717';//a task id valid and related to the previous proUid
|
||||
$inpDocUid = '70158392952979dedd77fe0058957493';//a input document id valid and related to the previous task id
|
||||
$idCase = PMFNewCase($proUid, $usrUid, $tasUid, array());
|
||||
$idCase = PMFNewCase(self::$proUid, self::$usrUid, self::$tasUid, array());
|
||||
$case = new \Cases();
|
||||
$appDocUid = $case->addInputDocument($inpDocUid, $appDocUid = \G::generateUniqueID(), '', 'INPUT',
|
||||
$appDocUid = $case->addInputDocument(self::$inpUid, $appDocUid = \G::generateUniqueID(), '', 'INPUT',
|
||||
'PHPUNIT TEST', '', $idCase, \AppDelegation::getCurrentIndex($idCase),
|
||||
$tasUid, $usrUid, "xmlform", '/home/user/desarrollo/test.txt', 0, '/home/user/desarrollo/test.txt');
|
||||
self::$tasUid, self::$usrUid, "xmlform", PATH_DATA_SITE.'db.php',
|
||||
0, PATH_DATA_SITE.'db.php');
|
||||
$aResponse = array();
|
||||
$aResponse = array_merge(array("idCase" => $idCase, "appDocUid" => $appDocUid, "inpDocUid" => $inpDocUid), $aResponse);
|
||||
$aResponse = array_merge(array("idCase" => $idCase, "appDocUid" => $appDocUid, "inpDocUid" => self::$inpUid), $aResponse);
|
||||
return $aResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for incorrect value of case in array
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\InputDocument::getCasesInputDocuments
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The Application row '12345678912345678912345678912345678' doesn't exist!
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testGetCasesInputDocumentsErrorIncorrectCaseValueArray()
|
||||
{
|
||||
$this->oInputDocument->getCasesInputDocuments('12345678912345678912345678912345678', self::$usrUid);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,10 +122,42 @@ class InputDocumentsCasesTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testGetCasesInputDocuments(array $aResponse)
|
||||
{
|
||||
$response = $this->oInputDocument->getCasesInputDocuments($aResponse["idCase"], '00000000000000000000000000000001');
|
||||
$response = $this->oInputDocument->getCasesInputDocuments($aResponse["idCase"], self::$usrUid);
|
||||
$this->assertTrue(is_array($response));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for incorrect value of task in array
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\InputDocument::getCasesInputDocument
|
||||
* @depends testAddInputDocument
|
||||
* @param array $aResponse
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The Application row '12345678912345678912345678912345678' doesn't exist!
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testGetCasesInputDocumentErrorIncorrectCaseValueArray(array $aResponse)
|
||||
{
|
||||
$this->oInputDocument->getCasesInputDocument('12345678912345678912345678912345678', self::$usrUid, $aResponse["appDocUid"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for incorrect value of input document in array
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\InputDocument::getCasesInputDocument
|
||||
* @depends testAddInputDocument
|
||||
* @param array $aResponse
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage This input document with id: 12345678912345678912345678912345678 doesn't exist!
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testGetCasesInputDocumentErrorIncorrectInputDocumentValueArray(array $aResponse)
|
||||
{
|
||||
$this->oInputDocument->getCasesInputDocument($aResponse["idCase"], self::$usrUid, '12345678912345678912345678912345678');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get InputDocument
|
||||
*
|
||||
@@ -80,10 +169,26 @@ class InputDocumentsCasesTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testGetCasesInputDocument(array $aResponse)
|
||||
{
|
||||
$response = $this->oInputDocument->getCasesInputDocument($aResponse["idCase"], '00000000000000000000000000000001', $aResponse["appDocUid"]);
|
||||
$response = $this->oInputDocument->getCasesInputDocument($aResponse["idCase"], self::$usrUid, $aResponse["appDocUid"]);
|
||||
$this->assertTrue(is_object($response));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for incorrect value of input document in array
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\InputDocument::removeInputDocument
|
||||
* @depends testAddInputDocument
|
||||
* @param array $aResponse
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage This input document with id: 12345678912345678912345678912345678 doesn't exist!
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testGetCasesInputDocumentErrorIncorrectApplicationValueArray(array $aResponse)
|
||||
{
|
||||
$this->oInputDocument->removeInputDocument('12345678912345678912345678912345678');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test remove InputDocument
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user