Merged in darojas/processmaker (pull request #176)

Se adiciona BEHAT para PMUSER. Fix notice CASE SCHEDULER.
This commit is contained in:
erik ao
2014-02-11 10:09:31 -04:00
3 changed files with 182 additions and 9 deletions

View File

@@ -0,0 +1,169 @@
@ProcessMakerMichelangelo @RestAPI
Feature: User
Background:
Given that I have a valid access_token
#GET /api/1.0/{workspace}/users?filter=abc&start=0&limit=25
# Get list Users
Scenario: Get list Users
And I request "users"
And the content type is "application/json"
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "array"
#GET /api/1.0/{workspace}/users?filter=abc&start=0&limit=25
# Get list Users
Scenario: Get list Users
And I request "users?filter=for basic behat"
And the content type is "application/json"
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "array"
And the json data is an empty array
#GET /api/1.0/{workspace}/user/{usr_uid}
# Get list Users
Scenario: Get list Users
And I request "user/00000000000000000000000000000001"
And the content type is "application/json"
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "object"
#POST /api/1.0/{workspace}/user
# Create new User
Scenario Outline: Create new User
Given POST this data:
"""
{
"usr_firstname": "<usr_firstname>",
"usr_lastname": "<usr_lastname>",
"usr_username": "<usr_username>",
"usr_email": "<usr_email>",
"usr_address": "",
"usr_zip_code": "",
"usr_country": "",
"usr_city": "",
"usr_location": "",
"usr_phone": "",
"usr_position": "",
"usr_replaced_by": "",
"usr_due_date": "<usr_due_date>",
"usr_calendar": "",
"usr_status": "<usr_status>",
"usr_role": "<usr_role>",
"usr_new_pass": "admin",
"usr_cnf_pass": "admin"
}
"""
And I request "user"
And the content type is "application/json"
Then the response status code should be <http_code>
And the response charset is "UTF-8"
And the type is "<type>"
Examples:
|usr_firstname | usr_lastname | usr_username | usr_email | usr_due_date | usr_status | usr_role |http_code| type |
| | bbb | ab | ab@ab.com | 2014-02-10 | ACTIVE | PROCESSMAKER_MANAGER |400 |string|
|aaa | | ab | ab@ab.com | 2014-02-10 | ACTIVE | PROCESSMAKER_MANAGER |400 |string|
|aaa | bbb | | ab@ab.com | 2014-02-10 | ACTIVE | PROCESSMAKER_MANAGER |400 |string|
|aaa | bbb | ab | | 2014-02-10 | ACTIVE | PROCESSMAKER_MANAGER |400 |string|
|aaa | bbb | ab | ab@ab.com | | ACTIVE | PROCESSMAKER_MANAGER |400 |string|
|aaa | bbb | ab | ab@ab.com |2014-02-10 | | PROCESSMAKER_MANAGER |400 |string|
|aaa | bbb | ab | ab@ab.com |2014-02-10 | ACTIVE | |400 |string|
#POST /api/1.0/{workspace}/user
# Create new User
Scenario Outline: Create new User
Given POST this data:
"""
{
"usr_firstname": "<usr_firstname>",
"usr_lastname": "<usr_lastname>",
"usr_username": "<usr_username>",
"usr_email": "<usr_email>",
"usr_address": "",
"usr_zip_code": "",
"usr_country": "",
"usr_city": "",
"usr_location": "",
"usr_phone": "",
"usr_position": "",
"usr_replaced_by": "",
"usr_due_date": "<usr_due_date>",
"usr_calendar": "",
"usr_status": "<usr_status>",
"usr_role": "<usr_role>",
"usr_new_pass": "admin",
"usr_cnf_pass": "admin"
}
"""
And I request "user"
And the content type is "application/json"
Then the response status code should be <http_code>
And the response charset is "UTF-8"
And the type is "<type>"
And store "usr_uid" in session array as variable "usr_uid"
Examples:
|usr_firstname | usr_lastname | usr_username | usr_email | usr_due_date | usr_status | usr_role |http_code| type |
|xxx | yyy | zzz | xy@zzz.com| 2014-02-20 | ACTIVE | PROCESSMAKER_MANAGER |201 |object|
#PUT /api/1.0/{workspace}/user/{usr_uid}
# Update User
Scenario Outline: Update User
Given PUT this data:
"""
{
"usr_firstname": "<usr_firstname>",
"usr_lastname": "<usr_lastname>",
"usr_username": "<usr_username>",
"usr_email": "<usr_email>",
"usr_address": "",
"usr_zip_code": "",
"usr_country": "",
"usr_city": "",
"usr_location": "",
"usr_phone": "",
"usr_position": "",
"usr_replaced_by": "",
"usr_due_date": "<usr_due_date>",
"usr_calendar": "",
"usr_status": "<usr_status>",
"usr_role": "<usr_role>",
"usr_new_pass": "admin",
"usr_cnf_pass": "admin"
}
"""
And that I want to update a resource with the key "usr_uid" stored in session array as variable "usr_uid"
And I request "user"
And the content type is "application/json"
Then the response status code should be <http_code>
And the response charset is "UTF-8"
And the type is "<type>"
Examples:
|usr_firstname | usr_lastname | usr_username | usr_email | usr_due_date | usr_status | usr_role |http_code| type |
|aaa | bbb | ccc | ab@ccc.com| 2014-06-22 | ACTIVE | PROCESSMAKER_OPERATOR |200 |object|
#DELETE /api/1.0/{workspace}/user/{usr_uid}
# Delete User
Scenario: Delete User
Given that I want to delete a resource with the key "usr_uid" stored in session array as variable "usr_uid"
And I request "user"
And the content type is "application/json"
Then the response status code should be 200
And the response charset is "UTF-8"

View File

@@ -747,6 +747,7 @@ class CaseScheduler
$dCurrentDay = date( "d" );
$dCurrentMonth = date( "m" );
$aStartDay = explode( "|", $aData['SCH_START_DAY'] );
$sDateTmp = '';
if ($sOption == '3' && $aStartDay[0] == '1') {
$monthsArray = explode( "|", $sMonths );
foreach ($monthsArray as $row) {

View File

@@ -322,10 +322,11 @@ class User
$aData['USR_PHONE'] = $form['USR_PHONE'];
$aData['USR_ZIP_CODE'] = $form['USR_ZIP_CODE'];
$aData['USR_POSITION'] = $form['USR_POSITION'];
//$aData['USR_ROLE'] = $form['USR_ROLE'];
$aData['USR_REPLACED_BY'] = $form['USR_REPLACED_BY'];
$oUser = new \Users();
$oUser -> create( $aData );
// comment photos files
/*
if ($_FILES['USR_PHOTO']['error'] != 1) {
//print (PATH_IMAGES_ENVIRONMENT_USERS);
if ($_FILES['USR_PHOTO']['tmp_name'] != '') {
@@ -335,7 +336,7 @@ class User
$result->success = false;
$result->fileError = true;
throw new \Exception($oError->$result);
}
}*/
if ((isset($form['USR_CALENDAR']))) {
//Save Calendar ID for this user
\G::LoadClass("calendar");
@@ -487,9 +488,8 @@ class User
$aData['USR_EMAIL'] = $form['USR_EMAIL'];
}
}
if ($form['USR_DUE_DATE'] == '') {
throw new \Exception('`usr_due_date`. '.\G::LoadTranslation('ID_MSG_ERROR_DUE_DATE'));
} else {
if ($form['USR_DUE_DATE'] != '') {
// throw new \Exception('`usr_due_date`. '.\G::LoadTranslation('ID_MSG_ERROR_DUE_DATE'));
$dueDate = explode("-", $form['USR_DUE_DATE']);
if (ctype_digit($dueDate[0])) {
if (checkdate($dueDate[1], $dueDate[2], $dueDate[0]) == false) {
@@ -540,6 +540,8 @@ class User
require_once (PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "Users.php");
$oUser = new \Users();
$oUser->update($aData);
// photo file comment
/*
if ($_FILES['USR_PHOTO']['error'] != 1) {
if ($_FILES['USR_PHOTO']['tmp_name'] != '') {
$aAux = explode('.', $_FILES['USR_PHOTO']['name']);
@@ -550,16 +552,16 @@ class User
$result->success = false;
$result->fileError = true;
throw new \Exception($result);
}
/* Saving preferences */
$def_lang = $form['PREF_DEFAULT_LANG'];
}*/
/* Saving preferences comment */
/*$def_lang = $form['PREF_DEFAULT_LANG'];
$def_menu = $form['PREF_DEFAULT_MENUSELECTED'];
$def_cases_menu = isset($form['PREF_DEFAULT_CASES_MENUSELECTED']) ? $form['PREF_DEFAULT_CASES_MENUSELECTED'] : '';
\G::loadClass('configuration');
$oConf = new \Configurations();
$aConf = Array('DEFAULT_LANG' => $def_lang, 'DEFAULT_MENU' => $def_menu, 'DEFAULT_CASES_MENU' => $def_cases_menu);
$oConf->aConfig = $aConf;
$oConf->saveConfig('USER_PREFERENCES', '', '', $usrLoggedUid);
$oConf->saveConfig('USER_PREFERENCES', '', '', $usrLoggedUid);*/
$oCriteria = $this->getUser($usrUid);
return $oCriteria;
} catch (\Exception $e) {
@@ -697,6 +699,7 @@ class User
public function getUser($userUid)
{
try {
$filter = '';
$aUserInfo = array();
$oUser = \UsersPeer::retrieveByPK($userUid);
if (is_null($oUser)) {