diff --git a/workflow/engine/src/BusinessModel/Cases.php b/workflow/engine/src/BusinessModel/Cases.php deleted file mode 100644 index 9090bfc63..000000000 --- a/workflow/engine/src/BusinessModel/Cases.php +++ /dev/null @@ -1,521 +0,0 @@ - - * @copyright Colosa - Bolivia - */ -class Cases -{ - /** - * Get list for Cases - * - * @access public - * @param array $dataList, Data for list - * @return array - * - * @author Brayan Pereyra (Cochalo) - * @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) - * @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) - * @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) - * @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) - * @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) - * @copyright Colosa - Bolivia - */ - public function deleteCase($app_uid) { - Validator::appUid($app_uid, '$cas_uid'); - $case = new \Cases(); - $case->removeCase( $app_uid ); - } -} diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php index 0dd798e63..4defc5ec0 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php @@ -321,7 +321,7 @@ class Cases $array['app_name'] = $array['caseName']; $array['app_status'] = $array['caseStatus']; $array['app_init_usr_uid'] = $array['caseCreatorUser']; - $array['app_init_usr_username'] = $array['caseCreatorUserName']; + $array['app_init_usr_username'] = trim($array['caseCreatorUserName']); $array['pro_uid'] = $array['processId']; $array['pro_name'] = $array['processName']; $array['app_create_date'] = $array['createDate']; @@ -412,7 +412,7 @@ class Cases $array['app_name'] = $array['caseName']; $array['app_status'] = $array['caseStatus']; $array['app_init_usr_uid'] = $array['caseCreatorUser']; - $array['app_init_usr_username'] = $array['caseCreatorUserName']; + $array['app_init_usr_username'] = trim($array['caseCreatorUserName']); $array['pro_uid'] = $array['processId']; $array['pro_name'] = $array['processName']; $array['app_create_date'] = $array['createDate']; @@ -529,6 +529,14 @@ class Cases if ($variables) { $variables = array_shift($variables); } + $oProcesses = new \Processes(); + if (! $oProcesses->processExists($processUid)) { + throw (new \Exception( 'Invalid value specified for \'pro_uid\'')); + } + $oTask = new \Task(); + if (! $oTask->taskExists($taskUid)) { + throw (new \Exception( 'Invalid value specified for \'tas_uid\'')); + } $fields = $ws->newCase($processUid, $userUid, $taskUid, $variables); $array = json_decode(json_encode($fields), true); if ($array ["status_code"] != 0) { @@ -570,6 +578,14 @@ class Cases } elseif ($variables == null) { $variables = array(array()); } + $oProcesses = new \Processes(); + if (! $oProcesses->processExists($processUid)) { + throw (new \Exception( 'Invalid value specified for \'pro_uid\'')); + } + $user = new \Users(); + if (! $user->userExists( $userUid )) { + throw (new \Exception( 'Invalid value specified for \'usr_uid\'')); + } $fields = $ws->newCaseImpersonate($processUid, $userUid, $variables, $taskUid); $array = json_decode(json_encode($fields), true); if ($array ["status_code"] != 0) { diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InputDocument.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InputDocument.php index 8f5d1b8a8..7cb818936 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InputDocument.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InputDocument.php @@ -14,6 +14,10 @@ class InputDocument public function getCasesInputDocuments($applicationUid, $userUid) { try { + $oApplication = \ApplicationPeer::retrieveByPk($applicationUid); + if (!is_object($oApplication)) { + throw (new \Exception("The Application with app_uid: '$applicationUid' doesn't exist!")); + } $sApplicationUID = $applicationUid; $sUserUID = $userUid; \G::LoadClass('case'); @@ -32,7 +36,7 @@ class InputDocument $docrow['app_doc_filename'] = $row['APP_DOC_FILENAME']; $docrow['doc_uid'] = $row['DOC_UID']; $docrow['app_doc_version'] = $row['DOC_VERSION']; - $docrow['app_doc_create_date'] = $row['CREATE_DATE']; + $docrow['app_doc_create_date'] = $row['CREATE_DATE']; $docrow['app_doc_create_user'] = $row['CREATED_BY']; $docrow['app_doc_type'] = $row['TYPE']; $docrow['app_doc_index'] = $row['APP_DOC_INDEX']; @@ -60,7 +64,7 @@ class InputDocument 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!')); + throw (new \Exception('This input document with inp_doc_uid: '.$inputDocumentUid.' doesn\'t exist!')); } $sApplicationUID = $applicationUid; $sUserUID = $userUid; @@ -109,7 +113,7 @@ class InputDocument 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!')); + throw (new \Exception('This input document with inp_doc_uid: '.$inputDocumentUid.' doesn\'t exist!')); } \G::LoadClass('wsBase'); $ws = new \wsBase(); diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/OutputDocument.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/OutputDocument.php index c47497f25..f21057f0d 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/OutputDocument.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/OutputDocument.php @@ -56,6 +56,10 @@ class OutputDocument public function getCasesOutputDocument($applicationUid, $userUid, $applicationDocumentUid) { try { + $oAppDocument = \AppDocumentPeer::retrieveByPK( $applicationDocumentUid, 1 ); + if (is_null( $oAppDocument ) || $oAppDocument->getAppDocStatus() == 'DELETED') { + throw (new \Exception('This output document with id: '.$applicationDocumentUid.' doesn\'t exist!')); + } $sApplicationUID = $applicationUid; $sUserUID = $userUid; \G::LoadClass('case'); diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/ProcessCategory.php b/workflow/engine/src/ProcessMaker/BusinessModel/ProcessCategory.php index 7cbc34de0..f88293cff 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/ProcessCategory.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/ProcessCategory.php @@ -282,7 +282,10 @@ class ProcessCategory public function addCategory($cat_name) { try { - require_once 'classes/model/ProcessCategory.php'; + require_once (PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes". PATH_SEP . "model" . PATH_SEP . "ProcessCategory.php"); + if ($cat_name == '') { + throw (new \Exception( 'cat_name. Process Category name can\'t be null')); + } $catName = trim( $cat_name ); if ($this->existsName( $cat_name )) { throw (new \Exception( 'cat_name. Duplicate Process Category name')); @@ -312,7 +315,7 @@ class ProcessCategory public function updateCategory($cat_uid, $cat_name) { try { - require_once 'classes/model/ProcessCategory.php'; + require_once (PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes". PATH_SEP . "model" . PATH_SEP . "ProcessCategory.php"); $catUID = $cat_uid; $catName = trim( $cat_name ); if ($this->existsName( $cat_name )) { diff --git a/workflow/engine/src/Tests/BusinessModel/InputDocumentsCasesTest.php b/workflow/engine/src/Tests/BusinessModel/InputDocumentsCasesTest.php index 4d0adb89f..286244aa8 100644 --- a/workflow/engine/src/Tests/BusinessModel/InputDocumentsCasesTest.php +++ b/workflow/engine/src/Tests/BusinessModel/InputDocumentsCasesTest.php @@ -177,14 +177,12 @@ class InputDocumentsCasesTest extends \PHPUnit_Framework_TestCase * 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) + public function testRemoveInputDocumentErrorIncorrectApplicationValueArray() { $this->oInputDocument->removeInputDocument('12345678912345678912345678912345678'); } diff --git a/workflow/engine/src/Tests/BusinessModel/OutputDocumentsCasesTest.php b/workflow/engine/src/Tests/BusinessModel/OutputDocumentsCasesTest.php index 140971356..59972c8d4 100644 --- a/workflow/engine/src/Tests/BusinessModel/OutputDocumentsCasesTest.php +++ b/workflow/engine/src/Tests/BusinessModel/OutputDocumentsCasesTest.php @@ -101,6 +101,20 @@ class OutputDocumentsCasesTest extends \PHPUnit_Framework_TestCase return $aResponse; } + /** + * Test error for incorrect value of application in array + * + * @covers \ProcessMaker\BusinessModel\Cases\OutputDocument::getCasesOutputDocuments + * @expectedException Exception + * @expectedExceptionMessage The Application row '12345678912345678912345678912345678' doesn't exist! + * + * @copyright Colosa - Bolivia + */ + public function testGetCasesOutputDocumentsErrorIncorrectApplicationValueArray() + { + $this->oOutputDocument->getCasesOutputDocuments('12345678912345678912345678912345678', self::$usrUid); + } + /** * Test get OutputDocuments * @@ -116,6 +130,38 @@ class OutputDocumentsCasesTest extends \PHPUnit_Framework_TestCase $this->assertTrue(is_array($response)); } + /** + * Test error for incorrect value of application in array + * + * @covers \ProcessMaker\BusinessModel\Cases\OutputDocument::getCasesOutputDocument + * @depends testAddCasesOutputDocument + * @param array $aResponse + * @expectedException Exception + * @expectedExceptionMessage The Application row '12345678912345678912345678912345678' doesn't exist! + * + * @copyright Colosa - Bolivia + */ + public function testGetCasesOutputDocumentErrorIncorrectApplicationValueArray(array $aResponse) + { + $this->oOutputDocument->getCasesOutputDocument('12345678912345678912345678912345678', self::$usrUid, $aResponse["app_doc_uid"]); + } + + /** + * Test error for incorrect value of output document in array + * + * @covers \ProcessMaker\BusinessModel\Cases\OutputDocument::getCasesOutputDocument + * @depends testAddCasesOutputDocument + * @param array $aResponse + * @expectedException Exception + * @expectedExceptionMessage This output document with id: 12345678912345678912345678912345678 doesn't exist! + * + * @copyright Colosa - Bolivia + */ + public function testGetCasesOutputDocumentErrorIncorrectOutputDocumentValueArray(array $aResponse) + { + $this->oOutputDocument->getCasesOutputDocument($aResponse["idCase"], self::$usrUid, '12345678912345678912345678912345678'); + } + /** * Test get OutputDocument * @@ -131,6 +177,20 @@ class OutputDocumentsCasesTest extends \PHPUnit_Framework_TestCase $this->assertTrue(is_object($response)); } + /** + * Test error for incorrect value of output document in array + * + * @covers \ProcessMaker\BusinessModel\Cases\OutputDocument::removeOutputDocument + * @expectedException Exception + * @expectedExceptionMessage This output document with id: 12345678912345678912345678912345678 doesn't exist! + * + * @copyright Colosa - Bolivia + */ + public function testRemoveOutputDocumentErrorIncorrectOutputDocumentValueArray() + { + $this->oOutputDocument->removeOutputDocument('12345678912345678912345678912345678'); + } + /** * Test remove OutputDocument * diff --git a/workflow/engine/src/Tests/BusinessModel/ProcessCategoryTest.php b/workflow/engine/src/Tests/BusinessModel/ProcessCategoryTest.php index f0a1a3e25..742cae5f2 100644 --- a/workflow/engine/src/Tests/BusinessModel/ProcessCategoryTest.php +++ b/workflow/engine/src/Tests/BusinessModel/ProcessCategoryTest.php @@ -40,6 +40,20 @@ class ProcessCategoryTest extends \PHPUnit_Framework_TestCase } } + /** + * Test error for incorrect value of category name in array + * + * @covers \BusinessModel\ProcessCategory::addCategory + * @expectedException Exception + * @expectedExceptionMessage cat_name. Process Category name can't be null + * + * @copyright Colosa - Bolivia + */ + public function testAddCategoryErrorIncorrectValue() + { + $this->oCategory->addCategory(''); + } + /** * Test add Category * @@ -55,6 +69,34 @@ class ProcessCategoryTest extends \PHPUnit_Framework_TestCase return $aResponse; } + /** + * Test error for incorrect value of category name in array + * + * @covers \BusinessModel\ProcessCategory::addCategory + * @expectedException Exception + * @expectedExceptionMessage cat_name. Duplicate Process Category name + * + * @copyright Colosa - Bolivia + */ + public function testAddCategoryErrorDuplicateValue() + { + $this->oCategory->addCategory('New Category Test'); + } + + /** + * Test error for incorrect value of category name in array + * + * @covers \BusinessModel\ProcessCategory::updateCategory + * @expectedException Exception + * @expectedExceptionMessage cat_name. Duplicate Process Category name + * + * @copyright Colosa - Bolivia + */ + public function testUpdateCategoryErrorDuplicateValue() + { + $this->oCategory->addCategory('New Category Test'); + } + /** * Test put Category * @@ -70,6 +112,20 @@ class ProcessCategoryTest extends \PHPUnit_Framework_TestCase $this->assertTrue(is_object($response)); } + /** + * Test error for incorrect value of category id + * + * @covers \BusinessModel\ProcessCategory::getCategory + * @expectedException Exception + * @expectedExceptionMessage The Category with cat_uid: 12345678912345678912345678912345678 doesn't exist! + * + * @copyright Colosa - Bolivia + */ + public function testGetErrorValue() + { + $this->oCategory->getCategory('12345678912345678912345678912345678'); + } + /** * Test get Category * @@ -85,6 +141,19 @@ class ProcessCategoryTest extends \PHPUnit_Framework_TestCase $this->assertTrue(is_object($response)); } + /** + * Test error for incorrect value of category id + * + * @covers \BusinessModel\ProcessCategory::deleteCategory + * @expectedException Exception + * @expectedExceptionMessage The Category with cat_uid: 12345678912345678912345678912345678 doesn't exist! + * + * @copyright Colosa - Bolivia + */ + public function testDeleteErrorValue() + { + $this->oCategory->deleteCategory('12345678912345678912345678912345678'); + } /** * Test delete Category