solved conflict composer.lock, config/app.php, workflow/engine/classes/SpoolRun.php

This commit is contained in:
Ronald Q
2019-07-11 11:03:09 -04:00
93 changed files with 7346 additions and 2617 deletions

View File

@@ -13,7 +13,6 @@ class Kernel extends ConsoleKernel
* @var array
*/
protected $commands = [
Commands\PMTranslationsPlugins::class
];
/**
@@ -34,6 +33,6 @@ class Kernel extends ConsoleKernel
*/
protected function commands()
{
$this->load(__DIR__ . '/Commands');
}
}

View File

@@ -0,0 +1,22 @@
<?php
namespace App\Logging;
use Monolog\Formatter\LineFormatter;
class CustomizeFormatter
{
/**
* Customize the given logger instance.
*
* @param \Illuminate\Log\Logger $logger
* @return void
*/
public function __invoke($logger)
{
foreach ($logger->getHandlers() as $handler) {
$handler->setFormatter(new LineFormatter(null, null, true, true));
}
}
}

View File

@@ -50,17 +50,6 @@ $app->singleton(
Handler::class
);
$app->configureMonologUsing(function ($monolog) use ($app) {
$monolog->pushHandler(
(new RotatingFileHandler(
// Set the log path
$app->storagePath() . '/logs/processmaker.log',
// Set the number of daily files you want to keep
$app->make('config')->get('app.log_max_files', 5)
))->setFormatter(new LineFormatter(null, null, true, true))
);
});
/*
|--------------------------------------------------------------------------
| Return The Application

View File

@@ -27,8 +27,8 @@
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=5.6",
"laravel/framework": "5.4.*",
"php": ">=7.1",
"laravel/framework": "5.7.*",
"luracast/restler": "^3.0",
"bshaffer/oauth2-server-php": "v1.0",
"colosa/pmUI": "release/3.3.1-dev",
@@ -43,7 +43,7 @@
"phpmailer/phpmailer": "5.2.27",
"pear/archive_tar": "1.4.*",
"pear/console_getopt": "1.4.*",
"TYPO3/class-alias-loader": "^1.0",
"typo3/class-alias-loader": "^1.0",
"ralouphie/getallheaders": "^2.0",
"smarty/smarty": "2.6.30",
"pdepend/pdepend": "@stable",
@@ -57,7 +57,7 @@
"fzaninotto/faker": "^1.7",
"guzzlehttp/guzzle": "^6.3",
"phpunit/phpunit": "~5.7",
"lmc/steward": "^2.2",
"filp/whoops": "~2.0",
"behat/behat": "^3.3",
"behat/mink-selenium2-driver": "^1.3",
"squizlabs/php_codesniffer": "^2.2 || ^3.0.2",
@@ -103,7 +103,11 @@
},
"scripts": {
"post-install-cmd": "\"vendor/bin/phpcs\" --config-set installed_paths vendor/wimg/php-compatibility",
"post-update-cmd": "\"vendor/bin/phpcs\" --config-set installed_paths vendor/wimg/php-compatibility"
"post-update-cmd": "\"vendor/bin/phpcs\" --config-set installed_paths vendor/wimg/php-compatibility",
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover"
]
},
"extra": {
"typo3/class-alias-loader": {

3511
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -9,24 +9,23 @@ return [
'url' => env('APP_URL', 'http://localhost'),
'env' => env('APP_ENV', 'production'),
'debug' => env('APP_DEBUG', false),
'log' => env('APP_LOG', 'single'),
'log_level' => env('APP_LOG_LEVEL', 'debug'),
'cache_lifetime' => env('APP_CACHE_LIFETIME', 60),
'key' => env('APP_KEY', 'base64:rU28h/tElUn/eiLY0qC24jJq1rakvAFRoRl1DWxj/kM='),
'cipher' => 'AES-256-CBC',
'timezone' => 'UTC',
'providers' => [
CacheServiceProvider::class,
FilesystemServiceProvider::class,
CacheServiceProvider::class,
ViewServiceProvider::class,
Illuminate\Database\DatabaseServiceProvider::class,
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
Illuminate\Queue\QueueServiceProvider::class,
Illuminate\Translation\TranslationServiceProvider::class,
Illuminate\Encryption\EncryptionServiceProvider::class,
Laravel\Tinker\TinkerServiceProvider::class,
ViewServiceProvider::class,
Illuminate\Notifications\NotificationServiceProvider::class,
],
'aliases' => [
'Crypt' => Illuminate\Support\Facades\Crypt::class
],

View File

@@ -70,6 +70,7 @@ workflow/engine/methods/setup/jasper.php
workflow/engine/methods/setup/webServices.php
workflow/engine/methods/setup/webServicesAjax.php
workflow/engine/methods/setup/webServicesList.php
workflow/engine/methods/users/data_usersList.php
workflow/engine/plugins/openFlash.php
workflow/engine/plugins/openFlash/chart-data.php
workflow/engine/plugins/openFlash/chart.php

85
config/logging.php Normal file
View File

@@ -0,0 +1,85 @@
<?php
use Monolog\Handler\StreamHandler;
return [
/*
|--------------------------------------------------------------------------
| Default Log Channel
|--------------------------------------------------------------------------
|
| This option defines the default log channel that gets used when writing
| messages to the logs. The name specified in this option should match
| one of the channels defined in the "channels" configuration array.
|
*/
'default' => env('APP_LOG', env('LOG_CHANNEL', 'daily')),
/*
|--------------------------------------------------------------------------
| Log Channels
|--------------------------------------------------------------------------
|
| Here you may configure the log channels for your application. Out of
| the box, Laravel uses the Monolog PHP logging library. This gives
| you a variety of powerful log handlers / formatters to utilize.
|
| Available Drivers: "single", "daily", "slack", "syslog",
| "errorlog", "monolog",
| "custom", "stack"
|
*/
'channels' => [
'stack' => [
'driver' => 'stack',
'channels' => ['single'],
],
'single' => [
'driver' => 'single',
'path' => storage_path('logs/processmaker.log'),
'level' => 'debug',
],
'daily' => [
'driver' => 'daily',
'tap' => [
App\Logging\CustomizeFormatter::class
],
'path' => storage_path('logs/processmaker.log'),
'level' => env('APP_LOG_LEVEL', 'debug'),
'days' => $app->make('config')->get('app.log_max_files', 5),
],
'slack' => [
'driver' => 'slack',
'url' => env('LOG_SLACK_WEBHOOK_URL'),
'username' => 'Laravel Log',
'emoji' => ':boom:',
'level' => 'critical',
],
'stderr' => [
'driver' => 'monolog',
'handler' => StreamHandler::class,
'with' => [
'stream' => 'php://stderr',
],
],
'syslog' => [
'driver' => 'syslog',
'level' => 'debug',
],
'errorlog' => [
'driver' => 'errorlog',
'level' => 'debug',
],
],
];

View File

@@ -4,16 +4,18 @@
* Model factory for a dynaform.
*/
use Faker\Generator as Faker;
use ProcessMaker\Model\Dynaform;
use ProcessMaker\Model\Process;
$factory->define(\ProcessMaker\Model\Dynaform::class, function(Faker $faker) {
$factory->define(Dynaform::class, function(Faker $faker) {
$date = $faker->dateTime();
return [
'DYN_UID' => G::generateUniqueID(),
'DYN_ID' => '',
'DYN_TITLE' => '',
'DYN_DESCRIPTION' => '',
'DYN_ID' => $faker->unique()->numberBetween(1, 10000),
'DYN_TITLE' => $faker->sentence(2),
'DYN_DESCRIPTION' => $faker->sentence(5),
'PRO_UID' => function() {
$process = factory(\ProcessMaker\Model\Process::class)->create();
$process = factory(Process::class)->create();
return $process->PRO_UID;
},
'DYN_TYPE' => 'xmlform',

View File

@@ -0,0 +1,30 @@
<?php
/**
* Model factory for a input document.
*/
use Faker\Generator as Faker;
use ProcessMaker\Model\InputDocument;
use ProcessMaker\Model\Process;
$factory->define(InputDocument::class, function(Faker $faker) {
return [
'INP_DOC_UID' => G::generateUniqueID(),
'INP_DOC_ID' => $faker->unique()->numberBetween(1, 10000),
'PRO_UID' => function() {
$process = factory(Process::class)->create();
return $process->PRO_UID;
},
'INP_DOC_TITLE' => $faker->sentence(2),
'INP_DOC_DESCRIPTION' => $faker->sentence(10),
'INP_DOC_FORM_NEEDED' => 'VIRTUAL',
'INP_DOC_ORIGINAL' => 'ORIGINAL',
'INP_DOC_PUBLISHED' => 'PRIVATE',
'INP_DOC_VERSIONING' => 0,
'INP_DOC_DESTINATION_PATH' => '',
'INP_DOC_TAGS' => 'INPUT',
'INP_DOC_TYPE_FILE' => '.*',
'INP_DOC_MAX_FILESIZE' => 0,
'INP_DOC_MAX_FILESIZE_UNIT' => 'KB'
];
});

View File

@@ -0,0 +1,43 @@
<?php
/**
* Model factory for a output document.
*/
use Faker\Generator as Faker;
use ProcessMaker\Model\OutputDocument;
use ProcessMaker\Model\Process;
$factory->define(OutputDocument::class, function(Faker $faker) {
$date = $faker->dateTime();
return [
'OUT_DOC_UID' => G::generateUniqueID(),
'OUT_DOC_ID' => $faker->unique()->numberBetween(1, 10000),
'OUT_DOC_TITLE' => $faker->sentence(2),
'OUT_DOC_DESCRIPTION' => $faker->sentence(10),
'OUT_DOC_FILENAME' => $faker->sentence(2),
'OUT_DOC_TEMPLATE' => '',
'PRO_UID' => function() {
$process = factory(Process::class)->create();
return $process->PRO_UID;
},
'OUT_DOC_REPORT_GENERATOR' => 'TCPDF',
'OUT_DOC_LANDSCAPE' => 0,
'OUT_DOC_MEDIA' => 'Letter',
'OUT_DOC_LEFT_MARGIN' => 20,
'OUT_DOC_RIGHT_MARGIN' => 20,
'OUT_DOC_TOP_MARGIN' => 20,
'OUT_DOC_BOTTOM_MARGIN' => 20,
'OUT_DOC_GENERATE' => 'BOTH',
'OUT_DOC_TYPE' => 'HTML',
'OUT_DOC_CURRENT_REVISION' => 0,
'OUT_DOC_FIELD_MAPPING' => '',
'OUT_DOC_VERSIONING' => 1,
'OUT_DOC_DESTINATION_PATH' => '',
'OUT_DOC_TAGS' => '',
'OUT_DOC_PDF_SECURITY_ENABLED' => 0,
'OUT_DOC_PDF_SECURITY_OPEN_PASSWORD' => '',
'OUT_DOC_PDF_SECURITY_OWNER_PASSWORD' => '',
'OUT_DOC_PDF_SECURITY_PERMISSIONS' => '',
'OUT_DOC_OPEN_TYPE' => 1
];
});

View File

@@ -0,0 +1,21 @@
<?php
use Faker\Generator as Faker;
use ProcessMaker\Model\ProcessVariables;
$factory->define(ProcessVariables::class, function (Faker $faker) {
return [
'VAR_UID' => G::generateUniqueID(),
'PRJ_UID' => G::generateUniqueID(),
'VAR_NAME' => $faker->word,
'VAR_FIELD_TYPE' => G::generateUniqueID(),
'VAR_FIELD_SIZE' => 10,
'VAR_LABEL' => 'string',
'VAR_DBCONNECTION' => 'workflow',
'VAR_SQL' => '',
'VAR_NULL' => 0,
'VAR_DEFAULT' => '',
'VAR_ACCEPTED_VALUES' => '',
'INP_DOC_UID' => ''
];
});

View File

@@ -0,0 +1,16 @@
<?php
use Faker\Generator as Faker;
use ProcessMaker\Model\Triggers;
$factory->define(Triggers::class, function (Faker $faker) {
return [
'TRI_UID' => G::generateUniqueID(),
'TRI_TITLE' => $faker->sentence(5),
'TRI_DESCRIPTION' => $faker->text,
'PRO_UID' => G::generateUniqueID(),
'TRI_TYPE' => 'SCRIPT',
'TRI_WEBBOT' => $faker->text,
'TRI_PARAM' => '',
];
});

View File

@@ -1839,7 +1839,7 @@ class Bootstrap
*
* @return multitype:string mixed Ambigous <number, string>
*/
public function parseNormalUri($aRequestUri, array $arrayFriendlyUri = null)
public static function parseNormalUri($aRequestUri, array $arrayFriendlyUri = null)
{
if (substr($aRequestUri[1], 0, 3) == 'sys') {
define('SYS_TEMP', substr($aRequestUri[1], 3));

View File

@@ -1636,16 +1636,13 @@ class G
/**
* Escapes special characters in a string for use in a SQL statement
* @param string $sqlString The string to be escaped
* @param string $dbEngine Target DBMS
*
* @return string
*/
public static function sqlEscape($sqlString, $dbEngine = DB_ADAPTER)
* @param string $sqlString The string to be escaped
* @param string $DBEngine Target DBMS
*/
public static function sqlEscape($sqlString, $DBEngine = DB_ADAPTER)
{
// @todo: Research why always this value is set with the same constant?
$dbEngine = DB_ADAPTER;
switch ($dbEngine) {
$DBEngine = DB_ADAPTER;
switch ($DBEngine) {
case 'mysql':
$con = Propel::getConnection('workflow');
return mysqli_real_escape_string($con->getResource(), stripslashes($sqlString));
@@ -1692,15 +1689,9 @@ class G
* @# Non-quoted parameter
* @! Evaluate string : Replace the parameters in value and then in the sql string
* @fn() Evaluate string with the function "fn"
*
* @param string $sqlString
* @param array $result
* @param string $dbEngine
* @param bool $applyHtmlEntities
*
* @return string
* @author David Callizaya <calidavidx21@hotmail.com>
*/
public static function replaceDataField($sqlString, $result, $dbEngine = 'mysql', $applyHtmlEntities = false)
public static function replaceDataField($sqlString, $result, $DBEngine = 'mysql', $recursive = true)
{
if (!is_array($result)) {
$result = array();
@@ -1719,12 +1710,7 @@ class G
$u = $match[0][$r][1] + strlen($match[0][$r][0]);
//Mysql quotes scape
if (($match[1][$r][0] == '@') && (isset($result[$match[2][$r][0]]))) {
$text = ($applyHtmlEntities && !stringIsValidHtml($result[$match[2][$r][0]])) ?
htmlentities(G::unhtmlentities($result[$match[2][$r][0]]), ENT_COMPAT, 'UTF-8') :
$result[$match[2][$r][0]];
// Replenish the tag <br /> because is valid
$text = str_replace('&lt;br /&gt;', '<br />', $text);
$__textoEval .= "\"" . G::sqlEscape($text, $dbEngine) . "\"";
$__textoEval .= "\"" . G::sqlEscape($result[$match[2][$r][0]], $DBEngine) . "\"";
continue;
}
//URL encode
@@ -1744,7 +1730,7 @@ class G
}
//Substring (Sub replaceDataField)
if (($match[1][$r][0] == '!') && (isset($result[$match[2][$r][0]]))) {
$__textoEval .= G::replaceDataField($result[$match[2][$r][0]], $result, $dbEngine, $applyHtmlEntities);
$__textoEval .= G::replaceDataField($result[$match[2][$r][0]], $result);
continue;
}
//Call function
@@ -1762,33 +1748,18 @@ class G
}
//Non-quoted
if (($match[1][$r][0] == '#') && (isset($result[$match[2][$r][0]]))) {
$text = ($applyHtmlEntities && !stringIsValidHtml($result[$match[2][$r][0]]) && $match[2][$r][0] !== '__ABE__') ?
htmlentities(G::unhtmlentities($result[$match[2][$r][0]]), ENT_COMPAT, 'UTF-8') :
$result[$match[2][$r][0]];
// Replenish the tag <br /> because is valid
$text = str_replace('&lt;br /&gt;', '<br />', $text);
$__textoEval .= G::replaceDataField($text, $result);
$__textoEval .= $recursive ? G::replaceDataField($result[$match[2][$r][0]], $result) : $result[$match[2][$r][0]];
continue;
}
//Non-quoted =
if (($match[1][$r][0] == '=') && (isset($result[$match[2][$r][0]]))) {
$text = ($applyHtmlEntities && !stringIsValidHtml($result[$match[2][$r][0]]) && $match[2][$r][0] !== '__ABE__') ?
htmlentities(G::unhtmlentities($result[$match[2][$r][0]]), ENT_COMPAT, 'UTF-8') :
$result[$match[2][$r][0]];
// Replenish the tag <br /> because is valid
$text = str_replace('&lt;br /&gt;', '<br />', $text);
$__textoEval .= G::replaceDataField($text, $result);
$__textoEval .= $recursive ? G::replaceDataField($result[$match[2][$r][0]], $result) : $result[$match[2][$r][0]];
continue;
}
//Objects attributes
if (($match[1][$r][0] == '&') && (isset($result[$match[2][$r][0]]))) {
if (isset($result[$match[2][$r][0]]->{$match[6][$r][0]})) {
$text = ($applyHtmlEntities && !stringIsValidHtml($result[$match[2][$r][0]]->{$match[6][$r][0]})) ?
htmlentities(G::unhtmlentities($result[$match[2][$r][0]]->{$match[6][$r][0]}), ENT_COMPAT, 'UTF-8') :
$result[$match[2][$r][0]]->{$match[6][$r][0]};
// Replenish the tag <br /> because is valid
$text = str_replace('&lt;br /&gt;', '<br />', $text);
$__textoEval .= $text;
$__textoEval .= $result[$match[2][$r][0]]->{$match[6][$r][0]};
}
continue;
}
@@ -1800,35 +1771,27 @@ class G
}
/**
* Replace Grid Values in a string.
* The tag @>GRID-NAME to open the grid and @<GRID-NAME to close the grid,
*
* @param string $content
* @param array $fields
* @param bool $nl2brRecursive
* @param bool $applyHtmlEntities
*
* @return string
*
* @see \Cases->sendMessage()
* @see \WsBase->sendMessage()
* @see \OutputDocument->generate()
* @see \ProcessMaker\BusinessModel\Cases\OutputDocument->generate()
*/
public static function replaceDataGridField($content, $fields, $nl2brRecursive = true, $applyHtmlEntities = false)
* Replace Grid Values
* The tag @>GRID-NAME to open the grid and @<GRID-NAME to close the grid,
*
* @param type String $sContent
* @param type Array $aFields
* @return type String
*/
public static function replaceDataGridField($sContent, $aFields, $nl2brRecursive = true)
{
$nrt = array("\n", "\r", "\t");
$nrthtml = array("(n /)", "(r /)", "(t /)");
$strContentAux = str_replace($nrt, $nrthtml, $content);
$sContent = G::unhtmlentities($sContent);
$strContentAux = str_replace($nrt, $nrthtml, $sContent);
$occurrences = preg_match_all('/\@(?:([\>])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]*(?:[\\\\][\w\W])?)*)\))((?:\s*\[[\'"]?\w+[\'"]?\])+)?/',
$strContentAux, $arrayMatch1, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE);
$iOcurrences = preg_match_all('/\@(?:([\>])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]*(?:[\\\\][\w\W])?)*)\))((?:\s*\[[\'"]?\w+[\'"]?\])+)?/', $strContentAux, $arrayMatch1, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE);
if ($occurrences) {
if ($iOcurrences) {
$arrayGrid = array();
for ($i = 0; $i <= $occurrences - 1; $i++) {
for ($i = 0; $i <= $iOcurrences - 1; $i++) {
$arrayGrid[] = $arrayMatch1[2][$i][0];
}
@@ -1854,16 +1817,16 @@ class G
while (preg_match($ereg, $strContentAux1, $arrayMatch2)) {
$strData = null;
if (isset($fields[$grdName]) && is_array($fields[$grdName])) {
foreach ($fields[$grdName] as $aRow) {
if (isset($aFields[$grdName]) && is_array($aFields[$grdName])) {
foreach ($aFields[$grdName] as $aRow) {
if ($nl2brRecursive) {
foreach ($aRow as $key => $item) {
if (!is_array($item)) {
$aRow[$key] = str_replace($nrt, $nrthtml, nl2br($aRow[$key]));
foreach ($aRow as $sKey => $vValue) {
if (!is_array($vValue)) {
$aRow[$sKey] = str_replace($nrt, $nrthtml, nl2br($aRow[$sKey]));
}
}
}
$strData = $strData . G::replaceDataField($arrayMatch2[2], $aRow, 'mysql', $applyHtmlEntities);
$strData = $strData . G::replaceDataField($arrayMatch2[2], $aRow, 'mysql', false);
}
}
@@ -1878,19 +1841,19 @@ class G
$strContentAux = str_replace($nrthtml, $nrt, $strContentAux);
$content = $strContentAux;
$sContent = $strContentAux;
if ($nl2brRecursive) {
foreach ($fields as $key => $item) {
if (!is_array($item) && !is_object($item)) {
$fields[$key] = nl2br($fields[$key]);
foreach ($aFields as $sKey => $vValue) {
if (!is_array($vValue) && !is_object($vValue)) {
$aFields[$sKey] = nl2br($aFields[$sKey]);
}
}
}
$content = G::replaceDataField($content, $fields, 'mysql', $applyHtmlEntities);
$sContent = G::replaceDataField($sContent, $aFields, 'mysql', false);
return $content;
return $sContent;
}
/**
@@ -5097,11 +5060,308 @@ class G
public static function reservedWordsSql()
{
//Reserved words SQL
$reservedWordsSql = array("ACCESSIBLE","ACTION","ADD","ALL","ALTER","ANALYZE","AND","ANY","AS","ASC","ASENSITIVE","AUTHORIZATION","BACKUP","BEFORE","BEGIN","BETWEEN","BIGINT","BINARY","BIT","BLOB","BOTH","BREAK","BROWSE","BULK","BY","CALL","CASCADE","CASE","CHANGE","CHAR","CHARACTER","CHECK","CHECKPOINT","CLOSE","CLUSTERED","COALESCE","COLLATE","COLUMN","COMMIT","COMPUTE","CONDITION","CONSTRAINT","CONTAINS","CONTAINSTABLE","CONTINUE","CONVERT","CREATE","CROSS","CURRENT","CURRENT_DATE","CURRENT_TIME","CURRENT_TIMESTAMP","CURRENT_USER","CURSOR","DATABASE","DATABASES","DATE","DAY_HOUR","DAY_MICROSECOND","DAY_MINUTE","DAY_SECOND","DBCC","DEALLOCATE","DEC","DECIMAL","DECLARE","DEFAULT","DELAYED","DELETE","DENY","DESC","DESCRIBE","DETERMINISTIC","DISK","DISTINCT","DISTINCTROW",
"DISTRIBUTED","DIV","DOUBLE","DROP","DUAL","DUMMY","DUMP","EACH","ELSE","ELSEIF","ENCLOSED","END","ENUM","ERRLVL","ESCAPE","ESCAPED","EXCEPT","EXEC","EXECUTE","EXISTS","EXIT","EXPLAIN","FALSE","FETCH","FILE","FILLFACTOR","FLOAT","FLOAT4","FLOAT8","FOR","FORCE","FOREIGN","FREETEXT","FREETEXTTABLE","FROM","FULL","FULLTEXT","FUNCTION","GENERAL","GOTO","GRANT","GROUP","HAVING","HIGH_PRIORITY","HOLDLOCK","HOUR_MICROSECOND","HOUR_MINUTE","HOUR_SECOND","IDENTITY","IDENTITYCOL","IDENTITY_INSERT","IF","IGNORE","IGNORE_SERVER_IDS","IN","INDEX","INFILE","INNER","INOUT","INSENSITIVE","INSERT","INT","INT1","INT2","INT3","INT4","INT8","INTEGER","INTERSECT","INTERVAL","INTO","IS","ITERATE","JOIN","KEY","KEYS","KILL","LEADING","LEAVE","LEFT","LIKE","LIMIT","LINEAR","LINENO","LINES",
"LOAD","LOCALTIME","LOCALTIMESTAMP","LOCK","LONG","LONGBLOB","LONGTEXT","LOOP","LOW_PRIORITY","MASTER_HEARTBEAT_PERIOD","MASTER_SSL_VERIFY_SERVER_CERT","MATCH","MAXVALUE","MEDIUMBLOB","MEDIUMINT","MEDIUMTEXT","MIDDLEINT","MINUTE_MICROSECOND","MINUTE_SECOND","MOD","MODIFIES","NATIONAL","NATURAL","NO","NOCHECK","NONCLUSTERED","NOT","NO_WRITE_TO_BINLOG","NULL","NULLIF","NUMERIC","OF","OFF","OFFSETS","ON","OPEN","OPENDATASOURCE","OPENQUERY","OPENROWSET","OPENXML","OPTIMIZE","OPTION","OPTIONALLY","OR","ORDER","OUT","OUTER","OUTFILE","OVER","PERCENT","PLAN","PRECISION","PRIMARY","PRINT","PROC","PROCEDURE","PUBLIC","PURGE","RAISERROR","RANGE","READ","READS","READTEXT","READ_WRITE","REAL","RECONFIGURE","REFERENCES","REGEXP","RELEASE","RENAME","REPEAT","REPLACE",
"REPLICATION","REQUIRE","RESIGNAL","RESTORE","RESTRICT","RETURN","REVOKE","RIGHT","RLIKE","ROLLBACK","ROWCOUNT","ROWGUIDCOL","RULE","SAVE","SCHEMA","SCHEMAS","SECOND_MICROSECOND","SELECT","SENSITIVE","SEPARATOR","SESSION_USER","SET","SETUSER","SHOW","SHUTDOWN","SIGNAL","SLOW","SMALLINT","SOME","SPATIAL","SPECIFIC","SQL","SQLEXCEPTION","SQLSTATE","SQLWARNING","SQL_BIG_RESULT","SQL_CALC_FOUND_ROWS","SQL_SMALL_RESULT","SSL","STARTING","STATISTICS","STRAIGHT_JOIN","SYSTEM_USER","TABLE","TERMINATED","TEXT","TEXTSIZE","THEN","TIME","TIMESTAMP","TINYBLOB","TINYINT","TINYTEXT","TO","TOP","TRAILING","TRAN","TRANSACTION","TRIGGER","TRUE","TRUNCATE","TSEQUAL","UNDO","UNION","UNIQUE","UNLOCK","UNSIGNED","UPDATE","UPDATETEXT","USAGE","USE","USER","USING","UTC_DATE","UTC_TIME",
"UTC_TIMESTAMP","VALUES","VARBINARY","VARCHAR","VARCHARACTER","VARYING","VIEW","WAITFOR","WHEN","WHERE","WHILE","WITH","WRITE","WRITETEXT","XOR","YEAR_MONTH","ZEROFILL");
$reservedWordsSql = [
"ACCESSIBLE",
"ADD",
"ALL",
"ALTER",
"ANALYZE",
"AND",
"AS",
"ASC",
"ASENSITIVE",
"AUTHORIZATION",
"BEFORE",
"BETWEEN",
"BIGINT",
"BINARY",
"BLOB",
"BOTH",
"BREAK",
"BROWSE",
"BULK",
"BY",
"CALL",
"CASCADE",
"CASE",
"CHANGE",
"CHAR",
"CHARACTER",
"CHECK",
"CHECKPOINT",
"CLUSTERED",
"COLLATE",
"COLUMN",
"COMPUTE",
"CONDITION",
"CONSTRAINT",
"CONTAINSTABLE",
"CONTINUE",
"CONVERT",
"CREATE",
"CROSS",
"CURRENT_DATE",
"CURRENT_TIME",
"CURRENT_TIMESTAMP",
"CURRENT_USER",
"CURSOR",
"DATABASE",
"DATABASES",
"DAY_HOUR",
"DAY_MICROSECOND",
"DAY_MINUTE",
"DAY_SECOND",
"DBCC",
"DEC",
"DECIMAL",
"DECLARE",
"DEFAULT",
"DELAYED",
"DELETE",
"DENY",
"DESC",
"DESCRIBE",
"DETERMINISTIC",
"DISTINCT",
"DISTINCTROW",
"DISTRIBUTED",
"DIV",
"DOUBLE",
"DROP",
"DUAL",
"DUMMY",
"DUMP",
"EACH",
"ELSE",
"ELSEIF",
"ENCLOSED",
"ERRLVL",
"ESCAPED",
"EXCEPT",
"EXEC",
"EXISTS",
"EXIT",
"EXPLAIN",
"FALSE",
"FETCH",
"FILLFACTOR",
"FLOAT",
"FLOAT4",
"FLOAT8",
"FOR",
"FORCE",
"FOREIGN",
"FREETEXT",
"FREETEXTTABLE",
"FROM",
"FULLTEXT",
"GENERATED",
"GET",
"GOTO",
"GRANT",
"GROUP",
"HAVING",
"HIGH_PRIORITY",
"HOLDLOCK",
"HOUR_MICROSECOND",
"HOUR_MINUTE",
"HOUR_SECOND",
"IDENTITY",
"IDENTITYCOL",
"IDENTITY_INSERT",
"IF",
"IGNORE",
"IN",
"INDEX",
"INFILE",
"INNER",
"INOUT",
"INSENSITIVE",
"INSERT",
"INT",
"INT1",
"INT2",
"INT3",
"INT4",
"INT8",
"INTEGER",
"INTERSECT",
"INTERVAL",
"INTO",
"IO_AFTER_GTIDS",
"IO_BEFORE_GTIDS",
"IS",
"ITERATE",
"JOIN",
"KEY",
"KEYS",
"KILL",
"LEADING",
"LEAVE",
"LEFT",
"LIKE",
"LIMIT",
"LINEAR",
"LINENO",
"LINES",
"LOAD",
"LOCALTIME",
"LOCALTIMESTAMP",
"LOCK",
"LONG",
"LONGBLOB",
"LONGTEXT",
"LOOP",
"LOW_PRIORITY",
"MASTER_BIND",
"MASTER_SSL_VERIFY_SERVER_CERT",
"MATCH",
"MAXVALUE",
"MEDIUMBLOB",
"MEDIUMINT",
"MEDIUMTEXT",
"MIDDLEINT",
"MINUTE_MICROSECOND",
"MINUTE_SECOND",
"MOD",
"MODIFIES",
"NATURAL",
"NOCHECK",
"NONCLUSTERED",
"NOT",
"NO_WRITE_TO_BINLOG",
"NULL",
"NULLIF",
"NUMERIC",
"OF",
"OFF",
"OFFSETS",
"ON",
"OPENDATASOURCE",
"OPENQUERY",
"OPENROWSET",
"OPENXML",
"OPTIMIZE",
"OPTIMIZER_COSTS",
"OPTION",
"OPTIONALLY",
"OR",
"ORDER",
"OUT",
"OUTER",
"OUTFILE",
"OVER",
"PARTITION",
"PARSE_GCOL_EXPR",
"PERCENT",
"PLAN",
"PRECISION",
"PRIMARY",
"PRINT",
"PROC",
"PROCEDURE",
"PUBLIC",
"PURGE",
"RAISERROR",
"RANGE",
"READ",
"READS",
"READTEXT",
"READ_WRITE",
"REAL",
"RECONFIGURE",
"REFERENCES",
"REGEXP",
"RELEASE",
"RENAME",
"REPEAT",
"REPLACE",
"REQUIRE",
"RESIGNAL",
"RESTRICT",
"RETURN",
"REVOKE",
"RIGHT",
"RLIKE",
"ROWCOUNT",
"ROWGUIDCOL",
"RULE",
"SAVE",
"SCHEMA",
"SCHEMAS",
"SECOND_MICROSECOND",
"SELECT",
"SENSITIVE",
"SEPARATOR",
"SESSION_USER",
"SET",
"SETUSER",
"SHOW",
"SIGNAL",
"SMALLINT",
"SPATIAL",
"SPECIFIC",
"SQL",
"SQLEXCEPTION",
"SQLSTATE",
"SQLWARNING",
"SQL_AFTER_GTIDS",
"SQL_BEFORE_GTIDS",
"SQL_BIG_RESULT",
"SQL_CALC_FOUND_ROWS",
"SQL_SMALL_RESULT",
"SSL",
"STARTING",
"STATISTICS",
"STORED",
"STRAIGHT_JOIN",
"SYSTEM_USER",
"TABLE",
"TERMINATED",
"TEXTSIZE",
"THEN",
"TINYBLOB",
"TINYINT",
"TINYTEXT",
"TO",
"TOP",
"TRAILING",
"TRAN",
"TRIGGER",
"TRUE",
"TSEQUAL",
"UNDO",
"UNION",
"UNIQUE",
"UNLOCK",
"UNSIGNED",
"UPDATE",
"UPDATETEXT",
"USAGE",
"USE",
"USING",
"UTC_DATE",
"UTC_TIME",
"UTC_TIMESTAMP",
"VALUES",
"VARBINARY",
"VARCHAR",
"VARCHARACTER",
"VARYING",
"VIRTUAL",
"WAITFOR",
"WHEN",
"WHERE",
"WHILE",
"WITH",
"WRITE",
"WRITETEXT",
"XOR",
"YEAR_MONTH",
"ZEROFILL",
"_FILENAME"
];
return $reservedWordsSql;
}

View File

@@ -213,7 +213,7 @@ class RBAC
* @access public
* @return object
*/
public function &getSingleton()
public static function &getSingleton()
{
if (self::$instance == null) {
self::$instance = new RBAC();

View File

@@ -15,7 +15,10 @@
<directory>./tests/workflow/engine/src/</directory>
</testsuite>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
<directory suffix="Test.php">./tests/unit</directory>
</testsuite>
<testsuite name="Performance">
<directory>./tests/Performance/</directory>
</testsuite>
</testsuites>
@@ -33,6 +36,10 @@
</filter>
<php>
<!--Main environment-->
<env name="MAIN_SYS_SYS" value="workflow" />
<env name="MAIN_TIME_ZONE" value="America/New_York" />
<env name="MAIN_SYSTEM_UTC_TIME_ZONE" value="1" />
<!--Connection to database-->
<env name="DB_HOST" value="127.0.0.1" />
<env name="DB_DATABASE" value="test" />
@@ -45,6 +52,8 @@
<env name="MSSQL_DATABASE" value="testexternal" />
<env name="MSSQL_USERNAME" value="test" />
<env name="MSSQL_PASSWORD" value="test" />
<!--Performance Mysql test-->
<env name="RUN_MYSQL_PERFORMANCE_TESTS" value="false" />
<!--Php variables-->
<var name="APP_ENV" value="testing" />
<var name="SYS_SYS" value="test" />

View File

@@ -1,43 +1,56 @@
<?php
namespace Tests\Feature;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Queue\Console\WorkCommand;
use Illuminate\Support\Facades\DB;
use ProcessMaker\Model\DbSource;
use ProcessMaker\Model\Process;
use Tests\TestCase;
use Propel;
use DbConnections;
class DBQueryTest extends TestCase
{
use DatabaseTransactions;
/**
* A basic cache example.
*
* @return void
* Sets up the unit tests.
*/
protected function setUp()
{
}
/**
* Verify the execution of a common SQL statement.
* @test
*/
public function testStandardExecuteQuery()
{
$results = executeQuery("SELECT * FROM USERS WHERE USR_UID = '00000000000000000000000000000001'");
$this->assertCount(1, $results);
// Note, we check index 1 because results from executeQuery are 1 indexed, not 0 indexed.
$this->assertArraySubset([
$expected = [
'USR_UID' => '00000000000000000000000000000001',
'USR_USERNAME' => 'admin'
], $results[1]);
];
$this->assertArraySubset($expected, $results[1]);
}
/**
* Verify the existence of the admin user.
* @test
*/
public function testDBFacadeQuery()
{
$record = DB::table('USERS')->where([
'USR_UID' => '00000000000000000000000000000001'
])->first();
$record = DB::table('USERS')->where('USR_UID', '=', '00000000000000000000000000000001')->first();
$this->assertEquals('admin', $record->USR_USERNAME);
}
/**
* Verify the execution of a SQL statement common to an MySQL external database.
* @test
*/
public function testStandardExecuteQueryWithExternalMySQLDatabase()
{
// Our test external database is created in our tests/bootstrap.php file
@@ -45,12 +58,12 @@ class DBQueryTest extends TestCase
$process = factory(Process::class)->create();
// Let's create an external DB to ourselves
$externalDB = factory(DbSource::class)->create([
'DBS_SERVER' => 'localhost',
'DBS_SERVER' => config('database.connections.testexternal.host'),
'DBS_PORT' => '3306',
'DBS_USERNAME' => env('DB_USERNAME'),
'DBS_USERNAME' => config('database.connections.testexternal.username'),
// Remember, we have to do some encryption here @see DbSourceFactory.php
'DBS_PASSWORD' => \G::encrypt( env('DB_PASSWORD'), 'testexternal') . "_2NnV3ujj3w",
'DBS_DATABASE_NAME' => 'testexternal',
'DBS_PASSWORD' => \G::encrypt(env('DB_PASSWORD'), config('database.connections.testexternal.database')) . "_2NnV3ujj3w",
'DBS_DATABASE_NAME' => config('database.connections.testexternal.database'),
'PRO_UID' => $process->PRO_UID
]);
@@ -65,9 +78,13 @@ class DBQueryTest extends TestCase
$this->assertEquals('testvalue', $results[1]['value']);
}
/**
* Verify the execution of a SQL statement common to an MSSQL external database.
* @test
*/
public function testStandardExecuteQueryWithExternalMSSqlDatabase()
{
if(!env('RUN_MSSQL_TESTS')) {
if (!env('RUN_MSSQL_TESTS')) {
$this->markTestSkipped('MSSQL Related Test Skipped');
}
// Our test external database is created in our tests/bootstrap.php file
@@ -80,8 +97,8 @@ class DBQueryTest extends TestCase
'DBS_TYPE' => 'mssql',
'DBS_USERNAME' => env('MSSQL_USERNAME'),
// Remember, we have to do some encryption here @see DbSourceFactory.php
'DBS_PASSWORD' => \G::encrypt( env('MSSQL_PASSWORD'), 'testexternal') . "_2NnV3ujj3w",
'DBS_DATABASE_NAME' => 'testexternal',
'DBS_PASSWORD' => \G::encrypt(env('MSSQL_PASSWORD'), env('MSSQL_DATABASE')) . "_2NnV3ujj3w",
'DBS_DATABASE_NAME' => env('MSSQL_DATABASE'),
'PRO_UID' => $process->PRO_UID
]);
// Now set our process ID
@@ -94,4 +111,4 @@ class DBQueryTest extends TestCase
$this->assertCount(1, $results);
$this->assertEquals('testvalue', $results[1]['value']);
}
}
}

View File

@@ -0,0 +1,514 @@
<?php
namespace Tests\Perfomance\workflow\src\ProcessMaker\Model;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use ProcessMaker\Model\AppAssignSelfServiceValue;
use ProcessMaker\Model\AppAssignSelfServiceValueGroup;
use ProcessMaker\Model\Application;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\GroupUser;
use ProcessMaker\Model\Groupwf;
use ProcessMaker\Model\Process;
use ProcessMaker\Model\Task;
use ProcessMaker\Model\TaskUser;
use ProcessMaker\Model\User;
use Tests\TestCase;
class DelegationTest extends TestCase
{
use DatabaseTransactions;
//This parameter is used for performance test, It has to be divisible by 4, because we have 4 types of self-service
private $totalCases;
//This parameter is used for performance test, It the maximum time in seconds
private $maximumExecutionTime;
/**
* Define values of some parameters of the test
*/
protected function setUp()
{
if (!env('RUN_MYSQL_PERFORMANCE_TESTS')) {
$this->markTestSkipped('Test related to the performance are disabled for this server configuration');
} else {
$this->totalCases = (int)env('TOTAL_CASES', 120);
$this->maximumExecutionTime = (int)env('MAX_EXECUTION_TIME', 60);
}
}
/**
* This checks the counters is working properly in self-service user assigned
* @covers Delegation::countSelfService
* @test
*/
public function it_should_count_cases_by_user_with_self_service_user_assigned()
{
//Define the total of cases to create
$total = $this->totalCases;
//Define the maximum time of execution
$maximumTime = $this->maximumExecutionTime;
//Create process
$process = factory(Process::class)->create();
//Create user
$user = factory(User::class)->create();
//Create a task self service
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create the register in delegation relate to self-service
factory(Delegation::class, $total)->create([
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the count self-service
$timeStart = microtime(true);
Delegation::countSelfService($user->USR_UID);
$timeEnd = microtime(true);
$time = $timeEnd - $timeStart;
//Compare if the time of execution is minor than the time defined in the .env
$this->assertLessThan($maximumTime, $time);
error_log('it_should_count_cases_by_user_with_self_service_user_assigned took [' . $total . ']--->' . $time);
}
/**
* This checks the counters is working properly in self-service-value-based when the variable has a value related with the USR_UID
* When the value assigned in the variable @@ARRAY_OF_USERS = [USR_UID]
* @covers Delegation::countSelfService
* @test
*/
public function it_should_count_cases_by_user_with_self_service_value_based_usr_uid()
{
//Define the total of cases to create
$total = $this->totalCases;
//Define the maximum time of execution
$maximumTime = $this->maximumExecutionTime;
//Create process
$process = factory(Process::class)->create();
//Create a case
$application = factory(Application::class)->create();
//Create user
$user = factory(User::class)->create();
//Create a task self service value based
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
'PRO_UID' => $process->PRO_UID
]);
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => 2,
'TAS_ID' => $task->TAS_ID
]);
factory(AppAssignSelfServiceValueGroup::class)->create([
'ID' => $appSelfValue->ID,
'GRP_UID' => $user->USR_UID,
'ASSIGNEE_ID' => $user->USR_ID, //The usrId or grpId
'ASSIGNEE_TYPE' => 1 //Related to the user=1 related to the group=2
]);
//Create the register in self-service
factory(Delegation::class, $total)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => $appSelfValue->DEL_INDEX,
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the count self-service
$timeStart = microtime(true);
Delegation::countSelfService($user->USR_UID);
$timeEnd = microtime(true);
$time = $timeEnd - $timeStart;
//Compare if the time of execution is minor than the time defined in the .env
$this->assertLessThan($maximumTime, $time);
error_log('it_should_count_cases_by_user_with_self_service_value_based_usr_uid took [' . $total . ']--->' . $time);
}
/**
* This checks the counters is working properly in self-service and self-service value based
* @covers Delegation::countSelfService
* @test
*/
public function it_should_count_cases_by_user_with_self_service_mixed_with_self_service_value_based()
{
//Define the total of cases to create
$total = $this->totalCases;
//Define the maximum time of execution
$maximumTime = $this->maximumExecutionTime;
//Create process
$process = factory(Process::class)->create();
//Create a case
$application = factory(Application::class)->create();
//Create user
$user = factory(User::class)->create();
//Create a task self service
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create the register in self service
factory(Delegation::class, $total / 2)->create([
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Create a task self service value based
$task1 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
'PRO_UID' => $process->PRO_UID
]);
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => 2,
'TAS_ID' => $task1->TAS_ID
]);
factory(AppAssignSelfServiceValueGroup::class)->create([
'ID' => $appSelfValue->ID,
'GRP_UID' => $user->USR_UID,
'ASSIGNEE_ID' => $user->USR_ID, //The usrId or grpId
'ASSIGNEE_TYPE' => 1 //Related to the user=1 related to the group=2
]);
//Create the register in self service value based
factory(Delegation::class, $total / 2)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => $appSelfValue->DEL_INDEX,
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the count self-service
$timeStart = microtime(true);
Delegation::countSelfService($user->USR_UID);
$timeEnd = microtime(true);
$time = $timeEnd - $timeStart;
//Compare if the time of execution is minor than the time defined in the .env
$this->assertLessThan($maximumTime, $time);
error_log('it_should_count_cases_by_user_with_self_service_mixed_with_self_service_value_based took [' . $total . ']--->' . $time);
}
/**
* This checks the counters is working properly in self-service group assigned
* @covers Delegation::countSelfService
* @test
*/
public function it_should_count_cases_by_user_with_self_service_group_assigned()
{
//Define the total of cases to create
$total = $this->totalCases;
//Define the maximum time of execution
$maximumTime = $this->maximumExecutionTime;
//Create process
$process = factory(Process::class)->create();
//Create group
$group = factory(Groupwf::class)->create();
//Create user
$user = factory(User::class)->create();
//Assign a user in the group
factory(GroupUser::class)->create([
'GRP_UID' => $group->GRP_UID,
'GRP_ID' => $group->GRP_ID,
'USR_UID' => $user->USR_UID
]);
//Create a task self service
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 2, //Related to the group
'TU_TYPE' => 1
]);
//Create the register in self-service
factory(Delegation::class, $total)->create([
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the count self-service
$timeStart = microtime(true);
Delegation::countSelfService($user->USR_UID);
$timeEnd = microtime(true);
$time = $timeEnd - $timeStart;
//Compare if the time of execution is minor than the time defined in the .env
$this->assertLessThan($maximumTime, $time);
error_log('it_should_count_cases_by_user_with_self_service_group_assigned took [' . $total . ']--->' . $time);
}
/**
* This checks the counters is working properly in self-service-value-based when the variable has a value related with the GRP_UID
* When the value assigned in the variable @@ARRAY_OF_USERS = [GRP_UID]
* @covers Delegation::countSelfService
* @test
*/
public function it_should_count_cases_by_user_with_self_service_value_based_grp_uid()
{
//Define the total of cases to create
$total = $this->totalCases;
//Define the maximum time of execution
$maximumTime = $this->maximumExecutionTime;
//Create process
$process = factory(Process::class)->create();
//Create a task self service value based
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
'PRO_UID' => $process->PRO_UID
]);
//Create a case
$application = factory(Application::class)->create();
//Create group
$group = factory(Groupwf::class)->create();
//Create user
$user = factory(User::class)->create([
'USR_USERNAME' => 'gary',
'USR_LASTNAME' => 'Gary',
'USR_FIRSTNAME' => 'Bailey',
]);
//Assign a user in the group
factory(GroupUser::class)->create([
'GRP_UID' => $group->GRP_UID,
'GRP_ID' => $group->GRP_ID,
'USR_UID' => $user->USR_UID,
]);
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'APP_UID' => $application->APP_UID,
'DEL_INDEX' => 2,
'TAS_ID' => $task->TAS_ID
]);
factory(AppAssignSelfServiceValueGroup::class)->create([
'ID' => $appSelfValue->ID,
'GRP_UID' => $group->GRP_UID,
'ASSIGNEE_ID' => $group->GRP_ID, //The usrId or grpId
'ASSIGNEE_TYPE' => 2 //Related to the user=1 related to the group=2
]);
//Create the register in self-service
factory(Delegation::class, $total)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => 2,
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the count self-service
$timeStart = microtime(true);
Delegation::countSelfService($user->USR_UID);
$timeEnd = microtime(true);
$time = $timeEnd - $timeStart;
//Compare if the time of execution is minor than the time defined in the .env
$this->assertLessThan($maximumTime, $time);
error_log('it_should_count_cases_by_user_with_self_service_value_based_grp_uid took [' . $total . ']--->' . $time);
}
/**
* This checks the counters is working properly in self-service user and group assigned in parallel task
* @covers Delegation::countSelfService
* @test
*/
public function it_should_count_cases_by_user_with_self_service_user_and_group_assigned_parallel_task()
{
//Define the total of cases to create
$total = $this->totalCases;
//Define the maximum time of execution
$maximumTime = $this->maximumExecutionTime;
//Create process
$process = factory(Process::class)->create();
//Create group
$group = factory(Groupwf::class)->create();
//Create user
$user = factory(User::class)->create();
//Assign a user in the group
factory(GroupUser::class)->create([
'GRP_UID' => $group->GRP_UID,
'GRP_ID' => $group->GRP_ID,
'USR_UID' => $user->USR_UID
]);
//Create a task self service
$task1 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task1
factory(TaskUser::class)->create([
'TAS_UID' => $task1->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create a task self service
$task2 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task2
factory(TaskUser::class)->create([
'TAS_UID' => $task2->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create a task self service
$task3 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $task3->TAS_UID,
'USR_UID' => $group->GRP_UID,
'TU_RELATION' => 2, //Related to the group
'TU_TYPE' => 1
]);
//Create a task self service
$task4 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $task4->TAS_UID,
'USR_UID' => $group->GRP_UID,
'TU_RELATION' => 2, //Related to the group
'TU_TYPE' => 1
]);
//Create the register in self-service related to the task1
factory(Delegation::class, $total / 4)->create([
'TAS_ID' => $task1->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Create the register in self-service related to the task2
factory(Delegation::class, $total / 4)->create([
'TAS_ID' => $task2->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Create the register in self-service related to the task3
factory(Delegation::class, $total / 4)->create([
'TAS_ID' => $task3->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Create the register in self-service related to the task4
factory(Delegation::class, $total / 4)->create([
'TAS_ID' => $task4->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the count self-service
$timeStart = microtime(true);
Delegation::countSelfService($user->USR_UID);
$timeEnd = microtime(true);
$time = $timeEnd - $timeStart;
//Compare if the time of execution is minor than the time defined in the .env
$this->assertLessThan($maximumTime, $time);
error_log('it_should_count_cases_by_user_with_self_service_user_and_group_assigned_parallel_task took [' . $total . ']--->' . $time);
}
/**
* This checks the counters is working properly in self-service-value-based with GRP_UID and USR_UID in parallel task
* When the value assigned in the variable @@ARRAY_OF_USERS = [GRP_UID, USR_UID]
* @covers Delegation::countSelfService
* @test
*/
public function it_should_count_cases_by_user_with_self_service_value_based_usr_uid_and_grp_uid()
{
//Define the total of cases to create
$total = $this->totalCases;
//Define the maximum time of execution
$maximumTime = $this->maximumExecutionTime;
//Create process
$process = factory(Process::class)->create();
//Create a case
$application = factory(Application::class)->create();
//Create user
$user = factory(User::class)->create();
//Create a task1 self service value based
$task1 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
'PRO_UID' => $process->PRO_UID
]);
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'TAS_ID' => $task1->TAS_ID
]);
factory(AppAssignSelfServiceValueGroup::class)->create([
'ID' => $appSelfValue->ID,
'GRP_UID' => $user->USR_UID,
'ASSIGNEE_ID' => $user->USR_ID, //The usrId or grpId
'ASSIGNEE_TYPE' => 1 //Related to the user=1 related to the group=2
]);
//Create the register in self-service
factory(Delegation::class, $total / 2)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => $appSelfValue->DEL_INDEX,
'TAS_ID' => $task1->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Create a task2 self service value based
$task2 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
'PRO_UID' => $process->PRO_UID
]);
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'TAS_ID' => $task2->TAS_ID
]);
factory(AppAssignSelfServiceValueGroup::class)->create([
'ID' => $appSelfValue->ID,
'GRP_UID' => $user->USR_UID,
'ASSIGNEE_ID' => $user->USR_ID, //The usrId or grpId
'ASSIGNEE_TYPE' => 1 //Related to the user=1 related to the group=2
]);
//Create the register in self-service
factory(Delegation::class, $total / 2)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => $appSelfValue->DEL_INDEX,
'TAS_ID' => $task2->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the count self-service
$timeStart = microtime(true);
Delegation::countSelfService($user->USR_UID);
$timeEnd = microtime(true);
$time = $timeEnd - $timeStart;
//Compare if the time of execution is minor than the time defined in the .env
$this->assertLessThan($maximumTime, $time);
error_log('it_should_count_cases_by_user_with_self_service_value_based_usr_uid_and_grp_uid took [' . $total . ']--->' . $time);
}
}

View File

@@ -1,26 +1,37 @@
<?php
namespace Tests;
use PDO;
use PHPUnit\Framework\TestCase as TestCaseFramework;
use ProcessMaker\Importer\XmlImporter;
use PHPUnit\Framework\TestCase;
/**
* Test case that could instance a workspace DB
*
*/
class WorkflowTestCase extends TestCase
class WorkflowTestCase extends TestCaseFramework
{
private $host;
private $user;
private $password;
private $database;
/**
* Create and install the database.
*/
protected function setupDB()
{
$this->host = env("DB_HOST");
$this->user = env("DB_USERNAME");
$this->password = env("DB_PASSWORD");
$this->database = env("DB_DATABASE");
//Install Database
$pdo0 = new PDO("mysql:host=".DB_HOST, DB_USER, DB_PASS);
$pdo0->query('DROP DATABASE IF EXISTS '.DB_NAME);
$pdo0->query('CREATE DATABASE '.DB_NAME);
$pdo = new PDO("mysql:host=".DB_HOST.";dbname=".DB_NAME, DB_USER,
DB_PASS);
$pdo0 = new PDO("mysql:host=".$this->host, $this->user, $this->password);
$pdo0->query('DROP DATABASE IF EXISTS '.$this->database);
$pdo0->query('CREATE DATABASE '.$this->database);
$pdo = new PDO("mysql:host=".$this->host.";dbname=".$this->database, $this->user,
$this->password);
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, 0);
$pdo->exec(file_get_contents(PATH_CORE.'data/mysql/schema.sql'));
$pdo->exec(file_get_contents(PATH_RBAC_CORE.'data/mysql/schema.sql'));
@@ -39,8 +50,8 @@ class WorkflowTestCase extends TestCase
protected function dropDB()
{
//Install Database
$pdo0 = new PDO("mysql:host=".DB_HOST, DB_USER, DB_PASS);
$pdo0->query('DROP DATABASE IF EXISTS '.DB_NAME);
$pdo0 = new PDO("mysql:host=".$this->host, $this->user, $this->password);
$pdo0->query('DROP DATABASE IF EXISTS '.$this->database);
}
/**

View File

@@ -14,31 +14,66 @@ use Illuminate\Support\Facades\Schema;
/**
* @todo Migrate to configuration parameters
*/
define('PATH_TRUNK', dirname(__DIR__));
define('PATH_CORE', PATH_TRUNK.'/workflow/engine/');
define('PATH_CORE', PATH_TRUNK . '/workflow/engine/');
define('PATH_CONFIG', PATH_CORE . 'config/');
define('PATH_RBAC_CORE',dirname(__DIR__).'/rbac/engine/');
define('PATH_DB', dirname(__DIR__).'/shared/sites/');
define('PATH_DATA', dirname(__DIR__).'/shared/rbac/');
$pathData = PATH_CONFIG . 'paths_installed.php';
if (file_exists($pathData)) {
require_once $pathData;
} else {
define('PATH_DATA', dirname(__DIR__) . '/shared/rbac/');
}
define('PATH_RBAC_CORE', dirname(__DIR__) . '/rbac/engine/');
define('PATH_DB', dirname(__DIR__) . '/shared/sites/');
define('PATH_SEP', '/');
define('PATH_METHODS', dirname(__DIR__).'/workflow/engine/methods/');
define('PATH_METHODS', dirname(__DIR__) . '/workflow/engine/methods/');
define('SYS_LANG', 'en');
define('DB_ADAPTER', 'mysql');
define('SYS_SKIN', 'neoclassic');
define('SYS_SYS', 'workflow');
define('PATH_WORKSPACE',PATH_TRUNK.'/shared/sites/' . SYS_SYS . '/');
define('PMTABLE_KEY','pmtable');
define('SYS_SYS', env('MAIN_SYS_SYS', 'workflow'));
define('PATH_WORKSPACE', PATH_TRUNK . '/shared/sites/' . SYS_SYS . '/');
define('PMTABLE_KEY', 'pmtable');
define('PATH_WORKFLOW_MYSQL_DATA', PATH_TRUNK . '/workflow/engine/data/mysql/');
define('PATH_RBAC_MYSQL_DATA', PATH_TRUNK . '/rbac/engine/data/mysql/');
define('PATH_LANGUAGECONT', PATH_DATA . '/META-INF/');
define('DB_ADAPTER', 'mysql');
define('PATH_RBAC_HOME', PATH_TRUNK . '/rbac/');
define('PATH_RBAC', PATH_RBAC_HOME . 'engine/classes/');
define("PATH_CUSTOM_SKINS", PATH_DATA . "skins/");
define("PATH_TPL", PATH_CORE . "templates/");
//timezone
$_SESSION['__SYSTEM_UTC_TIME_ZONE__'] = (int) (env('MAIN_SYSTEM_UTC_TIME_ZONE', 'workflow')) == 1;
//Set Time Zone
ini_set('date.timezone', $_SESSION['__SYSTEM_UTC_TIME_ZONE__'] ? 'UTC' : env('MAIN_TIME_ZONE', 'America/New_York'));
define('TIME_ZONE', ini_get('date.timezone'));
// Setup basic app services
$app = require __DIR__ . '/../bootstrap/app.php';
$app->make(Kernel::class)->bootstrap();
//Overwrite with the Processmaker env.ini configuration used in production environments
//@todo: move env.ini configuration to .env
ini_set('date.timezone', TIME_ZONE); //Set Time Zone
date_default_timezone_set(TIME_ZONE);
config(['app.timezone' => TIME_ZONE]);
//configuration values
config([
"system.workspace" => SYS_SYS
]);
define("PATH_DATA_SITE", PATH_DATA . "sites/" . config("system.workspace") . "/");
define("PATH_DYNAFORM", PATH_DATA_SITE . "xmlForms/");
define("PATH_DATA_MAILTEMPLATES", PATH_DATA_SITE . "mailTemplates/");
define("PATH_DATA_PUBLIC", PATH_DATA_SITE . "public/");
G::defineConstants();
// Setup our testexternal database
config(['database.connections.testexternal' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'database' => env('DB_DATABASE', 'testexternal'),
'database' => 'testexternal',
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', 'password'),
'unix_socket' => env('DB_SOCKET', ''),

View File

@@ -0,0 +1,72 @@
<?php
namespace Tests\unit\app;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Log;
use Tests\TestCase;
class CustomizeFormatterTest extends TestCase
{
private static $directory;
/**
* This is executed for each test.
*/
protected function setUp()
{
self::$directory = PATH_TRUNK . '/storage/logs/';
}
/**
* This is done before the first test.
*/
public static function setUpBeforeClass()
{
$file = new Filesystem();
$file->cleanDirectory(self::$directory);
}
/**
* This is done after the last test.
*/
public static function tearDownAfterClass()
{
$file = new Filesystem();
$file->cleanDirectory(self::$directory);
}
/**
* Return all of the log levels defined in the RFC 5424 specification.
* @return array
*/
public function levelProviders()
{
return [
['emergency', 'production.EMERGENCY'],
['alert', 'production.ALERT'],
['critical', 'production.CRITICAL'],
['error', 'production.ERROR'],
['warning', 'production.WARNING'],
['notice', 'production.NOTICE'],
['info', 'production.INFO'],
['debug', 'production.DEBUG'],
];
}
/**
* This check the creation of a record with the emergency level.
* @test
* @dataProvider levelProviders
*/
public function it_should_create_log_file_levels($level, $message)
{
Log::{$level}($level);
$files = File::allFiles(self::$directory);
$this->assertCount(1, $files);
$string = File::get($files[0]);
$this->assertRegExp("/{$message}/", $string);
}
}

View File

@@ -5,276 +5,164 @@ use Tests\TestCase;
class ReplaceDataFieldTest extends TestCase
{
/**
* This checks that strings with HTML reserved characters are replaced with entities
* Check that the value of "@q" followed by a string is not being set as empty when using "@#" to identify a variable
*
* @test
* @covers G::replaceDataField
*/
public function it_should_replace_entities()
public function it_should_not_set_empty_when_calling_a_variable_with_hashtag_symbol()
{
// Initializing Faker instance
$faker = Faker\Factory::create();
$string = '<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
<html>
<head>
</head>
<body>
<p>THIS IS ONLY A TEST OF THE VARIABLE&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;@#var_supplierEmail&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</p>
</body>
</html>';
// Initializing variables to use that will not change
$stringWithVariablesToReplace = 'Hello @@var1 the @#var2 is @=var3 not @&var4->value';
$dbEngine = 'mysql'; // This only affects the way to escape the variables with "@@" prefix
$applyEntities = true; // If a value to replace is a not valid HTML and have HTML reserved characters, entities should be applied
// Initializing variables to test the assertions, entities should be applied in variable with @@
$var4 = new stdClass();
$var4->value = $faker->words(1, true);
$valuesToReplace = [
'var1' => 'Java < PHP & Python',
'var2' => $faker->words(1, true),
'var3' => $faker->words(1, true),
'var4' => $var4
$result = [
'var_supplierEmail' => 'asa@qq.fds',
'var_supplierEmail_label' => 'asa@qq.fds',
];
// Replace variables in the string
$stringToCheck = G::replaceDataField($stringWithVariablesToReplace, $valuesToReplace, $dbEngine, $applyEntities);
$dbEngine = 'mysql';
$recursive = false;
// Assertions
$this->assertRegExp('/&lt;/', $stringToCheck);
$this->assertRegExp('/&amp;/', $stringToCheck);
// Replace variables in the string, $recursive is false because is don't needed replace recursively the same value
$stringToCheck = G::replaceDataField($string, $result, $dbEngine, $recursive);
// Initializing variables to test the assertions, entities should be applied in variable with @#
$var4 = new stdClass();
$var4->value = $faker->words(1, true);
$valuesToReplace = [
'var1' => $faker->words(1, true),
'var2' => 'Java < PHP & Python',
'var3' => $faker->words(1, true),
'var4' => $var4
// Assert the @qq is not being set as an empty value
$this->assertRegExp("/asa@qq.fds/", $stringToCheck);
// Testing with a "@qstring" value
$result = [
'var_supplierEmail' => '@qstring',
'var_supplierEmail_label' => '@qstring',
];
// Replace variables in the string
$stringToCheck = G::replaceDataField($stringWithVariablesToReplace, $valuesToReplace, $dbEngine, $applyEntities);
$dbEngine = 'mysql';
$recursive = false;
// Assertions
$this->assertRegExp('/&lt;/', $stringToCheck);
$this->assertRegExp('/&amp;/', $stringToCheck);
// Replace variables in the string, $recursive is false because is don't needed replace recursively the same value
$stringToCheck = G::replaceDataField($string, $result, $dbEngine, $recursive);
// Initializing variables to test the assertions, entities should be applied in variable with @=
$var4 = new stdClass();
$var4->value = $faker->words(1, true);
$valuesToReplace = [
'var1' => $faker->words(1, true),
'var2' => $faker->words(1, true),
'var3' => 'Java < PHP & Python',
'var4' => $var4
];
// Replace variables in the string
$stringToCheck = G::replaceDataField($stringWithVariablesToReplace, $valuesToReplace, $dbEngine, $applyEntities);
// Assertions
$this->assertRegExp('/&lt;/', $stringToCheck);
$this->assertRegExp('/&amp;/', $stringToCheck);
// Initializing variables to test the assertions, entities should be applied in variable with @&
$var4 = new stdClass();
$var4->value = 'Java < PHP & Python';
$valuesToReplace = [
'var1' => $faker->words(1, true),
'var2' => $faker->words(1, true),
'var3' => $faker->words(1, true),
'var4' => $var4
];
// Replace variables in the string
$stringToCheck = G::replaceDataField($stringWithVariablesToReplace, $valuesToReplace, $dbEngine, $applyEntities);
// Assertions
$this->assertRegExp('/&lt;/', $stringToCheck);
$this->assertRegExp('/&amp;/', $stringToCheck);
// Assert the @qstring is not being set as an empty value
$this->assertRegExp("/@qstring/", $stringToCheck);
}
/**
* This checks that strings with HTML reserved characters are NOT replaced with entities
* Check that the value of "@q" followed by a string is not being set as empty when using "@=" to identify a variable
*
* @test
* @covers G::replaceDataField
*/
public function it_should_no_replace_entities()
public function it_should_not_set_empty_when_calling_a_variable_with_equals_symbol()
{
// Initializing Faker instance
$faker = Faker\Factory::create();
$string = '<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
<html>
<head>
</head>
<body>
<p>THIS IS ONLY A TEST OF THE VARIABLE&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;@=var_supplierEmail&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</p>
</body>
</html>';
// Initializing variables to use that will not change
$stringWithVariablesToReplace = 'Hello @@var1 the @#var2 is @=var3 not @&var4->value';
$dbEngine = 'mysql'; // This only affects the way to escape the variables with "@@" prefix
$applyEntities = false; // The values should not be replaced with entities
// Initializing variables to test the assertions, entities should be applied in variable with @@
$var4 = new stdClass();
$var4->value = $faker->words(1, true);
$valuesToReplace = [
'var1' => 'Java < PHP & Python',
'var2' => $faker->words(1, true),
'var3' => $faker->words(1, true),
'var4' => $var4
$result = [
'var_supplierEmail' => 'asa@qq.fds',
'var_supplierEmail_label' => 'asa@qq.fds',
];
// Replace variables in the string
$stringToCheck = G::replaceDataField($stringWithVariablesToReplace, $valuesToReplace, $dbEngine, $applyEntities);
$dbEngine = 'mysql';
$recursive = false;
// Assertions
$this->assertRegExp('/</', $stringToCheck);
$this->assertRegExp('/&/', $stringToCheck);
// Replace variables in the string, $recursive is false because is don't needed replace recursively the same value
$stringToCheck = G::replaceDataField($string, $result, $dbEngine, $recursive);
// Initializing variables to test the assertions, entities should be applied in variable with @#
$var4 = new stdClass();
$var4->value = $faker->words(1, true);
$valuesToReplace = [
'var1' => $faker->words(1, true),
'var2' => 'Java < PHP & Python',
'var3' => $faker->words(1, true),
'var4' => $var4
// Assert the @qq is not being set as an empty value
$this->assertRegExp("/asa@qq.fds/", $stringToCheck);
// Testing with a "@qstring" value
$result = [
'var_supplierEmail' => '@qstring',
'var_supplierEmail_label' => '@qstring',
];
// Replace variables in the string
$stringToCheck = G::replaceDataField($stringWithVariablesToReplace, $valuesToReplace, $dbEngine, $applyEntities);
$dbEngine = 'mysql';
$recursive = false;
// Assertions
$this->assertRegExp('/</', $stringToCheck);
$this->assertRegExp('/&/', $stringToCheck);
// Replace variables in the string, $recursive is false because is don't needed replace recursively the same value
$stringToCheck = G::replaceDataField($string, $result, $dbEngine, $recursive);
// Initializing variables to test the assertions, entities should be applied in variable with @=
$var4 = new stdClass();
$var4->value = $faker->words(1, true);
$valuesToReplace = [
'var1' => $faker->words(1, true),
'var2' => $faker->words(1, true),
'var3' => 'Java < PHP & Python',
'var4' => $var4
];
// Replace variables in the string
$stringToCheck = G::replaceDataField($stringWithVariablesToReplace, $valuesToReplace, $dbEngine, $applyEntities);
// Assertions
$this->assertRegExp('/</', $stringToCheck);
$this->assertRegExp('/&/', $stringToCheck);
// Initializing variables to test the assertions, entities should be applied in variable with @&
$var4 = new stdClass();
$var4->value = 'Java < PHP & Python';
$valuesToReplace = [
'var1' => $faker->words(1, true),
'var2' => $faker->words(1, true),
'var3' => $faker->words(1, true),
'var4' => $var4
];
// Replace variables in the string
$stringToCheck = G::replaceDataField($stringWithVariablesToReplace, $valuesToReplace, $dbEngine, $applyEntities);
// Assertions
$this->assertRegExp('/</', $stringToCheck);
$this->assertRegExp('/&/', $stringToCheck);
// Assert the @qstring is not being set as an empty value
$this->assertRegExp("/@qstring/", $stringToCheck);
}
/**
* This checks that strings with HTML reserved characters are NOT replaced with entities if is a valid HTML, because
* PS team sometimes build a HTML string to insert in templates (output documents or emails), Ex.- A table to list
* users or results from a query
* Check that the variable using "@#" will be replaced recursively or not according to the parameters sent
*
* @test
* @covers G::replaceDataField
*/
public function it_should_no_replace_entities_if_exists_valid_html()
public function it_should_replace_recursively_a_variable_inside_another_variable_with_hashtag_symbol()
{
// Initializing Faker instance
$faker = Faker\Factory::create();
// Initialize variables
$string = '@#upload_New';
$variables = ['upload_New' => "javascript:uploadInputDocument('@#DOC_UID');",
'DOC_UID' => '1988828025cc89aba0cd2b8079038028'];
// Initializing variables to use
$stringWithVariablesToReplace = 'bla @#var1 bla @=listHtml bla @@var2 bla';
$valuesToReplace = [
'var1' => $faker->words(1, true),
'listHtml' => '<table>
<tr>
<th>t1</th>
<th>t2</th>
<th>t3</th>
<th>t4</th>
<th>t5</th>
<th>t6</th>
</tr>
<tr>
<td>c1</td>
<td>c2</td>
<td>c3</td>
<td>c4</td>
<td>c5</td>
<td>c6</td>
</tr>
</table>',
'var2' => $faker->words(1, true)
];
$dbEngine = 'mysql'; // This only affects the way to escape the variables with "@@" prefix
$applyEntities = true; // Is true because the string will b used in a output document or a email template
// Set parameters to test the method
$dbEngine = 'mysql';
$recursive = false;
// Replace variables in the string
$stringToCheck = G::replaceDataField($stringWithVariablesToReplace, $valuesToReplace, $dbEngine, $applyEntities);
// Replace variables in the string, $recursive is false because is don't needed replace recursively the same value
$stringToCheck = G::replaceDataField($string, $variables, $dbEngine, $recursive);
// Assertions
$this->assertRegExp('/<table>/', $stringToCheck);
$this->assertRegExp('/<tr>/', $stringToCheck);
$this->assertRegExp('/<th>/', $stringToCheck);
$this->assertRegExp('/<td>/', $stringToCheck);
// The variable @#DOC_UID inside in the variable "@#upload_New" shouldn't be replaced
$this->assertRegExp("/@#DOC_UID/", $stringToCheck);
// Set parameters to test the method
$dbEngine = 'mysql';
$recursive = true;
// Replace variables in the string, $recursive is true because is required replace recursively the same value
$stringToCheck = G::replaceDataField($string, $variables, $dbEngine, $recursive);
// The variable @#DOC_UID inside in the variable "@#upload_New" should be replaced correctly
$this->assertRegExp("/1988828025cc89aba0cd2b8079038028/", $stringToCheck);
}
/**
* This checks that strings with tag <br /> should not be replaced, because is a valid tag
* Check that the variable using "@=" will be replaced recursively or not according to the parameters sent
*
* @test
* @covers G::replaceDataField
*/
public function it_should_no_replace_tag_br()
public function it_should_replace_recursively_a_variable_inside_another_variable_with_equals_symbol()
{
// Initializing variables to use
$stringWithTagBr = nl2br("prospection auprès d'entreprises de CA < 10 M euros
test
<a
>a
&a
\"a
'a
¢a
£a
¥a
€a
©a
®a
test");
$valuesToReplace = [];
$dbEngine = 'mysql'; // This only affects the way to escape the variables with "@@" prefix
$applyEntities = true; // Is true because the string will be used in a output document or a email template
// Initialize variables
$string = '@=upload_New';
$variables = ['upload_New' => "javascript:uploadInputDocument('@=DOC_UID');",
'DOC_UID' => '1988828025cc89aba0cd2b8079038028'];
// Replace variables in the string
$stringToCheck = G::replaceDataField($stringWithTagBr, $valuesToReplace, $dbEngine, $applyEntities);
// Set parameters to test the method
$dbEngine = 'mysql';
$recursive = false;
// Assertions
$this->assertRegExp("/<br \/>/", $stringToCheck);
}
// Replace variables in the string, $recursive is false because is don't needed replace recursively the same value
$stringToCheck = G::replaceDataField($string, $variables, $dbEngine, $recursive);
/**
* Check that the value for the System variable "__ABE__" should not be replaced never
* @test
* @covers G::replaceDataField
*/
public function it_should_no_replace_entities_for_var_abe()
{
// Initializing variables to use
$string = "bla @#__ABE__ bla @#anotherVar bla";
$valuesToReplace = [// Add a value for reserved system variable "__ABE__" used in Actions By Email feature
'__ABE__' => 'Java < PHP', // The value for System variable "__ABE__" shouldn't be changed never
'anotherVar' => '.NET < Java' // The value for another variables should be validated/replaced normally
];
$dbEngine = 'mysql'; // This only affects the way to escape the variables with "@@" prefix
$applyEntities = true; // Is true because the string will be used in a output document or a email template
// The variable @=DOC_UID inside in the variable "@=upload_New" shouldn't be replaced
$this->assertRegExp("/@=DOC_UID/", $stringToCheck);
// Replace variables in the string
$stringToCheck = G::replaceDataField($string, $valuesToReplace, $dbEngine, $applyEntities);
// Set parameters to test the method
$dbEngine = 'mysql';
$recursive = true;
// Assertions
$this->assertRegExp("/Java < PHP/", $stringToCheck);
$this->assertRegExp("/.NET &lt; Java/", $stringToCheck);
// Replace variables in the string, $recursive is true because is required replace recursively the same value
$stringToCheck = G::replaceDataField($string, $variables, $dbEngine, $recursive);
// The variable @=DOC_UID inside in the variable "@=upload_New" should be replaced correctly
$this->assertRegExp("/1988828025cc89aba0cd2b8079038028/", $stringToCheck);
}
}

View File

@@ -0,0 +1,353 @@
<?php
namespace Tests\unit\gulliver\system;
use G;
use Tests\TestCase;
class gTest extends TestCase
{
/**
* It tests that the new words added to the array are present
*
* @test
*/
public function it_should_match_reserved_new_words()
{
$res = G::reservedWordsSql();
$newWords = [
'GENERATED',
'GET',
'IO_AFTER_GTIDS',
'IO_BEFORE_GTIDS',
'MASTER_BIND',
'OPTIMIZER_COSTS',
'PARTITION',
'PARSE_GCOL_EXPR',
'SQL_AFTER_GTIDS',
'SQL_BEFORE_GTIDS',
'STORED',
'VIRTUAL',
'_FILENAME'
];
foreach ($newWords as $word) {
//This assert the array contains the new words added
$this->assertContains($word, $res);
}
}
/**
* It tests that all the reserved words in MySQL 5.6 and MySQL 5.7 are present
*
* @test
*/
public function it_should_match_all_reserved_words_in_mysql_57()
{
$res = G::reservedWordsSql();
$words = [
"ACCESSIBLE",
"ADD",
"ALL",
"ALTER",
"ANALYZE",
"AND",
"AS",
"ASC",
"ASENSITIVE",
"AUTHORIZATION",
"BEFORE",
"BETWEEN",
"BIGINT",
"BINARY",
"BLOB",
"BOTH",
"BREAK",
"BROWSE",
"BULK",
"BY",
"CALL",
"CASCADE",
"CASE",
"CHANGE",
"CHAR",
"CHARACTER",
"CHECK",
"CHECKPOINT",
"CLUSTERED",
"COLLATE",
"COLUMN",
"COMPUTE",
"CONDITION",
"CONSTRAINT",
"CONTAINSTABLE",
"CONTINUE",
"CONVERT",
"CREATE",
"CROSS",
"CURRENT_DATE",
"CURRENT_TIME",
"CURRENT_TIMESTAMP",
"CURRENT_USER",
"CURSOR",
"DATABASE",
"DATABASES",
"DAY_HOUR",
"DAY_MICROSECOND",
"DAY_MINUTE",
"DAY_SECOND",
"DBCC",
"DEC",
"DECIMAL",
"DECLARE",
"DEFAULT",
"DELAYED",
"DELETE",
"DENY",
"DESC",
"DESCRIBE",
"DETERMINISTIC",
"DISTINCT",
"DISTINCTROW",
"DISTRIBUTED",
"DIV",
"DOUBLE",
"DROP",
"DUAL",
"DUMMY",
"DUMP",
"EACH",
"ELSE",
"ELSEIF",
"ENCLOSED",
"ERRLVL",
"ESCAPED",
"EXCEPT",
"EXEC",
"EXISTS",
"EXIT",
"EXPLAIN",
"FALSE",
"FETCH",
"FILLFACTOR",
"FLOAT",
"FLOAT4",
"FLOAT8",
"FOR",
"FORCE",
"FOREIGN",
"FREETEXT",
"FREETEXTTABLE",
"FROM",
"FULLTEXT",
"GENERATED",
"GET",
"GOTO",
"GRANT",
"GROUP",
"HAVING",
"HIGH_PRIORITY",
"HOLDLOCK",
"HOUR_MICROSECOND",
"HOUR_MINUTE",
"HOUR_SECOND",
"IDENTITY",
"IDENTITYCOL",
"IDENTITY_INSERT",
"IF",
"IGNORE",
"IN",
"INDEX",
"INFILE",
"INNER",
"INOUT",
"INSENSITIVE",
"INSERT",
"INT",
"INT1",
"INT2",
"INT3",
"INT4",
"INT8",
"INTEGER",
"INTERSECT",
"INTERVAL",
"INTO",
"IO_AFTER_GTIDS",
"IO_BEFORE_GTIDS",
"IS",
"ITERATE",
"JOIN",
"KEY",
"KEYS",
"KILL",
"LEADING",
"LEAVE",
"LEFT",
"LIKE",
"LIMIT",
"LINEAR",
"LINENO",
"LINES",
"LOAD",
"LOCALTIME",
"LOCALTIMESTAMP",
"LOCK",
"LONG",
"LONGBLOB",
"LONGTEXT",
"LOOP",
"LOW_PRIORITY",
"MASTER_BIND",
"MASTER_SSL_VERIFY_SERVER_CERT",
"MATCH",
"MAXVALUE",
"MEDIUMBLOB",
"MEDIUMINT",
"MEDIUMTEXT",
"MIDDLEINT",
"MINUTE_MICROSECOND",
"MINUTE_SECOND",
"MOD",
"MODIFIES",
"NATURAL",
"NOCHECK",
"NONCLUSTERED",
"NOT",
"NO_WRITE_TO_BINLOG",
"NULL",
"NULLIF",
"NUMERIC",
"OF",
"OFF",
"OFFSETS",
"ON",
"OPENDATASOURCE",
"OPENQUERY",
"OPENROWSET",
"OPENXML",
"OPTIMIZE",
"OPTIMIZER_COSTS",
"OPTION",
"OPTIONALLY",
"OR",
"ORDER",
"OUT",
"OUTER",
"OUTFILE",
"OVER",
"PARTITION",
"PARSE_GCOL_EXPR",
"PERCENT",
"PLAN",
"PRECISION",
"PRIMARY",
"PRINT",
"PROC",
"PROCEDURE",
"PUBLIC",
"PURGE",
"RAISERROR",
"RANGE",
"READ",
"READS",
"READTEXT",
"READ_WRITE",
"REAL",
"RECONFIGURE",
"REFERENCES",
"REGEXP",
"RELEASE",
"RENAME",
"REPEAT",
"REPLACE",
"REQUIRE",
"RESIGNAL",
"RESTRICT",
"RETURN",
"REVOKE",
"RIGHT",
"RLIKE",
"ROWCOUNT",
"ROWGUIDCOL",
"RULE",
"SAVE",
"SCHEMA",
"SCHEMAS",
"SECOND_MICROSECOND",
"SELECT",
"SENSITIVE",
"SEPARATOR",
"SESSION_USER",
"SET",
"SETUSER",
"SHOW",
"SIGNAL",
"SMALLINT",
"SPATIAL",
"SPECIFIC",
"SQL",
"SQLEXCEPTION",
"SQLSTATE",
"SQLWARNING",
"SQL_AFTER_GTIDS",
"SQL_BEFORE_GTIDS",
"SQL_BIG_RESULT",
"SQL_CALC_FOUND_ROWS",
"SQL_SMALL_RESULT",
"SSL",
"STARTING",
"STATISTICS",
"STORED",
"STRAIGHT_JOIN",
"SYSTEM_USER",
"TABLE",
"TERMINATED",
"TEXTSIZE",
"THEN",
"TINYBLOB",
"TINYINT",
"TINYTEXT",
"TO",
"TOP",
"TRAILING",
"TRAN",
"TRIGGER",
"TRUE",
"TSEQUAL",
"UNDO",
"UNION",
"UNIQUE",
"UNLOCK",
"UNSIGNED",
"UPDATE",
"UPDATETEXT",
"USAGE",
"USE",
"USING",
"UTC_DATE",
"UTC_TIME",
"UTC_TIMESTAMP",
"VALUES",
"VARBINARY",
"VARCHAR",
"VARCHARACTER",
"VARYING",
"VIRTUAL",
"WAITFOR",
"WHEN",
"WHERE",
"WHILE",
"WITH",
"WRITE",
"WRITETEXT",
"XOR",
"YEAR_MONTH",
"ZEROFILL",
"_FILENAME"
];
foreach ($words as $word) {
//This assert the array contains all the reserved words in MySQL 5.6 and MySQL 5.7
$this->assertContains($word, $res);
}
}
}

View File

@@ -0,0 +1,274 @@
<?php
namespace Tests\unit\workflow\engine\bin\tasks;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use ProcessMaker\Model\Dynaform;
use ProcessMaker\Model\Process;
use ProcessMaker\Model\ProcessVariables;
use ProcessMaker\Model\Triggers;
use Tests\TestCase;
class CliWorkspacesTest extends TestCase
{
use DatabaseTransactions;
/**
* Test that the deprecated files are removed successfully
*
* @covers WorkspaceTools::removeDeprecatedFiles
* @test
*/
public function it_should_delete_the_deprecated_files()
{
include(PATH_TRUNK . PATH_SEP . 'workflow/engine/bin/tasks/cliWorkspaces.php');
if (!file_exists(PATH_TRUNK . PATH_SEP . 'workflow/engine/methods/users/data_usersList.php')) {
$filename = PATH_TRUNK . PATH_SEP . 'workflow/engine/methods/users/data_usersList.php';
$handle = fopen($filename, 'w');
fclose($handle);
}
// This assert the data_usersList.php file do exists before being deleted
$this->assertTrue(file_exists(PATH_TRUNK . PATH_SEP . 'workflow/engine/methods/users/data_usersList.php'));
$path = PATH_TRUNK . PATH_SEP . 'workflow/engine/methods/users/';
if (getmyuid() == fileowner($path)) {
if (substr($this->getPermissions(PATH_TRUNK . PATH_SEP . 'workflow/engine/methods/users/data_usersList.php'),
1, 2) == 'rw' &&
substr($this->getPermissions(PATH_TRUNK . PATH_SEP . 'workflow/engine/methods/users/'), 2, 1) == 'w' &&
substr($this->getPermissions(PATH_TRUNK . PATH_SEP . 'workflow/engine/methods/'), 3, 1) == 'x' &&
substr($this->getPermissions(PATH_TRUNK . PATH_SEP . 'workflow/engine/'), 3, 1) == 'x' &&
substr($this->getPermissions(PATH_TRUNK . PATH_SEP . 'workflow/'), 3, 1) == 'x'
) {
remove_deprecated_files();
} else {
dd("Could not delete the file. Please, make sure the file have write permission for the direct parent directory and
execute permission for all parent directories.");
}
} else {
if (getmygid() == filegroup($path)) {
if (substr($this->getPermissions(PATH_TRUNK . PATH_SEP . 'workflow/engine/methods/users/data_usersList.php'),
4, 2) == 'rw' &&
substr($this->getPermissions(PATH_TRUNK . PATH_SEP . 'workflow/engine/methods/users/'), 5,
1) == 'w' &&
substr($this->getPermissions(PATH_TRUNK . PATH_SEP . 'workflow/engine/methods/'), 6, 1) == 'x' &&
substr($this->getPermissions(PATH_TRUNK . PATH_SEP . 'workflow/engine/'), 6, 1) == 'x' &&
substr($this->getPermissions(PATH_TRUNK . PATH_SEP . 'workflow/'), 6, 1) == 'x'
) {
remove_deprecated_files();
} else {
dd("Could not delete the file. Please, make sure the file have write permission for the direct parent directory and
execute permission for all parent directories.");
}
} else {
if (substr($this->getPermissions(PATH_TRUNK . PATH_SEP . 'workflow/engine/methods/users/data_usersList.php'),
7, 2) == 'rw' &&
substr($this->getPermissions(PATH_TRUNK . PATH_SEP . 'workflow/engine/methods/users/'), 8,
1) == 'w' &&
substr($this->getPermissions(PATH_TRUNK . PATH_SEP . 'workflow/engine/methods/'), 9, 1) == 'x' &&
substr($this->getPermissions(PATH_TRUNK . PATH_SEP . 'workflow/engine/'), 9, 1) == 'x' &&
substr($this->getPermissions(PATH_TRUNK . PATH_SEP . 'workflow/'), 9, 1) == 'x'
) {
remove_deprecated_files();
} else {
dd("Could not delete the file. Please, make sure the file have write permission for the direct parent directory and
execute permission for all parent directories.");
}
}
}
// This assert the data_usersList.php does not exist anymore
$this->assertFalse(file_exists(PATH_TRUNK . PATH_SEP . 'workflow/engine/methods/users/data_usersList.php'));
}
/**
* Get the permissions of a file or directory
*
* @param string $path
* @return string
*/
public function getPermissions($path)
{
$per = fileperms($path);
switch ($per & 0xF000) {
case 0xC000: // socket
$permissions = 's';
break;
case 0xA000: // symbolic link
$permissions = 'l';
break;
case 0x8000: // regular
$permissions = '-';
break;
case 0x6000: // block special
$permissions = 'b';
break;
case 0x4000: // directory
$permissions = 'd';
break;
case 0x2000: // character special
$permissions = 'c';
break;
case 0x1000: // FIFO pipe
$permissions = 'p';
break;
default: // unknown
$permissions = 'u';
}
// Owner
$permissions .= (($per & 0x0100) ? 'r' : '-');
$permissions .= (($per & 0x0080) ? 'w' : '-');
$permissions .= (($per & 0x0040) ?
(($per & 0x0800) ? 's' : 'x') :
(($per & 0x0800) ? 'S' : '-'));
// Group
$permissions .= (($per & 0x0020) ? 'r' : '-');
$permissions .= (($per & 0x0010) ? 'w' : '-');
$permissions .= (($per & 0x0008) ?
(($per & 0x0400) ? 's' : 'x') :
(($per & 0x0400) ? 'S' : '-'));
// Others
$permissions .= (($per & 0x0004) ? 'r' : '-');
$permissions .= (($per & 0x0002) ? 'w' : '-');
$permissions .= (($per & 0x0001) ?
(($per & 0x0200) ? 't' : 'x') :
(($per & 0x0200) ? 'T' : '-'));
return $permissions;
}
/**
* Test the queries incompatibilities in dynaforms
* @test
*/
public function it_should_test_the_incompatibilities_in_the_dynaforms_queries()
{
config(["system.workspace" => 'workflow']);
$process = factory(Process::class, 2)->create();
factory(Dynaform::class)->create(
[
'PRO_UID' => $process[0]['PRO_UID'],
'DYN_CONTENT' => '{"name":"2","description":"","items":[{"type":"form","variable":"","var_uid":"","dataType":"","id":"6170264265d1b544bebdbd5098250194","name":"2","description":"","mode":"edit","script":"","language":"en","externalLibs":"","printable":false,"items":[[{"type":"title","id":"title0000000001","label":"title_1","colSpan":12}],[{"type":"text","variable":"textVar002","var_uid":"9778460595d1b545088dd69091601043","dataType":"string","protectedValue":false,"id":"textVar002","name":"textVar002","label":"text_1","defaultValue":"","placeholder":"","hint":"","required":false,"requiredFieldErrorMessage":"","textTransform":"none","validate":"","validateMessage":"","maxLength":1000,"formula":"","mode":"parent","operation":"","dbConnection":"workflow","dbConnectionLabel":"PM Database","sql":"","var_name":"textVar002","colSpan":12}],[{"type":"textarea","variable":"textareaVar001","var_uid":"2934510045d1b5453f21373072798412","dataType":"string","protectedValue":false,"id":"textareaVar001","name":"textareaVar001","label":"textarea_1","defaultValue":"","placeholder":"","hint":"","required":false,"requiredFieldErrorMessage":"","validate":"","validateMessage":"","mode":"parent","dbConnection":"workflow","dbConnectionLabel":"PM Database","sql":"","rows":"5","var_name":"textareaVar001","colSpan":12}],[{"type":"datetime","variable":"datetimeVar001","var_uid":"9780823375d1b5455e9c3a2064729484","dataType":"datetime","protectedValue":false,"id":"datetimeVar001","name":"datetimeVar001","label":"datetime_1","placeholder":"","hint":"","required":false,"requiredFieldErrorMessage":"","mode":"parent","format":"YYYY-MM-DD","dayViewHeaderFormat":"MMMM YYYY","extraFormats":false,"stepping":1,"minDate":"","maxDate":"","useCurrent":"false","collapse":true,"locale":"","defaultDate":"","disabledDates":false,"enabledDates":false,"icons":{"time":"glyphicon glyphicon-time","date":"glyphicon glyphicon-calendar","up":"glyphicon glyphicon-chevron-up","down":"glyphicon glyphicon-chevron-down","previous":"glyphicon glyphicon-chevron-left","next":"glyphicon glyphicon-chevron-right","today":"glyphicon glyphicon-screenshot","clear":"glyphicon glyphicon-trash"},"useStrict":false,"sideBySide":false,"daysOfWeekDisabled":false,"calendarWeeks":false,"viewMode":"days","toolbarPlacement":"default","showTodayButton":false,"showClear":"false","widgetPositioning":{"horizontal":"auto","vertical":"auto"},"widgetParent":null,"keepOpen":false,"var_name":"datetimeVar001","colSpan":12}],[{"type":"submit","id":"submit0000000001","name":"submit0000000001","label":"submit_1","colSpan":12}]],"variables":[{"var_uid":"9778460595d1b545088dd69091601043","prj_uid":"5139642915ccb3fca429a36061714972","var_name":"textVar002","var_field_type":"string","var_field_size":10,"var_label":"string","var_dbconnection":"workflow","var_dbconnection_label":"PM Database","var_sql":"","var_null":0,"var_default":"","var_accepted_values":"[]","inp_doc_uid":""},{"var_uid":"2934510045d1b5453f21373072798412","prj_uid":"5139642915ccb3fca429a36061714972","var_name":"textareaVar001","var_field_type":"string","var_field_size":10,"var_label":"string","var_dbconnection":"workflow","var_dbconnection_label":"PM Database","var_sql":"","var_null":0,"var_default":"","var_accepted_values":"[]","inp_doc_uid":""},{"var_uid":"9780823375d1b5455e9c3a2064729484","prj_uid":"5139642915ccb3fca429a36061714972","var_name":"datetimeVar001","var_field_type":"datetime","var_field_size":10,"var_label":"datetime","var_dbconnection":"workflow","var_dbconnection_label":"PM Database","var_sql":"","var_null":0,"var_default":"","var_accepted_values":"[]","inp_doc_uid":""}]}]}'
]
);
$dynaform = factory(Dynaform::class)->create(
[
'PRO_UID' => $process[1]['PRO_UID'],
'DYN_CONTENT' => '{"name":"1","description":"","items":[{"type":"form","variable":"","var_uid":"","dataType":"","id":"6817532755d16225629cb05061521548","name":"1","description":"","mode":"edit","script":"","language":"en","externalLibs":"","printable":false,"items":[[{"type":"text","variable":"textVar001","var_uid":"4746221155d1622658943d1014840579","dataType":"string","protectedValue":false,"id":"textVar001","name":"textVar001","label":"text_1","defaultValue":"","placeholder":"","hint":"","required":false,"requiredFieldErrorMessage":"","textTransform":"none","validate":"","validateMessage":"","maxLength":1000,"formula":"","mode":"parent","operation":"","dbConnection":"workflow","dbConnectionLabel":"PM Database","sql":"SELECT * FROM USERS WHERE \nUSR_UID=\'$UID\' UNION SELECT * from PROCESS","var_name":"textVar001","colSpan":12}]],"variables":[{"var_uid":"4746221155d1622658943d1014840579","prj_uid":"5139642915ccb3fca429a36061714972","var_name":"textVar001","var_field_type":"string","var_field_size":10,"var_label":"string","var_dbconnection":"workflow","var_dbconnection_label":"PM Database","var_sql":"","var_null":0,"var_default":"","var_accepted_values":"[]","inp_doc_uid":""}]}]}'
]
);
check_queries_incompatibilities('workflow');
$result = ob_get_contents();
// This assert that the message contains the second process name
$this->assertRegExp('/'.$process[1]['PRO_TITLE'].'/',$result);
// This assert that the message contains the second dynaform with the UNION query
$this->assertRegExp('/'.$dynaform['DYN_TITLE'].'/',$result);
}
/**
* Test the queries incompatibilities in variables
* @test
*/
public function it_should_test_the_incompatibilities_in_the_variables_queries()
{
config(["system.workspace" => 'workflow']);
$process = factory(Process::class, 2)->create();
$variables = factory(ProcessVariables::class)->create(
[
'PRJ_UID' => $process[0]['PRO_UID'],
'VAR_SQL' => 'SELECT * FROM USERS WHERE USR_UID="213" UNION SELECT * from PROCESS'
]
);
factory(ProcessVariables::class)->create(
[
'PRJ_UID' => $process[1]['PRO_UID'],
'VAR_SQL' => ''
]
);
check_queries_incompatibilities('workflow');
$result = ob_get_contents();
// This assert that the message contains the first process name
$this->assertRegExp('/'.$process[0]['PRO_TITLE'].'/',$result);
// This assert that the message contains the first dynaform with the UNION query
$this->assertRegExp('/'.$variables['VAR_TITLE'].'/',$result);
}
/**
* Test the queries incompatibilities in triggers
* @test
*/
public function it_should_test_the_incompatibilities_in_the_triggers_queries()
{
config(["system.workspace" => 'workflow']);
$process = factory(Process::class, 3)->create();
$trigger = factory(Triggers::class)->create(
[
'PRO_UID' => $process[0]['PRO_UID'],
'TRI_WEBBOT' => '$text=222;
$var1= executeQuery("SELECT *
FROM USERS WHERE
USR_UID=\'$UID\' UNION SELECT * from PROCESS");
$var1= executeQuery("SELECT *
FROM USERS WHERE
USR_UID=\'$UID\' UNION SELECT * from PROCESS");
$query = "SELECT * FROM USERS UNION
SELECT * FROM TASKS";
$QUERY2 = "select * from USERS union SELECT * from GROUPS";
$s1 = "select * from USER";
$s2 = "select * from TASK";
$query3 = $s1. " UNION " . $s2;
executeQuery($query3);'
]
);
factory(Triggers::class)->create(
[
'PRO_UID' => $process[1]['PRO_UID'],
'TRI_WEBBOT' => 'die();'
]
);
factory(Triggers::class)->create(
[
'PRO_UID' => $process[2]['PRO_UID'],
'TRI_WEBBOT' => 'executeQuery("select * from USERS");'
]
);
check_queries_incompatibilities('workflow');
$result = ob_get_contents();
// This assert that the message contains the first process name
$this->assertRegExp('/'.$process[0]['PRO_TITLE'].'/',$result);
// This assert that the message contains the first trigger with the UNION query
$this->assertRegExp('/'.$trigger['TRI_TITLE'].'/',$result);
}
}

View File

@@ -0,0 +1,419 @@
<?php
namespace Tests\unit\workflow\engine\classes;
use Faker\Factory;
use G;
use Processes;
use ProcessMaker\Model\Dynaform;
use ProcessMaker\Model\InputDocument;
use ProcessMaker\Model\OutputDocument;
use ProcessMaker\Model\Process;
use Tests\TestCase;
class ProcessesTest extends TestCase
{
/**
* This is using instead of DatabaseTransactions
* @todo DatabaseTransactions is having conflicts with propel
*/
protected function setUp()
{
}
/**
* Sort array of array by column.
* @param array $data
* @param string $columnName
*/
public function sortArrayByColumn(&$data, $columnName)
{
usort($data, function($a, $b) use($columnName) {
return strnatcmp($a[$columnName], $b[$columnName]);
});
}
/**
* This checks if the returned dynaforms are correct with the different parameters.
* @test
* @covers \Processes::getDynaformRows()
*/
public function it_should_return_dynaforms()
{
$process = factory(Process::class)->create()->first();
$proUid = $process->PRO_UID;
$dynaforms = factory(Dynaform::class, 6)
->create([
'PRO_UID' => $proUid
])
->sortBy('DYN_UID')
->values();
//test with parameter false
$expected = $dynaforms->toArray();
$processes = new Processes();
$actual = $processes->getDynaformRows($proUid, false);
$this->sortArrayByColumn($actual, 'DYN_UID');
$this->assertEquals($expected, $actual);
//by default the method getDynaformRows removed DYN_ID column
$dynaforms->transform(function($item, $key) {
unset($item->DYN_ID);
return $item;
});
//test with parameter default
$expected = $dynaforms->toArray();
$processes = new Processes();
$actual = $processes->getDynaformRows($proUid);
$this->sortArrayByColumn($actual, 'DYN_UID');
$this->assertEquals($expected, $actual);
//test with parameter true
$expected = $dynaforms->toArray();
$processes = new Processes();
$actual = $processes->getDynaformRows($proUid, true);
$this->sortArrayByColumn($actual, 'DYN_UID');
$this->assertEquals($expected, $actual);
}
/**
* This check if the returned input documents are correct with the different
* parameters.
* @test
* @covers \Processes::getInputRows()
*/
public function it_should_return_input_documents()
{
$process = factory(Process::class)->create()->first();
$proUid = $process->PRO_UID;
$inputDocument = factory(InputDocument::class, 6)
->create([
'PRO_UID' => $proUid
])
->sortBy('INP_DOC_UID')
->values();
//test with parameter false
$expected = $inputDocument->toArray();
$processes = new Processes();
$actual = $processes->getInputRows($proUid, false);
$this->sortArrayByColumn($actual, 'INP_DOC_UID');
$this->assertEquals($expected, $actual);
//by default the mnethod getInputRows removed INP_DOC_ID column
$inputDocument->transform(function($item, $key) {
unset($item->INP_DOC_ID);
return $item;
});
//test with parameter default
$expected = $inputDocument->toArray();
$processes = new Processes();
$actual = $processes->getInputRows($proUid);
$this->sortArrayByColumn($actual, 'INP_DOC_UID');
$this->assertEquals($expected, $actual);
//test with the parameter true
$expected = $inputDocument->toArray();
$processes = new Processes();
$actual = $processes->getInputRows($proUid, true);
$this->sortArrayByColumn($actual, 'INP_DOC_UID');
$this->assertEquals($expected, $actual);
}
/**
* This checks fi the returned output documents are correct with the differect
* parameters.
* @test
* @covers Processes::getOutputRows()
*/
public function it_should_return_output_documents()
{
$process = factory(Process::class)->create()->first();
$proUid = $process->PRO_UID;
$outputDocument = factory(OutputDocument::class, 6)
->create([
'PRO_UID' => $proUid
])
->sortBy('OUT_DOC_UID')
->values();
//test with parameter false
$expected = $outputDocument->toArray();
$processes = new Processes();
$actual = $processes->getOutputRows($proUid, false);
$this->sortArrayByColumn($actual, 'OUT_DOC_UID');
$this->assertEquals($expected, $actual);
//by default the method getOutoutRows removed OUT_DOC_ID column
$outputDocument->transform(function($item, $key) {
unset($item->OUT_DOC_ID);
return $item;
});
//test with parameter default
$expected = $outputDocument->toArray();
$processes = new Processes();
$actual = $processes->getOutputRows($proUid);
$this->sortArrayByColumn($actual, 'OUT_DOC_UID');
$this->assertEquals($expected, $actual);
//test with parameter true
$expected = $outputDocument->toArray();
$processes = new Processes();
$actual = $processes->getOutputRows($proUid, true);
$this->sortArrayByColumn($actual, 'OUT_DOC_UID');
$this->assertEquals($expected, $actual);
}
/**
* This checks if the dynaforms structure is saved with the different parameters.
* @test
* @covers Processes::createDynaformRows()
*/
public function it_sholud_create_dynaform()
{
$faker = Factory::create();
$date = $faker->datetime();
$proUid = G::generateUniqueID();
$expected = [
[
'DYN_ID' => $faker->unique()->numberBetween(1, 10000000),
'DYN_UID' => G::generateUniqueID(),
'DYN_TITLE' => $faker->sentence(2),
'DYN_DESCRIPTION' => $faker->sentence(5),
'PRO_UID' => $proUid,
'DYN_TYPE' => 'xmlform',
'DYN_FILENAME' => '',
'DYN_CONTENT' => '',
'DYN_LABEL' => '',
'DYN_VERSION' => 2,
'DYN_UPDATE_DATE' => $date->format('Y-m-d H:i:s'),
'__DYN_ID_UPDATE__' => false,
],
[
'DYN_ID' => $faker->unique()->numberBetween(1, 10000000),
'DYN_UID' => G::generateUniqueID(),
'DYN_TITLE' => $faker->sentence(2),
'DYN_DESCRIPTION' => $faker->sentence(5),
'PRO_UID' => $proUid,
'DYN_TYPE' => 'xmlform',
'DYN_FILENAME' => '',
'DYN_CONTENT' => '',
'DYN_LABEL' => '',
'DYN_VERSION' => 2,
'DYN_UPDATE_DATE' => $date->format('Y-m-d H:i:s'),
'__DYN_ID_UPDATE__' => false,
],
];
$this->sortArrayByColumn($expected, 'DYN_UID');
$processes = new Processes();
$processes->createDynaformRows($expected);
foreach ($expected as &$value) {
ksort($value);
unset($value['__DYN_ID_UPDATE__']);
}
$dynaforms = Dynaform::getByProUid($proUid)
->sortBy('DYN_UID')
->values();
$dynaforms->transform(function($item, $key) {
return (array) $item;
});
$actual = $dynaforms->toArray();
foreach ($actual as $value) {
ksort($value);
}
$this->assertEquals($expected, $actual);
}
/**
* This checks if the input documents structure is saved with the different
* parameters.
* @test
* @covers Processes::createInputRows()
*/
public function it_should_create_input_document()
{
$faker = Factory::create();
$date = $faker->datetime();
$proUid = G::generateUniqueID();
$expected = [
[
'INP_DOC_UID' => G::generateUniqueID(),
'INP_DOC_ID' => $faker->unique()->numberBetween(1, 10000),
'PRO_UID' => $proUid,
'INP_DOC_TITLE' => $faker->sentence(2),
'INP_DOC_DESCRIPTION' => $faker->sentence(10),
'INP_DOC_FORM_NEEDED' => 'VIRTUAL',
'INP_DOC_ORIGINAL' => 'ORIGINAL',
'INP_DOC_PUBLISHED' => 'PRIVATE',
'INP_DOC_VERSIONING' => 0,
'INP_DOC_DESTINATION_PATH' => '',
'INP_DOC_TAGS' => 'INPUT',
'INP_DOC_TYPE_FILE' => '.*',
'INP_DOC_MAX_FILESIZE' => 0,
'INP_DOC_MAX_FILESIZE_UNIT' => 'KB',
'__INP_DOC_ID_UPDATE__' => false,
],
[
'INP_DOC_UID' => G::generateUniqueID(),
'INP_DOC_ID' => $faker->unique()->numberBetween(1, 10000),
'PRO_UID' => $proUid,
'INP_DOC_TITLE' => $faker->sentence(2),
'INP_DOC_DESCRIPTION' => $faker->sentence(10),
'INP_DOC_FORM_NEEDED' => 'VIRTUAL',
'INP_DOC_ORIGINAL' => 'ORIGINAL',
'INP_DOC_PUBLISHED' => 'PRIVATE',
'INP_DOC_VERSIONING' => 0,
'INP_DOC_DESTINATION_PATH' => '',
'INP_DOC_TAGS' => 'INPUT',
'INP_DOC_TYPE_FILE' => '.*',
'INP_DOC_MAX_FILESIZE' => 0,
'INP_DOC_MAX_FILESIZE_UNIT' => 'KB',
'__INP_DOC_ID_UPDATE__' => false,
],
];
$this->sortArrayByColumn($expected, 'INP_DOC_UID');
$processes = new Processes();
$processes->createInputRows($expected);
foreach ($expected as &$value) {
ksort($value);
unset($value['__INP_DOC_ID_UPDATE__']);
}
$inputDocuments = InputDocument::getByProUid($proUid)
->sortBy('INP_DOC_UID')
->values();
$inputDocuments->transform(function($item, $key) {
return $item->attributesToArray();
});
$actual = $inputDocuments->toArray();
foreach ($actual as &$value) {
ksort($value);
}
$this->assertEquals($expected, $actual);
}
/**
* This checks if the output documents structure is saved with the different
* parameters.
* @test
* @covers Processes::createOutputRows()
*/
public function it_should_create_output_document()
{
$faker = Factory::create();
$date = $faker->datetime();
$proUid = G::generateUniqueID();
$expected = [
[
'OUT_DOC_UID' => G::generateUniqueID(),
'OUT_DOC_ID' => $faker->unique()->numberBetween(1, 10000),
'OUT_DOC_TITLE' => $faker->sentence(2),
'OUT_DOC_DESCRIPTION' => $faker->sentence(10),
'OUT_DOC_FILENAME' => $faker->sentence(2),
'OUT_DOC_TEMPLATE' => '',
'PRO_UID' => $proUid,
'OUT_DOC_REPORT_GENERATOR' => 'TCPDF',
'OUT_DOC_LANDSCAPE' => 0,
'OUT_DOC_MEDIA' => 'Letter',
'OUT_DOC_LEFT_MARGIN' => 20,
'OUT_DOC_RIGHT_MARGIN' => 20,
'OUT_DOC_TOP_MARGIN' => 20,
'OUT_DOC_BOTTOM_MARGIN' => 20,
'OUT_DOC_GENERATE' => 'BOTH',
'OUT_DOC_TYPE' => 'HTML',
'OUT_DOC_CURRENT_REVISION' => 0,
'OUT_DOC_FIELD_MAPPING' => '',
'OUT_DOC_VERSIONING' => 1,
'OUT_DOC_DESTINATION_PATH' => '',
'OUT_DOC_TAGS' => '',
'OUT_DOC_PDF_SECURITY_ENABLED' => 0,
'OUT_DOC_PDF_SECURITY_OPEN_PASSWORD' => '',
'OUT_DOC_PDF_SECURITY_OWNER_PASSWORD' => '',
'OUT_DOC_PDF_SECURITY_PERMISSIONS' => '',
'OUT_DOC_OPEN_TYPE' => 1,
'__OUT_DOC_ID_UPDATE__' => false,
],
[
'OUT_DOC_UID' => G::generateUniqueID(),
'OUT_DOC_ID' => $faker->unique()->numberBetween(1, 10000),
'OUT_DOC_TITLE' => $faker->sentence(2),
'OUT_DOC_DESCRIPTION' => $faker->sentence(10),
'OUT_DOC_FILENAME' => $faker->sentence(2),
'OUT_DOC_TEMPLATE' => '',
'PRO_UID' => $proUid,
'OUT_DOC_REPORT_GENERATOR' => 'TCPDF',
'OUT_DOC_LANDSCAPE' => 0,
'OUT_DOC_MEDIA' => 'Letter',
'OUT_DOC_LEFT_MARGIN' => 20,
'OUT_DOC_RIGHT_MARGIN' => 20,
'OUT_DOC_TOP_MARGIN' => 20,
'OUT_DOC_BOTTOM_MARGIN' => 20,
'OUT_DOC_GENERATE' => 'BOTH',
'OUT_DOC_TYPE' => 'HTML',
'OUT_DOC_CURRENT_REVISION' => 0,
'OUT_DOC_FIELD_MAPPING' => '',
'OUT_DOC_VERSIONING' => 1,
'OUT_DOC_DESTINATION_PATH' => '',
'OUT_DOC_TAGS' => '',
'OUT_DOC_PDF_SECURITY_ENABLED' => 0,
'OUT_DOC_PDF_SECURITY_OPEN_PASSWORD' => '',
'OUT_DOC_PDF_SECURITY_OWNER_PASSWORD' => '',
'OUT_DOC_PDF_SECURITY_PERMISSIONS' => '',
'OUT_DOC_OPEN_TYPE' => 1,
'__OUT_DOC_ID_UPDATE__' => false,
]
];
$this->sortArrayByColumn($expected, 'OUT_DOC_UID');
$processes = new Processes();
$processes->createOutputRows($expected);
foreach ($expected as &$value) {
ksort($value);
unset($value['__OUT_DOC_ID_UPDATE__']);
}
$outputDocuments = OutputDocument::getByProUid($proUid)
->sortBy('OUT_DOC_UID')
->values();
$outputDocuments->transform(function($item, $key) {
return $item->attributestoArray();
});
$actual = $outputDocuments->toArray();
foreach ($actual as &$value) {
ksort($value);
}
$this->assertEquals($expected, $actual);
}
}

View File

@@ -9,13 +9,13 @@ use ProcessMaker\Model\Task;
use ProcessMaker\Model\User;
use Tests\TestCase;
class PmDynaformTest extends TestCase
class ReportTablesTest extends TestCase
{
use DatabaseTransactions;
/**
* Constructor of the class.
* Sets up the unit tests.
*/
protected function setUp()
{

View File

@@ -0,0 +1,68 @@
<?php
use Faker\Factory;
use Tests\TestCase;
class SpoolRunTest extends TestCase
{
/**
* Constructor of the class.
*/
function __construct()
{
}
/**
* Check if "envelope_cc" and "envelope_bcc" was set correctly in consecutive calls
*
* @covers SpoolRun::setData()
*
* @test
*/
public function it_should_check_if_cc_and_bcc_set_correctly_in_consecutive_calls()
{
// Initializing Faker instance
$faker = Factory::create();
// Instancing SpoolRun class
$spoolRun = new SpoolRun();
// Set a first set of data
$spoolRun->setData(
G::generateUniqueID(),
$faker->words(3, true),
$faker->companyEmail,
$faker->freeEmail,
$faker->text(),
$faker->dateTime()->format('Y-m-d H:i:s'),
$faker->companyEmail,
$faker->freeEmail
);
// Build the "to", "cc" an "bcc" values
$spoolRun->runHandleEnvelopeTo();
// Set a second set of data
$spoolRun->setData(
G::generateUniqueID(),
$faker->words(3, true),
$faker->companyEmail,
$faker->freeEmail,
$faker->text(),
$faker->dateTime()->format('Y-m-d H:i:s'),
$faker->companyEmail,
$faker->freeEmail
);
// Build the "to", "cc" an "bcc" values
$spoolRun->runHandleEnvelopeTo();
// Get data to check
$fileData = $spoolRun->getFileData();
// Asserts
$this->assertCount(1, $fileData['envelope_to']);
$this->assertCount(1, $fileData['envelope_cc']);
$this->assertCount(1, $fileData['envelope_bcc']);
}
}

View File

@@ -37,13 +37,6 @@ class GroupTest extends TestCase
*/
protected function setUp()
{
parent::setUp();
//Move section
global $RBAC;
$RBAC->initRBAC();
$RBAC->loadUserRolePermission($RBAC->sSystem, '00000000000000000000000000000001');
$this->setInstanceGroup(new Group());
}

View File

@@ -1,11 +1,15 @@
<?php
namespace ProcessMaker\BusinessModel;
namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel;
use ProcessMaker\BusinessModel\Language;
use System;
use Tests\TestCase;
/**
* Test the ProcessMaker\BusinessModel\Language class.
*/
class LanguageTest extends \WorkflowTestCase
class LanguageTest extends TestCase
{
/**
* @var Language
@@ -18,18 +22,35 @@ class LanguageTest extends \WorkflowTestCase
*/
protected function setUp()
{
$this->setupDB();
$this->getBaseUri();
$this->object = new Language;
$this->translationEnv = PATH_DATA."META-INF".PATH_SEP."translations.env";
$this->translationEnv = PATH_DATA . "META-INF" . PATH_SEP . "translations.env";
file_exists($this->translationEnv) ? unlink($this->translationEnv) : false;
}
/**
* Tears down the unit tests.
* Get base uri for rest applications.
* @return string
*/
protected function tearDown()
private function getBaseUri()
{
$this->dropDB();
$_SERVER = $this->getServerInformation();
$baseUri = System::getServerProtocolHost();
return $baseUri;
}
/**
* Get server information.
* @return object
*/
private function getServerInformation()
{
$pathData = PATH_DATA . "sites" . PATH_SEP . config("system.workspace") . PATH_SEP . ".server_info";
$content = file_get_contents($pathData);
$serverInfo = unserialize($content);
return $serverInfo;
}
/**
@@ -41,9 +62,11 @@ class LanguageTest extends \WorkflowTestCase
public function testGetLanguageList()
{
$list = $this->object->getLanguageList();
$this->assertCount(1, $list);
$this->assertEquals('en', $list[0]['LANG_ID']);
$this->assertEquals('English', $list[0]['LANG_NAME']);
$expected = [
'LANG_ID' => 'en',
'LANG_NAME' => 'English',
];
$this->assertContains($expected, $list);
}
/**
@@ -54,16 +77,23 @@ class LanguageTest extends \WorkflowTestCase
*/
public function testGetLanguageListInstalled()
{
$this->installLanguage('es', __DIR__.'/processmaker.es.po');
$this->installLanguage('es', __DIR__ . '/processmaker.es.po');
$list = $this->object->getLanguageList();
$this->assertCount(2, $list);
$this->assertEquals('en', $list[0]['LANG_ID']);
$this->assertEquals('English', $list[0]['LANG_NAME']);
$this->assertEquals('es-ES', $list[1]['LANG_ID']);
$this->assertEquals('Spanish (Spain)', $list[1]['LANG_NAME']);
$this->uninstallLanguage('es', __DIR__.'/processmaker.es.po');
$english = [
'LANG_ID' => 'en',
'LANG_NAME' => 'English',
];
$this->assertContains($english, $list);
$spanish = [
'LANG_ID' => 'es-ES',
'LANG_NAME' => 'Spanish (Spain)',
];
$this->assertContains($spanish, $list);
$this->uninstallLanguage('es', __DIR__ . '/processmaker.es.po');
$list2 = $this->object->getLanguageList();
$this->assertCount(1, $list2);
$this->assertContains($english, $list2);
}
/**
@@ -74,7 +104,7 @@ class LanguageTest extends \WorkflowTestCase
*/
private function installLanguage($lanId, $filename)
{
copy($filename, PATH_CORE.'content/translations/'.basename($filename));
copy($filename, PATH_CORE . 'content/translations/' . basename($filename));
$language = \LanguagePeer::retrieveByPK($lanId);
$language->setLanEnabled(1);
$language->save();
@@ -89,7 +119,7 @@ class LanguageTest extends \WorkflowTestCase
*/
private function uninstallLanguage($lanId, $filename)
{
unlink(PATH_CORE.'content/translations/'.basename($filename));
unlink(PATH_CORE . 'content/translations/' . basename($filename));
$language = \LanguagePeer::retrieveByPK($lanId);
$language->setLanEnabled(0);
$language->save();

View File

@@ -2,10 +2,13 @@
namespace ProcessMaker\BusinessModel;
use G;
use Tests\TestCase;
/**
* Skins Tests
*/
class SkinsTest extends \WorkflowTestCase
class SkinsTest extends TestCase
{
/**
* @var Skins
@@ -17,9 +20,7 @@ class SkinsTest extends \WorkflowTestCase
*/
protected function setUp()
{
$this->cleanShared();
$this->setupDB();
$this->object = new Skins;
$this->object = new Skins();
}
/**
@@ -27,8 +28,8 @@ class SkinsTest extends \WorkflowTestCase
*/
protected function tearDown()
{
$this->cleanShared();
$this->dropDB();
G::rm_dir(PATH_DATA . 'skins');
mkdir(PATH_DATA . 'skins');
}
/**
@@ -61,12 +62,7 @@ class SkinsTest extends \WorkflowTestCase
{
$this->object->createSkin('test', 'test');
$this->object->createSkin(
'test2',
'test2',
'Second skin',
'ProcessMaker Team',
'current',
'neoclassic'
'test2', 'test2', 'Second skin', 'ProcessMaker Team', 'current', 'neoclassic'
);
$skins = $this->object->getSkins();
$this->assertCount(4, $skins);

View File

@@ -1,13 +1,17 @@
<?php
namespace ProcessMaker\BusinessModel;
namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel;
use G;
use ProcessMaker\BusinessModel\WebEntryEvent;
use ProcessMaker\Importer\XmlImporter;
use System;
use Tests\WorkflowTestCase;
/**
* WebEntryEventTest test
*/
class WebEntryEventTest extends \WorkflowTestCase
class WebEntryEventTest extends WorkflowTestCase
{
const SKIP_VALUE = '&SKIP_VALUE%';
@@ -26,20 +30,19 @@ class WebEntryEventTest extends \WorkflowTestCase
*/
protected function setUp()
{
//to do: This is excluded because requires more changes
$this->markTestIncomplete();
$this->getBaseUri();
$this->setupDB();
$this->processUid = $this->import(__DIR__.'/WebEntryEventTest.pmx');
$this->processUid2 = $this->import(__DIR__.'/WebEntryEventTest2.pmx');
$this->object = new WebEntryEvent;
$this->setTranslation('ID_INVALID_VALUE_CAN_NOT_BE_EMPTY',
'ID_INVALID_VALUE_CAN_NOT_BE_EMPTY({0})');
$this->setTranslation('ID_UNDEFINED_VALUE_IS_REQUIRED',
'ID_UNDEFINED_VALUE_IS_REQUIRED({0})');
$this->setTranslation('ID_WEB_ENTRY_EVENT_DOES_NOT_EXIST',
'ID_WEB_ENTRY_EVENT_DOES_NOT_EXIST({0})');
$this->setTranslation('ID_INVALID_VALUE_ONLY_ACCEPTS_VALUES',
'ID_INVALID_VALUE_ONLY_ACCEPTS_VALUES({0},{1})');
$this->setTranslation('ID_DYNAFORM_IS_NOT_ASSIGNED_TO_ACTIVITY',
'ID_DYNAFORM_IS_NOT_ASSIGNED_TO_ACTIVITY({0},{1})');
$this->processUid = $this->import(__DIR__ . '/WebEntryEventTest.pmx');
$this->processUid2 = $this->import(__DIR__ . '/WebEntryEventTest2.pmx');
$this->object = new WebEntryEvent();
$this->setTranslation('ID_INVALID_VALUE_CAN_NOT_BE_EMPTY', 'ID_INVALID_VALUE_CAN_NOT_BE_EMPTY({0})');
$this->setTranslation('ID_UNDEFINED_VALUE_IS_REQUIRED', 'ID_UNDEFINED_VALUE_IS_REQUIRED({0})');
$this->setTranslation('ID_WEB_ENTRY_EVENT_DOES_NOT_EXIST', 'ID_WEB_ENTRY_EVENT_DOES_NOT_EXIST({0})');
$this->setTranslation('ID_INVALID_VALUE_ONLY_ACCEPTS_VALUES', 'ID_INVALID_VALUE_ONLY_ACCEPTS_VALUES({0},{1})');
$this->setTranslation('ID_DYNAFORM_IS_NOT_ASSIGNED_TO_ACTIVITY', 'ID_DYNAFORM_IS_NOT_ASSIGNED_TO_ACTIVITY({0},{1})');
}
/**
@@ -47,10 +50,34 @@ class WebEntryEventTest extends \WorkflowTestCase
*/
protected function tearDown()
{
$this->dropDB();
$this->clearTranslations();
}
/**
* Get base uri for rest applications.
* @return string
*/
private function getBaseUri()
{
$_SERVER = $this->getServerInformation();
$baseUri = System::getServerProtocolHost();
return $baseUri;
}
/**
* Get server information.
* @return object
*/
private function getServerInformation()
{
$pathData = PATH_DATA . "sites" . PATH_SEP . config("system.workspace") . PATH_SEP . ".server_info";
$content = file_get_contents($pathData);
$serverInfo = unserialize($content);
return $serverInfo;
}
/**
* @covers ProcessMaker\BusinessModel\WebEntryEvent::getWebEntryEvents
* @category HOR-3207:5

View File

@@ -0,0 +1,38 @@
<?php
namespace Tests\unit\workflow\engine\src\ProcessMaker\Core;
use ProcessMaker\Core\System;
use Tests\TestCase;
class SystemTest extends TestCase
{
/**
* Define the required variables
*/
protected function setUp()
{
$config = config('database.connections.testexternal');
define('DB_HOST', $config['host']);
define('DB_NAME', $config['database']);
define('DB_USER', $config['username']);
define('DB_PASS', $config['password']);
}
/**
* It tests the initLaravel method
*
* @test
*/
public function it_should_init_laravel_configurations()
{
$object = new System();
$object->initLaravel();
// Assert that the configurations were set successfully
$this->assertEquals(DB_HOST, config('database.connections.workflow.host'));
$this->assertEquals(DB_NAME, config('database.connections.workflow.database'));
$this->assertEquals(DB_USER, config('database.connections.workflow.username'));
$this->assertEquals(DB_PASS, config('database.connections.workflow.password'));
}
}

View File

@@ -2,13 +2,17 @@
namespace Tests\unit\workflow\src\ProcessMaker\Model;
use G;
use Faker;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use ProcessMaker\Model\AppAssignSelfServiceValue;
use ProcessMaker\Model\AppAssignSelfServiceValueGroup;
use ProcessMaker\Model\Application;
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\GroupUser;
use ProcessMaker\Model\Groupwf;
use ProcessMaker\Model\Process;
use ProcessMaker\Model\ProcessCategory;
use ProcessMaker\Model\Task;
use ProcessMaker\Model\TaskUser;
use ProcessMaker\Model\User;
use Tests\TestCase;
@@ -216,10 +220,10 @@ class DelegationTest extends TestCase
// Create a new delegation, but for this specific user
factory(Delegation::class)->create([
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->id
'USR_ID' => $user->USR_ID
]);
// Now fetch results, and assume delegation count is 1 and the user points to our user
$results = Delegation::search($user->id);
$results = Delegation::search($user->USR_ID);
$this->assertCount(1, $results['data']);
$this->assertEquals('testcaseuser', $results['data'][0]['USRCR_USR_USERNAME']);
}
@@ -640,7 +644,7 @@ class DelegationTest extends TestCase
// Create a new delegation, but for this specific user
factory(Delegation::class)->create([
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->id
'USR_ID' => $user->USR_ID
]);
$user = factory(User::class)->create([
'USR_USERNAME' => 'paul',
@@ -650,7 +654,7 @@ class DelegationTest extends TestCase
// Create a new delegation, but for this specific user
factory(Delegation::class)->create([
'USR_UID' => $user->USR_UID,
'USR_ID' => $user->id
'USR_ID' => $user->USR_ID
]);
// Now fetch results, and assume delegation count is 2 and the ordering ascending return Gary
$results = Delegation::search(null, 0, 25, null, null, null, 'ASC', 'APP_CURRENT_USER');
@@ -1136,4 +1140,417 @@ class DelegationTest extends TestCase
// Check the information returned
$this->assertEmpty($results);
}
/**
* This checks the counters is working properly in self-service user assigned
* @covers Delegation::countSelfService
* @test
*/
public function it_should_count_cases_by_user_with_self_service_user_assigned()
{
//Create process
$process = factory(Process::class)->create();
//Create user
$user = factory(User::class)->create();
//Create a task self service
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create the register in delegation relate to self-service
factory(Delegation::class, 25)->create([
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the count self-service
$result = Delegation::countSelfService($user->USR_UID);
$this->assertEquals(25, $result);
}
/**
* This checks the counters is working properly in self-service-value-based when the variable has a value related with the USR_UID
* When the value assigned in the variable @@ARRAY_OF_USERS = [USR_UID]
* @covers Delegation::countSelfService
* @test
*/
public function it_should_count_cases_by_user_with_self_service_value_based_usr_uid()
{
//Create process
$process = factory(Process::class)->create();
//Create a case
$application = factory(Application::class)->create();
//Create user
$user = factory(User::class)->create();
//Create a task self service value based
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
'PRO_UID' => $process->PRO_UID
]);
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => 2,
'TAS_ID' => $task->TAS_ID
]);
factory(AppAssignSelfServiceValueGroup::class)->create([
'ID' => $appSelfValue->ID,
'GRP_UID' => $user->USR_UID,
'ASSIGNEE_ID' => $user->USR_ID, //The usrId or grpId
'ASSIGNEE_TYPE' => 1 //Related to the user=1 related to the group=2
]);
//Create the register in self-service
factory(Delegation::class, 25)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => $appSelfValue->DEL_INDEX,
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the count self-service
$result = Delegation::countSelfService($user->USR_UID);
$this->assertEquals(25, $result);
}
/**
* This checks the counters is working properly in self-service and self-service value based
* @covers Delegation::countSelfService
* @test
*/
public function it_should_count_cases_by_user_with_self_service_mixed_with_self_service_value_based()
{
//Create process
$process = factory(Process::class)->create();
//Create a case
$application = factory(Application::class)->create();
//Create user
$user = factory(User::class)->create();
//Create a task self service
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create the register in self service
factory(Delegation::class, 15)->create([
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Create a task self service value based
$task1 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
'PRO_UID' => $process->PRO_UID
]);
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => 2,
'TAS_ID' => $task1->TAS_ID
]);
factory(AppAssignSelfServiceValueGroup::class)->create([
'ID' => $appSelfValue->ID,
'GRP_UID' => $user->USR_UID,
'ASSIGNEE_ID' => $user->USR_ID, //The usrId or grpId
'ASSIGNEE_TYPE' => 1 //Related to the user=1 related to the group=2
]);
//Create the register in self service value based
factory(Delegation::class, 15)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => $appSelfValue->DEL_INDEX,
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the count self-service
$result = Delegation::countSelfService($user->USR_UID);
$this->assertEquals(30, $result);
}
/**
* This checks the counters is working properly in self-service group assigned
* @covers Delegation::countSelfService
* @test
*/
public function it_should_count_cases_by_user_with_self_service_group_assigned()
{
//Create process
$process = factory(Process::class)->create();
//Create group
$group = factory(Groupwf::class)->create();
//Create user
$user = factory(User::class)->create();
//Assign a user in the group
factory(GroupUser::class)->create([
'GRP_UID' => $group->GRP_UID,
'GRP_ID' => $group->GRP_ID,
'USR_UID' => $user->USR_UID
]);
//Create a task self service
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 2, //Related to the group
'TU_TYPE' => 1
]);
//Create the register in self-service
factory(Delegation::class, 25)->create([
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the count self-service
$result = Delegation::countSelfService($user->USR_UID);
$this->assertEquals(25, $result);
}
/**
* This checks the counters is working properly in self-service-value-based when the variable has a value related with the GRP_UID
* When the value assigned in the variable @@ARRAY_OF_USERS = [GRP_UID]
* @covers Delegation::countSelfService
* @test
*/
public function it_should_count_cases_by_user_with_self_service_value_based_grp_uid()
{
//Create process
$process = factory(Process::class)->create();
//Create a task self service value based
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
'PRO_UID' => $process->PRO_UID
]);
//Create a case
$application = factory(Application::class)->create();
//Create group
$group = factory(Groupwf::class)->create();
//Create user
$user = factory(User::class)->create([
'USR_USERNAME' => 'gary',
'USR_LASTNAME' => 'Gary',
'USR_FIRSTNAME' => 'Bailey',
]);
//Assign a user in the group
factory(GroupUser::class)->create([
'GRP_UID' => $group->GRP_UID,
'GRP_ID' => $group->GRP_ID,
'USR_UID' => $user->USR_UID,
]);
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'APP_UID' => $application->APP_UID,
'DEL_INDEX' => 2,
'TAS_ID' => $task->TAS_ID
]);
factory(AppAssignSelfServiceValueGroup::class)->create([
'ID' => $appSelfValue->ID,
'GRP_UID' => $group->GRP_UID,
'ASSIGNEE_ID' => $group->GRP_ID, //The usrId or grpId
'ASSIGNEE_TYPE' => 2 //Related to the user=1 related to the group=2
]);
//Create the register in self-service
factory(Delegation::class, 25)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => 2,
'TAS_ID' => $task->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the count self-service
$result = Delegation::countSelfService($user->USR_UID);
$this->assertEquals(25, $result);
}
/**
* This checks the counters is working properly in self-service user and group assigned in parallel task
* @covers Delegation::countSelfService
* @test
*/
public function it_should_count_cases_by_user_with_self_service_user_and_group_assigned_parallel_task()
{
//Create process
$process = factory(Process::class)->create();
//Create group
$group = factory(Groupwf::class)->create();
//Create user
$user = factory(User::class)->create();
//Assign a user in the group
factory(GroupUser::class)->create([
'GRP_UID' => $group->GRP_UID,
'GRP_ID' => $group->GRP_ID,
'USR_UID' => $user->USR_UID
]);
//Create a task self service
$task1 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task1
factory(TaskUser::class)->create([
'TAS_UID' => $task1->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create a task self service
$task2 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task2
factory(TaskUser::class)->create([
'TAS_UID' => $task2->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create a task self service
$task3 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $task3->TAS_UID,
'USR_UID' => $group->GRP_UID,
'TU_RELATION' => 2, //Related to the group
'TU_TYPE' => 1
]);
//Create a task self service
$task4 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class)->create([
'TAS_UID' => $task4->TAS_UID,
'USR_UID' => $group->GRP_UID,
'TU_RELATION' => 2, //Related to the group
'TU_TYPE' => 1
]);
//Create the register in self-service related to the task1
factory(Delegation::class, 10)->create([
'TAS_ID' => $task1->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Create the register in self-service related to the task2
factory(Delegation::class, 10)->create([
'TAS_ID' => $task2->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Create the register in self-service related to the task3
factory(Delegation::class, 10)->create([
'TAS_ID' => $task3->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Create the register in self-service related to the task4
factory(Delegation::class, 10)->create([
'TAS_ID' => $task4->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the count self-service
$result = Delegation::countSelfService($user->USR_UID);
$this->assertEquals(40, $result);
}
/**
* This checks the counters is working properly in self-service-value-based with GRP_UID and USR_UID in parallel task
* When the value assigned in the variable @@ARRAY_OF_USERS = [GRP_UID, USR_UID]
* @covers Delegation::countSelfService
* @test
*/
public function it_should_count_cases_by_user_with_self_service_value_based_usr_uid_and_grp_uid()
{
//Create process
$process = factory(Process::class)->create();
//Create a case
$application = factory(Application::class)->create();
//Create user
$user = factory(User::class)->create();
//Create a task1 self service value based
$task1 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
'PRO_UID' => $process->PRO_UID
]);
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'TAS_ID' => $task1->TAS_ID
]);
factory(AppAssignSelfServiceValueGroup::class)->create([
'ID' => $appSelfValue->ID,
'GRP_UID' => $user->USR_UID,
'ASSIGNEE_ID' => $user->USR_ID, //The usrId or grpId
'ASSIGNEE_TYPE' => 1 //Related to the user=1 related to the group=2
]);
//Create the register in self-service
factory(Delegation::class, 10)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => $appSelfValue->DEL_INDEX,
'TAS_ID' => $task1->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Create a task2 self service value based
$task2 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
'PRO_UID' => $process->PRO_UID
]);
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'TAS_ID' => $task2->TAS_ID
]);
factory(AppAssignSelfServiceValueGroup::class)->create([
'ID' => $appSelfValue->ID,
'GRP_UID' => $user->USR_UID,
'ASSIGNEE_ID' => $user->USR_ID, //The usrId or grpId
'ASSIGNEE_TYPE' => 1 //Related to the user=1 related to the group=2
]);
//Create the register in self-service
factory(Delegation::class, 15)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => $appSelfValue->DEL_INDEX,
'TAS_ID' => $task2->TAS_ID,
'DEL_THREAD_STATUS' => 'OPEN',
'USR_ID' => 0,
]);
//Review the count self-service
$result = Delegation::countSelfService($user->USR_UID);
$this->assertEquals(25, $result);
}
}

View File

@@ -0,0 +1,50 @@
<?php
namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
use ProcessMaker\Model\Dynaform;
use ProcessMaker\Model\Process;
use Tests\TestCase;
class DynaformTest extends TestCase
{
/**
* It tests the process scope in the dynaform model
* @test
*/
public function it_should_test_process_scope_in_dynaform_model()
{
$process = factory(Process::class, 3)->create();
factory(Dynaform::class)->create(
[
'PRO_UID' => $process[0]['PRO_UID'],
'DYN_CONTENT' => '{"name":"2","description":"","items":[{"type":"form","variable":"","var_uid":"","dataType":"","id":"6170264265d1b544bebdbd5098250194","name":"2","description":"","mode":"edit","script":"","language":"en","externalLibs":"","printable":false,"items":[[{"type":"title","id":"title0000000001","label":"title_1","colSpan":12}],[{"type":"text","variable":"textVar002","var_uid":"9778460595d1b545088dd69091601043","dataType":"string","protectedValue":false,"id":"textVar002","name":"textVar002","label":"text_1","defaultValue":"","placeholder":"","hint":"","required":false,"requiredFieldErrorMessage":"","textTransform":"none","validate":"","validateMessage":"","maxLength":1000,"formula":"","mode":"parent","operation":"","dbConnection":"workflow","dbConnectionLabel":"PM Database","sql":"","var_name":"textVar002","colSpan":12}],[{"type":"textarea","variable":"textareaVar001","var_uid":"2934510045d1b5453f21373072798412","dataType":"string","protectedValue":false,"id":"textareaVar001","name":"textareaVar001","label":"textarea_1","defaultValue":"","placeholder":"","hint":"","required":false,"requiredFieldErrorMessage":"","validate":"","validateMessage":"","mode":"parent","dbConnection":"workflow","dbConnectionLabel":"PM Database","sql":"","rows":"5","var_name":"textareaVar001","colSpan":12}],[{"type":"datetime","variable":"datetimeVar001","var_uid":"9780823375d1b5455e9c3a2064729484","dataType":"datetime","protectedValue":false,"id":"datetimeVar001","name":"datetimeVar001","label":"datetime_1","placeholder":"","hint":"","required":false,"requiredFieldErrorMessage":"","mode":"parent","format":"YYYY-MM-DD","dayViewHeaderFormat":"MMMM YYYY","extraFormats":false,"stepping":1,"minDate":"","maxDate":"","useCurrent":"false","collapse":true,"locale":"","defaultDate":"","disabledDates":false,"enabledDates":false,"icons":{"time":"glyphicon glyphicon-time","date":"glyphicon glyphicon-calendar","up":"glyphicon glyphicon-chevron-up","down":"glyphicon glyphicon-chevron-down","previous":"glyphicon glyphicon-chevron-left","next":"glyphicon glyphicon-chevron-right","today":"glyphicon glyphicon-screenshot","clear":"glyphicon glyphicon-trash"},"useStrict":false,"sideBySide":false,"daysOfWeekDisabled":false,"calendarWeeks":false,"viewMode":"days","toolbarPlacement":"default","showTodayButton":false,"showClear":"false","widgetPositioning":{"horizontal":"auto","vertical":"auto"},"widgetParent":null,"keepOpen":false,"var_name":"datetimeVar001","colSpan":12}],[{"type":"submit","id":"submit0000000001","name":"submit0000000001","label":"submit_1","colSpan":12}]],"variables":[{"var_uid":"9778460595d1b545088dd69091601043","prj_uid":"5139642915ccb3fca429a36061714972","var_name":"textVar002","var_field_type":"string","var_field_size":10,"var_label":"string","var_dbconnection":"workflow","var_dbconnection_label":"PM Database","var_sql":"","var_null":0,"var_default":"","var_accepted_values":"[]","inp_doc_uid":""},{"var_uid":"2934510045d1b5453f21373072798412","prj_uid":"5139642915ccb3fca429a36061714972","var_name":"textareaVar001","var_field_type":"string","var_field_size":10,"var_label":"string","var_dbconnection":"workflow","var_dbconnection_label":"PM Database","var_sql":"","var_null":0,"var_default":"","var_accepted_values":"[]","inp_doc_uid":""},{"var_uid":"9780823375d1b5455e9c3a2064729484","prj_uid":"5139642915ccb3fca429a36061714972","var_name":"datetimeVar001","var_field_type":"datetime","var_field_size":10,"var_label":"datetime","var_dbconnection":"workflow","var_dbconnection_label":"PM Database","var_sql":"","var_null":0,"var_default":"","var_accepted_values":"[]","inp_doc_uid":""}]}]}'
]
);
factory(Dynaform::class)->create(
[
'PRO_UID' => $process[1]['PRO_UID'],
'DYN_CONTENT' => '{"name":"1","description":"","items":[{"type":"form","variable":"","var_uid":"","dataType":"","id":"6817532755d16225629cb05061521548","name":"1","description":"","mode":"edit","script":"","language":"en","externalLibs":"","printable":false,"items":[[{"type":"text","variable":"textVar001","var_uid":"4746221155d1622658943d1014840579","dataType":"string","protectedValue":false,"id":"textVar001","name":"textVar001","label":"text_1","defaultValue":"","placeholder":"","hint":"","required":false,"requiredFieldErrorMessage":"","textTransform":"none","validate":"","validateMessage":"","maxLength":1000,"formula":"","mode":"parent","operation":"","dbConnection":"workflow","dbConnectionLabel":"PM Database","sql":"SELECT * FROM USERS WHERE \nUSR_UID=\'$UID\' UNION SELECT * from PROCESS","var_name":"textVar001","colSpan":12}]],"variables":[{"var_uid":"4746221155d1622658943d1014840579","prj_uid":"5139642915ccb3fca429a36061714972","var_name":"textVar001","var_field_type":"string","var_field_size":10,"var_label":"string","var_dbconnection":"workflow","var_dbconnection_label":"PM Database","var_sql":"","var_null":0,"var_default":"","var_accepted_values":"[]","inp_doc_uid":""}]}]}'
]
);
factory(Dynaform::class)->create(
[
'PRO_UID' => $process[2]['PRO_UID'],
'DYN_CONTENT' => '{"name":"1","description":"","items":[{"type":"form","variable":"","var_uid":"","dataType":"","id":"6817532755d16225629cb05061521548","name":"1","description":"","mode":"edit","script":"","language":"en","externalLibs":"","printable":false,"items":[[{"type":"text","variable":"textVar001","var_uid":"4746221155d1622658943d1014840579","dataType":"string","protectedValue":false,"id":"textVar001","name":"textVar001","label":"text_1","defaultValue":"","placeholder":"","hint":"","required":false,"requiredFieldErrorMessage":"","textTransform":"none","validate":"","validateMessage":"","maxLength":1000,"formula":"","mode":"parent","operation":"","dbConnection":"workflow","dbConnectionLabel":"PM Database","sql":"SELECT * FROM USERS WHERE \nUSR_UID=\'$UID\' UNION SELECT * from PROCESS","var_name":"textVar001","colSpan":12}]],"variables":[{"var_uid":"4746221155d1622658943d1014840579","prj_uid":"5139642915ccb3fca429a36061714972","var_name":"textVar001","var_field_type":"string","var_field_size":10,"var_label":"string","var_dbconnection":"workflow","var_dbconnection_label":"PM Database","var_sql":"","var_null":0,"var_default":"","var_accepted_values":"[]","inp_doc_uid":""}]}]}'
]
);
$dynaformQuery = Dynaform::query()->select();
$dynaformQuery->process($process[0]['PRO_UID']);
$result = $dynaformQuery->get()->values()->toArray();
// Assert there is a dynaform for the specific process
$this->assertCount(1, $result);
// Assert that the result has the correct filtered process
$this->assertEquals($process[0]['PRO_UID'], $result[0]['PRO_UID']);
}
}

View File

@@ -32,32 +32,29 @@ class ListUnassignedTest extends TestCase
public function it_should_count_cases_by_user_with_self_service_user_assigned()
{
//Create process
$process = factory(Process::class, 1)->create();
$process = factory(Process::class)->create();
//Create user
$user = factory(User::class, 1)->create();
$user = factory(User::class)->create();
//Create a task self service
$task = factory(Task::class, 1)->create([
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process[0]->PRO_UID
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class, 1)->create([
'TAS_UID' => $task[0]->TAS_UID,
'USR_UID' => $user[0]->USR_UID,
factory(TaskUser::class)->create([
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create the register in list unassigned
factory(ListUnassigned::class, 15)->create([
'TAS_ID' => $task[0]->TAS_ID
factory(ListUnassigned::class, 25)->create([
'TAS_ID' => $task->TAS_ID
]);
$timeStart = microtime(true);
$result = ListUnassigned::doCount($user[0]->USR_UID);
$timeEnd = microtime(true);
$this->assertEquals(15, $result);
$time = $timeEnd - $timeStart;
error_log('it_should_count_cases_by_user_with_self_service_user_assigned took [15]--->' . $time);
//Review the count self-service
$result = ListUnassigned::countSelfService($user->USR_UID);
$this->assertEquals(25, $result);
}
/**
@@ -69,41 +66,38 @@ class ListUnassignedTest extends TestCase
public function it_should_count_cases_by_user_with_self_service_value_based_usr_uid()
{
//Create process
$process = factory(Process::class, 1)->create();
$process = factory(Process::class)->create();
//Create a case
$application = factory(Application::class, 1)->create();
$application = factory(Application::class)->create();
//Create user
$user = factory(User::class, 1)->create();
$user = factory(User::class)->create();
//Create a task self service value based
$task = factory(Task::class, 1)->create([
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
'PRO_UID' => $process[0]->PRO_UID
'PRO_UID' => $process->PRO_UID
]);
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
$appSelfValue = factory(AppAssignSelfServiceValue::class, 1)->create([
'APP_NUMBER' => $application[0]->APP_NUMBER,
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => 2,
'TAS_ID' => $task[0]->TAS_ID
'TAS_ID' => $task->TAS_ID
]);
factory(AppAssignSelfServiceValueGroup::class, 1)->create([
'ID' => $appSelfValue[0]->ID,
'GRP_UID' => $user[0]->USR_UID,
'ASSIGNEE_ID' => $user[0]->USR_ID, //The usrId or grpId
factory(AppAssignSelfServiceValueGroup::class)->create([
'ID' => $appSelfValue->ID,
'GRP_UID' => $user->USR_UID,
'ASSIGNEE_ID' => $user->USR_ID, //The usrId or grpId
'ASSIGNEE_TYPE' => 1 //Related to the user=1 related to the group=2
]);
//Create the register in list unassigned
factory(ListUnassigned::class, 10)->create([
'APP_NUMBER' => $application[0]->APP_NUMBER,
'DEL_INDEX' => $appSelfValue[0]->DEL_INDEX,
'TAS_ID' => $task[0]->TAS_ID,
factory(ListUnassigned::class, 25)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => $appSelfValue->DEL_INDEX,
'TAS_ID' => $task->TAS_ID,
]);
$timeStart = microtime(true);
$result = ListUnassigned::doCount($user[0]->USR_UID);
$this->assertEquals(10, $result);
$timeEnd = microtime(true);
$time = $timeEnd - $timeStart;
error_log('it_should_count_cases_by_user_with_self_service_value_based_usr_uid took [10]--->' . $time);
//Review the count self-service
$result = ListUnassigned::countSelfService($user->USR_UID);
$this->assertEquals(25, $result);
}
/**
@@ -114,59 +108,55 @@ class ListUnassignedTest extends TestCase
public function it_should_count_cases_by_user_with_self_service_mixed_with_self_service_value_based()
{
//Create process
$process = factory(Process::class, 1)->create();
$process = factory(Process::class)->create();
//Create a case
$application = factory(Application::class, 1)->create();
$application = factory(Application::class)->create();
//Create user
$user = factory(User::class, 1)->create();
$user = factory(User::class)->create();
//Create a task self service
$task = factory(Task::class, 1)->create([
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process[0]->PRO_UID
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class, 1)->create([
'TAS_UID' => $task[0]->TAS_UID,
'USR_UID' => $user[0]->USR_UID,
factory(TaskUser::class)->create([
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create the register in self service
factory(ListUnassigned::class, 15)->create([
'TAS_ID' => $task[0]->TAS_ID
'TAS_ID' => $task->TAS_ID
]);
//Create a task self service value based
$task1 = factory(Task::class, 1)->create([
$task1 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
'PRO_UID' => $process[0]->PRO_UID
'PRO_UID' => $process->PRO_UID
]);
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
$appSelfValue = factory(AppAssignSelfServiceValue::class, 1)->create([
'APP_NUMBER' => $application[0]->APP_NUMBER,
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => 2,
'TAS_ID' => $task1[0]->TAS_ID
'TAS_ID' => $task1->TAS_ID
]);
factory(AppAssignSelfServiceValueGroup::class, 1)->create([
'ID' => $appSelfValue[0]->ID,
'GRP_UID' => $user[0]->USR_UID,
'ASSIGNEE_ID' => $user[0]->USR_ID, //The usrId or grpId
factory(AppAssignSelfServiceValueGroup::class)->create([
'ID' => $appSelfValue->ID,
'GRP_UID' => $user->USR_UID,
'ASSIGNEE_ID' => $user->USR_ID, //The usrId or grpId
'ASSIGNEE_TYPE' => 1 //Related to the user=1 related to the group=2
]);
//Create the register in self service value based
factory(ListUnassigned::class, 10)->create([
'APP_NUMBER' => $application[0]->APP_NUMBER,
'DEL_INDEX' => $appSelfValue[0]->DEL_INDEX,
'TAS_ID' => $task[0]->TAS_ID,
factory(ListUnassigned::class, 15)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => $appSelfValue->DEL_INDEX,
'TAS_ID' => $task->TAS_ID,
]);
$timeStart = microtime(true);
$result = ListUnassigned::doCount($user[0]->USR_UID);
$timeEnd = microtime(true);
$this->assertEquals(25, $result);
$time = $timeEnd - $timeStart;
error_log('it_should_count_cases_by_user_with_self_service_mixed_with_self_service_value_based took [25]--->' . $time);
//Review the count self-service
$result = ListUnassigned::countSelfService($user->USR_UID);
$this->assertEquals(30, $result);
}
/**
@@ -177,40 +167,37 @@ class ListUnassignedTest extends TestCase
public function it_should_count_cases_by_user_with_self_service_group_assigned()
{
//Create process
$process = factory(Process::class, 1)->create();
$process = factory(Process::class)->create();
//Create group
$group = factory(Groupwf::class, 1)->create();
$group = factory(Groupwf::class)->create();
//Create user
$user = factory(User::class, 1)->create();
$user = factory(User::class)->create();
//Assign a user in the group
factory(GroupUser::class, 1)->create([
'GRP_UID' => $group[0]->GRP_UID,
'GRP_ID' => $group[0]->GRP_ID,
'USR_UID' => $user[0]->USR_UID
factory(GroupUser::class)->create([
'GRP_UID' => $group->GRP_UID,
'GRP_ID' => $group->GRP_ID,
'USR_UID' => $user->USR_UID
]);
//Create a task self service
$task = factory(Task::class, 1)->create([
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process[0]->PRO_UID
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class, 1)->create([
'TAS_UID' => $task[0]->TAS_UID,
'USR_UID' => $user[0]->USR_UID,
factory(TaskUser::class)->create([
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 2, //Related to the group
'TU_TYPE' => 1
]);
//Create the register in list unassigned
factory(ListUnassigned::class, 15)->create([
'TAS_ID' => $task[0]->TAS_ID
factory(ListUnassigned::class, 25)->create([
'TAS_ID' => $task->TAS_ID
]);
$timeStart = microtime(true);
$result = ListUnassigned::doCount($user[0]->USR_UID);
$timeEnd = microtime(true);
$this->assertEquals(15, $result);
$time = $timeEnd - $timeStart;
error_log('it_should_count_cases_by_user_with_self_service_group_assigned took [15]--->' . $time);
//Review the count self-service
$result = ListUnassigned::countSelfService($user->USR_UID);
$this->assertEquals(25, $result);
}
/**
@@ -222,54 +209,51 @@ class ListUnassignedTest extends TestCase
public function it_should_count_cases_by_user_with_self_service_value_based_grp_uid()
{
//Create process
$process = factory(Process::class, 1)->create();
$process = factory(Process::class)->create();
//Create a task self service value based
$task = factory(Task::class, 1)->create([
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
'PRO_UID' => $process[0]->PRO_UID
'PRO_UID' => $process->PRO_UID
]);
//Create a case
$application = factory(Application::class, 1)->create();
$application = factory(Application::class)->create();
//Create group
$group = factory(Groupwf::class, 1)->create();
$group = factory(Groupwf::class)->create();
//Create user
$user = factory(User::class, 1)->create([
$user = factory(User::class)->create([
'USR_USERNAME' => 'gary',
'USR_LASTNAME' => 'Gary',
'USR_FIRSTNAME' => 'Bailey',
]);
//Assign a user in the group
factory(GroupUser::class, 1)->create([
'GRP_UID' => $group[0]->GRP_UID,
'GRP_ID' => $group[0]->GRP_ID,
'USR_UID' => $user[0]->USR_UID,
factory(GroupUser::class)->create([
'GRP_UID' => $group->GRP_UID,
'GRP_ID' => $group->GRP_ID,
'USR_UID' => $user->USR_UID,
]);
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
$appSelfValue = factory(AppAssignSelfServiceValue::class, 1)->create([
'APP_NUMBER' => $application[0]->APP_NUMBER,
'APP_UID' => $application[0]->APP_UID,
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'APP_UID' => $application->APP_UID,
'DEL_INDEX' => 2,
'TAS_ID' => $task[0]->TAS_ID
'TAS_ID' => $task->TAS_ID
]);
factory(AppAssignSelfServiceValueGroup::class, 1)->create([
'ID' => $appSelfValue[0]->ID,
'GRP_UID' => $group[0]->GRP_UID,
'ASSIGNEE_ID' => $group[0]->GRP_ID, //The usrId or grpId
factory(AppAssignSelfServiceValueGroup::class)->create([
'ID' => $appSelfValue->ID,
'GRP_UID' => $group->GRP_UID,
'ASSIGNEE_ID' => $group->GRP_ID, //The usrId or grpId
'ASSIGNEE_TYPE' => 2 //Related to the user=1 related to the group=2
]);
//Create the register in list unassigned
factory(ListUnassigned::class, 10)->create([
'APP_NUMBER' => $application[0]->APP_NUMBER,
factory(ListUnassigned::class, 25)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => 2,
'TAS_ID' => $task[0]->TAS_ID,
'TAS_ID' => $task->TAS_ID,
]);
$timeStart = microtime(true);
$result = ListUnassigned::doCount($user[0]->USR_UID);
$this->assertEquals(10, $result);
$timeEnd = microtime(true);
$time = $timeEnd - $timeStart;
error_log('it_should_count_cases_by_user_with_self_service_value_based_grp_uid took [10]--->' . $time);
//Review the count self-service
$result = ListUnassigned::countSelfService($user->USR_UID);
$this->assertEquals(25, $result);
}
/**
@@ -280,91 +264,88 @@ class ListUnassignedTest extends TestCase
public function it_should_count_cases_by_user_with_self_service_user_and_group_assigned_parallel_task()
{
//Create process
$process = factory(Process::class, 1)->create();
$process = factory(Process::class)->create();
//Create group
$group = factory(Groupwf::class, 1)->create();
$group = factory(Groupwf::class)->create();
//Create user
$user = factory(User::class, 1)->create();
$user = factory(User::class)->create();
//Assign a user in the group
factory(GroupUser::class, 1)->create([
'GRP_UID' => $group[0]->GRP_UID,
'GRP_ID' => $group[0]->GRP_ID,
'USR_UID' => $user[0]->USR_UID
factory(GroupUser::class)->create([
'GRP_UID' => $group->GRP_UID,
'GRP_ID' => $group->GRP_ID,
'USR_UID' => $user->USR_UID
]);
//Create a task self service
$task1 = factory(Task::class, 1)->create([
$task1 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process[0]->PRO_UID
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task1
factory(TaskUser::class, 1)->create([
'TAS_UID' => $task1[0]->TAS_UID,
'USR_UID' => $user[0]->USR_UID,
factory(TaskUser::class)->create([
'TAS_UID' => $task1->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create a task self service
$task2 = factory(Task::class, 1)->create([
$task2 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process[0]->PRO_UID
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task2
factory(TaskUser::class, 1)->create([
'TAS_UID' => $task2[0]->TAS_UID,
'USR_UID' => $user[0]->USR_UID,
factory(TaskUser::class)->create([
'TAS_UID' => $task2->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create a task self service
$task3 = factory(Task::class, 1)->create([
$task3 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process[0]->PRO_UID
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class, 1)->create([
'TAS_UID' => $task3[0]->TAS_UID,
'USR_UID' => $group[0]->GRP_UID,
factory(TaskUser::class)->create([
'TAS_UID' => $task3->TAS_UID,
'USR_UID' => $group->GRP_UID,
'TU_RELATION' => 2, //Related to the group
'TU_TYPE' => 1
]);
//Create a task self service
$task4 = factory(Task::class, 1)->create([
$task4 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process[0]->PRO_UID
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class, 1)->create([
'TAS_UID' => $task4[0]->TAS_UID,
'USR_UID' => $group[0]->GRP_UID,
factory(TaskUser::class)->create([
'TAS_UID' => $task4->TAS_UID,
'USR_UID' => $group->GRP_UID,
'TU_RELATION' => 2, //Related to the group
'TU_TYPE' => 1
]);
//Create the register in list unassigned related to the task1
factory(ListUnassigned::class, 15)->create([
'TAS_ID' => $task1[0]->TAS_ID
factory(ListUnassigned::class, 10)->create([
'TAS_ID' => $task1->TAS_ID
]);
//Create the register in list unassigned related to the task2
factory(ListUnassigned::class, 15)->create([
'TAS_ID' => $task2[0]->TAS_ID
factory(ListUnassigned::class, 10)->create([
'TAS_ID' => $task2->TAS_ID
]);
//Create the register in list unassigned related to the task3
factory(ListUnassigned::class, 15)->create([
'TAS_ID' => $task3[0]->TAS_ID
factory(ListUnassigned::class, 10)->create([
'TAS_ID' => $task3->TAS_ID
]);
//Create the register in list unassigned related to the task4
factory(ListUnassigned::class, 15)->create([
'TAS_ID' => $task4[0]->TAS_ID
factory(ListUnassigned::class, 10)->create([
'TAS_ID' => $task4->TAS_ID
]);
$timeStart = microtime(true);
$result = ListUnassigned::doCount($user[0]->USR_UID);
$timeEnd = microtime(true);
$this->assertEquals(60, $result);
$time = $timeEnd - $timeStart;
error_log('it_should_count_cases_by_user_with_self_service_user_and_group_assigned_parallel_task took [60]--->' . $time);
//Review the count self-service
$result = ListUnassigned::countSelfService($user->USR_UID);
$this->assertEquals(40, $result);
}
/**
@@ -376,63 +357,60 @@ class ListUnassignedTest extends TestCase
public function it_should_count_cases_by_user_with_self_service_value_based_usr_uid_and_grp_uid()
{
//Create process
$process = factory(Process::class, 1)->create();
$process = factory(Process::class)->create();
//Create a case
$application = factory(Application::class, 1)->create();
$application = factory(Application::class)->create();
//Create user
$user = factory(User::class, 1)->create();
$user = factory(User::class)->create();
//Create a task1 self service value based
$task1 = factory(Task::class, 1)->create([
$task1 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
'PRO_UID' => $process[0]->PRO_UID
'PRO_UID' => $process->PRO_UID
]);
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
$appSelfValue = factory(AppAssignSelfServiceValue::class, 1)->create([
'APP_NUMBER' => $application[0]->APP_NUMBER,
'TAS_ID' => $task1[0]->TAS_ID
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'TAS_ID' => $task1->TAS_ID
]);
factory(AppAssignSelfServiceValueGroup::class, 1)->create([
'ID' => $appSelfValue[0]->ID,
'GRP_UID' => $user[0]->USR_UID,
'ASSIGNEE_ID' => $user[0]->USR_ID, //The usrId or grpId
factory(AppAssignSelfServiceValueGroup::class)->create([
'ID' => $appSelfValue->ID,
'GRP_UID' => $user->USR_UID,
'ASSIGNEE_ID' => $user->USR_ID, //The usrId or grpId
'ASSIGNEE_TYPE' => 1 //Related to the user=1 related to the group=2
]);
//Create the register in list unassigned
factory(ListUnassigned::class, 10)->create([
'APP_NUMBER' => $application[0]->APP_NUMBER,
'DEL_INDEX' => $appSelfValue[0]->DEL_INDEX,
'TAS_ID' => $task1[0]->TAS_ID,
factory(ListUnassigned::class, 15)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => $appSelfValue->DEL_INDEX,
'TAS_ID' => $task1->TAS_ID,
]);
//Create a task2 self service value based
$task2 = factory(Task::class, 1)->create([
$task2 = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
'PRO_UID' => $process[0]->PRO_UID
'PRO_UID' => $process->PRO_UID
]);
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
$appSelfValue = factory(AppAssignSelfServiceValue::class, 1)->create([
'APP_NUMBER' => $application[0]->APP_NUMBER,
'TAS_ID' => $task2[0]->TAS_ID
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'TAS_ID' => $task2->TAS_ID
]);
factory(AppAssignSelfServiceValueGroup::class, 1)->create([
'ID' => $appSelfValue[0]->ID,
'GRP_UID' => $user[0]->USR_UID,
'ASSIGNEE_ID' => $user[0]->USR_ID, //The usrId or grpId
factory(AppAssignSelfServiceValueGroup::class)->create([
'ID' => $appSelfValue->ID,
'GRP_UID' => $user->USR_UID,
'ASSIGNEE_ID' => $user->USR_ID, //The usrId or grpId
'ASSIGNEE_TYPE' => 1 //Related to the user=1 related to the group=2
]);
//Create the register in list unassigned
factory(ListUnassigned::class, 10)->create([
'APP_NUMBER' => $application[0]->APP_NUMBER,
'DEL_INDEX' => $appSelfValue[0]->DEL_INDEX,
'TAS_ID' => $task2[0]->TAS_ID,
factory(ListUnassigned::class, 15)->create([
'APP_NUMBER' => $application->APP_NUMBER,
'DEL_INDEX' => $appSelfValue->DEL_INDEX,
'TAS_ID' => $task2->TAS_ID,
]);
$timeStart = microtime(true);
$result = ListUnassigned::doCount($user[0]->USR_UID);
$this->assertEquals(20, $result);
$timeEnd = microtime(true);
$time = $timeEnd - $timeStart;
error_log('it_should_count_cases_by_user_with_self_service_value_based_usr_uid_and_grp_uid took [20]--->' . $time);
//Review the count self-service
$result = ListUnassigned::countSelfService($user->USR_UID);
$this->assertEquals(30, $result);
}
/**
@@ -443,38 +421,38 @@ class ListUnassignedTest extends TestCase
public function it_should_return_pages_of_data()
{
//Create process
$process = factory(Process::class, 1)->create();
$process = factory(Process::class)->create();
//Create user
$user = factory(User::class, 1)->create();
$user = factory(User::class)->create();
//Create a task self service
$task = factory(Task::class, 1)->create([
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process[0]->PRO_UID
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class, 1)->create([
'TAS_UID' => $task[0]->TAS_UID,
'USR_UID' => $user[0]->USR_UID,
factory(TaskUser::class)->create([
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create the register in list unassigned
factory(ListUnassigned::class, 51)->create([
'TAS_ID' => $task[0]->TAS_ID
'TAS_ID' => $task->TAS_ID
]);
//Define the filters
$filters = ['start' => 0, 'limit' => 25];
//Get data first page
$result = ListUnassigned::loadList($user[0]->USR_UID, $filters);
$result = ListUnassigned::loadList($user->USR_UID, $filters);
$this->assertCount(25, $result);
//Get data second page
$filters = ['start' => 25, 'limit' => 25];
$result = ListUnassigned::loadList($user[0]->USR_UID, $filters);
$result = ListUnassigned::loadList($user->USR_UID, $filters);
$this->assertCount(25, $result);
//Get data third page
$filters = ['start' => 50, 'limit' => 25];
$result = ListUnassigned::loadList($user[0]->USR_UID, $filters);
$result = ListUnassigned::loadList($user->USR_UID, $filters);
$this->assertCount(1, $result);
}
@@ -486,44 +464,44 @@ class ListUnassignedTest extends TestCase
public function it_should_sort_by_case_number()
{
//Create process
$process = factory(Process::class, 1)->create();
$process = factory(Process::class)->create();
//Create user
$user = factory(User::class, 1)->create();
$user = factory(User::class)->create();
//Create a task self service
$task = factory(Task::class, 1)->create([
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process[0]->PRO_UID
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class, 1)->create([
'TAS_UID' => $task[0]->TAS_UID,
'USR_UID' => $user[0]->USR_UID,
factory(TaskUser::class)->create([
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create a case
$application = factory(Application::class, 1)->create([
$application = factory(Application::class)->create([
'APP_NUMBER' => 3000
]);
//Create the register in list unassigned
factory(ListUnassigned::class, 1)->create([
'TAS_ID' => $task[0]->TAS_ID,
'APP_NUMBER' => $application[0]->APP_NUMBER
factory(ListUnassigned::class)->create([
'TAS_ID' => $task->TAS_ID,
'APP_NUMBER' => $application->APP_NUMBER
]);
//Create a case
$application = factory(Application::class, 1)->create([
$application = factory(Application::class)->create([
'APP_NUMBER' => 2000
]);
//Create the register in list unassigned
factory(ListUnassigned::class, 1)->create([
'TAS_ID' => $task[0]->TAS_ID,
'APP_NUMBER' => $application[0]->APP_NUMBER
factory(ListUnassigned::class)->create([
'TAS_ID' => $task->TAS_ID,
'APP_NUMBER' => $application->APP_NUMBER
]);
//Define the filters
$filters = ['sort' => 'APP_NUMBER', 'dir' => 'ASC'];
//Get data
$result = ListUnassigned::loadList($user[0]->USR_UID, $filters);
$result = ListUnassigned::loadList($user->USR_UID, $filters);
$this->assertCount(2, $result);
//Get the minor case number first
$this->assertEquals(2000, $result[0]['APP_NUMBER']);
@@ -532,7 +510,7 @@ class ListUnassignedTest extends TestCase
//Define the filters
$filters = ['sort' => 'APP_NUMBER', 'dir' => 'DESC'];
//Get data
$result = ListUnassigned::loadList($user[0]->USR_UID, $filters);
$result = ListUnassigned::loadList($user->USR_UID, $filters);
$this->assertCount(2, $result);
//Get the major case number first
$this->assertEquals(3000, $result[0]['APP_NUMBER']);
@@ -548,46 +526,46 @@ class ListUnassignedTest extends TestCase
public function it_should_sort_by_case_title()
{
//Create process
$process = factory(Process::class, 1)->create();
$process = factory(Process::class)->create();
//Create user
$user = factory(User::class, 1)->create();
$user = factory(User::class)->create();
//Create a task self service
$task = factory(Task::class, 1)->create([
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process[0]->PRO_UID
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class, 1)->create([
'TAS_UID' => $task[0]->TAS_UID,
'USR_UID' => $user[0]->USR_UID,
factory(TaskUser::class)->create([
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create a case
$application = factory(Application::class, 1)->create([
$application = factory(Application::class)->create([
'APP_NUMBER' => 3001
]);
//Create the register in list unassigned
factory(ListUnassigned::class, 1)->create([
'TAS_ID' => $task[0]->TAS_ID,
'APP_NUMBER' => $application[0]->APP_NUMBER,
'APP_TITLE' => 'Request nro ' . $application[0]->APP_NUMBER,
factory(ListUnassigned::class)->create([
'TAS_ID' => $task->TAS_ID,
'APP_NUMBER' => $application->APP_NUMBER,
'APP_TITLE' => 'Request nro ' . $application->APP_NUMBER,
]);
//Create a case
$application = factory(Application::class, 1)->create([
$application = factory(Application::class)->create([
'APP_NUMBER' => 2001
]);
//Create the register in list unassigned
factory(ListUnassigned::class, 1)->create([
'TAS_ID' => $task[0]->TAS_ID,
'APP_NUMBER' => $application[0]->APP_NUMBER,
'APP_TITLE' => 'Request nro ' . $application[0]->APP_NUMBER,
factory(ListUnassigned::class)->create([
'TAS_ID' => $task->TAS_ID,
'APP_NUMBER' => $application->APP_NUMBER,
'APP_TITLE' => 'Request nro ' . $application->APP_NUMBER,
]);
//Define the filters
$filters = ['sort' => 'APP_TITLE', 'dir' => 'ASC'];
//Get data
$result = ListUnassigned::loadList($user[0]->USR_UID, $filters);
$result = ListUnassigned::loadList($user->USR_UID, $filters);
$this->assertCount(2, $result);
//Get the minor case title first
$this->assertEquals('Request nro 2001', $result[0]['APP_TITLE']);
@@ -596,7 +574,7 @@ class ListUnassignedTest extends TestCase
//Define the filters
$filters = ['sort' => 'APP_TITLE', 'dir' => 'DESC'];
//Get data
$result = ListUnassigned::loadList($user[0]->USR_UID, $filters);
$result = ListUnassigned::loadList($user->USR_UID, $filters);
$this->assertCount(2, $result);
//Get the major case title first
$this->assertEquals('Request nro 3001', $result[0]['APP_TITLE']);
@@ -612,37 +590,37 @@ class ListUnassignedTest extends TestCase
public function it_should_sort_by_process()
{
//Create user
$user = factory(User::class, 1)->create();
$user = factory(User::class)->create();
//Create process
$process = factory(Process::class, 1)->create();
$process = factory(Process::class)->create();
//Create a task self service
$task = factory(Task::class, 1)->create([
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process[0]->PRO_UID
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class, 1)->create([
'TAS_UID' => $task[0]->TAS_UID,
'USR_UID' => $user[0]->USR_UID,
factory(TaskUser::class)->create([
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create the register in list unassigned
factory(ListUnassigned::class, 1)->create([
'TAS_ID' => $task[0]->TAS_ID,
factory(ListUnassigned::class)->create([
'TAS_ID' => $task->TAS_ID,
'APP_PRO_TITLE' => 'Egypt Supplier Payment Proposal',
]);
//Create the register in list unassigned
factory(ListUnassigned::class, 1)->create([
'TAS_ID' => $task[0]->TAS_ID,
factory(ListUnassigned::class)->create([
'TAS_ID' => $task->TAS_ID,
'APP_PRO_TITLE' => 'Russia Supplier Payment Proposal',
]);
//Define the filters
$filters = ['sort' => 'APP_PRO_TITLE', 'dir' => 'ASC'];
//Get data
$result = ListUnassigned::loadList($user[0]->USR_UID, $filters);
$result = ListUnassigned::loadList($user->USR_UID, $filters);
$this->assertCount(2, $result);
//Get the minor process name first
$this->assertEquals('Egypt Supplier Payment Proposal', $result[0]['APP_PRO_TITLE']);
@@ -651,7 +629,7 @@ class ListUnassignedTest extends TestCase
//Define the filters
$filters = ['sort' => 'APP_PRO_TITLE', 'dir' => 'DESC'];
//Get data
$result = ListUnassigned::loadList($user[0]->USR_UID, $filters);
$result = ListUnassigned::loadList($user->USR_UID, $filters);
$this->assertCount(2, $result);
//Get the major process name first
$this->assertEquals('Russia Supplier Payment Proposal', $result[0]['APP_PRO_TITLE']);
@@ -667,36 +645,36 @@ class ListUnassignedTest extends TestCase
public function it_should_sort_by_task()
{
//Create user
$user = factory(User::class, 1)->create();
$user = factory(User::class)->create();
//Create process
$process = factory(Process::class, 1)->create();
$process = factory(Process::class)->create();
//Create a task self service
$task = factory(Task::class, 1)->create([
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process[0]->PRO_UID
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class, 1)->create([
'TAS_UID' => $task[0]->TAS_UID,
'USR_UID' => $user[0]->USR_UID,
factory(TaskUser::class)->create([
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create the register in list unassigned
factory(ListUnassigned::class, 1)->create([
'TAS_ID' => $task[0]->TAS_ID,
factory(ListUnassigned::class)->create([
'TAS_ID' => $task->TAS_ID,
'APP_TAS_TITLE' => 'Initiate Request',
]);
//Create the register in list unassigned
factory(ListUnassigned::class, 1)->create([
'TAS_ID' => $task[0]->TAS_ID,
factory(ListUnassigned::class)->create([
'TAS_ID' => $task->TAS_ID,
'APP_TAS_TITLE' => 'Waiting for AP Manager Validation',
]);
//Define the filters
$filters = ['sort' => 'APP_TAS_TITLE', 'dir' => 'ASC'];
//Get data
$result = ListUnassigned::loadList($user[0]->USR_UID, $filters);
$result = ListUnassigned::loadList($user->USR_UID, $filters);
$this->assertCount(2, $result);
//Get the minor task name first
$this->assertEquals('Initiate Request', $result[0]['APP_TAS_TITLE']);
@@ -705,7 +683,7 @@ class ListUnassignedTest extends TestCase
//Define the filters
$filters = ['sort' => 'APP_TAS_TITLE', 'dir' => 'DESC'];
//Get data
$result = ListUnassigned::loadList($user[0]->USR_UID, $filters);
$result = ListUnassigned::loadList($user->USR_UID, $filters);
$this->assertCount(2, $result);
//Get the major task name first
$this->assertEquals('Waiting for AP Manager Validation', $result[0]['APP_TAS_TITLE']);
@@ -721,54 +699,54 @@ class ListUnassignedTest extends TestCase
public function it_should_return_data_filtered_by_process_category()
{
//Create user
$user = factory(User::class, 1)->create();
$user = factory(User::class)->create();
//Create a category
$category = factory(ProcessCategory::class, 1)->create();
$category = factory(ProcessCategory::class)->create();
//Create process
$process = factory(Process::class, 1)->create([
'PRO_CATEGORY' => $category[0]->CATEGORY_UID
$process = factory(Process::class)->create([
'PRO_CATEGORY' => $category->CATEGORY_UID
]);
//Create a category
$category1 = factory(ProcessCategory::class, 1)->create();
$category1 = factory(ProcessCategory::class)->create();
//Create process
$process1 = factory(Process::class, 1)->create([
'PRO_CATEGORY' => $category1[0]->CATEGORY_UID
$process1 = factory(Process::class)->create([
'PRO_CATEGORY' => $category1->CATEGORY_UID
]);
//Create a task self service
$task = factory(Task::class, 1)->create([
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process[0]->PRO_UID
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class, 1)->create([
'TAS_UID' => $task[0]->TAS_UID,
'USR_UID' => $user[0]->USR_UID,
factory(TaskUser::class)->create([
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create the register in list unassigned
factory(ListUnassigned::class, 2)->create([
'TAS_ID' => $task[0]->TAS_ID,
'PRO_UID' => $process[0]->PRO_UID,
'TAS_ID' => $task->TAS_ID,
'PRO_UID' => $process->PRO_UID,
]);
//Create the register in list unassigned
factory(ListUnassigned::class, 5)->create([
'TAS_ID' => $task[0]->TAS_ID,
'PRO_UID' => $process1[0]->PRO_UID,
'TAS_ID' => $task->TAS_ID,
'PRO_UID' => $process1->PRO_UID,
]);
//Get all data
$result = ListUnassigned::loadList($user[0]->USR_UID);
$result = ListUnassigned::loadList($user->USR_UID);
$this->assertCount(7, $result);
//Define the filters
$filters = ['category' => $category[0]->CATEGORY_UID];
$filters = ['category' => $category->CATEGORY_UID];
//Get data
$result = ListUnassigned::loadList($user[0]->USR_UID, $filters);
$result = ListUnassigned::loadList($user->USR_UID, $filters);
$this->assertCount(2, $result);
//Get the minor case number first
$this->assertEquals($category[0]->CATEGORY_UID, $result[0]['PRO_CATEGORY']);
$this->assertEquals($category->CATEGORY_UID, $result[0]['PRO_CATEGORY']);
//Get the major case number second
$this->assertEquals($category[0]->CATEGORY_UID, $result[1]['PRO_CATEGORY']);
$this->assertEquals($category->CATEGORY_UID, $result[1]['PRO_CATEGORY']);
}
/**
@@ -779,55 +757,55 @@ class ListUnassignedTest extends TestCase
public function it_should_return_data_filtered_by_generic_search()
{
//Create user
$user = factory(User::class, 1)->create();
$user = factory(User::class)->create();
//Create process
$process = factory(Process::class, 1)->create();
$process = factory(Process::class)->create();
//Create a task self service
$task = factory(Task::class, 1)->create([
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process[0]->PRO_UID
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class, 1)->create([
'TAS_UID' => $task[0]->TAS_UID,
'USR_UID' => $user[0]->USR_UID,
factory(TaskUser::class)->create([
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create the register in list unassigned
factory(ListUnassigned::class, 2)->create([
'TAS_ID' => $task[0]->TAS_ID,
'TAS_ID' => $task->TAS_ID,
'APP_TITLE' => 'This is a case name',
]);
//Create the register in list unassigned
factory(ListUnassigned::class, 2)->create([
'TAS_ID' => $task[0]->TAS_ID,
'TAS_ID' => $task->TAS_ID,
'APP_PRO_TITLE' => 'This is a process name',
]);
//Create the register in list unassigned
factory(ListUnassigned::class, 2)->create([
'TAS_ID' => $task[0]->TAS_ID,
'TAS_ID' => $task->TAS_ID,
'APP_TAS_TITLE' => 'This is a task name',
]);
//Create other registers
factory(ListUnassigned::class, 4)->create([
'TAS_ID' => $task[0]->TAS_ID
'TAS_ID' => $task->TAS_ID
]);
//Define the filters
$filters = ['search' => 'case name'];
//Get data related to the search
$result = ListUnassigned::loadList($user[0]->USR_UID, $filters);
$result = ListUnassigned::loadList($user->USR_UID, $filters);
$this->assertCount(2, $result);
//Define the filters
$filters = ['search' => 'process name'];
//Get data related to the search
$result = ListUnassigned::loadList($user[0]->USR_UID, $filters);
$result = ListUnassigned::loadList($user->USR_UID, $filters);
$this->assertCount(2, $result);
//Define the filters
$filters = ['search' => 'task name'];
//Get data related to the search
$result = ListUnassigned::loadList($user[0]->USR_UID, $filters);
$result = ListUnassigned::loadList($user->USR_UID, $filters);
$this->assertCount(2, $result);
}
}

View File

@@ -0,0 +1,51 @@
<?php
namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
use ProcessMaker\Model\Process;
use ProcessMaker\Model\ProcessVariables;
use Tests\TestCase;
class ProcessVariablesTest extends TestCase
{
/**
* It tests the process scope in the ProcessVariables model
* @test
*/
public function it_should_test_process_scope_in_process_variables_model()
{
$process = factory(Process::class, 2)->create();
factory(ProcessVariables::class)->create(
[
'PRJ_UID' => $process[0]['PRO_UID'],
'VAR_SQL' => 'SELECT * FROM USERS WHERE USR_UID="213" UNION SELECT * from PROCESS'
]
);
factory(ProcessVariables::class)->create(
[
'PRJ_UID' => $process[1]['PRO_UID'],
'VAR_SQL' => ''
]
);
factory(ProcessVariables::class)->create(
[
'PRJ_UID' => $process[0]['PRO_UID'],
'VAR_SQL' => ''
]
);
$variablesQuery = ProcessVariables::query()->select();
$variablesQuery->process($process[0]['PRO_UID']);
$result = $variablesQuery->get()->values()->toArray();
// Assert there are two process variables for the specific process
$this->assertCount(2, $result);
// Assert that the result has the correct filtered process
$this->assertEquals($process[0]['PRO_UID'], $result[0]['PRJ_UID']);
$this->assertEquals($process[0]['PRO_UID'], $result[1]['PRJ_UID']);
}
}

View File

@@ -0,0 +1,77 @@
<?php
namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
use ProcessMaker\Model\Process;
use ProcessMaker\Model\Triggers;
use Tests\TestCase;
class TriggersTest extends TestCase
{
/**
* It tests the process scope in the trigger model
* @test
*/
public function it_should_test_process_scope_in_trigger_model()
{
$process = factory(Process::class, 3)->create();
factory(Triggers::class)->create(
[
'PRO_UID' => $process[0]['PRO_UID'],
'TRI_WEBBOT' => '$text=222;
$var1= executeQuery("SELECT *
FROM USERS WHERE
USR_UID=\'$UID\' UNION SELECT * from PROCESS");
$var1= executeQuery("SELECT *
FROM USERS WHERE
USR_UID=\'$UID\' UNION SELECT * from PROCESS");
$query = "SELECT * FROM USERS UNION
SELECT * FROM TASKS";
$QUERY2 = "select * from USERS union SELECT * from GROUPS";
$s1 = "select * from USER";
$s2 = "select * from TASK";
$query3 = $s1. " UNION " . $s2;
executeQuery($query3);'
]
);
factory(Triggers::class)->create(
[
'PRO_UID' => $process[1]['PRO_UID'],
'TRI_WEBBOT' => 'die();'
]
);
factory(Triggers::class)->create(
[
'PRO_UID' => $process[2]['PRO_UID'],
'TRI_WEBBOT' => 'executeQuery("select * from USERS");'
]
);
factory(Triggers::class)->create(
[
'PRO_UID' => $process[2]['PRO_UID'],
'TRI_WEBBOT' => 'executeQuery();'
]
);
$triggerQuery = Triggers::query()->select();
$triggerQuery->process($process[2]['PRO_UID']);
$result = $triggerQuery->get()->values()->toArray();
// Assert there are two triggers for the specific process
$this->assertCount(2, $result);
// Assert that the result has the correct filtered process
$this->assertEquals($process[2]['PRO_UID'], $result[0]['PRO_UID']);
$this->assertEquals($process[2]['PRO_UID'], $result[1]['PRO_UID']);
}
}

View File

@@ -0,0 +1,361 @@
<?php
namespace Tests\unit\workflow\engine\src\ProcessMaker\Services\Api;
use G;
use GuzzleHttp\Client;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\File;
use ProcessMaker\Core\Installer;
use ProcessMaker\Core\System;
use ProcessMaker\Model\ListUnassigned;
use ProcessMaker\Model\Process;
use ProcessMaker\Model\Task;
use ProcessMaker\Model\TaskUser;
use ProcessMaker\Model\User;
use ProcessMaker\Util\DateTime;
use Tests\TestCase;
/**
* To do: This only works if the test database is the same where ProcessMaker is
* installed, improvements must be made so that the method "Installer::create_site()"
* can create the connection file (/processmaker/shared/sites/{workspace}/db.php)
* to different instances of MySql.
*/
class LightTest extends TestCase
{
private $http;
private $baseUri;
private $workspace;
private $clientId;
private $clientSecret;
private $user;
private $password;
private $authorization;
private $optionsForConvertDatetime;
private $timezone;
/**
* This is using instead of DatabaseTransactions
* @todo DatabaseTransactions is having conflicts with propel
*/
protected function setUp()
{
$this->timezone = config('app.timezone');
$_SESSION['USR_TIME_ZONE'] = $this->timezone;
$this->baseUri = $this->getBaseUri();
$this->workspace = env("DB_DATABASE", "test");
$this->clientId = config("oauthClients.pm.clientId");
$this->clientSecret = config("oauthClients.pm.clientSecret");
$this->user = "admin";
$this->password = "admin";
$this->createTestSite();
$this->http = new Client([
"base_uri" => $this->baseUri
]);
$this->optionsForConvertDatetime = [
'newerThan',
'oldestthan',
'date',
'delegateDate',
'dueDate',
'delRiskDate'
];
}
/**
* Get base uri for rest applications.
* @return string
*/
private function getBaseUri()
{
$_SERVER = $this->getServerInformation();
$baseUri = System::getServerProtocolHost();
return $baseUri;
}
/**
* Get server information.
* @return object
*/
private function getServerInformation()
{
$pathData = PATH_DATA . "sites" . PATH_SEP . config("system.workspace") . PATH_SEP . ".server_info";
$content = file_get_contents($pathData);
$serverInfo = unserialize($content);
return $serverInfo;
}
/**
* This method creates a test workspace so that the endpoints can be functional,
* it is necessary to change the permissions of the directory so that other
* users can access and write to the directory, these users can be for
* example: apache2, www-data, httpd, etc...
* This method finds the license file of the active site and uses it to register
* this license in the LICENSE_MANAGER table. If there is no license file in
* the active workspace, an asersion failure will be notified.
*/
private function createTestSite()
{
//We copy the license, otherwise you will not be able to lift the site
$pathTest = PATH_DATA . "sites" . PATH_SEP . $this->workspace;
File::copyDirectory(PATH_DATA . "sites" . PATH_SEP . config("system.workspace"), $pathTest);
//Write permission for other users for example: apache2, www-data, httpd.
passthru('chmod 777 -R ' . $pathTest . ' >> .log 2>&1');
$installer = new Installer();
$options = [
'isset' => true,
'name' => $this->workspace,
'admin' => [
'username' => $this->user,
'password' => $this->password
],
'advanced' => [
'ao_db_drop' => true,
'ao_db_wf' => $this->workspace,
'ao_db_rb' => $this->workspace,
'ao_db_rp' => $this->workspace
]
];
//The false option creates a connection to the database, necessary to create a site.
$installer->create_site($options, false);
//Now create site
$installer->create_site($options, true);
//Important so that the dates are stored in the same timezone
file_put_contents($pathTest . "/env.ini", "time_zone ='{$this->timezone}'", FILE_APPEND);
$matchingFiles = File::glob("{$pathTest}/*.dat");
$this->assertNotEmpty($matchingFiles);
//set license
$licensePath = array_pop($matchingFiles);
DB::Table("LICENSE_MANAGER")->insert([
"LICENSE_UID" => G::generateUniqueID(),
"LICENSE_USER" => "ProcessMaker Inc",
"LICENSE_START" => "1490932800",
"LICENSE_END" => 0,
"LICENSE_SPAN" => 0,
"LICENSE_STATUS" => "ACTIVE",
"LICENSE_DATA" => file_get_contents($licensePath),
"LICENSE_PATH" => $licensePath,
"LICENSE_WORKSPACE" => $this->workspace,
"LICENSE_TYPE" => ""
]);
}
/**
* Get authorization values.
*/
private function getAuthorization()
{
$request = $this->http->request("POST", "{$this->workspace}/oauth2/token", [
"form_params" => [
"grant_type" => "password",
"scope" => "*",
"client_id" => $this->clientId,
"client_secret" => $this->clientSecret,
"username" => $this->user,
"password" => $this->password
]
]);
//Here is to verify if the connection to the endpoint was satisfactory,
//so the connection status should be 200.
$statusCode = $request->getStatusCode();
$this->assertEquals(200, $statusCode);
//If the endpoint has responded we can obtain the data and verify if it
//is what we expected.
$contents = $request->getBody()->getContents();
$credentials = json_decode($contents);
$this->assertNotNull($credentials);
$this->assertObjectHasAttribute('access_token', $credentials);
$this->assertObjectHasAttribute('expires_in', $credentials);
$this->assertObjectHasAttribute('refresh_token', $credentials);
$this->assertObjectHasAttribute('scope', $credentials);
$this->assertObjectHasAttribute('token_type', $credentials);
$this->authorization = ucwords($credentials->token_type) . " {$credentials->access_token}";
}
/**
* Get current collection list unassigned.
* @return collection
*/
private function getCollectionListUnassigned()
{
//Create process
$process = factory(Process::class)->create();
//Get user
$user = User::select()
->where('USR_USERNAME', '=', $this->user)
->first();
//Create a task self service
$task = factory(Task::class)->create([
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
'TAS_GROUP_VARIABLE' => '',
'PRO_UID' => $process->PRO_UID
]);
//Assign a user in the task
factory(TaskUser::class, 1)->create([
'TAS_UID' => $task->TAS_UID,
'USR_UID' => $user->USR_UID,
'TU_RELATION' => 1, //Related to the user
'TU_TYPE' => 1
]);
//Create a record in list unassigned
$listUnassigned = factory(ListUnassigned::class, 15)->create([
'TAS_ID' => $task->TAS_ID,
'DEL_PREVIOUS_USR_UID' => $user->USR_UID
]);
$result = $listUnassigned->sortByDesc('DEL_DELEGATE_DATE');
return $result;
}
/**
* Changes the data to the format returned by REST API.
* @param array $collection
* @return array
*/
private function normalizeData($collection)
{
$result = [];
$collection->transform(function ($item, $key) use (&$result) {
$value = [
'caseId' => $item->APP_UID,
//The current EndPoint returns this value as a string, an Eloquent
//collection takes into account the string and numeric types.
'delIndex' => (string) $item->DEL_INDEX,
'task' => [
'taskId' => $item->TAS_UID,
'name' => $item->APP_TAS_TITLE
],
'process' => [
'processId' => $item->PRO_UID,
'name' => $item->APP_PRO_TITLE
],
//The current EndPoint returns this value as a string, an Eloquent
//collection takes into account the string and numeric types.
'caseNumber' => (string) $item->APP_NUMBER,
'caseTitle' => $item->APP_TITLE,
'date' => $item->APP_UPDATE_DATE->format('Y-m-d H:i:s'),
'delegateDate' => $item->DEL_DELEGATE_DATE->format('Y-m-d H:i:s'),
'prevUser' => [
'userId' => $item->DEL_PREVIOUS_USR_UID,
'userName' => $item->DEL_PREVIOUS_USR_USERNAME,
'firstName' => $item->DEL_PREVIOUS_USR_FIRSTNAME,
'lastName' => $item->DEL_PREVIOUS_USR_LASTNAME
],
'dueDate' => $item->DEL_DUE_DATE->format('Y-m-d H:i:s'),
];
$result[] = $value;
});
$converted = DateTime::convertUtcToIso8601($result, $this->optionsForConvertDatetime);
//Convert the elements to an object
$object = json_decode(json_encode($converted));
return $object;
}
/**
* This returns an array of arrays to test the $start and $limit parameters.
* The values correspond to the following structure:
* [
* [$page, $size, $start, $limit],
* [$page, $size, $start, $limit],
* [$page, $size, $start, $limit],
* ]
* $page and $size are necessary to test the pages we expect to have from the
* model collection.
* @return array
*/
public function pagesProvider()
{
return [
[1, 5, 0, 5],
[2, 5, 5, 5],
[3, 5, 10, 5],
[4, 5, 15, 5],
[5, 5, 20, 5],
[6, 5, 25, 5]
];
}
/**
* This check if the endpoint {workspace}/light/unassigned, is returning all data.
* @test
* @covers ProcessMaker\Services\Api\Light::doGetCasesListUnassigned
*/
public function it_should_get_all_data_without_start_and_limit_values()
{
$listUnassigned = $this->getCollectionListUnassigned();
$this->getAuthorization();
$request = $this->http->request("GET", "api/1.0/{$this->workspace}/light/unassigned", [
"headers" => [
"Authorization" => $this->authorization
]
]);
//Here is to verify if the connection to the endpoint was satisfactory,
//so the connection status should be 200.
$statusCode = $request->getStatusCode();
$this->assertEquals(200, $statusCode);
//If the endpoint has responded we can obtain the data and verify if it
//is what we expected.
$expected = $this->normalizeData($listUnassigned);
$contents = $request->getBody()->getContents();
$content = json_decode($contents);
$this->assertEquals($expected, $content);
}
/**
* This check if the endpoint {workspace}/light/unassigned, is returning the
* requested data set according to the start and limit parameters. The $start
* and $limit test values are obtained from the data provider pagesProvider().
* @test
* @covers ProcessMaker\Services\Api\Light::doGetCasesListUnassigned
* @dataProvider pagesProvider
*/
public function it_should_get_data_with_start_and_limit($page, $size, $start, $limit)
{
$listUnassigned = $this->getCollectionListUnassigned();
$result = $listUnassigned->forPage($page, $size);
$this->getAuthorization();
$request = $this->http->request("GET", "api/1.0/{$this->workspace}/light/unassigned?start={$start}&limit={$limit}", [
"headers" => [
"Authorization" => $this->authorization
]
]);
//Here is to verify if the connection to the endpoint was satisfactory,
//so the connection status should be 200.
$statusCode = $request->getStatusCode();
$this->assertEquals(200, $statusCode);
//If the endpoint has responded we can obtain the data and verify if it
//is what we expected.
$expected = $this->normalizeData($result);
$contents = $request->getBody()->getContents();
$content = json_decode($contents);
$this->assertEquals($expected, $content);
}
}

View File

@@ -0,0 +1,219 @@
<?php
namespace Tests\unit\workflow\engine\src\ProcessMaker\Validation;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use ProcessMaker\Model\Dynaform;
use ProcessMaker\Model\Process;
use ProcessMaker\Model\ProcessVariables;
use ProcessMaker\Model\Triggers;
use ProcessMaker\Validation\MySQL57;
use Tests\TestCase;
class MySQL57Test extends TestCase
{
use DatabaseTransactions;
/**
* Test the MySQL 5.7 incompatibilities in dynaforms
*
* @test
*/
public function it_should_test_incompatibilities_with_dynaforms()
{
$process = factory(Process::class, 2)->create();
factory(Dynaform::class)->create(
[
'PRO_UID' => $process[0]['PRO_UID'],
'DYN_CONTENT' => '{"name":"2","description":"","items":[{"type":"form","variable":"","var_uid":"","dataType":"","id":"6170264265d1b544bebdbd5098250194","name":"2","description":"","mode":"edit","script":"","language":"en","externalLibs":"","printable":false,"items":[[{"type":"title","id":"title0000000001","label":"title_1","colSpan":12}],[{"type":"text","variable":"textVar002","var_uid":"9778460595d1b545088dd69091601043","dataType":"string","protectedValue":false,"id":"textVar002","name":"textVar002","label":"text_1","defaultValue":"","placeholder":"","hint":"","required":false,"requiredFieldErrorMessage":"","textTransform":"none","validate":"","validateMessage":"","maxLength":1000,"formula":"","mode":"parent","operation":"","dbConnection":"workflow","dbConnectionLabel":"PM Database","sql":"","var_name":"textVar002","colSpan":12}],[{"type":"textarea","variable":"textareaVar001","var_uid":"2934510045d1b5453f21373072798412","dataType":"string","protectedValue":false,"id":"textareaVar001","name":"textareaVar001","label":"textarea_1","defaultValue":"","placeholder":"","hint":"","required":false,"requiredFieldErrorMessage":"","validate":"","validateMessage":"","mode":"parent","dbConnection":"workflow","dbConnectionLabel":"PM Database","sql":"","rows":"5","var_name":"textareaVar001","colSpan":12}],[{"type":"datetime","variable":"datetimeVar001","var_uid":"9780823375d1b5455e9c3a2064729484","dataType":"datetime","protectedValue":false,"id":"datetimeVar001","name":"datetimeVar001","label":"datetime_1","placeholder":"","hint":"","required":false,"requiredFieldErrorMessage":"","mode":"parent","format":"YYYY-MM-DD","dayViewHeaderFormat":"MMMM YYYY","extraFormats":false,"stepping":1,"minDate":"","maxDate":"","useCurrent":"false","collapse":true,"locale":"","defaultDate":"","disabledDates":false,"enabledDates":false,"icons":{"time":"glyphicon glyphicon-time","date":"glyphicon glyphicon-calendar","up":"glyphicon glyphicon-chevron-up","down":"glyphicon glyphicon-chevron-down","previous":"glyphicon glyphicon-chevron-left","next":"glyphicon glyphicon-chevron-right","today":"glyphicon glyphicon-screenshot","clear":"glyphicon glyphicon-trash"},"useStrict":false,"sideBySide":false,"daysOfWeekDisabled":false,"calendarWeeks":false,"viewMode":"days","toolbarPlacement":"default","showTodayButton":false,"showClear":"false","widgetPositioning":{"horizontal":"auto","vertical":"auto"},"widgetParent":null,"keepOpen":false,"var_name":"datetimeVar001","colSpan":12}],[{"type":"submit","id":"submit0000000001","name":"submit0000000001","label":"submit_1","colSpan":12}]],"variables":[{"var_uid":"9778460595d1b545088dd69091601043","prj_uid":"5139642915ccb3fca429a36061714972","var_name":"textVar002","var_field_type":"string","var_field_size":10,"var_label":"string","var_dbconnection":"workflow","var_dbconnection_label":"PM Database","var_sql":"","var_null":0,"var_default":"","var_accepted_values":"[]","inp_doc_uid":""},{"var_uid":"2934510045d1b5453f21373072798412","prj_uid":"5139642915ccb3fca429a36061714972","var_name":"textareaVar001","var_field_type":"string","var_field_size":10,"var_label":"string","var_dbconnection":"workflow","var_dbconnection_label":"PM Database","var_sql":"","var_null":0,"var_default":"","var_accepted_values":"[]","inp_doc_uid":""},{"var_uid":"9780823375d1b5455e9c3a2064729484","prj_uid":"5139642915ccb3fca429a36061714972","var_name":"datetimeVar001","var_field_type":"datetime","var_field_size":10,"var_label":"datetime","var_dbconnection":"workflow","var_dbconnection_label":"PM Database","var_sql":"","var_null":0,"var_default":"","var_accepted_values":"[]","inp_doc_uid":""}]}]}'
]
);
factory(Dynaform::class)->create(
[
'PRO_UID' => $process[1]['PRO_UID'],
'DYN_CONTENT' => '{"name":"1","description":"","items":[{"type":"form","variable":"","var_uid":"","dataType":"","id":"6817532755d16225629cb05061521548","name":"1","description":"","mode":"edit","script":"","language":"en","externalLibs":"","printable":false,"items":[[{"type":"text","variable":"textVar001","var_uid":"4746221155d1622658943d1014840579","dataType":"string","protectedValue":false,"id":"textVar001","name":"textVar001","label":"text_1","defaultValue":"","placeholder":"","hint":"","required":false,"requiredFieldErrorMessage":"","textTransform":"none","validate":"","validateMessage":"","maxLength":1000,"formula":"","mode":"parent","operation":"","dbConnection":"workflow","dbConnectionLabel":"PM Database","sql":"SELECT * FROM USERS WHERE \nUSR_UID=\'$UID\' UNION SELECT * from PROCESS","var_name":"textVar001","colSpan":12}]],"variables":[{"var_uid":"4746221155d1622658943d1014840579","prj_uid":"5139642915ccb3fca429a36061714972","var_name":"textVar001","var_field_type":"string","var_field_size":10,"var_label":"string","var_dbconnection":"workflow","var_dbconnection_label":"PM Database","var_sql":"","var_null":0,"var_default":"","var_accepted_values":"[]","inp_doc_uid":""}]}]}'
]
);
$processes = [
[
"PRO_UID" => $process[0]['PRO_UID'],
"PRO_TITLE" => $process[0]['PRO_TITLE']
],
[
"PRO_UID" => $process[1]['PRO_UID'],
"PRO_TITLE" => $process[1]['PRO_TITLE']
]
];
$object = new MySQL57();
$result = $object->checkIncompatibilityDynaforms($processes);
// This asserts that there is a result
$this->assertNotEmpty($result);
// This asserts that there is a process that contains an UNION query inside a dynaform
$this->assertCount(1, $result);
// This asserts that the process containing the UNION queries inside a dynaform, is the first one
$this->assertEquals($result[0]['PRO_UID'], $process[1]['PRO_UID']);
}
/**
* Test the MySQL 5.7 incompatibilities in variables
*
* @test
*/
public function it_should_test_incompatibilities_with_variables()
{
$process = factory(Process::class, 2)->create();
factory(ProcessVariables::class)->create(
[
'PRJ_UID' => $process[0]['PRO_UID'],
'VAR_SQL' => 'SELECT * FROM USERS WHERE USR_UID="213" UNION SELECT * from PROCESS',
]
);
$variables = factory(ProcessVariables::class)->create(
[
'PRJ_UID' => $process[1]['PRO_UID'],
'VAR_SQL' => '',
]
);
$processes = [
[
"PRO_UID" => $process[0]['PRO_UID'],
"PRO_TITLE" => $process[0]['PRO_TITLE']
],
[
"PRO_UID" => $process[1]['PRO_UID'],
"PRO_TITLE" => $process[1]['PRO_TITLE']
]
];
$object = new MySQL57();
$result = $object->checkIncompatibilityVariables($processes);
// This asserts that there is a result
$this->assertNotEmpty($result);
// This asserts that there is a process that contains an UNION query in a variable
$this->assertCount(1, $result);
// This asserts that the process containing the UNION query in a variable, is the first one
$this->assertEquals($result[0]['PRO_UID'], $process[0]['PRO_UID']);
// This asserts that the result does not contain a variable that does not have a UNION query
$this->assertNotEquals($result[0]['VAR_UID'], $variables['VAR_UID']);
}
/**
* Test the MySQL 5.7 incompatibilities in triggers
*
* @test
*/
public function it_should_test_incompatibilities_with_triggers()
{
$process = factory(Process::class, 3)->create();
factory(Triggers::class)->create(
[
'PRO_UID' => $process[0]['PRO_UID'],
'TRI_WEBBOT' => '$text=222;
$var1= executeQuery("SELECT *
FROM USERS WHERE
USR_UID=\'$UID\' UNION SELECT * from PROCESS");
$var1= executeQuery("SELECT *
FROM USERS WHERE
USR_UID=\'$UID\' UNION SELECT * from PROCESS");
$query = "SELECT * FROM USERS UNION
SELECT * FROM TASKS";
$QUERY2 = "select * from USERS union SELECT * from GROUPS";
$s1 = "select * from USER";
$s2 = "select * from TASK";
$query3 = $s1. " UNION " . $s2;
executeQuery($query3);'
]
);
factory(Triggers::class)->create(
[
'PRO_UID' => $process[1]['PRO_UID'],
'TRI_WEBBOT' => 'die();'
]
);
factory(Triggers::class)->create(
[
'PRO_UID' => $process[2]['PRO_UID'],
'TRI_WEBBOT' => 'executeQuery("select * from USERS");'
]
);
$processes = [
[
"PRO_UID" => $process[0]['PRO_UID'],
"PRO_TITLE" => $process[0]['PRO_TITLE']
],
[
"PRO_UID" => $process[1]['PRO_UID'],
"PRO_TITLE" => $process[1]['PRO_TITLE']
],
[
"PRO_UID" => $process[2]['PRO_UID'],
"PRO_TITLE" => $process[2]['PRO_TITLE']
]
];
$object = new MySQL57();
$result = $object->checkIncompatibilityTriggers($processes);
// This asserts that there is a result
$this->assertNotEmpty($result);
// This asserts that there is a process that contains an UNION query
$this->assertCount(1, $result);
// This asserts that the process containing the UNION queries is the first one
$this->assertEquals($result[0]['PRO_UID'], $process[0]['PRO_UID']);
}
/**
* Test the query analyzer method
*
* @test
*/
public function it_should_test_the_query_analyzer()
{
$query = "";
$object = new MySQL57();
$result = $object->analyzeQuery($query);
// This asserts that there is not a UNION query
$this->assertFalse($result);
$query = "select * from USERS UNION select '1241412515'";
$result = $object->analyzeQuery($query);
// This asserts that there is a UNION query
$this->assertTrue($result);
$query = "select * from USERS LEFT JOIN TASKS ON 'USERS.USR_UID = TASKS.USR_UID '";
$result = $object->analyzeQuery($query);
// This asserts that there is not a UNION query
$this->assertFalse($result);
}
}

View File

@@ -80,7 +80,7 @@
* @access public
* @return void
*/
public function pakeYAMLNode() {
public function __construct() {
$this->id = uniqid('');
}
}

View File

@@ -126,7 +126,7 @@ class Log
* @access public
* @since Log 1.0
*/
function &factory($handler, $name = '', $ident = '', $conf = array(),
public static function &factory($handler, $name = '', $ident = '', $conf = array(),
$level = PEAR_LOG_DEBUG)
{
$handler = strtolower($handler);
@@ -188,7 +188,7 @@ class Log
* @access public
* @since Log 1.0
*/
function &singleton($handler, $name = '', $ident = '', $conf = array(),
public static function &singleton($handler, $name = '', $ident = '', $conf = array(),
$level = PEAR_LOG_DEBUG)
{
static $instances;

View File

@@ -1,5 +1,8 @@
<?php
use ProcessMaker\Model\Process;
use ProcessMaker\Validation\MySQL57;
CLI::taskName('info');
CLI::taskDescription(<<<EOT
Print information about the current system and any specified workspaces.
@@ -362,6 +365,31 @@ EOT
CLI::taskArg('workspace');
CLI::taskRun("run_sync_forms_with_info_from_input_documents");
/**
* Remove the deprecated files
*/
CLI::taskName('remove-unused-files');
CLI::taskDescription(<<<EOT
Remove the deprecated files.
EOT
);
CLI::taskRun("remove_deprecated_files");
/*********************************************************************/
CLI::taskName("check-queries-incompatibilities");
CLI::taskDescription(<<<EOT
Check queries incompatibilities (MySQL 5.7) for the specified workspace(s).
This command checks the queries incompatibilities (MySQL 5.7) in the specified workspace(s).
If no workspace is specified, the command will be run in all workspaces.
More than one workspace can be specified.
EOT
);
CLI::taskArg("workspace-name", true, true);
CLI::taskRun("run_check_queries_incompatibilities");
/*********************************************************************/
/**
* Function run_info
*
@@ -467,6 +495,7 @@ function run_upgrade_content($args, $opts)
}
}
}
/**
* This function will upgrade the CONTENT table for a workspace
* This function is executed only for one workspace
@@ -1348,3 +1377,89 @@ function run_sync_forms_with_info_from_input_documents($args, $opts) {
}
}
}
/**
* Remove the deprecated files
*
* @return void
* @see workflow/engine/bin/tasks/cliWorkspaces.php CLI::taskRun()
* @link https://wiki.processmaker.com/3.3/processmaker_command
*/
function remove_deprecated_files()
{
//The constructor requires an argument, so we send an empty value in order to use the class.
$workspaceTools = new WorkspaceTools('');
$workspaceTools->removeDeprecatedFiles();
CLI::logging("<*> The deprecated files has been removed. \n");
}
/**
* This function review the queries for each workspace or for an specific workspace
*
* @param array $args
*
* @return void
*/
function run_check_queries_incompatibilities($args)
{
try {
$workspaces = get_workspaces_from_args($args);
if (count($args) === 1) {
CLI::logging("> Workspace: " . $workspaces[0]->name . PHP_EOL);
check_queries_incompatibilities($workspaces[0]->name);
} else {
foreach ($workspaces as $workspace) {
passthru(PHP_BINARY . " processmaker check-queries-incompatibilities " . $workspace->name);
}
}
echo "Done!\n\n";
} catch (Exception $e) {
G::outRes(CLI::error($e->getMessage()) . "\n");
}
}
/**
* Check for the incompatibilities in the queries for the specific workspace
*
* @param string $wsName
*/
function check_queries_incompatibilities($wsName)
{
Bootstrap::setConstantsRelatedWs($wsName);
require_once(PATH_DB . $wsName . '/db.php');
System::initLaravel();
$query = Process::query()->select('PRO_UID', 'PRO_TITLE');
$processesToCheck = $query->get()->values()->toArray();
$obj = new MySQL57();
$resTriggers = $obj->checkIncompatibilityTriggers($processesToCheck);
if (!empty($resTriggers)) {
foreach ($resTriggers as $trigger) {
echo ">> The \"" . $trigger['PRO_TITLE'] . "\" process has a trigger called: \"" . $trigger['TRI_TITLE'] . "\" that contains UNION queries. Review the code to discard incompatibilities with MySQL5.7." . PHP_EOL;
}
} else {
echo ">> No MySQL 5.7 incompatibilities in triggers found for this workspace." . PHP_EOL;
}
$resDynaforms = $obj->checkIncompatibilityDynaforms($processesToCheck);
if (!empty($resDynaforms)) {
foreach ($resDynaforms as $dynaform) {
echo ">> The \"" . $dynaform['PRO_TITLE'] . "\" process has a dynaform called: \"" . $dynaform['DYN_TITLE'] . "\" that contains UNION queries. Review the code to discard incompatibilities with MySQL5.7." . PHP_EOL;
}
} else {
echo ">> No MySQL 5.7 incompatibilities in dynaforms found for this workspace." . PHP_EOL;
}
$resVariables = $obj->checkIncompatibilityVariables($processesToCheck);
if (!empty($resVariables)) {
foreach ($resVariables as $variable) {
echo ">> The \"" . $variable['PRO_TITLE'] . "\" process has a variable called: \"" . $variable['VAR_NAME'] . "\" that contains UNION queries. Review the code to discard incompatibilities with MySQL5.7." . PHP_EOL;
}
} else {
echo ">> No MySQL 5.7 incompatibilities in variables found for this workspace." . PHP_EOL;
}
}

View File

@@ -628,7 +628,7 @@ class Cases
$task = TaskPeer::retrieveByPk($currentDelegations[$r]->getTasUid());
$caseLabel = $task->$getTasDef();
if ($caseLabel != '') {
$appLabel = G::replaceDataField($caseLabel, $aAppData);
$appLabel = G::replaceDataField($caseLabel, $aAppData, 'mysql', false);
break;
}
}
@@ -686,7 +686,7 @@ class Cases
//Get the case title
$tasDefTitle = trim($row['TAS_DEF_TITLE']);
if (!empty($tasDefTitle) && !$flagTitle) {
$newAppProperty = G::replaceDataField($tasDefTitle, $lastFieldsCase);
$newAppProperty = G::replaceDataField($tasDefTitle, $lastFieldsCase, 'mysql', false);
$res['APP_TITLE'] = $newAppProperty;
if (!(isset($currentValue) && ($currentValue == $tasDefTitle))) {
$newValues['APP_TITLE'] = $newAppProperty;
@@ -696,7 +696,7 @@ class Cases
//Get the case description
$tasDefDescription = trim($row['TAS_DEF_DESCRIPTION']);
if (!empty($tasDefDescription) && !$flagDescription) {
$newAppProperty = G::replaceDataField($tasDefDescription, $lastFieldsCase);
$newAppProperty = G::replaceDataField($tasDefDescription, $lastFieldsCase, 'mysql', false);
$res['APP_DESCRIPTION'] = $newAppProperty;
if (!(isset($currentValue) && ($currentValue == $tasDefDescription))) {
$newValues['APP_DESCRIPTION'] = $newAppProperty;
@@ -5441,7 +5441,7 @@ class Cases
switch ($typeSend) {
case 'LAST':
if (isset($aTaskInfo['TAS_DEF_SUBJECT_MESSAGE']) && $aTaskInfo['TAS_DEF_SUBJECT_MESSAGE'] != '') {
$sSubject = G::replaceDataField($aTaskInfo['TAS_DEF_SUBJECT_MESSAGE'], $arrayData);
$sSubject = G::replaceDataField($aTaskInfo['TAS_DEF_SUBJECT_MESSAGE'], $arrayData, 'mysql', false);
} else {
$sSubject = G::LoadTranslation('ID_MESSAGE_SUBJECT_DERIVATION');
}
@@ -5526,7 +5526,7 @@ class Cases
break;
case 'RECEIVE':
if (isset($aTaskInfo['TAS_RECEIVE_SUBJECT_MESSAGE']) && $aTaskInfo['TAS_RECEIVE_SUBJECT_MESSAGE'] != '') {
$sSubject = G::replaceDataField($aTaskInfo['TAS_RECEIVE_SUBJECT_MESSAGE'], $arrayData);
$sSubject = G::replaceDataField($aTaskInfo['TAS_RECEIVE_SUBJECT_MESSAGE'], $arrayData, 'mysql', false);
} else {
$sSubject = G::LoadTranslation('ID_MESSAGE_SUBJECT_DERIVATION');
}
@@ -5612,30 +5612,30 @@ class Cases
/**
* This function send an email for each task in $arrayTask if $to is definded
*
* @param array $dataLastEmail
* @param array $arrayData
* @param array $arrayTask
* @param $dataLastEmail
* @param $arrayData
* @param $arrayTask
* @return void
*
* @see \Cases->sendNotifications()
*/
public function sendMessage($dataLastEmail, $arrayData, $arrayTask)
{
foreach ($arrayTask as $theTask) {
foreach ($arrayTask as $aTask) {
//Check and fix if Task Id is complex
if (strpos($theTask['TAS_UID'], "/") !== false) {
$aux = explode("/", $theTask['TAS_UID']);
if (strpos($aTask['TAS_UID'], "/") !== false) {
$aux = explode("/", $aTask['TAS_UID']);
if (isset($aux[1])) {
$theTask['TAS_UID'] = $aux[1];
$aTask['TAS_UID'] = $aux[1];
}
}
//if the next is EOP dont send notification and continue with the next
if ($theTask['TAS_UID'] === '-1') {
if ($aTask['TAS_UID'] === '-1') {
continue;
}
if (isset($theTask['DEL_INDEX'])) {
if (isset($aTask['DEL_INDEX'])) {
$arrayData2 = $arrayData;
$appDelegation = AppDelegationPeer::retrieveByPK($dataLastEmail['applicationUid'], $theTask['DEL_INDEX']);
$appDelegation = AppDelegationPeer::retrieveByPK($dataLastEmail['applicationUid'], $aTask['DEL_INDEX']);
if (!is_null($appDelegation)) {
$oTaskUpd = new Task();
$aTaskUpdate = $oTaskUpd->load($appDelegation->getTasUid());
@@ -5646,25 +5646,25 @@ class Cases
$arrayData2 = $arrayData;
}
if (isset($theTask['USR_UID']) && !empty($theTask['USR_UID'])) {
if (isset($aTask['USR_UID']) && !empty($aTask['USR_UID'])) {
$user = new \ProcessMaker\BusinessModel\User();
$arrayUserData = $user->getUser($theTask['USR_UID'], true);
$arrayUserData = $user->getUser($aTask['USR_UID'], true);
$arrayData2 = \ProcessMaker\Util\DateTime::convertUtcToTimeZone($arrayData2,
(trim($arrayUserData['USR_TIME_ZONE']) != '') ? trim($arrayUserData['USR_TIME_ZONE']) :
\ProcessMaker\Util\System::getTimeZone());
} else {
$arrayData2 = \ProcessMaker\Util\DateTime::convertUtcToTimeZone($arrayData2);
}
$body2 = G::replaceDataGridField($dataLastEmail['body'], $arrayData2, false, true);
$body2 = G::replaceDataGridField($dataLastEmail['body'], $arrayData2, false);
$to = null;
$cc = '';
if ($theTask['TAS_UID'] != '-1') {
$respTo = $this->getTo($theTask['TAS_UID'], $theTask['USR_UID'], $arrayData);
if ($aTask['TAS_UID'] != '-1') {
$respTo = $this->getTo($aTask['TAS_UID'], $aTask['USR_UID'], $arrayData);
$to = $respTo['to'];
$cc = $respTo['cc'];
}
if ($theTask["TAS_ASSIGN_TYPE"] === "SELF_SERVICE") {
if ($aTask ["TAS_ASSIGN_TYPE"] === "SELF_SERVICE") {
if ($dataLastEmail['swtplDefault'] == 1) {
G::verifyPath($dataLastEmail['pathEmail'], true); // Create if it does not exist
$fileTemplate = $dataLastEmail['pathEmail'] . G::LoadTranslation('ID_UNASSIGNED_MESSAGE');
@@ -5674,7 +5674,7 @@ class Cases
) {
@copy(PATH_TPL . "mails" . PATH_SEP . G::LoadTranslation('ID_UNASSIGNED_MESSAGE'), $fileTemplate);
}
$body2 = G::replaceDataField(file_get_contents($fileTemplate), $arrayData2);
$body2 = G::replaceDataField(file_get_contents($fileTemplate), $arrayData2, 'mysql', false);
}
}
@@ -6976,7 +6976,7 @@ class Cases
return isset($row['DEL_INDEX']) ? $row['DEL_INDEX'] : 0;
}
public function clearCaseSessionData()
public static function clearCaseSessionData()
{
if (isset($_SESSION['APPLICATION'])) {
unset($_SESSION['APPLICATION']);

View File

@@ -22,7 +22,7 @@ class EnterpriseClass extends PMPlugin
{
}
public function enterpriseSystemUpdate($data) //$data = $oData
public static function enterpriseSystemUpdate($data) //$data = $oData
{
if (count(glob(PATH_DATA_SITE . 'license/*.dat')) == 0) {
return;

View File

@@ -253,7 +253,7 @@ class PmDynaform
}
}
}
$sql = G::replaceDataField($json->sql, $dtFields);
$sql = G::replaceDataField($json->sql, $dtFields, 'mysql', false);
if ($value === "suggest") {
$sql = $this->prepareSuggestSql($sql, $json);
}
@@ -715,7 +715,7 @@ class PmDynaform
}
}
if ($json->dbConnection !== "" && $json->dbConnection !== "none" && $json->sql !== "") {
$sql = G::replaceDataField($json->sql, $data);
$sql = G::replaceDataField($json->sql, $data, 'mysql', false);
$dt = $this->getCacheQueryData($json->dbConnection, $sql, $json->type);
$row = isset($dt[0]) ? $dt[0] : [];
$index = $json->variable === "" ? $json->id : $json->variable;

View File

@@ -1919,14 +1919,19 @@ class Processes
/**
* Gets Input Documents Rows from aProcess.
* Gets Input Documents Rows from process.
*
* @param string $proUid
* @param boolean $unsetInpDocId
*
* @return array
* @throws Exception
*
* @see Processes::getWorkflowData()
* @see ProcessMaker\BusinessModel\Migrator\InputDocumentsMigrator::export()
* @see ProcessMaker\Importer\Importer::saveCurrentProcess()
*/
public function getInputRows($proUid)
public function getInputRows($proUid, $unsetInpDocId = true)
{
try {
$inputList = [];
@@ -1938,7 +1943,9 @@ class Processes
while ($row = $dataset->getRow()) {
$input = new InputDocument();
$infoInput = $input->load($row['INP_DOC_UID']);
unset($infoInput['INP_DOC_ID']);
if ($unsetInpDocId === true) {
unset($infoInput['INP_DOC_ID']);
}
$inputList[] = $infoInput;
$dataset->next();
}
@@ -1956,6 +1963,10 @@ class Processes
*
* @return void
* @throws Exception
*
* @see Processes::createProcessPropertiesFromData()
* @see Processes::updateProcessFromData()
* @see ProcessMaker\BusinessModel\Migrator\InputDocumentsMigrator::import()
*/
public function createInputRows($input)
{
@@ -1970,11 +1981,15 @@ class Processes
//Get the INP_DOC_ID column
$dataSet = BasePeer::doSelect($criteria, $con);
$dataSet->setFetchmode(ResultSet::FETCHMODE_ASSOC);
if ($dataSet->next()) {
$inputInfo = $dataSet->getRow();
$row['INP_DOC_ID'] = $inputInfo['INP_DOC_ID'];
if (isset($row["__INP_DOC_ID_UPDATE__"]) && $row["__INP_DOC_ID_UPDATE__"] === false) {
unset($row["__INP_DOC_ID_UPDATE__"]);
} else {
$row['INP_DOC_ID'] = null;
if ($dataSet->next()) {
$inputInfo = $dataSet->getRow();
$row['INP_DOC_ID'] = $inputInfo['INP_DOC_ID'];
} else {
$row['INP_DOC_ID'] = null;
}
}
BasePeer::doDelete($criteria, $con);
//Prepare the insert
@@ -2102,11 +2117,16 @@ class Processes
* Gets the Output Documents Rows from a Process.
*
* @param string $proUid
* @param boolean $unsetOutDocId
*
* @return array
* @throws Exception
*
* @see Processes::getWorkflowData()
* @see ProcessMaker\BusinessModel\Migrator\OutputDocumentsMigrator::export()
* @see ProcessMaker\Importer\Importer::saveCurrentProcess()
*/
public function getOutputRows($proUid)
public function getOutputRows($proUid, $unsetOutDocId = true)
{
try {
$outputList = [];
@@ -2118,7 +2138,9 @@ class Processes
while ($row = $dataset->getRow()) {
$output = new OutputDocument();
$infoOutput = $output->Load($row['OUT_DOC_UID']);
unset($infoOutput['OUT_DOC_ID']);
if ($unsetOutDocId === true) {
unset($infoOutput['OUT_DOC_ID']);
}
$outputList[] = $infoOutput;
$dataset->next();
}
@@ -2136,6 +2158,10 @@ class Processes
*
* @return void
* @throws Exception
*
* @see Processes::createProcessPropertiesFromData()
* @see Processes::updateProcessFromData()
* @see ProcessMaker\BusinessModel\Migrator\OutputDocumentsMigrator::import()
*/
public function createOutputRows($output)
{
@@ -2150,11 +2176,15 @@ class Processes
//Get the OUT_DOC_ID column
$dataSet = BasePeer::doSelect($criteria, $con);
$dataSet->setFetchmode(ResultSet::FETCHMODE_ASSOC);
if ($dataSet->next()) {
$outputInfo = $dataSet->getRow();
$row['OUT_DOC_ID'] = $outputInfo['OUT_DOC_ID'];
if (isset($row["__OUT_DOC_ID_UPDATE__"]) && $row["__OUT_DOC_ID_UPDATE__"] === false) {
unset($row["__OUT_DOC_ID_UPDATE__"]);
} else {
$row['OUT_DOC_ID'] = null;
if ($dataSet->next()) {
$outputInfo = $dataSet->getRow();
$row['OUT_DOC_ID'] = $outputInfo['OUT_DOC_ID'];
} else {
$row['OUT_DOC_ID'] = null;
}
}
BasePeer::doDelete($criteria, $con);
//Prepare the insert
@@ -2931,11 +2961,16 @@ class Processes
* Get Dynaform Rows from a Process
*
* @param string $proUid
* @param boolean $unsetDynId
*
* @return array
* @throws Exception
*
* @see Processes::getWorkflowData()
* @see ProcessMaker\BusinessModel\Migrator\DynaformsMigrator::export()
* @see ProcessMaker\Importer\Importer::saveCurrentProcess()
*/
public function getDynaformRows($proUid)
public function getDynaformRows($proUid, $unsetDynId = true)
{
try {
$dynaformList = [];
@@ -2947,7 +2982,9 @@ class Processes
while ($row = $dataset->getRow()) {
$dynaform = new Dynaform();
$infoDyn = $dynaform->Load($row['DYN_UID']);
unset($infoDyn['DYN_ID']);
if ($unsetDynId === true) {
unset($infoDyn['DYN_ID']);
}
$dynaformList[] = $infoDyn;
$dataset->next();
}
@@ -3077,12 +3114,16 @@ class Processes
}
/**
* Create dynaforms for a process
* Create dynaforms for a process.
*
* @param array $dynaforms
*
* @return void
* @throws Exception
*
* @see Processes::createProcessPropertiesFromData()
* @see Processes::updateProcessFromData()
* @see ProcessMaker\BusinessModel\Migrator\DynaformsMigrator::import()
*/
public function createDynaformRows($dynaforms)
{
@@ -3097,11 +3138,15 @@ class Processes
//Get the DYN_ID column
$dataSet = BasePeer::doSelect($criteria, $con);
$dataSet->setFetchmode(ResultSet::FETCHMODE_ASSOC);
if ($dataSet->next()) {
$dynInfo = $dataSet->getRow();
$row['DYN_ID'] = $dynInfo['DYN_ID'];
if (isset($row["__DYN_ID_UPDATE__"]) && $row["__DYN_ID_UPDATE__"] === false) {
unset($row["__DYN_ID_UPDATE__"]);
} else {
$row['DYN_ID'] = null;
if ($dataSet->next()) {
$dynInfo = $dataSet->getRow();
$row['DYN_ID'] = $dynInfo['DYN_ID'];
} else {
$row['DYN_ID'] = null;
}
}
BasePeer::doDelete($criteria, $con);
//Prepare the insert

View File

@@ -111,6 +111,16 @@ class SpoolRun
return $this->spoolId;
}
/**
* Get the fileData property
*
* @return array
*/
public function getFileData()
{
return $this->fileData;
}
/**
* get all files into spool in a list
*
@@ -232,32 +242,52 @@ class SpoolRun
}
/**
* set email parameters
* Set email parameters
*
* @param string $sAppMsgUid , $sSubject, $sFrom, $sTo, $sBody, $sDate, $sCC, $sBCC, $sTemplate
* @return none
* @param string $appMsgUid
* @param string $subject
* @param string $from
* @param string $to
* @param string $body
* @param string $date
* @param string $cc
* @param string $bcc
* @param string $template
* @param array $attachments
* @param bool $contentTypeIsHtml
* @param string $error
*
* @see SpoolRun->create()
* @see SpoolRun->resendEmails()
*/
public function setData($sAppMsgUid, $sSubject, $sFrom, $sTo, $sBody, $sDate = "", $sCC = "", $sBCC = "", $sTemplate = "", $aAttachment = array(), $bContentTypeIsHtml = true, $sError = "")
public function setData($appMsgUid, $subject, $from, $to, $body, $date = '', $cc = '', $bcc = '', $template = '', $attachments = [],
$contentTypeIsHtml = true, $error = '')
{
$this->spoolId = $sAppMsgUid;
$this->fileData['subject'] = $sSubject;
$this->fileData['from'] = $sFrom;
$this->fileData['to'] = $sTo;
$this->fileData['body'] = $sBody;
$this->fileData['date'] = ($sDate != '' ? $sDate : date('Y-m-d H:i:s'));
$this->fileData['cc'] = $sCC;
$this->fileData['bcc'] = $sBCC;
$this->fileData['template'] = $sTemplate;
$this->fileData['attachments'] = $aAttachment;
$this->fileData['envelope_to'] = array();
$this->fileData["contentTypeIsHtml"] = $bContentTypeIsHtml;
$this->fileData["error"] = $sError;
// Fill "fileData" property
$this->spoolId = $appMsgUid;
$this->fileData['subject'] = $subject;
$this->fileData['from'] = $from;
$this->fileData['to'] = $to;
$this->fileData['body'] = $body;
$this->fileData['date'] = (!empty($date) ? $date : date('Y-m-d H:i:s'));
$this->fileData['cc'] = $cc;
$this->fileData['bcc'] = $bcc;
$this->fileData['template'] = $template;
$this->fileData['attachments'] = $attachments;
$this->fileData["contentTypeIsHtml"] = $contentTypeIsHtml;
$this->fileData["error"] = $error;
// Initialize some values used internally
$this->fileData['envelope_to'] = [];
$this->fileData['envelope_cc'] = [];
$this->fileData['envelope_bcc'] = [];
// Domain validation when the email engine is "OpenMail"
if (array_key_exists('MESS_ENGINE', $this->config)) {
if ($this->config['MESS_ENGINE'] == 'OPENMAIL') {
if ($this->config['MESS_SERVER'] != '') {
if (($sAux = @gethostbyaddr($this->config['MESS_SERVER']))) {
$this->fileData['domain'] = $sAux;
if ($this->config['MESS_ENGINE'] === 'OPENMAIL') {
if (!empty($this->config['MESS_SERVER'])) {
if (($domain = @gethostbyaddr($this->config['MESS_SERVER']))) {
$this->fileData['domain'] = $domain;
} else {
$this->fileData['domain'] = $this->config['MESS_SERVER'];
}
@@ -841,4 +871,12 @@ class SpoolRun
return $appMsgUid;
}
/**
* Run the private method "handleEnvelopeTo", this method was created in order to use in the unit tests
*/
public function runHandleEnvelopeTo()
{
$this->handleEnvelopeTo();
}
}

View File

@@ -1074,7 +1074,6 @@ class WorkspaceTools
$this->checkRbacPermissions();//check or add new permissions
$this->checkSequenceNumber();
$this->migrateIteeToDummytask($this->name);
$this->upgradeConfiguration();
/*----------------------------------********---------------------------------*/
$this->upgradeAuditLog($this->name);
/*----------------------------------********---------------------------------*/
@@ -3739,13 +3738,6 @@ class WorkspaceTools
CLI::logging($message);
}
public function upgradeConfiguration()
{
$conf = new Configurations();
$conf->aConfig = 'neoclassic';
$conf->saveConfig('SKIN_CRON', '');
}
public function upgradeAuditLog($workspace)
{
$conf = new Configurations();

View File

@@ -991,7 +991,7 @@ class WsBase
$subject,
G::buildFrom($setup, $from),
$to,
G::replaceDataGridField(file_get_contents($fileTemplate), $fieldsCase, false, true),
G::replaceDataGridField(file_get_contents($fileTemplate), $fieldsCase, false),
$cc,
$bcc,
'',

View File

@@ -1750,7 +1750,7 @@ function PMFGenerateOutputDocument ($outputID, $sApplication = null, $index = nu
//The $_GET['UID'] variable is used when a process executes.
//$_GET['UID']=($aOD['OUT_DOC_VERSIONING'])?$_GET['UID']:$aOD['OUT_DOC_UID'];
//$sUID = ($aOD['OUT_DOC_VERSIONING'])?$_GET['UID']:$aOD['OUT_DOC_UID'];
$sFilename = preg_replace( '[^A-Za-z0-9_]', '_', G::replaceDataField( $aOD['OUT_DOC_FILENAME'], $Fields['APP_DATA'] ) );
$sFilename = preg_replace( '[^A-Za-z0-9_]', '_', G::replaceDataField( $aOD['OUT_DOC_FILENAME'], $Fields['APP_DATA'], 'mysql', false ) );
require_once 'classes/model/AppFolder.php';
require_once 'classes/model/AppDocument.php';

View File

@@ -706,7 +706,7 @@ class PMScript
try {
$cnn = Propel::getConnection($varInfo["VAR_DBCONNECTION"]);
$stmt = $cnn->createStatement();
$sql = G::replaceDataField($varInfo["VAR_SQL"], $this->aFields);
$sql = G::replaceDataField($varInfo["VAR_SQL"], $this->aFields, 'mysql', false);
$rs = $stmt->executeQuery($sql, \ResultSet::FETCHMODE_NUM);
while ($rs->next()) {
$row = $rs->getRow();

View File

@@ -1735,7 +1735,7 @@ class AppCacheView extends BaseAppCacheView
$arrayAppField = $app->Load($appcvAppUid);
$appTitle = (!empty($appTitle))? $appTitle : "#" . $arrayAppField["APP_NUMBER"];
$appTitleNew = G::replaceDataField($appTitle, unserialize($arrayAppField["APP_DATA"]));
$appTitleNew = G::replaceDataField($appTitle, unserialize($arrayAppField["APP_DATA"]), 'mysql', false);
if (isset($arrayAppField["APP_TITLE"]) && $arrayAppField["APP_TITLE"] != $appTitleNew) {
//Updating the value in content, where...

View File

@@ -101,7 +101,7 @@ class AppDelay extends BaseAppDelay
*
* @return boolean
*/
public function isPaused($appUid, $delIndex)
public static function isPaused($appUid, $delIndex)
{
$criteria = new Criteria('workflow');
$criteria->add(AppDelayPeer::APP_UID, $appUid);

View File

@@ -797,7 +797,7 @@ class AppDelegation extends BaseAppDelegation
* @param integer $index, Index to review
* @return array
*/
public function getCurrentUsers($appUid, $index)
public static function getCurrentUsers($appUid, $index)
{
$oCriteria = new Criteria();
$oCriteria->addSelectColumn(AppDelegationPeer::USR_UID);

View File

@@ -145,8 +145,7 @@ class AppFolder extends BaseAppFolder
$oApplication = new Application();
$appFields = $oApplication->Load( $sessionID );
$folderPathParsed = G::replaceDataField( $folderPath, $appFields );
$folderPathParsed = G::replaceDataField( $folderPath, unserialize( $appFields['APP_DATA'] ) );
$folderPathParsed = G::replaceDataField( $folderPath, unserialize( $appFields['APP_DATA'] ), 'mysql', false );
$folderPathParsedArray = explode( "/", $folderPathParsed );
$folderRoot = "/"; //Always starting from Root
foreach ($folderPathParsedArray as $folderName) {
@@ -174,8 +173,7 @@ class AppFolder extends BaseAppFolder
$oApplication = new Application();
$appFields = $oApplication->Load( $sessionID );
$fileTagsParsed = G::replaceDataField( $fileTags, $appFields );
$fileTagsParsed = G::replaceDataField( $fileTags, unserialize( $appFields['APP_DATA'] ) );
$fileTagsParsed = G::replaceDataField( $fileTags, unserialize( $appFields['APP_DATA'] ), 'mysql', false );
return $fileTagsParsed;
}

View File

@@ -213,7 +213,7 @@ class AppNotes extends BaseAppNotes
$configNoteNotification['subject'] = G::LoadTranslation('ID_MESSAGE_SUBJECT_NOTE_NOTIFICATION') . " @#APP_TITLE ";
//Define the body for the notification
$configNoteNotification['body'] = $this->getBodyCaseNote($authorName, $noteContent);
$body = nl2br(G::replaceDataField($configNoteNotification['body'], $fieldCase));
$body = nl2br(G::replaceDataField($configNoteNotification['body'], $fieldCase, 'mysql', false));
$users = new Users();
$recipientsArray = explode(",", $noteRecipients);
@@ -229,7 +229,7 @@ class AppNotes extends BaseAppNotes
$appUid,
$delIndex,
WsBase::MESSAGE_TYPE_CASE_NOTE,
G::replaceDataField($configNoteNotification['subject'], $fieldCase),
G::replaceDataField($configNoteNotification['subject'], $fieldCase, 'mysql', false),
G::buildFrom($configuration, $from),
$to,
$body,

View File

@@ -34,7 +34,7 @@ class ListInbox extends BaseListInbox implements ListInterface
if (isset($data['APP_TITLE'])) {
$oCase = new Cases();
$aData = $oCase->loadCase($data["APP_UID"]);
$data['APP_TITLE'] = G::replaceDataField($data['APP_TITLE'], $aData['APP_DATA']);
$data['APP_TITLE'] = G::replaceDataField($data['APP_TITLE'], $aData['APP_DATA'], 'mysql', false);
}
if (!empty($data['PRO_UID']) && empty($data['PRO_ID'])) {
$p = new Process();
@@ -124,7 +124,7 @@ class ListInbox extends BaseListInbox implements ListInterface
if (isset($data['APP_TITLE'])) {
$oCase = new Cases();
$aData = $oCase->loadCase($data["APP_UID"]);
$data['APP_TITLE'] = G::replaceDataField($data['APP_TITLE'], $aData['APP_DATA']);
$data['APP_TITLE'] = G::replaceDataField($data['APP_TITLE'], $aData['APP_DATA'], 'mysql', false);
}
if ($isSelfService) {
$listParticipatedLast = new ListParticipatedLast();

View File

@@ -508,29 +508,20 @@ class OutputDocument extends BaseOutputDocument
}
}
/**
/*
* Generate the output document
*
* @param string $outDocUid
* @param array $caseFields
* @param string $path
* @param string $filename
* @param string $content
* @param bool $landscape
* @param string $typeDocsToGen
* @param array $properties
*
* @return mixed
*
* @see workflow/engine/methods/cases/cases_Step.php
* @see workflow/engine/classes/class.pmFunctions.php:PMFGenerateOutputDocument()
* @param string $sUID
* @param array $aFields
* @param string $sPath
* @return variant
*/
public function generate($outDocUid, $caseFields, $path, $filename, $content, $landscape = false, $typeDocsToGen = 'BOTH', $properties = [])
{
if (($outDocUid != '') && is_array($caseFields) && ($path != '')) {
$content = G::replaceDataGridField($content, $caseFields, true, true);
if (strpos($content, '<!---{') !== false) {
public function generate($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape = false, $sTypeDocToGener = 'BOTH', $aProperties = array())
{
if (($sUID != '') && is_array($aFields) && ($sPath != '')) {
$sContent = G::replaceDataGridField($sContent, $aFields);
if (strpos($sContent, '<!---{') !== false) {
$template = new Smarty();
$template->compile_dir = PATH_SMARTY_C;
$template->cache_dir = PATH_SMARTY_CACHE;
@@ -538,20 +529,20 @@ class OutputDocument extends BaseOutputDocument
$template->caching = false;
$template->left_delimiter = '<!---{';
$template->right_delimiter = '}--->';
$fp = fopen($path . $filename . '_smarty.html', 'wb');
fwrite($fp, $content);
fclose($fp);
$template->templateFile = $path . $filename . '_smarty.html';
$oFile = fopen($sPath . $sFilename . '_smarty.html', 'wb');
fwrite($oFile, $sContent);
fclose($oFile);
$template->templateFile = $sPath . $sFilename . '_smarty.html';
//assign the variables and use the template $template
$template->assign($caseFields);
$content = $template->fetch($template->templateFile);
$template->assign($aFields);
$sContent = $template->fetch($template->templateFile);
unlink($template->templateFile);
}
G::verifyPath($path, true);
G::verifyPath($sPath, true);
//Start - Create .doc
$fp = fopen($path . $filename . '.doc', 'wb');
$oFile = fopen($sPath . $sFilename . '.doc', 'wb');
$size = [];
$size["Letter"] = "216mm 279mm";
@@ -575,7 +566,6 @@ class OutputDocument extends BaseOutputDocument
$size["Screenshot800"] = "800mm 600mm";
$size["Screenshot1024"] = "1024mm 768mm";
$sizeLandscape = [];
$sizeLandscape["Letter"] = "279mm 216mm";
$sizeLandscape["Legal"] = "357mm 216mm";
$sizeLandscape["Executive"] = "267mm 184mm";
@@ -597,41 +587,41 @@ class OutputDocument extends BaseOutputDocument
$sizeLandscape["Screenshot800"] = "600mm 800mm";
$sizeLandscape["Screenshot1024"] = "768mm 1024mm";
if (!isset($properties['media'])) {
$properties['media'] = 'Letter';
if (!isset($aProperties['media'])) {
$aProperties['media'] = 'Letter';
}
if ($landscape) {
$media = $sizeLandscape[$properties['media']];
if ($sLandscape) {
$media = $sizeLandscape[$aProperties['media']];
} else {
$media = $size[$properties['media']];
$media = $size[$aProperties['media']];
}
$marginLeft = '15';
if (isset($properties['margins']['left'])) {
$marginLeft = $properties['margins']['left'];
if (isset($aProperties['margins']['left'])) {
$marginLeft = $aProperties['margins']['left'];
}
$marginRight = '15';
if (isset($properties['margins']['right'])) {
$marginRight = $properties['margins']['right'];
if (isset($aProperties['margins']['right'])) {
$marginRight = $aProperties['margins']['right'];
}
$marginTop = '15';
if (isset($properties['margins']['top'])) {
$marginTop = $properties['margins']['top'];
if (isset($aProperties['margins']['top'])) {
$marginTop = $aProperties['margins']['top'];
}
$marginBottom = '15';
if (isset($properties['margins']['bottom'])) {
$marginBottom = $properties['margins']['bottom'];
if (isset($aProperties['margins']['bottom'])) {
$marginBottom = $aProperties['margins']['bottom'];
}
fwrite($fp, '<html xmlns:v="urn:schemas-microsoft-com:vml"
fwrite($oFile, '<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">
@@ -677,31 +667,31 @@ class OutputDocument extends BaseOutputDocument
<body>
<div class=WordSection1>');
fwrite($fp, $content);
fwrite($fp, "\n</div></body></html>\n\n");
fclose($fp);
fwrite($oFile, $sContent);
fwrite($oFile, "\n</div></body></html>\n\n");
fclose($oFile);
/* End - Create .doc */
if ($typeDocsToGen == 'BOTH' || $typeDocsToGen == 'PDF') {
$fp = fopen($path . $filename . '.html', 'wb');
fwrite($fp, $content);
fclose($fp);
if ($sTypeDocToGener == 'BOTH' || $sTypeDocToGener == 'PDF') {
$oFile = fopen($sPath . $sFilename . '.html', 'wb');
fwrite($oFile, $sContent);
fclose($oFile);
/* Start - Create .pdf */
if (isset($properties['report_generator'])) {
switch ($properties['report_generator']) {
if (isset($aProperties['report_generator'])) {
switch ($aProperties['report_generator']) {
case 'TCPDF':
$this->generateTcpdf($outDocUid, $caseFields, $path, $filename, $content, $landscape, $properties);
$this->generateTcpdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape, $aProperties);
break;
case 'HTML2PDF':
default:
$this->generateHtml2ps_pdf($outDocUid, $caseFields, $path, $filename, $content, $landscape, $properties);
$this->generateHtml2ps_pdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape, $aProperties);
break;
}
} else {
$this->generateHtml2ps_pdf($outDocUid, $caseFields, $path, $filename, $content, $landscape, $properties);
$this->generateHtml2ps_pdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape, $aProperties);
}
}
//end if $typeDocsToGen
//end if $sTypeDocToGener
/* End - Create .pdf */
} else {
return PEAR::raiseError(

View File

@@ -746,7 +746,13 @@ class Process extends BaseProcess
return $aProcesses;
}
public function getCasesCountForProcess($pro_uid)
/**
* This returns the number of cases for the process.
* @param string $pro_uid
* @return integer
* @see ProcessMaker\Project\Bpmn::canRemove()
*/
public static function getCasesCountForProcess($pro_uid)
{
$oCriteria = new Criteria('workflow');
$oCriteria->addSelectColumn('COUNT(*) AS TOTAL_CASES');

View File

@@ -2815,6 +2815,12 @@ msgstr "Base DN"
msgid "Batch Routing"
msgstr "Batch Routing"
# TRANSLATION
# LABEL/ID_BATCH_ROUTING_APPLY_CHANGES
#: LABEL/ID_BATCH_ROUTING_APPLY_CHANGES
msgid "The modification will be applied to all rows"
msgstr "The modification will be applied to all rows"
# TRANSLATION
# LABEL/ID_BATCH_ROUTING_TABLE_ALREADY_EXISTS
#: LABEL/ID_BATCH_ROUTING_TABLE_ALREADY_EXISTS
@@ -23768,8 +23774,8 @@ msgstr "Setting SUPER privilege"
# TRANSLATION
# LABEL/ID_SETUP
#: LABEL/ID_SETUP
msgid "ADMIN"
msgstr "ADMIN"
msgid "Admin"
msgstr "Admin"
# TRANSLATION
# LABEL/ID_SETUP_MAILCONF_TITLE

View File

@@ -1,20 +1,9 @@
<?php
/**
* pmTablesProxy
*
* @author Erik Amaru Ortiz <erik@colosa.com, aortiz.erik@gmail.com>
* @inherits HttpProxyController
* @access public
*/
use ProcessMaker\Core\System;
use ProcessMaker\Validation\ExceptionRestApi;
use ProcessMaker\Validation\ValidationUploadedFiles;
//We need to suppress the error for the unittest that use this function
@header("Content-type: text/html;charset=utf-8");
class pmTablesProxy extends HttpProxyController
{

View File

@@ -57271,6 +57271,7 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE
( 'LABEL','ID_BARS','en','Bars','2015-03-09') ,
( 'LABEL','ID_BASE_DN','en','Base DN','2014-01-15') ,
( 'LABEL','ID_BATCH_ROUTING','en','Batch Routing','2016-02-29') ,
( 'LABEL','ID_BATCH_ROUTING_APPLY_CHANGES','en','The modification will be applied to all rows','2019-06-03') ,
( 'LABEL','ID_BATCH_ROUTING_TABLE_ALREADY_EXISTS','en','The specified batch routing table already exists. The existing table will be used to store the batch routing information. Please be sure that the table has the correct batch routing configuration.','2017-03-27') ,
( 'LABEL','ID_BEFORE','en','Before','2014-01-15') ,
( 'LABEL','ID_BEFORE_ASSIGNMENT','en','Before Assignment','2014-01-15') ,
@@ -60846,7 +60847,7 @@ INSERT INTO TRANSLATION (TRN_CATEGORY,TRN_ID,TRN_LANG,TRN_VALUE,TRN_UPDATE_DATE
( 'LABEL','ID_SETTINGS_HEARTBEAT_TITLE','en','Display Setting','2014-01-15') ,
( 'LABEL','ID_SETTING_MESSAGE','en','The Settings tool was clicked','2014-01-15') ,
( 'LABEL','ID_SETTING_SUPER','en','Setting SUPER privilege','2014-01-28') ,
( 'LABEL','ID_SETUP','en','ADMIN','2014-01-15') ,
( 'LABEL','ID_SETUP','en','Admin','2014-01-15') ,
( 'LABEL','ID_SETUP_MAILCONF_TITLE','en','Test SMTP Connection','2014-01-15') ,
( 'LABEL','ID_SETUP_WEBSERVICES','en','Setup','2014-01-15') ,
( 'LABEL','ID_SET_A_TABLE_NAME','en','Set a Table Name','2014-01-15') ,
@@ -61632,8 +61633,7 @@ INSERT INTO CONFIGURATION (CFG_UID,OBJ_UID,CFG_VALUE,PRO_UID,USR_UID,APP_UID) VA
('MIGRATED_APP_HISTORY', 'history', 'a:1:{s:7:\"updated\";b:1;}', '', '', ''),
('MIGRATED_CONTENT','content','a:12:{i:0;s:7:"Groupwf";i:1;s:7:"Process";i:2;s:10:"Department";i:3;s:4:"Task";i:4;s:13:"InputDocument";i:5;s:11:"Application";i:6;s:11:"AppDocument";i:7;s:8:"Dynaform";i:8;s:14:"OutputDocument";i:9;s:11:"ReportTable";i:10;s:8:"Triggers";i:11;s:41:"\\ProcessMaker\\BusinessModel\\WebEntryEvent";}','','',''),
('MIGRATED_LIST','list','true','list','list','list'),
('MIGRATED_LIST_UNASSIGNED','list','true','list','list','list'),
('SKIN_CRON','','s:10:\"neoclassic\";','','','');
('MIGRATED_LIST_UNASSIGNED','list','true','list','list','list');
INSERT INTO CATALOG (CAT_UID,CAT_LABEL_ID,CAT_TYPE,CAT_FLAG,CAT_OBSERVATION,CAT_CREATE_DATE,CAT_UPDATE_DATE) VALUES
('10','ID_BARS','GRAPHIC','','','2015-03-04 00:00:00','2015-03-04 00:00:00'),

View File

@@ -2,32 +2,9 @@
/**
* processmaker.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*
* ProcessMaker main menu
*/
/*************************************
* ---= Processmaker main menu=---
*************************************/
global $G_TMP_MENU;
global $RBAC;
@@ -57,7 +34,7 @@ if ($RBAC->userCanAccess('PM_DASHBOARD') == 1) {
// ADMIN MODULE
if ($RBAC->userCanAccess('PM_SETUP') == 1 || $RBAC->userCanAccess('PM_USERS') == 1) {
$G_TMP_MENU->AddIdRawOption('SETUP', 'setup/main', strtolower(G::LoadTranslation('ID_SETUP')), '', '', '', 'x-pm-setup');
$G_TMP_MENU->AddIdRawOption('SETUP', 'setup/main', G::LoadTranslation('ID_SETUP'), '', '', '', 'x-pm-setup');
}

View File

@@ -162,14 +162,16 @@ if ($RBAC->userCanAccess('PM_USERS') === 1) {
);
}
if ($RBAC->userCanAccess('PM_SETUP_ADVANCE') === 1 && $RBAC->userCanAccess('PM_USERS') === 1 && $RBAC->userCanAccess
('PM_SETUP_USERS_AUTHENTICATION_SOURCES') === 1) {
if ($RBAC->userCanAccess('PM_USERS') === 1 && $RBAC->userCanAccess('PM_SETUP_USERS_AUTHENTICATION_SOURCES') === 1) {
$G_TMP_MENU->AddIdRawOption(
'AUTHSOURCES', '../authSources/authSources_List',
G::LoadTranslation('ID_AUTH_SOURCES'),
'', '', 'users'
);
$G_TMP_MENU->AddIdRawOption('UX', '../admin/uxList', G::LoadTranslation('ID_USER_EXPERIENCE'), '', '', 'users');
}
if ($RBAC->userCanAccess('PM_SETUP_ADVANCE') === 1) {
$G_TMP_MENU->AddIdRawOption('SYSTEM', '../admin/system', G::LoadTranslation('ID_SYSTEM'), '', '', 'settings');
$G_TMP_MENU->AddIdRawOption(
'INFORMATION', '../setup/systemInfo?option=processInfo',

View File

@@ -116,7 +116,9 @@ try {
$columnSearch
);
} else {
$data = Delegation::search(
//This section is used by the community version
$apps = new Applications();
$data = $apps->getAll(
$userUid,
$start,
$limit,

View File

@@ -23,7 +23,7 @@ $aFields = $oCase->loadCase($appUid);
foreach ($G_FORM->fields as $key => $val) {
if ($fieldName == $val->name) {
if ($G_FORM->fields[$key]->sql != null) {
$sqlQuery = G::replaceDataField($G_FORM->fields[$key]->sql, $aFields ["APP_DATA"]);
$sqlQuery = G::replaceDataField($G_FORM->fields[$key]->sql, $aFields ["APP_DATA"], 'mysql', false);
}
//$coma = "";
//$data1 = "";

View File

@@ -1,67 +0,0 @@
<?php
/**
* data_usersList.php
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2008 Colosa Inc.23
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 2566 Le Jeune Rd.,
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
*/
isset( $_POST['textFilter'] ) ? $filter = $_POST['textFilter'] : $filter = '';
$sDelimiter = DBAdapter::getStringDelimiter();
$oCriteria = new Criteria( 'workflow' );
$oCriteria->addSelectColumn( UsersPeer::USR_UID );
$sDataBase = 'database_' . strtolower( DB_ADAPTER );
if (G::LoadSystemExist( $sDataBase )) {
$oDataBase = new database();
$oCriteria->addAsColumn( 'USR_COMPLETENAME', $oDataBase->concatString( "USR_LASTNAME", "' '", "USR_FIRSTNAME" ) );
//$oCriteria->addAsColumn('USR_PHOTO', $oDataBase->concatString("'".PATH_IMAGES_ENVIRONMENT_USERS."'", "USR_UID","'.gif'"));
}
$oCriteria->addSelectColumn( UsersPeer::USR_USERNAME );
$oCriteria->addSelectColumn( UsersPeer::USR_EMAIL );
$oCriteria->addSelectColumn( UsersPeer::USR_ROLE );
$oCriteria->addSelectColumn( UsersPeer::USR_DUE_DATE );
//$oCriteria->addAsColumn('USR_VIEW', $sDelimiter . G::LoadTranslation('ID_DETAIL') . $sDelimiter);
//$oCriteria->addAsColumn('USR_EDIT', $sDelimiter . G::LoadTranslation('ID_EDIT') . $sDelimiter);
//$oCriteria->addAsColumn('USR_DELETE', $sDelimiter . G::LoadTranslation('ID_DELETE') . $sDelimiter);
//$oCriteria->addAsColumn('USR_AUTH', $sDelimiter . G::LoadTranslation('ID_AUTHENTICATION') . $sDelimiter);
//$oCriteria->addAsColumn('USR_REASSIGN', $sDelimiter . G::LoadTranslation('ID_REASSIGN_CASES') . $sDelimiter);
$oCriteria->add( UsersPeer::USR_STATUS, array ('CLOSED'
), Criteria::NOT_IN );
if ($filter != '') {
$cc = $oCriteria->getNewCriterion( UsersPeer::USR_USERNAME, '%' . $filter . '%', Criteria::LIKE )->addOr( $oCriteria->getNewCriterion( UsersPeer::USR_FIRSTNAME, '%' . $filter . '%', Criteria::LIKE )->addOr( $oCriteria->getNewCriterion( UsersPeer::USR_LASTNAME, '%' . $filter . '%', Criteria::LIKE ) ) );
$oCriteria->add( $cc );
//echo $oCriteria->toString();
}
$rs = UsersPeer::DoSelectRS( $oCriteria, Propel::getDbConnection('workflow_ro') );
$rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
$rows = Array ();
while ($rs->next()) {
$rows[] = $rs->getRow();
// if (!file_exists($aux['USR_PHOTO'])) $aux['USR_PHOTO'] = 'public_html/images/user.gif';
// $rows[] = $aux;
}
echo '{users: ' . G::json_encode( $rows ) . '}';

View File

@@ -1,9 +1,6 @@
<?php
namespace ProcessMaker\BusinessModel\Cases;
use G;
use OutputDocument as ClassesOutputDocument;
use PEAR;
use ProcessMaker\Core\System;
use ProcessMaker\Plugins\PluginRegistry;
@@ -595,31 +592,21 @@ class OutputDocument
}
}
/**
/*
* Generate the output document
*
* @param string $outDocUid
* @param array $caseFields
* @param string $path
* @param string $filename
* @param string $content
* @param bool $landscape
* @param string $typeDocsToGen
* @param array $properties
* @param string $application
*
* @return mixed
*
* @see this->addCasesOutputDocument()
* @param string $sUID
* @param array $aFields
* @param string $sPath
* @return variant
*/
public function generate($outDocUid, $caseFields, $path, $filename, $content, $landscape = false, $typeDocsToGen = 'BOTH', $properties = [], $application = '')
public function generate($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape = false, $sTypeDocToGener = 'BOTH', $aProperties = array(), $sApplication)
{
if (($outDocUid != '') && is_array($caseFields) && ($path != '')) {
$content = G::replaceDataGridField($content, $caseFields, true, true);
G::verifyPath($path, true);
if (($sUID != '') && is_array($aFields) && ($sPath != '')) {
$sContent = \G::replaceDataGridField($sContent, $aFields);
\G::verifyPath($sPath, true);
//Start - Create .doc
$fp = fopen($path . $filename . '.doc', 'wb');
$size = [];
$oFile = fopen($sPath . $sFilename . '.doc', 'wb');
$size = array();
$size["Letter"] = "216mm 279mm";
$size["Legal"] = "216mm 357mm";
$size["Executive"] = "184mm 267mm";
@@ -640,7 +627,6 @@ class OutputDocument
$size["Screenshot640"] = "640mm 480mm";
$size["Screenshot800"] = "800mm 600mm";
$size["Screenshot1024"] = "1024mm 768mm";
$sizeLandscape = [];
$sizeLandscape["Letter"] = "279mm 216mm";
$sizeLandscape["Legal"] = "357mm 216mm";
$sizeLandscape["Executive"] = "267mm 184mm";
@@ -661,31 +647,31 @@ class OutputDocument
$sizeLandscape["Screenshot640"] = "480mm 640mm";
$sizeLandscape["Screenshot800"] = "600mm 800mm";
$sizeLandscape["Screenshot1024"] = "768mm 1024mm";
if (!isset($properties['media'])) {
$properties['media'] = 'Letter';
if (!isset($aProperties['media'])) {
$aProperties['media'] = 'Letter';
}
if ($landscape) {
$media = $sizeLandscape[$properties['media']];
if ($sLandscape) {
$media = $sizeLandscape[$aProperties['media']];
} else {
$media = $size[$properties['media']];
$media = $size[$aProperties['media']];
}
$marginLeft = '15';
if (isset($properties['margins']['left'])) {
$marginLeft = $properties['margins']['left'];
if (isset($aProperties['margins']['left'])) {
$marginLeft = $aProperties['margins']['left'];
}
$marginRight = '15';
if (isset($properties['margins']['right'])) {
$marginRight = $properties['margins']['right'];
if (isset($aProperties['margins']['right'])) {
$marginRight = $aProperties['margins']['right'];
}
$marginTop = '15';
if (isset($properties['margins']['top'])) {
$marginTop = $properties['margins']['top'];
if (isset($aProperties['margins']['top'])) {
$marginTop = $aProperties['margins']['top'];
}
$marginBottom = '15';
if (isset($properties['margins']['bottom'])) {
$marginBottom = $properties['margins']['bottom'];
if (isset($aProperties['margins']['bottom'])) {
$marginBottom = $aProperties['margins']['bottom'];
}
fwrite($fp, '<html xmlns:v="urn:schemas-microsoft-com:vml"
fwrite($oFile, '<html xmlns:v="urn:schemas-microsoft-com:vml"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">
@@ -730,40 +716,40 @@ class OutputDocument
</head>
<body>
<div class=WordSection1>');
fwrite($fp, $content);
fwrite($fp, "\n</div></body></html>\n\n");
fclose($fp);
fwrite($oFile, $sContent);
fwrite($oFile, "\n</div></body></html>\n\n");
fclose($oFile);
/* End - Create .doc */
if ($typeDocsToGen == 'BOTH' || $typeDocsToGen == 'PDF') {
$fp = fopen($path . $filename . '.html', 'wb');
fwrite($fp, $content);
fclose($fp);
if ($sTypeDocToGener == 'BOTH' || $sTypeDocToGener == 'PDF') {
$oFile = fopen($sPath . $sFilename . '.html', 'wb');
fwrite($oFile, $sContent);
fclose($oFile);
/* Start - Create .pdf */
if (isset($properties['report_generator'])) {
switch ($properties['report_generator']) {
if (isset($aProperties['report_generator'])) {
switch ($aProperties['report_generator']) {
case 'TCPDF':
$o = new ClassesOutputDocument();
if (strlen($content) == 0) {
$o = new \OutputDocument();
if (strlen($sContent) == 0) {
libxml_use_internal_errors(true);
$o->generateTcpdf($outDocUid, $caseFields, $path, $filename, ' ', $landscape, $properties);
$o->generateTcpdf($sUID, $aFields, $sPath, $sFilename, ' ', $sLandscape, $aProperties);
libxml_use_internal_errors(false);
} else {
$o->generateTcpdf($outDocUid, $caseFields, $path, $filename, $content, $landscape, $properties);
$o->generateTcpdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape, $aProperties);
}
break;
case 'HTML2PDF':
default:
$this->generateHtml2ps_pdf($outDocUid, $caseFields, $path, $filename, $content, $landscape, $properties, $application);
$this->generateHtml2ps_pdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape, $aProperties, $sApplication);
break;
}
} else {
$this->generateHtml2ps_pdf($outDocUid, $caseFields, $path, $filename, $content, $landscape, $properties);
$this->generateHtml2ps_pdf($sUID, $aFields, $sPath, $sFilename, $sContent, $sLandscape, $aProperties);
}
}
//end if $typeDocsToGen
//end if $sTypeDocToGener
/* End - Create .pdf */
} else {
return PEAR::raiseError(
return \PEAR::raiseError(
null,
G_ERROR_USER_UID,
null,

View File

@@ -1108,7 +1108,7 @@ class Consolidated
foreach ($G_FORM->fields as $key => $val) {
if ($fieldName == $val->name) {
if ($G_FORM->fields[$key]->sql != "") {
$sqlQuery = G::replaceDataField($G_FORM->fields[$key]->sql, $aFields ["APP_DATA"]);
$sqlQuery = G::replaceDataField($G_FORM->fields[$key]->sql, $aFields ["APP_DATA"], 'mysql', false);
}
if ((is_array($val->options)) && (!empty($val->options))) {
foreach ($val->options as $key1 => $val1) {

View File

@@ -522,7 +522,7 @@ class EmailEvent
$emailTo,
'',
'',
G::replaceDataField($arrayData[5], $arrayApplicationData['APP_DATA']),
G::replaceDataField($arrayData[5], $arrayApplicationData['APP_DATA'], 'mysql', false),
$contentFile['prf_filename'],
[],
[],

View File

@@ -2,13 +2,13 @@
namespace ProcessMaker\BusinessModel;
use \G;
use \Criteria;
use \UsersPeer;
use \PMLicensedFeatures;
use G;
use Criteria;
use PMLicensedFeatures;
use ProcessMaker\Model\Delegation;
use UsersPeer;
/**
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
class Lists
@@ -258,6 +258,7 @@ class Lists
/**
* Get counters for lists
*
* @param $userId
* @return array
*/
@@ -271,6 +272,13 @@ class Lists
$total = $this->$listObject->getCountList($userId, array('action' => 'draft'));
array_push($response, (array('count' => $total, 'item' => $item)));
break;
case 'ListSelfService':
$total = Delegation::countSelfService($userId);
array_push($response, ([
'count' => $total,
'item' => $item
]));
break;
/*----------------------------------********---------------------------------*/
case 'ListConsolidated':
$licensedFeatures = PMLicensedFeatures::getSingleton();

View File

@@ -9,6 +9,7 @@ use Faker;
use G;
use GzipFile;
use Illuminate\Database\QueryException;
use Illuminate\Foundation\Http\Kernel;
use Illuminate\Support\Facades\DB;
use InputFilter;
use InstallerModule;
@@ -1023,7 +1024,7 @@ class System
*
* @return array $skinListArray
*/
public function getSkingList()
public static function getSkingList()
{
//Create Skins custom folder if it doesn't exists
if (!is_dir(PATH_CUSTOM_SKINS)) {
@@ -1629,5 +1630,21 @@ class System
{
return !empty(self::getServerHostname()) ? self::getServerHostname() : 'processmaker.com';
}
/**
* Initialize laravel database configuration
* @see workflow/engine/bin/tasks/cliWorkspaces.php->check_queries_incompatibilities()
*/
public static function initLaravel()
{
config(['database.connections.workflow.host' => DB_HOST]);
config(['database.connections.workflow.database' => DB_NAME]);
config(['database.connections.workflow.username' => DB_USER]);
config(['database.connections.workflow.password' => DB_PASS]);
app()->useStoragePath(realpath(PATH_DATA));
app()->make(Kernel::class)->bootstrap();
restore_error_handler();
}
}
// end System class

View File

@@ -300,6 +300,24 @@ abstract class Importer
$this->preserveEmailEventConfiguration($emailEvent);
}
}
if (isset($this->importData["tables"]["workflow"]["dynaforms"])) {
foreach ($this->importData["tables"]["workflow"]["dynaforms"] as &$dynaform) {
$this->preserveDynaformId($dynaform);
}
}
if (isset($this->importData["tables"]["workflow"]["inputs"])) {
foreach ($this->importData["tables"]["workflow"]["inputs"] as &$input) {
$this->preserveInputDocumentId($input);
}
}
if (isset($this->importData["tables"]["workflow"]["outputs"])) {
foreach ($this->importData["tables"]["workflow"]["outputs"] as &$output) {
$this->preserveOutputDocumentId($output);
}
}
$objectList = $granularObj->loadObjectsListSelected($this->importData, $newObjectArray);
if (sizeof($objectList) > 0 && $processGranulate) {
@@ -602,6 +620,18 @@ abstract class Importer
foreach ($arrayWorkflowTables["emailEvent"] as &$emailEvent) {
$this->preserveEmailEventConfiguration($emailEvent);
}
foreach ($arrayWorkflowTables["dynaforms"] as &$dynaform) {
$this->preserveDynaformId($dynaform);
}
foreach ($arrayWorkflowTables["inputs"] as &$input) {
$this->preserveInputDocumentId($input);
}
foreach ($arrayWorkflowTables["outputs"] as &$output) {
$this->preserveOutputDocumentId($output);
}
$this->importWfTables($arrayWorkflowTables);
@@ -862,6 +892,8 @@ abstract class Importer
* Saves the current objects before import.
*
* @param string $proUid
*
* @see ProcessMaker\Importer\Importer::import()
*/
public function saveCurrentProcess($proUid)
{
@@ -873,9 +905,9 @@ abstract class Importer
$result->tasks = $processes->getTaskRows($proUid);
$result->abeConfigurations = $processes->getActionsByEmail($proUid);
$result->emailEvents = $processes->getEmailEvent($proUid);
$result->dynaforms = $processes->getDynaformRows($proUid);
$result->inputs = $processes->getInputRows($proUid);
$result->outputs = $processes->getOutputRows($proUid);
$result->dynaforms = $processes->getDynaformRows($proUid, false);
$result->inputs = $processes->getInputRows($proUid, false);
$result->outputs = $processes->getOutputRows($proUid, false);
$this->setCurrentProcess($result);
}
@@ -948,4 +980,87 @@ abstract class Importer
}
}
/**
* Restore DYN_ID value for specific dynaform.
* The value of __DYN_ID_UPDATE__ only used like a reference.
*
* @param array $data
*
* @see ProcessMaker\Importer\Importer::import()
* @see ProcessMaker\Importer\Importer::doImport()
* @link https://wiki.processmaker.com/3.1/Importing_and_Exporting_Projects#Importing_a_Project
*/
public function preserveDynaformId(&$data)
{
$currentProccess = $this->getCurrentProcess();
if (!is_object($currentProccess)) {
return;
}
if (!is_array($currentProccess->dynaforms)) {
return;
}
foreach ($currentProccess->dynaforms as $dynaform) {
if ($data["DYN_UID"] === $dynaform["DYN_UID"]) {
$data["DYN_ID"] = $dynaform["DYN_ID"];
$data["__DYN_ID_UPDATE__"] = false;
break;
}
}
}
/**
* Restore INP_DOC_ID value for specific input document.
* The value of __INP_DOC_ID_UPDATE__ only used like a reference.
*
* @param array $data
*
* @see ProcessMaker\Importer\Importer::import()
* @see ProcessMaker\Importer\Importer::doImport()
* @link https://wiki.processmaker.com/3.1/Importing_and_Exporting_Projects#Importing_a_Project
*/
public function preserveInputDocumentId(&$data)
{
$currentProccess = $this->getCurrentProcess();
if (!is_object($currentProccess)) {
return;
}
if (!is_array($currentProccess->inputs)) {
return;
}
foreach ($currentProccess->inputs as $inputDocument) {
if ($data["INP_DOC_UID"] === $inputDocument["INP_DOC_UID"]) {
$data["INP_DOC_ID"] = $inputDocument["INP_DOC_ID"];
$data["__INP_DOC_ID_UPDATE__"] = false;
break;
}
}
}
/**
* Restore OUT_DOC_ID value for specific output document.
* The value of __OUT_DOC_ID_UPDATE__ only used like a reference.
*
* @param array $data
*
* @see ProcessMaker\Importer\Importer::import()
* @see ProcessMaker\Importer\Importer::doImport()
* @link https://wiki.processmaker.com/3.1/Importing_and_Exporting_Projects#Importing_a_Project
*/
public function preserveOutputDocumentId(&$data)
{
$currentProccess = $this->getCurrentProcess();
if (!is_object($currentProccess)) {
return;
}
if (!is_array($currentProccess->outputs)) {
return;
}
foreach ($currentProccess->outputs as $outputDocument) {
if ($data["OUT_DOC_UID"] === $outputDocument["OUT_DOC_UID"]) {
$data["OUT_DOC_ID"] = $outputDocument["OUT_DOC_ID"];
$data["__OUT_DOC_ID_UPDATE__"] = false;
break;
}
}
}
}

View File

@@ -10,5 +10,63 @@ class AppAssignSelfServiceValue extends Model
protected $primaryKey = 'ID';
// We do not have create/update timestamps for this table
public $timestamps = false;
/**
* Return the case number this belongs to
*/
public function appNumber()
{
return $this->belongsTo(Delegation::class, 'APP_NUMBER', 'APP_NUMBER');
}
/**
* Return the index this belongs to
*/
public function index()
{
return $this->belongsTo(Delegation::class, 'DEL_INDEX', 'DEL_INDEX');
}
/**
* Return the task this belongs to
*/
public function task()
{
return $this->belongsTo(Task::class, 'TAS_ID', 'TAS_ID');
}
/**
* Get cases with assignment Self-Service Value Based
*
* @param string $usrUid
*
* @return array
*/
public static function getSelfServiceCasesByEvaluatePerUser($usrUid)
{
//Get the groups related to the user
$groups = GroupUser::getGroups($usrUid);
// Build query
$query = AppAssignSelfServiceValue::query()->select();
$query->join('APP_ASSIGN_SELF_SERVICE_VALUE_GROUP', function ($join) {
$join->on('APP_ASSIGN_SELF_SERVICE_VALUE.ID', '=', 'APP_ASSIGN_SELF_SERVICE_VALUE_GROUP.ID');
});
$query->where(function ($query) use ($usrUid, $groups) {
//Filtering the user assigned in the task
$query->where('APP_ASSIGN_SELF_SERVICE_VALUE_GROUP.GRP_UID', '=', $usrUid);
if (!empty($groups)) {
//Consider the group related to the user
$query->orWhere(function ($query) use ($groups) {
$query->whereIn('APP_ASSIGN_SELF_SERVICE_VALUE_GROUP.ASSIGNEE_ID', $groups);
$query->where('APP_ASSIGN_SELF_SERVICE_VALUE_GROUP.ASSIGNEE_TYPE', '=', 2);
});
}
});
$query->distinct();
$result = $query->get()->values()->toArray();
return $result;
}
}

View File

@@ -9,5 +9,13 @@ class AppAssignSelfServiceValueGroup extends Model
protected $table = 'APP_ASSIGN_SELF_SERVICE_VALUE_GROUP';
// We do not have create/update timestamps for this table
public $timestamps = false;
/**
* Return the appSelfServiceValue this belongs to
*/
public function appSelfService()
{
return $this->belongsTo(AppAssignSelfServiceValue::class, 'ID', 'ID');
}
}

View File

@@ -58,6 +58,79 @@ class Delegation extends Model
return $query->where('APP_UID', '=', $appUid);
}
/**
* Scope a query to only include open threads
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeIsThreadOpen($query)
{
return $query->where('DEL_THREAD_STATUS', '=', 'OPEN');
}
/**
* Scope a query to only include threads without user
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeNoUserInThread($query)
{
return $query->where('USR_ID', '=', 0);
}
/**
* Scope a query to only include specific tasks
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param array $tasks
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeTasksIn($query, array $tasks)
{
return $query->whereIn('APP_DELEGATION.TAS_ID', $tasks);
}
/**
* Scope a query to only include a specific case
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param integer $appNumber
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeCase($query, $appNumber)
{
return $query->where('APP_NUMBER', '=', $appNumber);
}
/**
* Scope a query to only include a specific index
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param integer $index
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeIndex($query, $index)
{
return $query->where('DEL_INDEX', '=', $index);
}
/**
* Scope a query to only include a specific task
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param integer $task
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeTask($query, $task)
{
return $query->where('APP_DELEGATION.TAS_ID', '=', $task);
}
/**
* Searches for delegations which match certain criteria
*
@@ -389,4 +462,47 @@ class Delegation extends Model
return $arrayData;
}
/**
* Count the self-services cases by user
*
* @param string $usrUid
*
* @return integer
*/
public static function countSelfService($usrUid)
{
//Get the task self services related to the user
$taskSelfService = TaskUser::getSelfServicePerUser($usrUid);
//Get the task self services value based related to the user
$selfServiceValueBased = AppAssignSelfServiceValue::getSelfServiceCasesByEvaluatePerUser($usrUid);
//Start the query for get the cases related to the user
$query = Delegation::query()->select('APP_NUMBER');
//Add Join with task filtering only the type self-service
$query->join('TASK', function ($join) {
$join->on('APP_DELEGATION.TAS_ID', '=', 'TASK.TAS_ID')
->where('TASK.TAS_ASSIGN_TYPE', '=', 'SELF_SERVICE');
});
//Filtering the open threads and without users
$query->isThreadOpen()->noUserInThread();
//Get the cases unassigned
if (!empty($selfServiceValueBased)) {
$query->where(function ($query) use ($selfServiceValueBased, $taskSelfService) {
//Get the cases related to the task self service
$query->tasksIn($taskSelfService);
foreach ($selfServiceValueBased as $case) {
//Get the cases related to the task self service value based
$query->orWhere(function ($query) use ($case) {
$query->case($case['APP_NUMBER'])->index($case['DEL_INDEX'])->task($case['TAS_ID']);
});
}
});
} else {
//Get the cases related to the task self service
$query->tasksIn($taskSelfService);
}
return $query->count();
}
}

View File

@@ -14,8 +14,13 @@ use Illuminate\Support\Facades\DB;
class Dynaform extends Model
{
protected $table = 'DYNAFORM';
protected $primaryKey = "DYN_ID";
public $timestamps = false;
/**
* Return relation process.
* @return object
*/
public function process()
{
return $this->belongsTo(Process::class, 'PRO_UID', 'PRO_UID');
@@ -61,4 +66,16 @@ class Dynaform extends Model
->where('DYNAFORM.DYN_UID', '!=', $dynUid)
->get();
}
/**
* Scope a query to filter an specific process
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param string $columns
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeProcess($query, string $proUID)
{
return $query->where('PRO_UID', $proUID);
}
}

View File

@@ -9,5 +9,53 @@ class GroupUser extends Model
protected $table = 'GROUP_USER';
// We do not have create/update timestamps for this table
public $timestamps = false;
/**
* Return the user this belongs to
*/
public function user()
{
return $this->belongsTo(User::class, 'USR_UID', 'USR_UID');
}
/**
* Return the group user this belongs to
*/
public function groupsWf()
{
return $this->belongsTo(Groupwf::class, 'GRP_ID', 'GRP_ID');
}
/**
* Scope a query to specific user
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param string $user
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeUser($query, $user)
{
return $query->where('USR_UID', '=', $user);
}
/**
* Return the groups from a user
*
* @param string $usrUid
* @param string $column
*
* @return array
*/
public static function getGroups($usrUid, $column = 'GRP_ID')
{
$groups = GroupUser::query()->select(['GROUP_USER.' . $column])
->join('GROUPWF', function ($join) use ($usrUid) {
$join->on('GROUPWF.GRP_ID', '=', 'GROUP_USER.GRP_ID')
->where('GROUPWF.GRP_STATUS', 'ACTIVE')
->where('GROUP_USER.USR_UID', $usrUid);
})->get()->values()->toArray();
return $groups;
}
}

View File

@@ -10,5 +10,24 @@ class Groupwf extends Model
protected $primaryKey = 'GRP_ID';
// We do not have create/update timestamps for this table
public $timestamps = false;
/**
* Scope a query to active groups
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeActive($query)
{
return $query->where('GRP_STATUS', '=', 'ACTIVE');
}
/**
* Return the user this belongs to
*/
public function groupUsers()
{
return $this->belongsTo(GroupUser::class, 'GRP_ID', 'GRP_ID');
}
}

View File

@@ -0,0 +1,45 @@
<?php
namespace ProcessMaker\Model;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
/**
* Represents a input document object in the system.
*/
class InputDocument extends Model
{
protected $table = 'INPUT_DOCUMENT';
protected $primaryKey = 'INP_DOC_ID';
public $timestamps = false;
/**
* Return relation process.
* @return object
*/
public function process()
{
return $this->belongsTo(Process::class, 'PRO_UID', 'PRO_UID');
}
/**
* Get input documents by PRO_UID
* @param string $proUid
* @return \Illuminate\Database\Eloquent\Collection
*/
public static function getByProUid($proUid)
{
return InputDocument::where('PRO_UID', '=', $proUid)->get();
}
/**
* Get input document by INP_DOC_UID
* @param type $inpDocUid
* @return Model
*/
public static function getByInpDocUid($inpDocUid)
{
return InputDocument::where('INP_DOC_UID', '=', $inpDocUid)->first();
}
}

View File

@@ -35,6 +35,65 @@ class ListUnassigned extends Model
return $this->belongsTo(Process::class, 'PRO_ID', 'PRO_ID');
}
/**
* Return the user this belongs to
*/
public function previousUser()
{
return $this->belongsTo(User::class, 'DEL_PREVIOUS_USR_UID', 'USR_UID');
}
/**
* Scope a query to only include specific tasks
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param array $tasks
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeTasksIn($query, array $tasks)
{
return $query->whereIn('TAS_ID', $tasks);
}
/**
* Scope a query to only include a specific case
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param integer $appNumber
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeCase($query, $appNumber)
{
return $query->where('APP_NUMBER', '=', $appNumber);
}
/**
* Scope a query to only include a specific index
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param integer $index
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeIndex($query, $index)
{
return $query->where('DEL_INDEX', '=', $index);
}
/**
* Scope a query to only include a specific task
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param integer $task
*
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeTask($query, $task)
{
return $query->where('TAS_ID', '=', $task);
}
/**
* Get count
*
@@ -42,7 +101,7 @@ class ListUnassigned extends Model
* @param array $filters
*
* @return array
*/
*/
public static function doCount($userUid, $filters = [])
{
$list = new PropelListUnassigned();
@@ -51,6 +110,43 @@ class ListUnassigned extends Model
return $result;
}
/**
* Count the self-services cases by user
*
* @param string $usrUid
*
* @return integer
*/
public static function countSelfService($usrUid)
{
//Get the task self services related to the user
$taskSelfService = TaskUser::getSelfServicePerUser($usrUid);
//Get the task self services value based related to the user
$selfServiceValueBased = AppAssignSelfServiceValue::getSelfServiceCasesByEvaluatePerUser($usrUid);
//Start the query for get the cases related to the user
$query = ListUnassigned::query()->select('APP_NUMBER');
//Get the cases unassigned
if (!empty($selfServiceValueBased)) {
$query->where(function ($query) use ($selfServiceValueBased, $taskSelfService) {
//Get the cases related to the task self service
$query->tasksIn($taskSelfService);
foreach ($selfServiceValueBased as $case) {
//Get the cases related to the task self service value based
$query->orWhere(function ($query) use ($case) {
$query->case($case['APP_NUMBER'])->index($case['DEL_INDEX'])->task($case['TAS_ID']);
});
}
});
} else {
//Get the cases related to the task self service
$query->tasksIn($taskSelfService);
}
return $query->count();
}
/**
* Search data
*
@@ -67,4 +163,3 @@ class ListUnassigned extends Model
return $result;
}
}

View File

@@ -0,0 +1,45 @@
<?php
namespace ProcessMaker\Model;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
/**
* Represents a output document object in the system.
*/
class OutputDocument extends Model
{
protected $table = 'OUTPUT_DOCUMENT';
protected $primaryKey = 'OUT_DOC_ID';
public $timestamps = false;
/**
* Return relation process.
* @return object
*/
public function process()
{
return $this->belongsTo(Process::class, 'PRO_UID', 'PRO_UID');
}
/**
* Get output documents by PRO_UID.
* @param string $proUid
* @return \Illuminate\Database\Eloquent\Collection
*/
public static function getByProUid($proUid)
{
return OutputDocument::where('PRO_UID', '=', $proUid)->get();
}
/**
* Get output document by OUT_DOC_UID.
* @param string $outDocUid
* @return Model
*/
public static function getByOutDocUid($outDocUid)
{
return OutputDocument::where('OUT_DOC_UID', '=', $outDocUid)->first();
}
}

View File

@@ -0,0 +1,27 @@
<?php
namespace ProcessMaker\Model;
use Illuminate\Database\Eloquent\Model;
class ProcessVariables extends Model
{
// Set our table name
protected $table = 'PROCESS_VARIABLES';
// No timestamps
public $timestamps = false;
//primary key
protected $primaryKey = 'VAR_UID';
/**
* Scope a query to filter an specific process
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param string $columns
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeProcess($query, string $proUID)
{
return $query->where('PRJ_UID', $proUID);
}
}

View File

@@ -20,4 +20,16 @@ class Task extends Model
{
return $this->hasMany(Delegation::class, 'TAS_ID', 'TAS_ID');
}
/**
* Scope a query to only include self-service
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeIsSelfService($query)
{
return $query->where('TAS_ASSIGN_TYPE', '=', 'SELF_SERVICE')
->where('TAS_GROUP_VARIABLE', '=', '');
}
}

View File

@@ -9,4 +9,64 @@ class TaskUser extends Model
protected $table = 'TASK_USER';
public $timestamps = false;
/**
* Return the task this belongs to
*/
public function task()
{
return $this->belongsTo(Task::class, 'TAS_UID', 'TAS_UID');
}
/**
* Return the user this belongs to
*/
public function user()
{
return $this->belongsTo(User::class, 'USR_UID', 'USR_UID');
}
/**
* Get the task self services related to the user
*
* @param string $usrUid
*
* @return array
*/
public static function getSelfServicePerUser($usrUid)
{
//Get the groups related to the user
$groups = GroupUser::getGroups($usrUid, 'GRP_UID');
// Build query
$query = Task::query()->select('TAS_ID');
//Add Join with process filtering only the active process
$query->join('PROCESS', function ($join) {
$join->on('PROCESS.PRO_UID', '=', 'TASK.PRO_UID')
->where('PROCESS.PRO_STATUS', 'ACTIVE');
});
//Add join with with the task users
$query->join('TASK_USER', function ($join) {
$join->on('TASK.TAS_UID', '=', 'TASK_USER.TAS_UID')
//We not considered the Ad-hoc
->where('TASK_USER.TU_TYPE', '=', 1);
});
//Filtering only the task self-service
$query->isSelfService();
//Filtering the task related to the user
$query->where(function ($query) use ($usrUid, $groups) {
//Filtering the user assigned in the task
$query->where('TASK_USER.USR_UID', '=', $usrUid);
if (!empty($groups)) {
//Consider the group related to the user
$query->orWhere(function ($query) use ($groups) {
$query->whereIn('TASK_USER.USR_UID', $groups);
});
}
});
$query->distinct();
$tasks = $query->get()->values()->toArray();
return $tasks;
}
}

View File

@@ -0,0 +1,27 @@
<?php
namespace ProcessMaker\Model;
use Illuminate\Database\Eloquent\Model;
class Triggers extends Model
{
// Set our table name
protected $table = 'TRIGGERS';
// No timestamps
public $timestamps = false;
//primary key
protected $primaryKey = 'TRI_UID';
/**
* Scope a query to filter an specific process
*
* @param \Illuminate\Database\Eloquent\Builder $query
* @param string $columns
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeProcess($query, string $proUID)
{
return $query->where('PRO_UID', $proUID);
}
}

View File

@@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Model;
class User extends Model
{
protected $table = "USERS";
protected $primaryKey = 'USR_ID';
// Our custom timestamp columns
const CREATED_AT = 'USR_CREATE_DATE';
const UPDATED_AT = 'USR_UPDATE_DATE';
@@ -18,4 +19,24 @@ class User extends Model
{
return $this->hasMany(Delegation::class, 'USR_ID', 'USR_ID');
}
/**
* Return the user this belongs to
*/
public function groups()
{
return $this->belongsTo(GroupUser::class, 'USR_UID', 'USR_UID');
}
/**
* Return the groups from a user
*
* @param boolean $usrUid
*
* @return array
*/
public static function getGroups($usrUid)
{
return User::find($usrUid)->groups()->get();
}
}

View File

@@ -652,10 +652,11 @@ class Light extends Api
if (preg_match($this->regexNull, $newerThan)) {
return [];
}
$paged = ($start === 0 && $limit === 0) ? false : true;
$dataList['userId'] = $this->getUserId();
$dataList['action'] = 'unassigned';
$dataList['paged'] = false;
$dataList['paged'] = $paged;
$dataList['start'] = $start;
$dataList['limit'] = $limit;
@@ -682,6 +683,9 @@ class Light extends Api
/*----------------------------------********---------------------------------*/
}
/*----------------------------------********---------------------------------*/
if ($paged === true) {
$response = $response['data'];
}
$result = $this->parserDataUnassigned($response);
return DateTime::convertUtcToIso8601($result, $this->arrayFieldIso8601);

View File

@@ -409,7 +409,7 @@ class Server implements iAuthenticate
return $this->server;
}
public function getUserId()
public static function getUserId()
{
return self::$userId;
}

View File

@@ -485,33 +485,6 @@ function csrfToken()
return isset($_SESSION['USR_CSRF_TOKEN']) ? $_SESSION['USR_CSRF_TOKEN'] : '';
}
/**
* Check if a string is a valid HTML code
*
* @param string $string
*
* @return bool
*
* @see G::replaceDataField()
*/
function stringIsValidHtml($string)
{
// To validate we use the DOMDocument class
$doc = new DOMDocument('1.0', 'UTF-8');
// Clean previous errors
libxml_clear_errors();
// This line have to be silenced because if the string is not an HTML a Warning is displayed
@$doc->loadHTML($string);
// Get last error parsing the HTML
$libXmlError = libxml_get_last_error();
// If the attribute "textContent" is empty or exists libxml errors, is not a valid HTML
return $doc->textContent !== '' && empty($libXmlError);
}
// Methods deleted in PHP 7.x, added in this file in order to keep compatibility with old libraries included/used in ProcessMaker
if (!function_exists('set_magic_quotes_runtime')) {
function set_magic_quotes_runtime($value) {

View File

@@ -0,0 +1,110 @@
<?php
namespace ProcessMaker\Validation;
use ProcessMaker\Model\Dynaform;
use ProcessMaker\Model\Process;
use ProcessMaker\Model\ProcessVariables;
use ProcessMaker\Model\Triggers;
class MySQL57
{
const REGEX = '/(?i)(select|\$).*?UNION.*?(select|\$).*?/ms';
/**
* Checks the queries inside triggers that could have possible incompatibilities with MySQL 5.7
*
* @see workflow/engine/bin/tasks/cliWorkspaces.php->check_queries_incompatibilities()
* @param array $processes
* @return array
*/
public function checkIncompatibilityTriggers($processes)
{
$result = [];
foreach ($processes as $process) {
$triggerQuery = Triggers::query()->select();
//Call the scope method to filter by process
$triggerQuery->process($process['PRO_UID']);
$triggers = $triggerQuery->get()->values()->toArray();
foreach ($triggers as $trigger) {
$resultIncompatibility = $this->analyzeQuery($trigger['TRI_WEBBOT']);
if ($resultIncompatibility) {
$aux = array_merge($process, $trigger);
array_push($result, $aux);
}
}
}
return $result;
}
/**
* Checks the queries inside dynaforms that could have possible incompatibilities with MySQL 5.7
*
* @see workflow/engine/bin/tasks/cliWorkspaces.php->check_queries_incompatibilities()
* @param array $processes
* @return array
*/
public function checkIncompatibilityDynaforms($processes)
{
$result = [];
foreach ($processes as $process) {
$dynaformQuery = Dynaform::query()->select();
//Call the scope method to filter by process
$dynaformQuery->process($process['PRO_UID']);
$dynaforms = $dynaformQuery->get()->values()->toArray();
foreach ($dynaforms as $dynaform) {
$resultIncompatibility = $this->analyzeQuery($dynaform['DYN_CONTENT']);
if ($resultIncompatibility) {
$aux = array_merge($process, $dynaform);
array_push($result, $aux);
}
}
}
return $result;
}
/**
* Checks the queries inside variables that could have possible incompatibilities with MySQL 5.7
*
* @see workflow/engine/bin/tasks/cliWorkspaces.php->check_queries_incompatibilities()
* @param array $processes
* @return array
*/
public function checkIncompatibilityVariables($processes)
{
$result = [];
foreach ($processes as $process) {
$variablesQuery = ProcessVariables::query()->select();
//Call the scope method to filter by process
$variablesQuery->process($process['PRO_UID']);
$variables = $variablesQuery->get()->values()->toArray();
foreach ($variables as $variable) {
$resultIncompatibility = $this->analyzeQuery($variable['VAR_SQL']);
if ($resultIncompatibility) {
$aux = array_merge($process, $variable);
array_push($result, $aux);
}
}
}
return $result;
}
/**
* Analyze the query using the regular expression
*
* @param string $query
* @return bool
*/
public function analyzeQuery($query)
{
preg_match_all($this::REGEX, $query, $matches, PREG_SET_ORDER, 0);
return !empty($matches);
}
}

View File

@@ -793,7 +793,7 @@ function generateGridClassic(proUid, tasUid, dynUid) {
if (Ext.getCmp("chk_allColumn").checked) {
Ext.Msg.show({
title: "",
msg: "The modification will be applied to all rows in your selection.",
msg: _("ID_BATCH_ROUTING_APPLY_CHANGES"),
buttons: Ext.Msg.YESNO,
fn: function (btn) {
if (btn == "yes") {
@@ -1027,7 +1027,7 @@ function generateGrid(proUid, tasUid, dynUid) {
if (Ext.getCmp("chk_allColumn").checked) {
Ext.Msg.show({
title: "",
msg: "The modification will be applied to all rows in your selection.",
msg: _("ID_BATCH_ROUTING_APPLY_CHANGES"),
buttons: Ext.Msg.YESNO,
fn: function (btn) {
if (btn == "yes") {