Complete tests, and check validations for WebEntry CRUD.
This commit is contained in:
davidcallizaya
2017-05-22 11:26:15 -04:00
parent bfc0be7e44
commit 2b918b25fc
12 changed files with 227 additions and 45 deletions

View File

@@ -77,4 +77,30 @@ class WorkflowTestCase extends TestCase
exec('../../gulliver/bin/gulliver propel-build-model');
chdir($pwd);
}
/**
* Set the text of and specific translated message.
*
* @global array $translation
* @param type $msgId
* @param type $text
*/
protected function setTranslation($msgId, $text)
{
global $translation;
$translation[$msgId] = $text;
}
/**
* Clear all the translated messages loaded.
*
* @global array $translation
*/
protected function clearTranslations()
{
global $translation;
foreach ($translation as $msgId => $text) {
unset($translation[$msgId]);
}
}
}

View File

@@ -2,7 +2,7 @@
// ProcessMaker Test Unit Bootstrap
// Defining the PATH_SEP constant, he we are defining if the the path separator symbol will be '\\' or '/'
error_reporting(E_ALL ^ E_STRICT);
error_reporting(E_ALL ^ E_STRICT ^ E_DEPRECATED);
define('PATH_SEP', '/');
if (!defined('__DIR__')) {
@@ -232,3 +232,8 @@ define('TIME_ZONE', $config ['time_zone']);
require_once 'WorkflowTestCase.php';
require_once(PATH_CLASSES.'model/Task.php');
global $RBAC;
$RBAC = \RBAC::getSingleton( PATH_DATA, session_id() );
$RBAC->sSystem = 'PROCESSMAKER';
\G::LoadClass('pmFunctions');

View File

@@ -1307,7 +1307,7 @@ class wsBase
return $result;
} catch (Exception $e) {
$result = wsCreateUserResponse( 100, $e->getMessage(), null );
$result = new wsCreateUserResponse( 100, $e->getMessage(), null );
return $result;
}

View File

@@ -79,7 +79,7 @@ class WebEntryEventMapBuilder
$tMap->addColumn('DYN_UID', 'DynUid', 'string', CreoleTypes::VARCHAR, false, 32);
$tMap->addColumn('USR_UID', 'UsrUid', 'string', CreoleTypes::VARCHAR, true, 32);
$tMap->addColumn('USR_UID', 'UsrUid', 'string', CreoleTypes::VARCHAR, false, 32);
$tMap->addColumn('WEE_STATUS', 'WeeStatus', 'string', CreoleTypes::VARCHAR, true, 10);

View File

@@ -55,7 +55,7 @@ abstract class BaseWebEntry extends BaseObject implements Persistent
* The value for the usr_uid field.
* @var string
*/
protected $usr_uid = '';
protected $usr_uid;
/**
* The value for the we_method field.
@@ -560,7 +560,7 @@ abstract class BaseWebEntry extends BaseObject implements Persistent
$v = (string) $v;
}
if ($this->usr_uid !== $v || $v === '') {
if ($this->usr_uid !== $v) {
$this->usr_uid = $v;
$this->modifiedColumns[] = WebEntryPeer::USR_UID;
}

View File

@@ -3334,7 +3334,7 @@
<column name="PRO_UID" type="VARCHAR" size="32" required="true" />
<column name="TAS_UID" type="VARCHAR" size="32" required="true" />
<column name="DYN_UID" type="VARCHAR" size="32" required="false" />
<column name="USR_UID" type="VARCHAR" size="32" default="" />
<column name="USR_UID" type="VARCHAR" size="32" required="false" />
<column name="WE_METHOD" type="VARCHAR" size="4" default="HTML" />
<column name="WE_INPUT_DOCUMENT_ACCESS" type="INTEGER" default="0" />
<column name="WE_DATA" type="LONGVARCHAR" />
@@ -4805,7 +4805,7 @@
<column name="EVN_UID" type="VARCHAR" size="32" required="true" />
<column name="ACT_UID" type="VARCHAR" size="32" required="true" />
<column name="DYN_UID" type="VARCHAR" size="32" required="false" />
<column name="USR_UID" type="VARCHAR" size="32" required="true" />
<column name="USR_UID" type="VARCHAR" size="32" required="false" />
<column name="WEE_STATUS" type="VARCHAR" size="10" required="true" default="ENABLED" />
<column name="WEE_WE_UID" type="VARCHAR" size="32" required="true" default="" />
<column name="WEE_WE_TAS_UID" type="VARCHAR" size="32" required="true" default="" />

View File

@@ -1653,7 +1653,7 @@ CREATE TABLE `WEB_ENTRY`
`PRO_UID` VARCHAR(32) NOT NULL,
`TAS_UID` VARCHAR(32) NOT NULL,
`DYN_UID` VARCHAR(32),
`USR_UID` VARCHAR(32) default '',
`USR_UID` VARCHAR(32),
`WE_METHOD` VARCHAR(4) default 'HTML',
`WE_INPUT_DOCUMENT_ACCESS` INTEGER default 0,
`WE_DATA` MEDIUMTEXT,
@@ -2735,7 +2735,7 @@ CREATE TABLE `WEB_ENTRY_EVENT`
`EVN_UID` VARCHAR(32) NOT NULL,
`ACT_UID` VARCHAR(32) NOT NULL,
`DYN_UID` VARCHAR(32),
`USR_UID` VARCHAR(32) NOT NULL,
`USR_UID` VARCHAR(32),
`WEE_STATUS` VARCHAR(10) default 'ENABLED' NOT NULL,
`WEE_WE_UID` VARCHAR(32) default '' NOT NULL,
`WEE_WE_TAS_UID` VARCHAR(32) default '' NOT NULL,

View File

@@ -171,7 +171,6 @@ class Process
$fieldNameAux = (isset($arrayFieldNameForException[$arrayFieldDefinition[$fieldName]['fieldNameAux']]))? $arrayFieldNameForException[$arrayFieldDefinition[$fieldName]['fieldNameAux']] : $fieldName;
if ($arrayFieldDefinition[$fieldName]["required"] && !isset($arrayData[$fieldName])) {
var_dump($fieldNameAux);
throw new \Exception(\G::LoadTranslation('ID_UNDEFINED_VALUE_IS_REQUIRED', [$fieldNameAux]));
}
}

View File

@@ -8,7 +8,7 @@ class WebEntry
"TAS_UID" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "taskUid"),
"DYN_UID" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "dynaFormUid"),
"USR_UID" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "userUid"),
"USR_UID" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "userUid"),
"WE_TITLE" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "webEntryTitle"),
"WE_DESCRIPTION" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "webEntryDescription"),
"WE_METHOD" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array("WS", "HTML"), "fieldNameAux" => "webEntryMethod"),
@@ -16,7 +16,7 @@ class WebEntry
);
private $arrayUserFieldDefinition = array(
"USR_UID" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "userUid")
"USR_UID" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "userUid")
);
private $formatFieldNameInUppercase = true;
@@ -293,7 +293,7 @@ class WebEntry
}
}
if ($arrayDataMain["WE_METHOD"] == "WS" && isset($arrayData["TAS_UID"])) {
if ($arrayDataMain["WE_METHOD"] == "WS" && isset($arrayData["TAS_UID"]) && (!isset($arrayData["WE_AUTHENTICATION"]) || $arrayData["WE_AUTHENTICATION"]!='LOGIN_REQUIRED')) {
$task = new \Tasks();
if ($task->assignUsertoTask($arrayData["TAS_UID"]) == 0) {

View File

@@ -9,7 +9,7 @@ class WebEntryEvent
"EVN_UID" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "eventUid"),
"ACT_UID" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "activityUid"),
"DYN_UID" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "dynaFormUid"),
"USR_UID" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "userUid"),
"USR_UID" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "userUid"),
"WEE_TITLE" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "webEntryEventTitle"),
"WEE_DESCRIPTION" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "webEntryEventDescription"),
@@ -260,6 +260,15 @@ class WebEntryEvent
//Verify data - Field definition
$process = new \ProcessMaker\BusinessModel\Process();
//Dependent fields:
if (!isset($arrayData['WE_AUTHENTICATION']) || $arrayData['WE_AUTHENTICATION']
== 'ANONYMOUS') {
$this->arrayFieldDefinition['USR_UID']['required'] = true;
}
if (!isset($arrayData['WE_TYPE']) || $arrayData['WE_TYPE']
== 'SINGLE') {
$this->arrayFieldDefinition['DYN_UID']['required'] = true;
}
$process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, $flagInsert);
@@ -371,8 +380,9 @@ class WebEntryEvent
//Task - User
$task = new \Tasks();
$result = $task->assignUser($this->webEntryEventWebEntryTaskUid, $userUid, 1);
if (!(isset($arrayData['WE_AUTHENTICATION']) && $arrayData['WE_AUTHENTICATION']==='LOGIN_REQUIRED')) {
$task->assignUser($this->webEntryEventWebEntryTaskUid, $userUid, 1);
}
//Route
$workflow = \ProcessMaker\Project\Workflow::load($projectUid);
@@ -491,6 +501,14 @@ class WebEntryEvent
$arrayData["WEE_STATUS"] = "ENABLED";
}
if (!array_key_exists('USR_UID', $arrayData)) {
$arrayData['USR_UID'] = null;
}
if (!isset($arrayData["WEE_TITLE"])) {
$arrayData["WEE_TITLE"] = null;
}
//Verify data
$process->throwExceptionIfNotExistsProcess($projectUid, $this->arrayFieldNameForException["projectUid"]);

View File

@@ -32,6 +32,8 @@ class WebEntryEvent extends Api
/**
* @url GET /:prj_uid/web-entry-events
* @access protected
* @class AccessControl {@permission PM_FACTORY}
*
* @param string $prj_uid {@min 32}{@max 32}
*/