Merge branch 'master' of bitbucket.org:colosa/processmaker
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -36,3 +36,4 @@ workflow/public_html/build-log.html
|
||||
temp.txt
|
||||
update.sh
|
||||
workflow/public_html/translations/
|
||||
|
||||
|
||||
@@ -166,8 +166,8 @@ Scenario: Create a new Calendars (with work days less than 3)
|
||||
|
||||
|
||||
|
||||
#Scenario: Delete Calendar when it is assigned to a project "Test Process"
|
||||
# Given that I want to delete a "Calendar"
|
||||
# And I request "calendar/14606161052f50839307899033145440"
|
||||
# Then the response status code should be 400
|
||||
# And the response status message should have the following text "cannot be deleted"
|
||||
Scenario: Delete Calendar when it is assigned to a project "Test Process"
|
||||
Given that I want to delete a "Calendar"
|
||||
And I request "calendar/14606161052f50839307899033145440"
|
||||
Then the response status code should be 400
|
||||
And the response status message should have the following text "cannot be deleted"
|
||||
@@ -38,7 +38,7 @@ Background:
|
||||
Then the response status code should be 200
|
||||
And the response charset is "UTF-8"
|
||||
And the type is "array"
|
||||
And the response has 7 record
|
||||
And the response has 6 record
|
||||
|
||||
|
||||
Scenario: Create a new department in the workspace
|
||||
|
||||
@@ -68,7 +68,7 @@ Feature: PM Group Negative Tests
|
||||
And the response status message should have the following text "already assigned"
|
||||
|
||||
|
||||
# Scenario: Delete a pm_group when have asigned user (negative tests) "Credit Supervisors"
|
||||
# Scenario: Delete a pm_group when have asigned user and this is assigned to a task (negative tests) "Credit Supervisors"
|
||||
# Given that I want to delete a "Group"
|
||||
# And I request "group/53254668952d56744764b08079100881"
|
||||
# Then the response status code should be 400
|
||||
|
||||
@@ -74,8 +74,8 @@ Feature: PM User Main Tests
|
||||
| Create with User exist | Peter | Vanko | peter | colosaqatest@gmail.com | | | | | | | | | 2016-02-15 | | ACTIVE | PROCESSMAKER_OPERATOR | sample | sample | 400 | string | exists |
|
||||
|
||||
|
||||
# Scenario: Delete a pm_user when have asigned cases (negative tests) "amy"
|
||||
# Given that I want to delete a "User"
|
||||
# And I request "user/25286582752d56713231082039265791"
|
||||
# Then the response status code should be 400
|
||||
# And the response status message should have the following text "cannot be deleted"
|
||||
Scenario: Delete a pm_user when have asigned cases (negative tests) "amy with 4 cases"
|
||||
Given that I want to delete a "User"
|
||||
And I request "user/25286582752d56713231082039265791"
|
||||
Then the response status code should be 400
|
||||
And the response status message should have the following text "cannot be deleted"
|
||||
@@ -67,8 +67,8 @@ Scenario Outline: Assign Permission "PM_DASHBOARD" to Role (NEGATIVE TESTS)
|
||||
| Create rol without per_uid | 00000000000000000000000000000004 | | 400 | per_uid |
|
||||
|
||||
|
||||
# Scenario: Delete a role when have asigned users (negative tests) "PROCESSMAKER_OPERATOR"
|
||||
# Given that I want to delete a "Role"
|
||||
# And I request "role/00000000000000000000000000000003"
|
||||
# Then the response status code should be 400
|
||||
# And the response status message should have the following text "cannot be deleted"
|
||||
Scenario: Delete a role when have asigned users (negative tests) "PROCESSMAKER_OPERATOR"
|
||||
Given that I want to delete a "Role"
|
||||
And I request "role/00000000000000000000000000000003"
|
||||
Then the response status code should be 400
|
||||
And the response status message should have the following text "cannot be deleted"
|
||||
@@ -156,17 +156,17 @@ class UsersProperties extends BaseUsersProperties
|
||||
$aErrors[] = 'ID_PPP_MAXIMUM_LENGTH';
|
||||
}
|
||||
if (PPP_NUMERICAL_CHARACTER_REQUIRED == 1) {
|
||||
if (preg_match_all( '/[0-9]/', $sPassword, $aMatch, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE ) == 0) {
|
||||
if (preg_match_all( '/[0-9]/', $sPassword, $aMatch, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE ) == 0 || $nowLogin) {
|
||||
$aErrors[] = 'ID_PPP_NUMERICAL_CHARACTER_REQUIRED';
|
||||
}
|
||||
}
|
||||
if (PPP_UPPERCASE_CHARACTER_REQUIRED == 1) {
|
||||
if (preg_match_all( '/[A-Z]/', $sPassword, $aMatch, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE ) == 0) {
|
||||
if (preg_match_all( '/[A-Z]/', $sPassword, $aMatch, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE ) == 0 || $nowLogin) {
|
||||
$aErrors[] = 'ID_PPP_UPPERCASE_CHARACTER_REQUIRED';
|
||||
}
|
||||
}
|
||||
if (PPP_SPECIAL_CHARACTER_REQUIRED == 1) {
|
||||
if (preg_match_all( '/[<5B><>\\!|"@<40>#$~%<25>&<26>\/()=\'?<3F><>*+\-_.:,;]/', $sPassword, $aMatch, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE ) == 0) {
|
||||
if (preg_match_all( '/[<5B><>\\!|"@<40>#$~%<25>&<26>\/()=\'?<3F><>*+\-_.:,;]/', $sPassword, $aMatch, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE ) == 0 || $nowLogin) {
|
||||
$aErrors[] = 'ID_PPP_SPECIAL_CHARACTER_REQUIRED';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,6 +90,7 @@ try {
|
||||
$_SESSION['PROCESS'] = $aFields['PRO_UID'];
|
||||
$_SESSION['TASK'] = - 1;
|
||||
$_SESSION['STEP_POSITION'] = 0;
|
||||
$_SESSION['CURRENT_TASK'] = $aFields['TAS_UID'];
|
||||
|
||||
require_once (PATH_METHODS . 'cases' . PATH_SEP . 'cases_Resume.php');
|
||||
exit();
|
||||
@@ -208,10 +209,12 @@ try {
|
||||
break;
|
||||
default: //APP_STATUS <> DRAFT and TO_DO
|
||||
$_SESSION['APPLICATION'] = $sAppUid;
|
||||
$_SESSION['INDEX'] = $iDelIndex != "" ? $iDelIndex : $oCase->getCurrentDelegationCase( $_GET['APP_UID'] );
|
||||
$_SESSION['INDEX'] = $oCase->getCurrentDelegationCase( $_GET['APP_UID'] );
|
||||
$_SESSION['PROCESS'] = $aFields['PRO_UID'];
|
||||
$_SESSION['TASK'] = - 1;
|
||||
$_SESSION['STEP_POSITION'] = 0;
|
||||
$Fields = $oCase->loadCase( $_SESSION['APPLICATION'], $_SESSION['INDEX']);
|
||||
$_SESSION['CURRENT_TASK'] = $Fields['TAS_UID'];
|
||||
|
||||
require_once (PATH_METHODS . 'cases' . PATH_SEP . 'cases_Resume.php');
|
||||
}
|
||||
|
||||
@@ -4,11 +4,11 @@ namespace ProcessMaker\BusinessModel;
|
||||
class ProcessCategory
|
||||
{
|
||||
private $arrayFieldDefinition = array(
|
||||
"CAT_UID" => array("fieldName" => "CATEGORY_UID", "type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "processCategoryUid"),
|
||||
"CAT_UID" => array("fieldName" => "CATEGORY_UID", "type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "categoryUid"),
|
||||
|
||||
"CAT_PARENT" => array("fieldName" => "CATEGORY_PARENT", "type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "processCategoryParent"),
|
||||
"CAT_NAME" => array("fieldName" => "CATEGORY_NAME", "type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "processCategoryName"),
|
||||
"CAT_ICON" => array("fieldName" => "CATEGORY_ICON", "type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "processCategoryIcon")
|
||||
"CAT_PARENT" => array("fieldName" => "CATEGORY_PARENT", "type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "categoryParent"),
|
||||
"CAT_NAME" => array("fieldName" => "CATEGORY_NAME", "type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "categoryName"),
|
||||
"CAT_ICON" => array("fieldName" => "CATEGORY_ICON", "type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "categoryIcon")
|
||||
);
|
||||
|
||||
private $formatFieldNameInUppercase = true;
|
||||
@@ -60,7 +60,7 @@ class ProcessCategory
|
||||
*
|
||||
* return void
|
||||
*/
|
||||
public function setArrayFieldNameForException($arrayData)
|
||||
public function setArrayFieldNameForException(array $arrayData)
|
||||
{
|
||||
try {
|
||||
foreach ($arrayData as $key => $value) {
|
||||
@@ -88,14 +88,244 @@ class ProcessCategory
|
||||
}
|
||||
|
||||
/**
|
||||
* Get criteria for Process Category
|
||||
* Verify if exists the name of a Category
|
||||
*
|
||||
* return object
|
||||
* @param string $categoryName Name
|
||||
* @param string $categoryUidExclude Unique id of Category to exclude
|
||||
*
|
||||
* return bool Return true if exists the name of a Category, false otherwise
|
||||
*/
|
||||
public function getProcessCategoryCriteria()
|
||||
public function existsName($categoryName, $categoryUidExclude = "")
|
||||
{
|
||||
try {
|
||||
$criteria = new \Criteria("workflow");
|
||||
|
||||
$criteria->addSelectColumn(\ProcessCategoryPeer::CATEGORY_UID);
|
||||
|
||||
if ($categoryUidExclude != "") {
|
||||
$criteria->add(\ProcessCategoryPeer::CATEGORY_UID, $categoryUidExclude, \Criteria::NOT_EQUAL);
|
||||
}
|
||||
|
||||
$criteria->add(\ProcessCategoryPeer::CATEGORY_NAME, $categoryName, \Criteria::EQUAL);
|
||||
|
||||
$rsCriteria = \ProcessCategoryPeer::doSelectRS($criteria);
|
||||
|
||||
if ($rsCriteria->next()) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if does not exist the Category in table PROCESS_CATEGORY
|
||||
*
|
||||
* @param string $categoryUid Unique id of Category
|
||||
* @param string $fieldNameForException Field name for the exception
|
||||
*
|
||||
* return void Throw exception if does not exist the Category in table PROCESS_CATEGORY
|
||||
*/
|
||||
public function throwExceptionIfNotExistsCategory($categoryUid, $fieldNameForException)
|
||||
{
|
||||
try {
|
||||
$obj = \ProcessCategoryPeer::retrieveByPK($categoryUid);
|
||||
|
||||
if (is_null($obj)) {
|
||||
throw new \Exception(\G::LoadTranslation("ID_CATEGORY_NOT_EXIST", array($fieldNameForException, $categoryUid)));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if exists the name of a Category
|
||||
*
|
||||
* @param string $categoryName Name
|
||||
* @param string $fieldNameForException Field name for the exception
|
||||
* @param string $categoryUidExclude Unique id of Category to exclude
|
||||
*
|
||||
* return void Throw exception if exists the name of a Category
|
||||
*/
|
||||
public function throwExceptionIfExistsName($categoryName, $fieldNameForException, $categoryUidExclude = "")
|
||||
{
|
||||
try {
|
||||
if ($this->existsName($categoryName, $categoryUidExclude)) {
|
||||
throw new \Exception(\G::LoadTranslation("ID_CATEGORY_NAME_ALREADY_EXISTS", array($fieldNameForException, $categoryName)));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the data if they are invalid (INSERT and UPDATE)
|
||||
*
|
||||
* @param string $categoryUid Unique id of Category
|
||||
* @param array $arrayData Data
|
||||
*
|
||||
* return void Throw exception if data has an invalid value
|
||||
*/
|
||||
public function throwExceptionIfDataIsInvalid($categoryUid, array $arrayData)
|
||||
{
|
||||
try {
|
||||
//Set variables
|
||||
$arrayCategoryData = ($categoryUid == "")? array() : $this->getCategory($categoryUid, true);
|
||||
$flagInsert = ($categoryUid == "")? true : false;
|
||||
|
||||
$arrayDataMain = array_merge($arrayCategoryData, $arrayData);
|
||||
|
||||
//Verify data - Field definition
|
||||
$process = new \ProcessMaker\BusinessModel\Process();
|
||||
|
||||
$process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, $flagInsert);
|
||||
|
||||
//Verify data
|
||||
if (isset($arrayData["CAT_NAME"])) {
|
||||
$this->throwExceptionIfExistsName($arrayData["CAT_NAME"], $this->arrayFieldNameForException["categoryName"], $categoryUid);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Category
|
||||
*
|
||||
* @param array $arrayData Data
|
||||
*
|
||||
* return array Return data of the new Category created
|
||||
*/
|
||||
public function create(array $arrayData)
|
||||
{
|
||||
try {
|
||||
//Verify data
|
||||
$process = new \ProcessMaker\BusinessModel\Process();
|
||||
$validator = new \ProcessMaker\BusinessModel\Validator();
|
||||
|
||||
$validator->throwExceptionIfDataIsEmpty($arrayData, "\$arrayData");
|
||||
|
||||
//Set data
|
||||
$arrayData = array_change_key_case($arrayData, CASE_UPPER);
|
||||
|
||||
unset($arrayData["CAT_UID"]);
|
||||
|
||||
//Verify data
|
||||
$this->throwExceptionIfDataIsInvalid("", $arrayData);
|
||||
|
||||
//Create
|
||||
$category = new \ProcessCategory();
|
||||
|
||||
$categoryUid = \ProcessMaker\Util\Common::generateUID();
|
||||
|
||||
$category->setNew(true);
|
||||
$category->setCategoryUid($categoryUid);
|
||||
$category->setCategoryName($arrayData["CAT_NAME"]);
|
||||
|
||||
$result = $category->save();
|
||||
|
||||
//Return
|
||||
return $this->getCategory($categoryUid);
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Category
|
||||
*
|
||||
* @param string $categoryUid Unique id of Category
|
||||
* @param array $arrayData Data
|
||||
*
|
||||
* return array Return data of the Category updated
|
||||
*/
|
||||
public function update($categoryUid, array $arrayData)
|
||||
{
|
||||
try {
|
||||
//Verify data
|
||||
$process = new \ProcessMaker\BusinessModel\Process();
|
||||
$validator = new \ProcessMaker\BusinessModel\Validator();
|
||||
|
||||
$validator->throwExceptionIfDataIsEmpty($arrayData, "\$arrayData");
|
||||
|
||||
//Set data
|
||||
$arrayData = array_change_key_case($arrayData, CASE_UPPER);
|
||||
$arrayDataBackup = $arrayData;
|
||||
|
||||
//Verify data
|
||||
$this->throwExceptionIfNotExistsCategory($categoryUid, $this->arrayFieldNameForException["categoryUid"]);
|
||||
|
||||
$this->throwExceptionIfDataIsInvalid($categoryUid, $arrayData);
|
||||
|
||||
//Update
|
||||
$category = new \ProcessCategory();
|
||||
|
||||
$category->setNew(false);
|
||||
$category->setCategoryUid($categoryUid);
|
||||
|
||||
if (isset($arrayData["CAT_NAME"])) {
|
||||
$category->setCategoryName($arrayData["CAT_NAME"]);
|
||||
}
|
||||
|
||||
$result = $category->save();
|
||||
|
||||
$arrayData = $arrayDataBackup;
|
||||
|
||||
//Return
|
||||
if (!$this->formatFieldNameInUppercase) {
|
||||
$arrayData = array_change_key_case($arrayData, CASE_LOWER);
|
||||
}
|
||||
|
||||
return $arrayData;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete Category
|
||||
*
|
||||
* @param string $categoryUid Unique id of Category
|
||||
*
|
||||
* return void
|
||||
*/
|
||||
public function delete($categoryUid)
|
||||
{
|
||||
try {
|
||||
//Verify data
|
||||
$this->throwExceptionIfNotExistsCategory($categoryUid, $this->arrayFieldNameForException["categoryUid"]);
|
||||
|
||||
$process = new \Process();
|
||||
|
||||
$arrayTotalProcessesByCategory = $process->getAllProcessesByCategory();
|
||||
|
||||
if (isset($arrayTotalProcessesByCategory[$categoryUid])) {
|
||||
throw new \Exception(\G::LoadTranslation("ID_MSG_CANNOT_DELETE_CATEGORY"));
|
||||
}
|
||||
|
||||
//Delete
|
||||
$category = new \ProcessCategory();
|
||||
|
||||
$category->setCategoryUid($categoryUid);
|
||||
$category->delete();
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get criteria for Category
|
||||
*
|
||||
* return object
|
||||
*/
|
||||
public function getCategoryCriteria()
|
||||
{
|
||||
try {
|
||||
$criteria = new \Criteria("workflow");
|
||||
|
||||
$criteria->addSelectColumn(\ProcessCategoryPeer::CATEGORY_UID);
|
||||
$criteria->addSelectColumn(\ProcessCategoryPeer::CATEGORY_PARENT);
|
||||
$criteria->addSelectColumn(\ProcessCategoryPeer::CATEGORY_NAME);
|
||||
@@ -109,13 +339,13 @@ class ProcessCategory
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data of a Process Category from a record
|
||||
* Get data of a Category from a record
|
||||
*
|
||||
* @param array $record Record
|
||||
*
|
||||
* return array Return an array with data Process Category
|
||||
* return array Return an array with data Category
|
||||
*/
|
||||
public function getProcessCategoryDataFromRecord($record)
|
||||
public function getCategoryDataFromRecord(array $record)
|
||||
{
|
||||
try {
|
||||
return array(
|
||||
@@ -129,7 +359,7 @@ class ProcessCategory
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all Process Categories
|
||||
* Get all Categories
|
||||
*
|
||||
* @param array $arrayFilterData Data of the filters
|
||||
* @param string $sortField Field name to sort
|
||||
@@ -137,12 +367,12 @@ class ProcessCategory
|
||||
* @param int $start Start
|
||||
* @param int $limit Limit
|
||||
*
|
||||
* return array Return an array with all Process Categories
|
||||
* return array Return an array with all Categories
|
||||
*/
|
||||
public function getCategories($arrayFilterData = null, $sortField = null, $sortDir = null, $start = null, $limit = null)
|
||||
public function getCategories(array $arrayFilterData = null, $sortField = null, $sortDir = null, $start = null, $limit = null)
|
||||
{
|
||||
try {
|
||||
$arrayProcessCategory = array();
|
||||
$arrayCategory = array();
|
||||
|
||||
//Verify data
|
||||
$process = new \ProcessMaker\BusinessModel\Process();
|
||||
@@ -151,7 +381,7 @@ class ProcessCategory
|
||||
|
||||
//Get data
|
||||
if (!is_null($limit) && $limit . "" == "0") {
|
||||
return $arrayProcessCategory;
|
||||
return $arrayCategory;
|
||||
}
|
||||
|
||||
//Set variables
|
||||
@@ -160,7 +390,7 @@ class ProcessCategory
|
||||
$arrayTotalProcessesByCategory = $process->getAllProcessesByCategory();
|
||||
|
||||
//SQL
|
||||
$criteria = $this->getProcessCategoryCriteria();
|
||||
$criteria = $this->getCategoryCriteria();
|
||||
|
||||
if (!is_null($arrayFilterData) && is_array($arrayFilterData) && isset($arrayFilterData["filter"]) && trim($arrayFilterData["filter"]) != "") {
|
||||
$criteria->add(\ProcessCategoryPeer::CATEGORY_NAME, "%" . $arrayFilterData["filter"] . "%", \Criteria::LIKE);
|
||||
@@ -170,7 +400,7 @@ class ProcessCategory
|
||||
$criteriaCount = clone $criteria;
|
||||
|
||||
$criteriaCount->clearSelectColumns();
|
||||
$criteriaCount->addSelectColumn("COUNT(" . \ProcessCategoryPeer::CATEGORY_UID . ") AS NUM_REC");
|
||||
$criteriaCount->addAsColumn("NUM_REC", "COUNT(" . \ProcessCategoryPeer::CATEGORY_UID . ")");
|
||||
|
||||
$rsCriteriaCount = \ProcessCategoryPeer::doSelectRS($criteriaCount);
|
||||
$rsCriteriaCount->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
@@ -185,16 +415,10 @@ class ProcessCategory
|
||||
$sortField = strtoupper($sortField);
|
||||
$sortField = (isset($this->arrayFieldDefinition[$sortField]["fieldName"]))? $this->arrayFieldDefinition[$sortField]["fieldName"] : $sortField;
|
||||
|
||||
switch ($sortField) {
|
||||
case "CATEGORY_UID":
|
||||
case "CATEGORY_PARENT":
|
||||
case "CATEGORY_NAME":
|
||||
case "CATEGORY_ICON":
|
||||
$sortField = \ProcessCategoryPeer::TABLE_NAME . "." . $sortField;
|
||||
break;
|
||||
default:
|
||||
$sortField = \ProcessCategoryPeer::CATEGORY_NAME;
|
||||
break;
|
||||
if (in_array($sortField, array("CATEGORY_UID", "CATEGORY_PARENT", "CATEGORY_NAME", "CATEGORY_ICON"))) {
|
||||
$sortField = \ProcessCategoryPeer::TABLE_NAME . "." . $sortField;
|
||||
} else {
|
||||
$sortField = \ProcessCategoryPeer::CATEGORY_NAME;
|
||||
}
|
||||
} else {
|
||||
$sortField = \ProcessCategoryPeer::CATEGORY_NAME;
|
||||
@@ -222,187 +446,59 @@ class ProcessCategory
|
||||
|
||||
$row["CATEGORY_TOTAL_PROCESSES"] = (isset($arrayTotalProcessesByCategory[$row["CATEGORY_UID"]]))? $arrayTotalProcessesByCategory[$row["CATEGORY_UID"]] : 0;
|
||||
|
||||
$arrayProcessCategory[] = $this->getProcessCategoryDataFromRecord($row);
|
||||
$arrayCategory[] = $this->getCategoryDataFromRecord($row);
|
||||
}
|
||||
|
||||
//Return
|
||||
return $arrayProcessCategory;
|
||||
return $arrayCategory;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Process Category
|
||||
* Get data of a Category
|
||||
*
|
||||
* @param string $cat_uid Category Id
|
||||
* @param string $categoryUid Unique id of Category
|
||||
* @param bool $flagGetRecord Value that set the getting
|
||||
*
|
||||
* return array Return an object with the Process Category
|
||||
* return array Return an array with data of a Category
|
||||
*/
|
||||
public function getCategory($cat_uid)
|
||||
public function getCategory($categoryUid, $flagGetRecord = false)
|
||||
{
|
||||
try {
|
||||
$oProcessCategory = '';
|
||||
$process = new \Process();
|
||||
$oTotalProcessesByCategory = $process->getAllProcessesByCategory();
|
||||
$criteria = $this->getAProcessCategoryCriteria($cat_uid);
|
||||
$criteriaCount = clone $criteria;
|
||||
$criteriaCount->clearSelectColumns();
|
||||
$criteriaCount->addSelectColumn("COUNT(" . \ProcessCategoryPeer::CATEGORY_UID . ") AS NUM_REC");
|
||||
$rsCriteriaCount = \ProcessCategoryPeer::doSelectRS($criteriaCount);
|
||||
$rsCriteriaCount->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
$rsCriteriaCount->next();
|
||||
//Verify data
|
||||
$this->throwExceptionIfNotExistsCategory($categoryUid, $this->arrayFieldNameForException["categoryUid"]);
|
||||
|
||||
//Set variables
|
||||
if (!$flagGetRecord) {
|
||||
$process = new \Process();
|
||||
|
||||
$arrayTotalProcessesByCategory = $process->getAllProcessesByCategory();
|
||||
}
|
||||
|
||||
//Get data
|
||||
//SQL
|
||||
$criteria = $this->getCategoryCriteria();
|
||||
|
||||
$criteria->add(\ProcessCategoryPeer::CATEGORY_UID, $categoryUid, \Criteria::EQUAL);
|
||||
|
||||
$rsCriteria = \ProcessCategoryPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
while ($rsCriteria->next()) {
|
||||
$row = $rsCriteria->getRow();
|
||||
$row["CATEGORY_TOTAL_PROCESSES"] = (isset($oTotalProcessesByCategory[$row["CATEGORY_UID"]]))? $oTotalProcessesByCategory[$row["CATEGORY_UID"]] : 0;
|
||||
$oProcessCategory = $this->getProcessCategoryDataFromRecord($row);
|
||||
}
|
||||
//Return
|
||||
if ($oProcessCategory != '') {
|
||||
$oProcessCategory = array_change_key_case($oProcessCategory, CASE_LOWER);
|
||||
$oResponse = json_decode(json_encode($oProcessCategory), false);
|
||||
return $oResponse;
|
||||
} else {
|
||||
throw (new \Exception( 'The Category with cat_uid: '.$cat_uid.' doesn\'t exist!'));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Post Process Category
|
||||
*
|
||||
* @param string $cat_name Name of Category
|
||||
*
|
||||
* return array
|
||||
*/
|
||||
public function addCategory($cat_name)
|
||||
{
|
||||
try {
|
||||
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'));
|
||||
}
|
||||
$catUid = \G::GenerateUniqueID();
|
||||
$pcat = new \ProcessCategory();
|
||||
$pcat->setNew( true );
|
||||
$pcat->setCategoryUid( $catUid );
|
||||
$pcat->setCategoryName( $catName );
|
||||
$pcat->save();
|
||||
$oProcessCategory = $this->getCategory( $catUid );
|
||||
//Return
|
||||
return $oProcessCategory;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Put Process Category
|
||||
*
|
||||
* @param string $cat_uid Category id
|
||||
* @param string $cat_name Category Name
|
||||
*
|
||||
* return array
|
||||
*/
|
||||
public function updateCategory($cat_uid, $cat_name)
|
||||
{
|
||||
try {
|
||||
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 )) {
|
||||
throw (new \Exception( 'cat_name. Duplicate Process Category name'));
|
||||
}
|
||||
$pcat = new \ProcessCategory();
|
||||
$pcat->setNew( false );
|
||||
$pcat->setCategoryUid( $catUID );
|
||||
$pcat->setCategoryName( $catName );
|
||||
$pcat->save();
|
||||
$oProcessCategory = $this->getCategory( $cat_uid );
|
||||
//Return
|
||||
$oResponse = json_decode(json_encode($oProcessCategory), false);
|
||||
return $oResponse;
|
||||
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete Process Category
|
||||
*
|
||||
* @param string $cat_uid Category id
|
||||
*
|
||||
* return array
|
||||
*/
|
||||
public function deleteCategory($cat_uid)
|
||||
{
|
||||
try {
|
||||
require_once 'classes/model/ProcessCategory.php';
|
||||
$criteria = $this->getAProcessCategoryCriteria($cat_uid);
|
||||
$rsCriteria = \ProcessCategoryPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
$rsCriteria->next();
|
||||
|
||||
$row = $rsCriteria->getRow();
|
||||
if ($row) {
|
||||
$cat = new \ProcessCategory();
|
||||
$cat->setCategoryUid( $cat_uid );
|
||||
$cat->delete();
|
||||
} else {
|
||||
throw (new \Exception( 'The Category with cat_uid: '.$cat_uid.' doesn\'t exist!'));
|
||||
|
||||
if (!$flagGetRecord) {
|
||||
$row["CATEGORY_TOTAL_PROCESSES"] = (isset($arrayTotalProcessesByCategory[$row["CATEGORY_UID"]]))? $arrayTotalProcessesByCategory[$row["CATEGORY_UID"]] : 0;
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get criteria for Process Category
|
||||
*
|
||||
* return object
|
||||
*/
|
||||
public function getAProcessCategoryCriteria($cat_uid)
|
||||
{
|
||||
try {
|
||||
$criteria = new \Criteria("workflow");
|
||||
$criteria->addSelectColumn(\ProcessCategoryPeer::CATEGORY_UID);
|
||||
$criteria->addSelectColumn(\ProcessCategoryPeer::CATEGORY_PARENT);
|
||||
$criteria->addSelectColumn(\ProcessCategoryPeer::CATEGORY_NAME);
|
||||
$criteria->addSelectColumn(\ProcessCategoryPeer::CATEGORY_ICON);
|
||||
$criteria->add(\ProcessCategoryPeer::CATEGORY_UID, $cat_uid);
|
||||
return $criteria;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the name exists
|
||||
*
|
||||
* @param string $name Name
|
||||
*
|
||||
* return bool Return true if the name exists, false otherwise
|
||||
*/
|
||||
public function existsName($name)
|
||||
{
|
||||
try {
|
||||
$criteria = new \Criteria("workflow");
|
||||
$criteria->add(\ProcessCategoryPeer::CATEGORY_NAME, $name, \Criteria::EQUAL);
|
||||
$rsCriteria = \ProcessCategoryPeer::doSelectRS($criteria);
|
||||
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
$rsCriteria->next();
|
||||
return $rsCriteria->getRow();
|
||||
//Return
|
||||
return (!$flagGetRecord)? $this->getCategoryDataFromRecord($row) : $row;
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -337,8 +337,6 @@ class Role
|
||||
public function update($roleUid, array $arrayData)
|
||||
{
|
||||
try {
|
||||
$arrayDataBackup = $arrayData;
|
||||
|
||||
//Verify data
|
||||
$process = new \ProcessMaker\BusinessModel\Process();
|
||||
$validator = new \ProcessMaker\BusinessModel\Validator();
|
||||
@@ -347,6 +345,7 @@ class Role
|
||||
|
||||
//Set data
|
||||
$arrayData = array_change_key_case($arrayData, CASE_UPPER);
|
||||
$arrayDataBackup = $arrayData;
|
||||
|
||||
$arrayRoleData = $this->getRole($roleUid);
|
||||
|
||||
|
||||
@@ -5,13 +5,29 @@ use \ProcessMaker\Services\Api;
|
||||
use \Luracast\Restler\RestException;
|
||||
|
||||
/**
|
||||
* Group Api Controller
|
||||
* ProcessCategory Api Controller
|
||||
*
|
||||
* @protected
|
||||
*/
|
||||
class ProcessCategory extends Api
|
||||
{
|
||||
private $formatFieldNameInUppercase = false;
|
||||
private $category;
|
||||
|
||||
/**
|
||||
* Constructor of the class
|
||||
*
|
||||
* return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
try {
|
||||
$this->category = new \ProcessMaker\BusinessModel\ProcessCategory();
|
||||
|
||||
$this->category->setFormatFieldNameInUppercase(false);
|
||||
} catch (\Exception $e) {
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @url GET /categories
|
||||
@@ -19,87 +35,76 @@ class ProcessCategory extends Api
|
||||
public function doGetCategories($filter = null, $start = null, $limit = null)
|
||||
{
|
||||
try {
|
||||
$processCategory = new \ProcessMaker\BusinessModel\ProcessCategory();
|
||||
$processCategory->setFormatFieldNameInUppercase($this->formatFieldNameInUppercase);
|
||||
|
||||
$response = $processCategory->getCategories(array("filter" => $filter), null, null, $start, $limit);
|
||||
$response = $this->category->getCategories(array("filter" => $filter), null, null, $start, $limit);
|
||||
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @url GET /category/:cat_uid
|
||||
*
|
||||
* @param string $cat_uid {@min 32}{@max 32}
|
||||
* @param string $cat_uid {@min 32}{@max 32}
|
||||
*/
|
||||
public function doGetCategory($cat_uid)
|
||||
{
|
||||
try {
|
||||
$processCategory = new \ProcessMaker\BusinessModel\ProcessCategory();
|
||||
$processCategory->setFormatFieldNameInUppercase($this->formatFieldNameInUppercase);
|
||||
|
||||
$response = $processCategory->getCategory($cat_uid);
|
||||
$response = $this->category->getCategory($cat_uid);
|
||||
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @url POST /category
|
||||
*
|
||||
* @param string $cat_name
|
||||
* @param array $request_data
|
||||
*
|
||||
* @status 201
|
||||
*/
|
||||
public function doPostCategory($cat_name)
|
||||
public function doPostCategory(array $request_data)
|
||||
{
|
||||
try {
|
||||
$processCategory = new \ProcessMaker\BusinessModel\ProcessCategory();
|
||||
$response = $processCategory->addCategory($cat_name);
|
||||
$arrayData = $this->category->create($request_data);
|
||||
|
||||
$response = $arrayData;
|
||||
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @url PUT /category/:cat_uid
|
||||
*
|
||||
* @param string $cat_uid {@min 32}{@max 32}
|
||||
* @param string $cat_name
|
||||
*
|
||||
* @param string $cat_uid {@min 32}{@max 32}
|
||||
* @param array $request_data
|
||||
*/
|
||||
public function doPutCategory($cat_uid, $cat_name)
|
||||
public function doPutCategory($cat_uid, array $request_data)
|
||||
{
|
||||
try {
|
||||
$processCategory = new \ProcessMaker\BusinessModel\ProcessCategory();
|
||||
$response = $processCategory->updateCategory($cat_uid, $cat_name);
|
||||
|
||||
return $response;
|
||||
$arrayData = $this->category->update($cat_uid, $request_data);
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @url DELETE /category/:cat_uid
|
||||
*
|
||||
* @param string $cat_uid {@min 32}{@max 32}
|
||||
*
|
||||
* @param string $cat_uid {@min 32}{@max 32}
|
||||
*/
|
||||
public function doDeleteCategory($cat_uid)
|
||||
{
|
||||
try {
|
||||
$processCategory = new \ProcessMaker\BusinessModel\ProcessCategory();
|
||||
$processCategory->deleteCategory($cat_uid);
|
||||
|
||||
$this->category->delete($cat_uid);
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,213 +2,319 @@
|
||||
namespace Tests\BusinessModel;
|
||||
|
||||
if (!class_exists("Propel")) {
|
||||
include_once (__DIR__ . "/../bootstrap.php");
|
||||
require_once(__DIR__ . "/../bootstrap.php");
|
||||
}
|
||||
|
||||
/**
|
||||
* Class ProcessCategoryTest
|
||||
*
|
||||
* @package Tests/ProcessMaker/BusinessModel
|
||||
* @package Tests\BusinessModel
|
||||
*/
|
||||
class ProcessCategoryTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected static $arrayUid = array();
|
||||
protected $oCategory;
|
||||
protected static $category;
|
||||
protected static $numCategory = 2;
|
||||
|
||||
/**
|
||||
* Set class for test
|
||||
*
|
||||
* @coversNothing
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function setUp()
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
$this->oCategory = new \ProcessMaker\BusinessModel\ProcessCategory();
|
||||
}
|
||||
|
||||
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
foreach (self::$arrayUid as $processCategoryUid) {
|
||||
if ($processCategoryUid != "") {
|
||||
$processCategory = new \ProcessCategory();
|
||||
|
||||
$processCategory->setCategoryUid($processCategoryUid);
|
||||
$processCategory->delete();
|
||||
}
|
||||
}
|
||||
self::$category = new \ProcessMaker\BusinessModel\ProcessCategory();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for incorrect value of category name in array
|
||||
* Test create categories
|
||||
*
|
||||
* @covers \BusinessModel\ProcessCategory::addCategory
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage cat_name. Process Category name can't be null
|
||||
* @covers \ProcessMaker\BusinessModel\ProcessCategory::create
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
* @return array
|
||||
*/
|
||||
public function testAddCategoryErrorIncorrectValue()
|
||||
{
|
||||
$this->oCategory->addCategory('');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test add Category
|
||||
*
|
||||
* @covers \BusinessModel\ProcessCategory::addCategory
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testAddCategory()
|
||||
{
|
||||
$response = $this->oCategory->addCategory('New Category Test');
|
||||
$this->assertTrue(is_object($response));
|
||||
$aResponse = json_decode(json_encode($response), true);
|
||||
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
|
||||
*
|
||||
* @covers \BusinessModel\ProcessCategory::updateCategory
|
||||
* @depends testAddCategory
|
||||
* @param array $aResponse
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testUpdateCategory(array $aResponse)
|
||||
{
|
||||
$response = $this->oCategory->updateCategory($aResponse["cat_uid"], 'Name Update Category Test');
|
||||
$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
|
||||
*
|
||||
* @covers \BusinessModel\ProcessCategory::getCategory
|
||||
* @depends testAddCategory
|
||||
* @param array $aResponse
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testGetCategory(array $aResponse)
|
||||
{
|
||||
$response = $this->oCategory->getCategory($aResponse["cat_uid"]);
|
||||
$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
|
||||
*
|
||||
* @covers \BusinessModel\ProcessCategory::deleteCategory
|
||||
* @depends testAddCategory
|
||||
* @param array $aResponse
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testDeleteCategory(array $aResponse)
|
||||
{
|
||||
$response = $this->oCategory->deleteCategory($aResponse["cat_uid"]);
|
||||
$this->assertTrue(empty($response));
|
||||
}
|
||||
|
||||
public function testCreate()
|
||||
{
|
||||
try {
|
||||
$processCategory = new \ProcessCategory();
|
||||
$arrayRecord = array();
|
||||
|
||||
$processCategoryUid = \G::GenerateUniqueID();
|
||||
//Create
|
||||
for ($i = 0; $i <= self::$numCategory - 1; $i++) {
|
||||
$arrayData = array(
|
||||
"CAT_NAME" => "PHPUnit My Category " . $i
|
||||
);
|
||||
|
||||
$processCategory->setNew(true);
|
||||
$processCategory->setCategoryUid($processCategoryUid);
|
||||
$processCategory->setCategoryName("PHPUnit Category");
|
||||
$processCategory->save();
|
||||
} catch (\Exception $e) {
|
||||
$processCategoryUid = "";
|
||||
$arrayCategory = self::$category->create($arrayData);
|
||||
|
||||
$this->assertTrue(is_array($arrayCategory));
|
||||
$this->assertNotEmpty($arrayCategory);
|
||||
|
||||
$this->assertTrue(isset($arrayCategory["CAT_UID"]));
|
||||
|
||||
$arrayRecord[] = $arrayCategory;
|
||||
}
|
||||
|
||||
self::$arrayUid[] = $processCategoryUid;
|
||||
//Create - Japanese characters
|
||||
$arrayData = array(
|
||||
"CAT_NAME" => "テスト(PHPUnitの)",
|
||||
);
|
||||
|
||||
$this->assertNotEmpty($processCategoryUid);
|
||||
$arrayCategory = self::$category->create($arrayData);
|
||||
|
||||
$this->assertTrue(is_array($arrayCategory));
|
||||
$this->assertNotEmpty($arrayCategory);
|
||||
|
||||
$this->assertTrue(isset($arrayCategory["CAT_UID"]));
|
||||
|
||||
$arrayRecord[] = $arrayCategory;
|
||||
|
||||
//Return
|
||||
return $arrayRecord;
|
||||
}
|
||||
|
||||
|
||||
public function testGetCategories()
|
||||
/**
|
||||
* Test update categories
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\ProcessCategory::update
|
||||
*
|
||||
* @depends testCreate
|
||||
* @param array $arrayRecord Data of the categories
|
||||
*/
|
||||
public function testUpdate(array $arrayRecord)
|
||||
{
|
||||
$processCategory = new \ProcessMaker\BusinessModel\ProcessCategory();
|
||||
$arrayData = array("CAT_NAME" => "PHPUnit My Category 1...");
|
||||
|
||||
$arrayProcessCategory = $processCategory->getCategories();
|
||||
$arrayCategory = self::$category->update($arrayRecord[1]["CAT_UID"], $arrayData);
|
||||
|
||||
$this->assertNotEmpty($arrayProcessCategory);
|
||||
$arrayCategory = self::$category->getCategory($arrayRecord[1]["CAT_UID"]);
|
||||
|
||||
$arrayProcessCategory = $processCategory->getCategories(null, null, null, 0, 0);
|
||||
$this->assertTrue(is_array($arrayCategory));
|
||||
$this->assertNotEmpty($arrayCategory);
|
||||
|
||||
$this->assertEmpty($arrayProcessCategory);
|
||||
$this->assertEquals($arrayCategory["CAT_NAME"], $arrayData["CAT_NAME"]);
|
||||
}
|
||||
|
||||
$arrayProcessCategory = $processCategory->getCategories(array("filter" => "PHP"));
|
||||
/**
|
||||
* Test get categories
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\ProcessCategory::getCategories
|
||||
*
|
||||
* @depends testCreate
|
||||
* @param array $arrayRecord Data of the categories
|
||||
*/
|
||||
public function testGetCategories(array $arrayRecord)
|
||||
{
|
||||
$arrayCategory = self::$category->getCategories();
|
||||
|
||||
$this->assertNotEmpty($arrayProcessCategory);
|
||||
$this->assertNotEmpty($arrayCategory);
|
||||
|
||||
$this->assertEquals($arrayProcessCategory[0]["CAT_NAME"], "PHPUnit Category");
|
||||
$this->assertEquals($arrayProcessCategory[0]["CAT_TOTAL_PROCESSES"], 0);
|
||||
$arrayCategory = self::$category->getCategories(null, null, null, 0, 0);
|
||||
|
||||
$this->assertEmpty($arrayCategory);
|
||||
|
||||
$arrayCategory = self::$category->getCategories(array("filter" => "PHPUnit"));
|
||||
|
||||
$this->assertTrue(is_array($arrayCategory));
|
||||
$this->assertNotEmpty($arrayCategory);
|
||||
|
||||
$this->assertEquals($arrayCategory[0]["CAT_UID"], $arrayRecord[0]["CAT_UID"]);
|
||||
$this->assertEquals($arrayCategory[0]["CAT_NAME"], $arrayRecord[0]["CAT_NAME"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get category
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\ProcessCategory::getCategory
|
||||
*
|
||||
* @depends testCreate
|
||||
* @param array $arrayRecord Data of the categories
|
||||
*/
|
||||
public function testGetCategory(array $arrayRecord)
|
||||
{
|
||||
//Get
|
||||
$arrayCategory = self::$category->getCategory($arrayRecord[0]["CAT_UID"]);
|
||||
|
||||
$this->assertTrue(is_array($arrayCategory));
|
||||
$this->assertNotEmpty($arrayCategory);
|
||||
|
||||
$this->assertEquals($arrayCategory["CAT_UID"], $arrayRecord[0]["CAT_UID"]);
|
||||
$this->assertEquals($arrayCategory["CAT_NAME"], $arrayRecord[0]["CAT_NAME"]);
|
||||
|
||||
//Get - Japanese characters
|
||||
$arrayCategory = self::$category->getCategory($arrayRecord[self::$numCategory]["CAT_UID"]);
|
||||
|
||||
$this->assertTrue(is_array($arrayCategory));
|
||||
$this->assertNotEmpty($arrayCategory);
|
||||
|
||||
$this->assertEquals($arrayCategory["CAT_UID"], $arrayRecord[self::$numCategory]["CAT_UID"]);
|
||||
$this->assertEquals($arrayCategory["CAT_NAME"], "テスト(PHPUnitの)");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for empty data
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\ProcessCategory::create
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid value for "$arrayData", it can not be empty.
|
||||
*/
|
||||
public function testCreateExceptionEmptyData()
|
||||
{
|
||||
$arrayData = array();
|
||||
|
||||
$arrayCategory = self::$category->create($arrayData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for required data (CAT_NAME)
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\ProcessCategory::create
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Undefined value for "CAT_NAME", it is required.
|
||||
*/
|
||||
public function testCreateExceptionRequiredDataCatName()
|
||||
{
|
||||
$arrayData = array(
|
||||
"CAT_NAMEX" => "PHPUnit My Category N"
|
||||
);
|
||||
|
||||
$arrayCategory = self::$category->create($arrayData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for invalid data (CAT_NAME)
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\ProcessCategory::create
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid value for "CAT_NAME", it can not be empty.
|
||||
*/
|
||||
public function testCreateExceptionInvalidDataCatName()
|
||||
{
|
||||
$arrayData = array(
|
||||
"CAT_NAME" => ""
|
||||
);
|
||||
|
||||
$arrayCategory = self::$category->create($arrayData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for category name existing
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\ProcessCategory::create
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The category name with CAT_NAME: "PHPUnit My Category 0" already exists.
|
||||
*/
|
||||
public function testCreateExceptionExistsCatName()
|
||||
{
|
||||
$arrayData = array(
|
||||
"CAT_NAME" => "PHPUnit My Category 0"
|
||||
);
|
||||
|
||||
$arrayCategory = self::$category->create($arrayData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for empty data
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\ProcessCategory::update
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid value for "$arrayData", it can not be empty.
|
||||
*/
|
||||
public function testUpdateExceptionEmptyData()
|
||||
{
|
||||
$arrayData = array();
|
||||
|
||||
$arrayCategory = self::$category->update("", $arrayData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for invalid category UID
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\ProcessCategory::update
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The category with CAT_UID: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' does not exist.
|
||||
*/
|
||||
public function testUpdateExceptionInvalidCatUid()
|
||||
{
|
||||
$arrayData = array(
|
||||
"CAT_NAME" => "PHPUnit My Category N"
|
||||
);
|
||||
|
||||
$arrayCategory = self::$category->update("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", $arrayData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for invalid data (CAT_NAME)
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\ProcessCategory::update
|
||||
*
|
||||
* @depends testCreate
|
||||
* @param array $arrayRecord Data of the categories
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid value for "CAT_NAME", it can not be empty.
|
||||
*/
|
||||
public function testUpdateExceptionInvalidDataCatName(array $arrayRecord)
|
||||
{
|
||||
$arrayData = array(
|
||||
"CAT_NAME" => ""
|
||||
);
|
||||
|
||||
$arrayCategory = self::$category->update($arrayRecord[0]["CAT_UID"], $arrayData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for category name existing
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\ProcessCategory::update
|
||||
*
|
||||
* @depends testCreate
|
||||
* @param array $arrayRecord Data of the categories
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The category name with CAT_NAME: "PHPUnit My Category 0" already exists.
|
||||
*/
|
||||
public function testUpdateExceptionExistsCatName(array $arrayRecord)
|
||||
{
|
||||
$arrayData = $arrayRecord[0];
|
||||
|
||||
$arrayCategory = self::$category->update($arrayRecord[1]["CAT_UID"], $arrayData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test delete categories
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\ProcessCategory::delete
|
||||
*
|
||||
* @depends testCreate
|
||||
* @param array $arrayRecord Data of the categories
|
||||
*/
|
||||
public function testDelete(array $arrayRecord)
|
||||
{
|
||||
foreach ($arrayRecord as $value) {
|
||||
self::$category->delete($value["CAT_UID"]);
|
||||
}
|
||||
|
||||
$arrayCategory = self::$category->getCategories(array("filter" => "PHPUnit"));
|
||||
|
||||
$this->assertTrue(is_array($arrayCategory));
|
||||
$this->assertEmpty($arrayCategory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for invalid category UID
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\ProcessCategory::delete
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The category with CAT_UID: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' does not exist.
|
||||
*/
|
||||
public function testDeleteExceptionInvalidCatUid()
|
||||
{
|
||||
self::$category->delete("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -93,36 +93,38 @@ var cboxAuthSourse = new Ext.form.ComboBox({
|
||||
else
|
||||
window.location = 'authSources_New?AUTH_SOURCE_PROVIDER='+formAuthSourceOptoins.getForm().findField('AUTH_SOURCE_PROVIDER').getValue();
|
||||
return false;*/
|
||||
formAuthSourceOptoins.getForm().submit({
|
||||
waitTitle : " ",
|
||||
url: '../adminProxy/testingOption',
|
||||
params: {
|
||||
action : 'test',
|
||||
optionAuthS: formAuthSourceOptoins.getForm().findField('AUTH_SOURCE_PROVIDER').getValue()
|
||||
},
|
||||
method: 'POST',
|
||||
waitMsg : _('ID_LOADING_GRID'),
|
||||
timeout : 500,
|
||||
success: function(f,a){
|
||||
resp = Ext.util.JSON.decode(a.response.responseText);
|
||||
// alert(resp.optionAuthS);return false;
|
||||
// alert(resp.sUID);return false;
|
||||
if (resp.success){
|
||||
if(resp.optionAuthS=='ldap')
|
||||
// window.location = 'authSources_kindof?sUID='+resp.sUID+'&sprovider='+resp.optionAuthS;
|
||||
window.location = 'authSources_kindof?sprovider='+resp.optionAuthS;
|
||||
else
|
||||
window.location = 'authSources_New?AUTH_SOURCE_PROVIDER='+resp.optionAuthS;
|
||||
}
|
||||
if (formAuthSourceOptoins.getForm().findField('AUTH_SOURCE_PROVIDER').getValue() != '') {
|
||||
formAuthSourceOptoins.getForm().submit({
|
||||
waitTitle : " ",
|
||||
url: '../adminProxy/testingOption',
|
||||
params: {
|
||||
action : 'test',
|
||||
optionAuthS: formAuthSourceOptoins.getForm().findField('AUTH_SOURCE_PROVIDER').getValue()
|
||||
},
|
||||
method: 'POST',
|
||||
waitMsg : _('ID_LOADING_GRID'),
|
||||
timeout : 500,
|
||||
success: function(f,a){
|
||||
resp = Ext.util.JSON.decode(a.response.responseText);
|
||||
if (resp.success) {
|
||||
if (resp.optionAuthS=='ldap') {
|
||||
window.location = 'authSources_kindof?sprovider='+resp.optionAuthS;
|
||||
} else {
|
||||
window.location = 'authSources_New?AUTH_SOURCE_PROVIDER='+resp.optionAuthS;
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
failure: function(f,a){
|
||||
if (a.failureType === Ext.form.Action.CONNECT_FAILURE){
|
||||
Ext.Msg.alert( _('ID_FAILURE'), _('ID_SERVER_REPORTED')+':'+a.response.status+' '+a.response.statusText);
|
||||
}
|
||||
if (a.failureType === Ext.form.Action.SERVER_INVALID){
|
||||
Ext.Msg.alert( _('ID_WARNING'), _('ID_YOU_HAVE_ERROR'));
|
||||
}
|
||||
},
|
||||
failure: function(f,a){
|
||||
if (a.failureType === Ext.form.Action.CONNECT_FAILURE){
|
||||
Ext.Msg.alert( _('ID_FAILURE'), _('ID_SERVER_REPORTED')+':'+a.response.status+' '+a.response.statusText);
|
||||
}
|
||||
if (a.failureType === Ext.form.Action.SERVER_INVALID){
|
||||
Ext.Msg.alert( _('ID_WARNING'), _('ID_YOU_HAVE_ERROR'));
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Ext.Msg.alert( _('ID_FAILURE'), _('ID_CHOOSE_PROVIDER'));
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user