PMC-962
This commit is contained in:
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
22
app/Logging/CustomizeFormatter.php
Normal file
22
app/Logging/CustomizeFormatter.php
Normal 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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",
|
||||
@@ -55,7 +55,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",
|
||||
@@ -101,7 +101,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": {
|
||||
|
||||
3473
composer.lock
generated
3473
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -9,8 +9,6 @@ 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),
|
||||
'timezone' => 'UTC',
|
||||
'providers' => [
|
||||
@@ -22,6 +20,7 @@ return [
|
||||
Illuminate\Queue\QueueServiceProvider::class,
|
||||
Illuminate\Translation\TranslationServiceProvider::class,
|
||||
Laravel\Tinker\TinkerServiceProvider::class,
|
||||
Illuminate\Notifications\NotificationServiceProvider::class,
|
||||
],
|
||||
|
||||
'aliases' => [
|
||||
|
||||
85
config/logging.php
Normal file
85
config/logging.php
Normal 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',
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
21
database/factories/ProcessVariablesFactory.php
Normal file
21
database/factories/ProcessVariablesFactory.php
Normal 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' => ''
|
||||
];
|
||||
});
|
||||
16
database/factories/TriggerFactory.php
Normal file
16
database/factories/TriggerFactory.php
Normal 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' => '',
|
||||
];
|
||||
});
|
||||
@@ -5060,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;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<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>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
23
tests/bootstrap.php
Normal file → Executable file
23
tests/bootstrap.php
Normal file → Executable file
@@ -39,6 +39,11 @@ define('PM_NEW_PROCESS_SAVE', 1006);
|
||||
define('PATH_DATA_SITE', PATH_DATA . 'sites/' . SYS_SYS . '/');
|
||||
define("PATH_DATA_MAILTEMPLATES", PATH_DATA_SITE . "mailTemplates/");
|
||||
define('PATH_DATA_PUBLIC', PATH_DATA_SITE . 'public/');
|
||||
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;
|
||||
@@ -57,11 +62,22 @@ 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', ''),
|
||||
@@ -72,11 +88,6 @@ config(['database.connections.testexternal' => [
|
||||
'engine' => null
|
||||
]]);
|
||||
|
||||
//configuration values
|
||||
config([
|
||||
"system.workspace" => SYS_SYS
|
||||
]);
|
||||
|
||||
// Now, drop all test tables and repopulate with schema
|
||||
Schema::connection('testexternal')->dropIfExists('test');
|
||||
|
||||
|
||||
72
tests/unit/app/CustomizeFormatterTest.php
Normal file
72
tests/unit/app/CustomizeFormatterTest.php
Normal 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);
|
||||
}
|
||||
}
|
||||
353
tests/unit/gulliver/system/gTest.php
Executable file
353
tests/unit/gulliver/system/gTest.php
Executable 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,10 +2,17 @@
|
||||
|
||||
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
|
||||
*
|
||||
@@ -134,4 +141,134 @@ class CliWorkspacesTest extends TestCase
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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'));
|
||||
}
|
||||
}
|
||||
@@ -220,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']);
|
||||
}
|
||||
@@ -644,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',
|
||||
@@ -654,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');
|
||||
|
||||
@@ -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']);
|
||||
}
|
||||
}
|
||||
@@ -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']);
|
||||
}
|
||||
}
|
||||
@@ -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']);
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,12 @@ 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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
2
thirdparty/pake/pakeYaml.class.php
vendored
2
thirdparty/pake/pakeYaml.class.php
vendored
@@ -80,7 +80,7 @@
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function pakeYAMLNode() {
|
||||
public function __construct() {
|
||||
$this->id = uniqid('');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
@@ -372,6 +375,21 @@ 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
|
||||
*
|
||||
@@ -477,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
|
||||
@@ -1373,3 +1392,74 @@ function remove_deprecated_files()
|
||||
$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;
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -61616,8 +61616,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'),
|
||||
|
||||
@@ -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;
|
||||
@@ -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
|
||||
|
||||
@@ -66,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);
|
||||
}
|
||||
}
|
||||
|
||||
27
workflow/engine/src/ProcessMaker/Model/ProcessVariables.php
Normal file
27
workflow/engine/src/ProcessMaker/Model/ProcessVariables.php
Normal 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);
|
||||
}
|
||||
}
|
||||
27
workflow/engine/src/ProcessMaker/Model/Triggers.php
Normal file
27
workflow/engine/src/ProcessMaker/Model/Triggers.php
Normal 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);
|
||||
}
|
||||
}
|
||||
110
workflow/engine/src/ProcessMaker/Validation/MySQL57.php
Normal file
110
workflow/engine/src/ProcessMaker/Validation/MySQL57.php
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user