Merge branch 'develop' of bitbucket.org:colosa/processmaker into KR-7471
This commit is contained in:
42
app/Console/Commands/AddParametersTrait.php
Normal file
42
app/Console/Commands/AddParametersTrait.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Maveriks\WebApplication;
|
||||
|
||||
trait AddParametersTrait
|
||||
{
|
||||
|
||||
/**
|
||||
* Create a new queue command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->signature .= '
|
||||
{--workspace=workflow : ProcessMaker Indicates the workspace to be processed.}
|
||||
{--processmakerPath=./ : ProcessMaker path.}
|
||||
';
|
||||
|
||||
$this->description .= ' (ProcessMaker has extended this command)';
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$workspace = $this->option('workspace');
|
||||
if (!empty($workspace)) {
|
||||
$webApplication = new WebApplication();
|
||||
$webApplication->setRootDir($this->option('processmakerPath'));
|
||||
$webApplication->loadEnvironment($workspace);
|
||||
}
|
||||
parent::handle();
|
||||
}
|
||||
}
|
||||
39
app/Console/Commands/FailedTableCommand.php
Normal file
39
app/Console/Commands/FailedTableCommand.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Illuminate\Queue\Console\FailedTableCommand as BaseFailedTableCommand;
|
||||
use Illuminate\Support\Composer;
|
||||
|
||||
class FailedTableCommand extends BaseFailedTableCommand
|
||||
{
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'queue:failed-table';
|
||||
|
||||
/**
|
||||
* This contains the necessary code to add parameters.
|
||||
*/
|
||||
use AddParametersTrait;
|
||||
|
||||
/**
|
||||
* Create a new queue failed-table command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Filesystem $files, Composer $composer)
|
||||
{
|
||||
$this->signature .= '
|
||||
{--workspace=workflow : ProcessMaker Indicates the workspace to be processed.}
|
||||
{--processmakerPath=./ : ProcessMaker path.}
|
||||
';
|
||||
|
||||
$this->description .= ' (ProcessMaker has extended this command)';
|
||||
|
||||
parent::__construct($files, $composer);
|
||||
}
|
||||
}
|
||||
20
app/Console/Commands/FlushFailedCommand.php
Normal file
20
app/Console/Commands/FlushFailedCommand.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Queue\Console\FlushFailedCommand as BaseFlushFailedCommand;
|
||||
|
||||
class FlushFailedCommand extends BaseFlushFailedCommand
|
||||
{
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'queue:flush';
|
||||
|
||||
/**
|
||||
* This contains the necessary code to add parameters.
|
||||
*/
|
||||
use AddParametersTrait;
|
||||
}
|
||||
14
app/Console/Commands/ForgetFailedCommand.php
Normal file
14
app/Console/Commands/ForgetFailedCommand.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Queue\Console\ForgetFailedCommand as BaseForgetFailedCommand;
|
||||
|
||||
class ForgetFailedCommand extends BaseForgetFailedCommand
|
||||
{
|
||||
|
||||
/**
|
||||
* This contains the necessary code to add parameters.
|
||||
*/
|
||||
use AddParametersTrait;
|
||||
}
|
||||
20
app/Console/Commands/ListFailedCommand.php
Normal file
20
app/Console/Commands/ListFailedCommand.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Queue\Console\ListFailedCommand as BaseListFailedCommand;
|
||||
|
||||
class ListFailedCommand extends BaseListFailedCommand
|
||||
{
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'queue:failed';
|
||||
|
||||
/**
|
||||
* This contains the necessary code to add parameters.
|
||||
*/
|
||||
use AddParametersTrait;
|
||||
}
|
||||
20
app/Console/Commands/RestartCommand.php
Normal file
20
app/Console/Commands/RestartCommand.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Queue\Console\RestartCommand as BaseRestartCommand;
|
||||
|
||||
class RestartCommand extends BaseRestartCommand
|
||||
{
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'queue:restart';
|
||||
|
||||
/**
|
||||
* This contains the necessary code to add parameters.
|
||||
*/
|
||||
use AddParametersTrait;
|
||||
}
|
||||
14
app/Console/Commands/RetryCommand.php
Normal file
14
app/Console/Commands/RetryCommand.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Queue\Console\RetryCommand as BaseRetryCommand;
|
||||
|
||||
class RetryCommand extends BaseRetryCommand
|
||||
{
|
||||
|
||||
/**
|
||||
* This contains the necessary code to add parameters.
|
||||
*/
|
||||
use AddParametersTrait;
|
||||
}
|
||||
39
app/Console/Commands/TableCommand.php
Normal file
39
app/Console/Commands/TableCommand.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Illuminate\Queue\Console\TableCommand as BaseTableCommand;
|
||||
use Illuminate\Support\Composer;
|
||||
|
||||
class TableCommand extends BaseTableCommand
|
||||
{
|
||||
/**
|
||||
* The console command name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'queue:table';
|
||||
|
||||
/**
|
||||
* This contains the necessary code to add parameters.
|
||||
*/
|
||||
use AddParametersTrait;
|
||||
|
||||
/**
|
||||
* Create a new queue table command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Filesystem $files, Composer $composer)
|
||||
{
|
||||
$this->signature .= '
|
||||
{--workspace=workflow : ProcessMaker Indicates the workspace to be processed.}
|
||||
{--processmakerPath=./ : ProcessMaker path.}
|
||||
';
|
||||
|
||||
$this->description .= ' (ProcessMaker has extended this command)';
|
||||
|
||||
parent::__construct($files, $composer);
|
||||
}
|
||||
}
|
||||
31
app/Console/Commands/WorkCommand.php
Normal file
31
app/Console/Commands/WorkCommand.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Queue\Console\WorkCommand as BaseWorkCommand;
|
||||
use Illuminate\Queue\Worker;
|
||||
|
||||
class WorkCommand extends BaseWorkCommand
|
||||
{
|
||||
|
||||
use AddParametersTrait;
|
||||
|
||||
/**
|
||||
* Create a new queue work command.
|
||||
*
|
||||
* @param \Illuminate\Queue\Worker $worker
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Worker $worker)
|
||||
{
|
||||
$this->signature .= '
|
||||
{--workspace=workflow : ProcessMaker Indicates the workspace to be processed.}
|
||||
{--processmakerPath=./ : ProcessMaker path.}
|
||||
';
|
||||
|
||||
$this->description .= ' (ProcessMaker has extended this command)';
|
||||
|
||||
parent::__construct($worker);
|
||||
}
|
||||
}
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
8
app/Jobs/Email.php
Normal file
8
app/Jobs/Email.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
class Email extends QueuedClosure
|
||||
{
|
||||
|
||||
}
|
||||
8
app/Jobs/EmailEvent.php
Normal file
8
app/Jobs/EmailEvent.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
class EmailEvent extends QueuedClosure
|
||||
{
|
||||
|
||||
}
|
||||
21
app/Jobs/QueuedClosure.php
Normal file
21
app/Jobs/QueuedClosure.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Queue\CallQueuedClosure;
|
||||
use Illuminate\Queue\SerializableClosure;
|
||||
|
||||
abstract class QueuedClosure extends CallQueuedClosure
|
||||
{
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @param \Illuminate\Queue\SerializableClosure $closure
|
||||
*/
|
||||
public function __construct(Closure $closure)
|
||||
{
|
||||
parent::__construct(new SerializableClosure($closure));
|
||||
}
|
||||
}
|
||||
8
app/Jobs/ScriptTask.php
Normal file
8
app/Jobs/ScriptTask.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
class ScriptTask extends QueuedClosure
|
||||
{
|
||||
|
||||
}
|
||||
8
app/Jobs/ServiceTask.php
Normal file
8
app/Jobs/ServiceTask.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
class ServiceTask extends QueuedClosure
|
||||
{
|
||||
|
||||
}
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
24
app/Providers/WorkCommandServiceProvider.php
Normal file
24
app/Providers/WorkCommandServiceProvider.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Console\Commands\WorkCommand;
|
||||
use Illuminate\Queue\QueueServiceProvider;
|
||||
|
||||
class WorkCommandServiceProvider extends QueueServiceProvider
|
||||
{
|
||||
|
||||
/**
|
||||
* Overrides "register" method from Queue provider.
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
parent::register();
|
||||
|
||||
//Extend command "queue:work".
|
||||
$this->app->extend('command.queue.work', function ($command, $app) {
|
||||
return new WorkCommand($app['queue.worker']);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -80,7 +80,6 @@ return array(
|
||||
'ToolBar' => ToolBar::class,
|
||||
'Tree' => PmTree::class,
|
||||
'triggerLibrary' => TriggerLibrary::class,
|
||||
'Upgrade' => Upgrade::class,
|
||||
'workspaceTools' => WorkspaceTools::class,
|
||||
'wsBase' => WsBase::class,
|
||||
'wsResponse' => WsResponse::class,
|
||||
|
||||
@@ -27,13 +27,13 @@
|
||||
"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",
|
||||
"colosa/MichelangeloFE": "release/3.3.1-dev",
|
||||
"colosa/pmdynaform": "release/3.3.1-dev",
|
||||
"colosa/pmUI": "release/3.4.0-dev",
|
||||
"colosa/MichelangeloFE": "release/3.4.0-dev",
|
||||
"colosa/pmdynaform": "release/3.4.0-dev",
|
||||
"google/apiclient": "1.1.6",
|
||||
"dapphp/securimage": "^3.6",
|
||||
"psr/log": "1.0.0",
|
||||
@@ -43,11 +43,12 @@
|
||||
"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",
|
||||
"chumper/zipper": "^1.0",
|
||||
"php-imap/php-imap": "^3.0",
|
||||
"nikic/php-parser": "3.1.5",
|
||||
"laravel/tinker": "^1.0"
|
||||
},
|
||||
@@ -55,7 +56,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",
|
||||
@@ -66,7 +67,7 @@
|
||||
"ProcessMaker\\": "workflow/engine/src"
|
||||
},
|
||||
"psr-4": {
|
||||
"App\\": "app/",
|
||||
"App\\": "app/",
|
||||
"Maveriks\\": "framework/src/Maveriks/",
|
||||
"Tests\\": "tests/"
|
||||
},
|
||||
@@ -101,7 +102,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": {
|
||||
|
||||
3718
composer.lock
generated
3718
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -9,9 +9,9 @@ return [
|
||||
'url' => env('APP_URL', 'http://localhost'),
|
||||
'env' => env('APP_ENV', 'production'),
|
||||
'debug' => env('APP_DEBUG', false),
|
||||
'log' => env('APP_LOG', 'single'),
|
||||
'log_level' => env('APP_LOG_LEVEL', 'debug'),
|
||||
'cache_lifetime' => env('APP_CACHE_LIFETIME', 60),
|
||||
'key' => env('APP_KEY', 'base64:rU28h/tElUn/eiLY0qC24jJq1rakvAFRoRl1DWxj/kM='),
|
||||
'cipher' => 'AES-256-CBC',
|
||||
'timezone' => 'UTC',
|
||||
'providers' => [
|
||||
FilesystemServiceProvider::class,
|
||||
@@ -21,10 +21,14 @@ return [
|
||||
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
|
||||
Illuminate\Queue\QueueServiceProvider::class,
|
||||
Illuminate\Translation\TranslationServiceProvider::class,
|
||||
Illuminate\Encryption\EncryptionServiceProvider::class,
|
||||
Laravel\Tinker\TinkerServiceProvider::class,
|
||||
Illuminate\Notifications\NotificationServiceProvider::class,
|
||||
Illuminate\Bus\BusServiceProvider::class,
|
||||
],
|
||||
|
||||
'aliases' => [
|
||||
'Crypt' => Illuminate\Support\Facades\Crypt::class
|
||||
],
|
||||
|
||||
];
|
||||
|
||||
@@ -58,6 +58,7 @@ workflow/engine/methods/cases/casesDemo.php
|
||||
workflow/engine/methods/cases/cases_Scheduler_Save.php
|
||||
workflow/engine/methods/cases/cases_Scheduler_Update.php
|
||||
workflow/engine/methods/cases/proxyPMTablesSaveFields.php
|
||||
workflow/engine/methods/cases/proxyProcessList.php
|
||||
workflow/engine/methods/cases/saveFormSupervisor.php
|
||||
workflow/engine/methods/controls/buscador.php
|
||||
workflow/engine/methods/dbConnections/genericDbConnections.php
|
||||
@@ -70,6 +71,7 @@ workflow/engine/methods/setup/jasper.php
|
||||
workflow/engine/methods/setup/webServices.php
|
||||
workflow/engine/methods/setup/webServicesAjax.php
|
||||
workflow/engine/methods/setup/webServicesList.php
|
||||
workflow/engine/methods/users/data_usersList.php
|
||||
workflow/engine/plugins/openFlash.php
|
||||
workflow/engine/plugins/openFlash/chart-data.php
|
||||
workflow/engine/plugins/openFlash/chart.php
|
||||
|
||||
85
config/logging.php
Normal file
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',
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
87
config/queue.php
Normal file
87
config/queue.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Default Queue Connection Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Laravel's queue API supports an assortment of back-ends via a single
|
||||
| API, giving you convenient access to each back-end using the same
|
||||
| syntax for every one. Here you may define a default connection.
|
||||
|
|
||||
*/
|
||||
|
||||
'default' => env('QUEUE_CONNECTION', 'database'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Queue Connections
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the connection information for each server that
|
||||
| is used by your application. A default configuration has been added
|
||||
| for each back-end shipped with Laravel. You are free to add more.
|
||||
|
|
||||
| Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null"
|
||||
|
|
||||
*/
|
||||
|
||||
'connections' => [
|
||||
|
||||
'sync' => [
|
||||
'driver' => 'sync',
|
||||
],
|
||||
|
||||
'database' => [
|
||||
'driver' => 'database',
|
||||
'table' => 'JOBS_PENDING',
|
||||
'queue' => 'default',
|
||||
'retry_after' => 90,
|
||||
],
|
||||
|
||||
'beanstalkd' => [
|
||||
'driver' => 'beanstalkd',
|
||||
'host' => 'localhost',
|
||||
'queue' => 'default',
|
||||
'retry_after' => 90,
|
||||
'block_for' => 0,
|
||||
],
|
||||
|
||||
'sqs' => [
|
||||
'driver' => 'sqs',
|
||||
'key' => env('AWS_ACCESS_KEY_ID'),
|
||||
'secret' => env('AWS_SECRET_ACCESS_KEY'),
|
||||
'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'),
|
||||
'queue' => env('SQS_QUEUE', 'your-queue-name'),
|
||||
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
|
||||
],
|
||||
|
||||
'redis' => [
|
||||
'driver' => 'redis',
|
||||
'connection' => 'default',
|
||||
'queue' => env('REDIS_QUEUE', 'default'),
|
||||
'retry_after' => 90,
|
||||
'block_for' => null,
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Failed Queue Jobs
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| These options configure the behavior of failed queue job logging so you
|
||||
| can control which database and table are used to store the jobs that
|
||||
| have failed. You may change them to any database / table you wish.
|
||||
|
|
||||
*/
|
||||
|
||||
'failed' => [
|
||||
'database' => env('DB_CONNECTION', 'workflow'),
|
||||
'table' => 'JOBS_FAILED',
|
||||
],
|
||||
|
||||
];
|
||||
20
database/factories/BpmnProjectFactory.php
Normal file
20
database/factories/BpmnProjectFactory.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(\ProcessMaker\Model\BpmnProject::class, function (Faker $faker) {
|
||||
return [
|
||||
'PRJ_UID' => G::generateUniqueID(),
|
||||
'PRJ_NAME' => '',
|
||||
'PRJ_DESCRIPTION' => $faker->text,
|
||||
'PRJ_EXPRESION_LANGUAGE' => '',
|
||||
'PRJ_TYPE_LANGUAGE' => '',
|
||||
'PRJ_EXPORTER' => '',
|
||||
'PRJ_EXPORTER_VERSION' => '',
|
||||
'PRJ_CREATE_DATE' => new \Carbon\Carbon(2030, 1, 1),
|
||||
'PRJ_UPDATE_DATE' => new \Carbon\Carbon(2030, 1, 1),
|
||||
'PRJ_AUTHOR' => '',
|
||||
'PRJ_AUTHOR_VERSION' => '',
|
||||
'PRJ_ORIGINAL_SOURCE' => '',
|
||||
];
|
||||
});
|
||||
37
database/factories/ConfigurationFactory.php
Normal file
37
database/factories/ConfigurationFactory.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* Model factory for a configuration
|
||||
*/
|
||||
use Faker\Generator as Faker;
|
||||
use ProcessMaker\Model\Configuration;
|
||||
use ProcessMaker\Model\User;
|
||||
|
||||
$factory->define(Configuration::class, function(Faker $faker) {
|
||||
return [
|
||||
'CFG_UID' => $faker->randomElement(['AUDIT_LOG', 'EE']),
|
||||
'OBJ_UID' => '',
|
||||
'CFG_VALUE' => '',
|
||||
'PRO_UID' => G::generateUniqueID(),
|
||||
'USR_UID' => G::generateUniqueID(),
|
||||
'APP_UID' => G::generateUniqueID(),
|
||||
];
|
||||
});
|
||||
|
||||
$factory->state(Configuration::class, 'userPreferencesEmpty', function (Faker $faker) {
|
||||
// Grab a user if random
|
||||
$users = User::all();
|
||||
if (!empty($users)) {
|
||||
$user = factory(User::class)->create();
|
||||
} else {
|
||||
$user = $users->random();
|
||||
}
|
||||
return [
|
||||
'CFG_UID' => 'USER_PREFERENCES',
|
||||
'OBJ_UID' => '',
|
||||
'CFG_VALUE' => '',
|
||||
'PRO_UID' => '',
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'APP_UID' => '',
|
||||
];
|
||||
});
|
||||
|
||||
@@ -4,16 +4,18 @@
|
||||
* Model factory for a dynaform.
|
||||
*/
|
||||
use Faker\Generator as Faker;
|
||||
use ProcessMaker\Model\Dynaform;
|
||||
use ProcessMaker\Model\Process;
|
||||
|
||||
$factory->define(\ProcessMaker\Model\Dynaform::class, function(Faker $faker) {
|
||||
$factory->define(Dynaform::class, function(Faker $faker) {
|
||||
$date = $faker->dateTime();
|
||||
return [
|
||||
'DYN_UID' => G::generateUniqueID(),
|
||||
'DYN_ID' => '',
|
||||
'DYN_TITLE' => '',
|
||||
'DYN_DESCRIPTION' => '',
|
||||
'DYN_ID' => $faker->unique()->numberBetween(1, 10000),
|
||||
'DYN_TITLE' => $faker->sentence(2),
|
||||
'DYN_DESCRIPTION' => $faker->sentence(5),
|
||||
'PRO_UID' => function() {
|
||||
$process = factory(\ProcessMaker\Model\Process::class)->create();
|
||||
$process = factory(Process::class)->create();
|
||||
return $process->PRO_UID;
|
||||
},
|
||||
'DYN_TYPE' => 'xmlform',
|
||||
|
||||
23
database/factories/EmailServerFactory.php
Normal file
23
database/factories/EmailServerFactory.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(\ProcessMaker\Model\EmailServer::class, function(Faker $faker) {
|
||||
return [
|
||||
'MESS_UID' => G::generateUniqueID(),
|
||||
'MESS_ENGINE' => '',
|
||||
'MESS_SERVER' => '',
|
||||
'MESS_PORT' => 0,
|
||||
'MESS_INCOMING_SERVER' => '',
|
||||
'MESS_INCOMING_PORT' => 0,
|
||||
'MESS_RAUTH' => 0,
|
||||
'MESS_ACCOUNT' => '',
|
||||
'MESS_PASSWORD' => '',
|
||||
'MESS_FROM_MAIL' => '',
|
||||
'MESS_FROM_NAME' => '',
|
||||
'SMTPSECURE' => 'No',
|
||||
'MESS_TRY_SEND_INMEDIATLY' => 0,
|
||||
'MAIL_TO' => '',
|
||||
'MESS_DEFAULT' => 0,
|
||||
];
|
||||
});
|
||||
30
database/factories/InputDocumentFactory.php
Normal file
30
database/factories/InputDocumentFactory.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Model factory for a input document.
|
||||
*/
|
||||
use Faker\Generator as Faker;
|
||||
use ProcessMaker\Model\InputDocument;
|
||||
use ProcessMaker\Model\Process;
|
||||
|
||||
$factory->define(InputDocument::class, function(Faker $faker) {
|
||||
return [
|
||||
'INP_DOC_UID' => G::generateUniqueID(),
|
||||
'INP_DOC_ID' => $faker->unique()->numberBetween(1, 10000),
|
||||
'PRO_UID' => function() {
|
||||
$process = factory(Process::class)->create();
|
||||
return $process->PRO_UID;
|
||||
},
|
||||
'INP_DOC_TITLE' => $faker->sentence(2),
|
||||
'INP_DOC_DESCRIPTION' => $faker->sentence(10),
|
||||
'INP_DOC_FORM_NEEDED' => 'VIRTUAL',
|
||||
'INP_DOC_ORIGINAL' => 'ORIGINAL',
|
||||
'INP_DOC_PUBLISHED' => 'PRIVATE',
|
||||
'INP_DOC_VERSIONING' => 0,
|
||||
'INP_DOC_DESTINATION_PATH' => '',
|
||||
'INP_DOC_TAGS' => 'INPUT',
|
||||
'INP_DOC_TYPE_FILE' => '.*',
|
||||
'INP_DOC_MAX_FILESIZE' => 0,
|
||||
'INP_DOC_MAX_FILESIZE_UNIT' => 'KB'
|
||||
];
|
||||
});
|
||||
43
database/factories/OutputDocumentFactory.php
Normal file
43
database/factories/OutputDocumentFactory.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Model factory for a output document.
|
||||
*/
|
||||
use Faker\Generator as Faker;
|
||||
use ProcessMaker\Model\OutputDocument;
|
||||
use ProcessMaker\Model\Process;
|
||||
|
||||
$factory->define(OutputDocument::class, function(Faker $faker) {
|
||||
$date = $faker->dateTime();
|
||||
return [
|
||||
'OUT_DOC_UID' => G::generateUniqueID(),
|
||||
'OUT_DOC_ID' => $faker->unique()->numberBetween(1, 10000),
|
||||
'OUT_DOC_TITLE' => $faker->sentence(2),
|
||||
'OUT_DOC_DESCRIPTION' => $faker->sentence(10),
|
||||
'OUT_DOC_FILENAME' => $faker->sentence(2),
|
||||
'OUT_DOC_TEMPLATE' => '',
|
||||
'PRO_UID' => function() {
|
||||
$process = factory(Process::class)->create();
|
||||
return $process->PRO_UID;
|
||||
},
|
||||
'OUT_DOC_REPORT_GENERATOR' => 'TCPDF',
|
||||
'OUT_DOC_LANDSCAPE' => 0,
|
||||
'OUT_DOC_MEDIA' => 'Letter',
|
||||
'OUT_DOC_LEFT_MARGIN' => 20,
|
||||
'OUT_DOC_RIGHT_MARGIN' => 20,
|
||||
'OUT_DOC_TOP_MARGIN' => 20,
|
||||
'OUT_DOC_BOTTOM_MARGIN' => 20,
|
||||
'OUT_DOC_GENERATE' => 'BOTH',
|
||||
'OUT_DOC_TYPE' => 'HTML',
|
||||
'OUT_DOC_CURRENT_REVISION' => 0,
|
||||
'OUT_DOC_FIELD_MAPPING' => '',
|
||||
'OUT_DOC_VERSIONING' => 1,
|
||||
'OUT_DOC_DESTINATION_PATH' => '',
|
||||
'OUT_DOC_TAGS' => '',
|
||||
'OUT_DOC_PDF_SECURITY_ENABLED' => 0,
|
||||
'OUT_DOC_PDF_SECURITY_OPEN_PASSWORD' => '',
|
||||
'OUT_DOC_PDF_SECURITY_OWNER_PASSWORD' => '',
|
||||
'OUT_DOC_PDF_SECURITY_PERMISSIONS' => '',
|
||||
'OUT_DOC_OPEN_TYPE' => 1
|
||||
];
|
||||
});
|
||||
17
database/factories/ProcessFilesFactory.php
Normal file
17
database/factories/ProcessFilesFactory.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(\ProcessMaker\Model\ProcessFiles::class, function(Faker $faker) {
|
||||
return [
|
||||
'PRF_UID' => G::generateUniqueID(),
|
||||
'PRO_UID' => '',
|
||||
'USR_UID' => '',
|
||||
'PRF_UPDATE_USR_UID' => '',
|
||||
'PRF_PATH' => '',
|
||||
'PRF_TYPE' => '',
|
||||
'PRF_EDITABLE' => 1,
|
||||
'PRF_CREATE_DATE' => $faker->dateTime(),
|
||||
'PRF_UPDATE_DATE' => $faker->dateTime(),
|
||||
];
|
||||
});
|
||||
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' => '',
|
||||
];
|
||||
});
|
||||
@@ -1,7 +1,8 @@
|
||||
<?php
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(\ProcessMaker\Model\User::class, function(Faker $faker) {
|
||||
$factory->define(\ProcessMaker\Model\User::class, function (Faker $faker) {
|
||||
return [
|
||||
'USR_UID' => G::generateUniqueID(),
|
||||
'USR_USERNAME' => $faker->unique()->userName,
|
||||
@@ -9,11 +10,12 @@ $factory->define(\ProcessMaker\Model\User::class, function(Faker $faker) {
|
||||
'USR_FIRSTNAME' => $faker->firstName,
|
||||
'USR_LASTNAME' => $faker->lastName,
|
||||
'USR_EMAIL' => $faker->unique()->email,
|
||||
'USR_DUE_DATE' => new \Carbon\Carbon(2030,1,1),
|
||||
'USR_DUE_DATE' => new \Carbon\Carbon(2030, 1, 1),
|
||||
'USR_STATUS' => 'ACTIVE',
|
||||
'USR_ROLE' => $faker->randomElement(['PROCESSMAKER_ADMIN', 'PROCESSMAKER_OPERATOR']),
|
||||
'USR_UX' => 'NORMAL',
|
||||
'USR_TIME_ZONE' => 'America/Anguilla',
|
||||
'USR_DEFAULT_LANG' => 'en',
|
||||
'USR_LAST_LOGIN' => new \Carbon\Carbon(2019, 1, 1)
|
||||
];
|
||||
});
|
||||
@@ -9,6 +9,7 @@ use Illuminate\Foundation\Http\Kernel;
|
||||
use Luracast\Restler\Format\UploadFormat;
|
||||
use Luracast\Restler\RestException;
|
||||
use Maveriks\Util;
|
||||
use ProcessMaker\Core\JobsManager;
|
||||
use ProcessMaker\Core\System;
|
||||
use ProcessMaker\Plugins\PluginRegistry;
|
||||
use ProcessMaker\Services;
|
||||
@@ -612,6 +613,11 @@ class WebApplication
|
||||
|
||||
\Propel::init(PATH_CONFIG . "databases.php");
|
||||
|
||||
/**
|
||||
* JobsManager
|
||||
*/
|
||||
JobsManager::getSingleton()->init();
|
||||
|
||||
$oPluginRegistry = PluginRegistry::loadSingleton();
|
||||
$attributes = $oPluginRegistry->getAttributes();
|
||||
Bootstrap::LoadTranslationPlugins(defined('SYS_LANG') ? SYS_LANG : "en", $attributes);
|
||||
|
||||
0
gulliver/bin/gulliver
Executable file → Normal file
0
gulliver/bin/gulliver
Executable file → Normal file
@@ -1839,7 +1839,7 @@ class Bootstrap
|
||||
*
|
||||
* @return multitype:string mixed Ambigous <number, string>
|
||||
*/
|
||||
public function parseNormalUri($aRequestUri, array $arrayFriendlyUri = null)
|
||||
public static function parseNormalUri($aRequestUri, array $arrayFriendlyUri = null)
|
||||
{
|
||||
if (substr($aRequestUri[1], 0, 3) == 'sys') {
|
||||
define('SYS_TEMP', substr($aRequestUri[1], 3));
|
||||
|
||||
@@ -393,19 +393,20 @@ class database extends database_base
|
||||
}
|
||||
|
||||
/**
|
||||
* generate a sentence to add indexes or primary keys
|
||||
* Generate a sentence to add indexes or primary keys
|
||||
*
|
||||
* @param string $table table name
|
||||
* @param string $indexName index name
|
||||
* @param array $keys array of keys
|
||||
* @param string $indexType the index type
|
||||
*
|
||||
* @return string sql sentence
|
||||
* @throws Exception
|
||||
*/
|
||||
|
||||
public function generateAddKeysSQL($table, $indexName, $keys)
|
||||
public function generateAddKeysSQL($table, $indexName, $keys, $indexType = 'INDEX')
|
||||
{
|
||||
try {
|
||||
$indexType = 'INDEX';
|
||||
if ($indexName === 'primaryKey' || $indexName === 'PRIMARY') {
|
||||
$indexType = 'PRIMARY';
|
||||
$indexName = 'KEY';
|
||||
@@ -519,13 +520,15 @@ class database extends database_base
|
||||
}
|
||||
|
||||
/**
|
||||
* execute a sql query
|
||||
* Execute a sql query
|
||||
*
|
||||
* @param string $query
|
||||
* @param bool $throwError
|
||||
*
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
public function executeQuery($query)
|
||||
public function executeQuery($query, $throwError = false)
|
||||
{
|
||||
$this->logQuery($query);
|
||||
|
||||
@@ -545,7 +548,11 @@ class database extends database_base
|
||||
return $result;
|
||||
} catch (Exception $exception) {
|
||||
$this->logQuery($exception->getMessage());
|
||||
return [];
|
||||
if ($throwError) {
|
||||
throw $exception;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1012,4 +1019,98 @@ class database extends database_base
|
||||
}
|
||||
return $flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate drop trigger SQL
|
||||
*
|
||||
* @param string $triggerName
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getDropTrigger($triggerName)
|
||||
{
|
||||
return "DROP TRIGGER IF EXISTS `{$triggerName}`;";
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate alter table with or without adding the indexes
|
||||
*
|
||||
* @param string $tableName
|
||||
* @param array $columns
|
||||
* @param array $indexes
|
||||
* @param array $fulltextIndexes
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function generateAddColumnsSql($tableName, $columns, $indexes = [], $fulltextIndexes = [])
|
||||
{
|
||||
$indexesAlreadyAdded = [];
|
||||
$sql = 'ALTER TABLE ' . $this->sQuoteCharacter . $tableName . $this->sQuoteCharacter . ' ';
|
||||
foreach ($columns as $columnName => $parameters) {
|
||||
if (isset($parameters['Type']) && isset($parameters['Null'])) {
|
||||
$sql .= 'ADD COLUMN ' . $this->sQuoteCharacter . $columnName . $this->sQuoteCharacter . ' ' . $parameters['Type'];
|
||||
if ($parameters['Null'] == 'YES') {
|
||||
$sql .= ' NULL';
|
||||
} else {
|
||||
$sql .= ' NOT NULL';
|
||||
}
|
||||
}
|
||||
if (isset($parameters['AutoIncrement']) && $parameters['AutoIncrement']) {
|
||||
$sql .= ' AUTO_INCREMENT';
|
||||
}
|
||||
if (isset($parameters['PrimaryKey']) && $parameters['PrimaryKey']) {
|
||||
$sql .= ' PRIMARY KEY';
|
||||
$indexesAlreadyAdded[] = $columnName;
|
||||
}
|
||||
if (isset($parameters['Unique']) && $parameters['Unique']) {
|
||||
$sql .= ' UNIQUE';
|
||||
}
|
||||
|
||||
// We need to check the property AI
|
||||
if (isset($parameters['AI'])) {
|
||||
if ($parameters['AI'] == 1) {
|
||||
$sql .= ' AUTO_INCREMENT';
|
||||
} else {
|
||||
if ($parameters['Default'] != '') {
|
||||
$sql .= " DEFAULT '" . $parameters['Default'] . "'";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (isset($parameters['Default'])) {
|
||||
$sql .= " DEFAULT '" . $parameters['Default'] . "'";
|
||||
}
|
||||
}
|
||||
$sql .= ', ';
|
||||
}
|
||||
// Add the normal indexes if are not "primaryKeys" already added
|
||||
foreach ($indexes as $indexName => $indexColumns) {
|
||||
$indexType = 'INDEX';
|
||||
if ($indexName === 'primaryKey' || $indexName === 'PRIMARY') {
|
||||
$indexType = 'PRIMARY';
|
||||
$indexName = 'KEY';
|
||||
// If is primary key is not needed add a new index, the column already was added like primary key
|
||||
if (count($indexColumns) == 1 && $indexesAlreadyAdded == $indexColumns) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$sql .= 'ADD ' . $indexType . ' ' . $indexName . ' (';
|
||||
foreach ($indexColumns as $column) {
|
||||
$sql .= $this->sQuoteCharacter . $column . $this->sQuoteCharacter . ', ';
|
||||
}
|
||||
$sql = substr($sql, 0, -2);
|
||||
$sql .= '), ';
|
||||
}
|
||||
// Add the "fulltext" indexes always
|
||||
foreach ($fulltextIndexes as $indexName => $indexColumns) {
|
||||
$sql .= 'ADD FULLTEXT ' . $indexName . ' (';
|
||||
foreach ($indexColumns as $column) {
|
||||
$sql .= $this->sQuoteCharacter . $column . $this->sQuoteCharacter . ', ';
|
||||
}
|
||||
$sql = substr($sql, 0, -2);
|
||||
$sql .= '), ';
|
||||
}
|
||||
$sql = rtrim($sql, ', ');
|
||||
|
||||
return $sql;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ class DBConnection
|
||||
* @return string
|
||||
*
|
||||
*/
|
||||
public function DBConnection($strServer = DB_HOST, $strUser = DB_USER, $strPwd = DB_PASS, $strDB = DB_NAME, $type = DB_ADAPTER, $strPort = 0, $errorLevel = 2)
|
||||
public function __construct($strServer = DB_HOST, $strUser = DB_USER, $strPwd = DB_PASS, $strDB = DB_NAME, $type = DB_ADAPTER, $strPort = 0, $errorLevel = 2)
|
||||
{
|
||||
$this->errorLevel = $errorLevel;
|
||||
if ($type == null) {
|
||||
|
||||
@@ -47,9 +47,9 @@ class DBRecordSet
|
||||
* @param string $intResult Database recordset default value = false
|
||||
* @return void
|
||||
*/
|
||||
function DBRecordSet ($intResult = null)
|
||||
public function __construct($intResult = null)
|
||||
{
|
||||
$this->SetTo( $intResult );
|
||||
$this->SetTo($intResult);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -52,12 +52,12 @@ class DBSession
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
function DBSession ($objConnection = null, $strDBName = '')
|
||||
public function __construct($objConnection = null, $strDBName = '')
|
||||
{
|
||||
if ($strDBName != '') {
|
||||
$strDBName = $objConnection->db->_db;
|
||||
}
|
||||
$this->setTo( $objConnection, $strDBName );
|
||||
$this->setTo($objConnection, $strDBName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -53,12 +53,15 @@ class DBTable
|
||||
/**
|
||||
* Initiate a database conecction using default values
|
||||
*
|
||||
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
||||
* @access public
|
||||
* @param object $objConnection conecction string
|
||||
*
|
||||
* @param object $objConnection
|
||||
* @param string $strTable
|
||||
* @param array $arrKeys
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function dBTable($objConnection = null, $strTable = "", $arrKeys = array('UID'))
|
||||
public function __construct($objConnection = null, $strTable = "", $arrKeys = ['UID'])
|
||||
{
|
||||
$this->_dbc = null;
|
||||
$this->_dbses = null;
|
||||
|
||||
@@ -77,12 +77,12 @@ class G_Error extends PEAR_Error
|
||||
*
|
||||
* @see PEAR_Error
|
||||
*/
|
||||
public function G_Error ($code = G_ERROR, $mode = PEAR_ERROR_RETURN, $level = E_USER_NOTICE, $debuginfo = null)
|
||||
public function __construct($code = G_ERROR, $mode = PEAR_ERROR_RETURN, $level = E_USER_NOTICE, $debuginfo = null)
|
||||
{
|
||||
if (is_int( $code )) {
|
||||
$this->PEAR_Error( 'G Error: ' . G_Error::errorMessage( $code ), $code, $mode, $level, $debuginfo );
|
||||
if (is_int($code)) {
|
||||
$this->PEAR_Error('G Error: ' . G_Error::errorMessage($code), $code, $mode, $level, $debuginfo);
|
||||
} else {
|
||||
$this->PEAR_Error( "G Error: $code", DB_ERROR, $mode, $level, $debuginfo );
|
||||
$this->PEAR_Error("G Error: $code", DB_ERROR, $mode, $level, $debuginfo);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1636,16 +1636,13 @@ class G
|
||||
|
||||
/**
|
||||
* Escapes special characters in a string for use in a SQL statement
|
||||
* @param string $sqlString The string to be escaped
|
||||
* @param string $dbEngine Target DBMS
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function sqlEscape($sqlString, $dbEngine = DB_ADAPTER)
|
||||
* @param string $sqlString The string to be escaped
|
||||
* @param string $DBEngine Target DBMS
|
||||
*/
|
||||
public static function sqlEscape($sqlString, $DBEngine = DB_ADAPTER)
|
||||
{
|
||||
// @todo: Research why always this value is set with the same constant?
|
||||
$dbEngine = DB_ADAPTER;
|
||||
switch ($dbEngine) {
|
||||
$DBEngine = DB_ADAPTER;
|
||||
switch ($DBEngine) {
|
||||
case 'mysql':
|
||||
$con = Propel::getConnection('workflow');
|
||||
return mysqli_real_escape_string($con->getResource(), stripslashes($sqlString));
|
||||
@@ -1692,15 +1689,9 @@ class G
|
||||
* @# Non-quoted parameter
|
||||
* @! Evaluate string : Replace the parameters in value and then in the sql string
|
||||
* @fn() Evaluate string with the function "fn"
|
||||
*
|
||||
* @param string $sqlString
|
||||
* @param array $result
|
||||
* @param string $dbEngine
|
||||
* @param bool $applyHtmlEntities
|
||||
*
|
||||
* @return string
|
||||
* @author David Callizaya <calidavidx21@hotmail.com>
|
||||
*/
|
||||
public static function replaceDataField($sqlString, $result, $dbEngine = 'mysql', $applyHtmlEntities = false)
|
||||
public static function replaceDataField($sqlString, $result, $DBEngine = 'mysql', $recursive = true)
|
||||
{
|
||||
if (!is_array($result)) {
|
||||
$result = array();
|
||||
@@ -1719,12 +1710,7 @@ class G
|
||||
$u = $match[0][$r][1] + strlen($match[0][$r][0]);
|
||||
//Mysql quotes scape
|
||||
if (($match[1][$r][0] == '@') && (isset($result[$match[2][$r][0]]))) {
|
||||
$text = ($applyHtmlEntities && !stringIsValidHtml($result[$match[2][$r][0]])) ?
|
||||
htmlentities(G::unhtmlentities($result[$match[2][$r][0]]), ENT_COMPAT, 'UTF-8') :
|
||||
$result[$match[2][$r][0]];
|
||||
// Replenish the tag <br /> because is valid
|
||||
$text = str_replace('<br />', '<br />', $text);
|
||||
$__textoEval .= "\"" . G::sqlEscape($text, $dbEngine) . "\"";
|
||||
$__textoEval .= "\"" . G::sqlEscape($result[$match[2][$r][0]], $DBEngine) . "\"";
|
||||
continue;
|
||||
}
|
||||
//URL encode
|
||||
@@ -1744,7 +1730,7 @@ class G
|
||||
}
|
||||
//Substring (Sub replaceDataField)
|
||||
if (($match[1][$r][0] == '!') && (isset($result[$match[2][$r][0]]))) {
|
||||
$__textoEval .= G::replaceDataField($result[$match[2][$r][0]], $result, $dbEngine, $applyHtmlEntities);
|
||||
$__textoEval .= G::replaceDataField($result[$match[2][$r][0]], $result);
|
||||
continue;
|
||||
}
|
||||
//Call function
|
||||
@@ -1762,33 +1748,18 @@ class G
|
||||
}
|
||||
//Non-quoted
|
||||
if (($match[1][$r][0] == '#') && (isset($result[$match[2][$r][0]]))) {
|
||||
$text = ($applyHtmlEntities && !stringIsValidHtml($result[$match[2][$r][0]]) && $match[2][$r][0] !== '__ABE__') ?
|
||||
htmlentities(G::unhtmlentities($result[$match[2][$r][0]]), ENT_COMPAT, 'UTF-8') :
|
||||
$result[$match[2][$r][0]];
|
||||
// Replenish the tag <br /> because is valid
|
||||
$text = str_replace('<br />', '<br />', $text);
|
||||
$__textoEval .= G::replaceDataField($text, $result);
|
||||
$__textoEval .= $recursive ? G::replaceDataField($result[$match[2][$r][0]], $result) : $result[$match[2][$r][0]];
|
||||
continue;
|
||||
}
|
||||
//Non-quoted =
|
||||
if (($match[1][$r][0] == '=') && (isset($result[$match[2][$r][0]]))) {
|
||||
$text = ($applyHtmlEntities && !stringIsValidHtml($result[$match[2][$r][0]]) && $match[2][$r][0] !== '__ABE__') ?
|
||||
htmlentities(G::unhtmlentities($result[$match[2][$r][0]]), ENT_COMPAT, 'UTF-8') :
|
||||
$result[$match[2][$r][0]];
|
||||
// Replenish the tag <br /> because is valid
|
||||
$text = str_replace('<br />', '<br />', $text);
|
||||
$__textoEval .= G::replaceDataField($text, $result);
|
||||
$__textoEval .= $recursive ? G::replaceDataField($result[$match[2][$r][0]], $result) : $result[$match[2][$r][0]];
|
||||
continue;
|
||||
}
|
||||
//Objects attributes
|
||||
if (($match[1][$r][0] == '&') && (isset($result[$match[2][$r][0]]))) {
|
||||
if (isset($result[$match[2][$r][0]]->{$match[6][$r][0]})) {
|
||||
$text = ($applyHtmlEntities && !stringIsValidHtml($result[$match[2][$r][0]]->{$match[6][$r][0]})) ?
|
||||
htmlentities(G::unhtmlentities($result[$match[2][$r][0]]->{$match[6][$r][0]}), ENT_COMPAT, 'UTF-8') :
|
||||
$result[$match[2][$r][0]]->{$match[6][$r][0]};
|
||||
// Replenish the tag <br /> because is valid
|
||||
$text = str_replace('<br />', '<br />', $text);
|
||||
$__textoEval .= $text;
|
||||
$__textoEval .= $result[$match[2][$r][0]]->{$match[6][$r][0]};
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -1800,35 +1771,27 @@ class G
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace Grid Values in a string.
|
||||
* The tag @>GRID-NAME to open the grid and @<GRID-NAME to close the grid,
|
||||
*
|
||||
* @param string $content
|
||||
* @param array $fields
|
||||
* @param bool $nl2brRecursive
|
||||
* @param bool $applyHtmlEntities
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @see \Cases->sendMessage()
|
||||
* @see \WsBase->sendMessage()
|
||||
* @see \OutputDocument->generate()
|
||||
* @see \ProcessMaker\BusinessModel\Cases\OutputDocument->generate()
|
||||
*/
|
||||
public static function replaceDataGridField($content, $fields, $nl2brRecursive = true, $applyHtmlEntities = false)
|
||||
* Replace Grid Values
|
||||
* The tag @>GRID-NAME to open the grid and @<GRID-NAME to close the grid,
|
||||
*
|
||||
* @param type String $sContent
|
||||
* @param type Array $aFields
|
||||
* @return type String
|
||||
*/
|
||||
public static function replaceDataGridField($sContent, $aFields, $nl2brRecursive = true)
|
||||
{
|
||||
$nrt = array("\n", "\r", "\t");
|
||||
$nrthtml = array("(n /)", "(r /)", "(t /)");
|
||||
|
||||
$strContentAux = str_replace($nrt, $nrthtml, $content);
|
||||
$sContent = G::unhtmlentities($sContent);
|
||||
$strContentAux = str_replace($nrt, $nrthtml, $sContent);
|
||||
|
||||
$occurrences = preg_match_all('/\@(?:([\>])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]*(?:[\\\\][\w\W])?)*)\))((?:\s*\[[\'"]?\w+[\'"]?\])+)?/',
|
||||
$strContentAux, $arrayMatch1, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE);
|
||||
$iOcurrences = preg_match_all('/\@(?:([\>])([a-zA-Z\_]\w*)|([a-zA-Z\_][\w\-\>\:]*)\(((?:[^\\\\\)]*(?:[\\\\][\w\W])?)*)\))((?:\s*\[[\'"]?\w+[\'"]?\])+)?/', $strContentAux, $arrayMatch1, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE);
|
||||
|
||||
if ($occurrences) {
|
||||
if ($iOcurrences) {
|
||||
$arrayGrid = array();
|
||||
|
||||
for ($i = 0; $i <= $occurrences - 1; $i++) {
|
||||
for ($i = 0; $i <= $iOcurrences - 1; $i++) {
|
||||
$arrayGrid[] = $arrayMatch1[2][$i][0];
|
||||
}
|
||||
|
||||
@@ -1854,16 +1817,16 @@ class G
|
||||
while (preg_match($ereg, $strContentAux1, $arrayMatch2)) {
|
||||
$strData = null;
|
||||
|
||||
if (isset($fields[$grdName]) && is_array($fields[$grdName])) {
|
||||
foreach ($fields[$grdName] as $aRow) {
|
||||
if (isset($aFields[$grdName]) && is_array($aFields[$grdName])) {
|
||||
foreach ($aFields[$grdName] as $aRow) {
|
||||
if ($nl2brRecursive) {
|
||||
foreach ($aRow as $key => $item) {
|
||||
if (!is_array($item)) {
|
||||
$aRow[$key] = str_replace($nrt, $nrthtml, nl2br($aRow[$key]));
|
||||
foreach ($aRow as $sKey => $vValue) {
|
||||
if (!is_array($vValue)) {
|
||||
$aRow[$sKey] = str_replace($nrt, $nrthtml, nl2br($aRow[$sKey]));
|
||||
}
|
||||
}
|
||||
}
|
||||
$strData = $strData . G::replaceDataField($arrayMatch2[2], $aRow, 'mysql', $applyHtmlEntities);
|
||||
$strData = $strData . G::replaceDataField($arrayMatch2[2], $aRow, 'mysql', false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1878,19 +1841,19 @@ class G
|
||||
|
||||
$strContentAux = str_replace($nrthtml, $nrt, $strContentAux);
|
||||
|
||||
$content = $strContentAux;
|
||||
$sContent = $strContentAux;
|
||||
|
||||
if ($nl2brRecursive) {
|
||||
foreach ($fields as $key => $item) {
|
||||
if (!is_array($item) && !is_object($item)) {
|
||||
$fields[$key] = nl2br($fields[$key]);
|
||||
foreach ($aFields as $sKey => $vValue) {
|
||||
if (!is_array($vValue) && !is_object($vValue)) {
|
||||
$aFields[$sKey] = nl2br($aFields[$sKey]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$content = G::replaceDataField($content, $fields, 'mysql', $applyHtmlEntities);
|
||||
$sContent = G::replaceDataField($sContent, $aFields, 'mysql', false);
|
||||
|
||||
return $content;
|
||||
return $sContent;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -5097,11 +5060,308 @@ class G
|
||||
public static function reservedWordsSql()
|
||||
{
|
||||
//Reserved words SQL
|
||||
$reservedWordsSql = array("ACCESSIBLE","ACTION","ADD","ALL","ALTER","ANALYZE","AND","ANY","AS","ASC","ASENSITIVE","AUTHORIZATION","BACKUP","BEFORE","BEGIN","BETWEEN","BIGINT","BINARY","BIT","BLOB","BOTH","BREAK","BROWSE","BULK","BY","CALL","CASCADE","CASE","CHANGE","CHAR","CHARACTER","CHECK","CHECKPOINT","CLOSE","CLUSTERED","COALESCE","COLLATE","COLUMN","COMMIT","COMPUTE","CONDITION","CONSTRAINT","CONTAINS","CONTAINSTABLE","CONTINUE","CONVERT","CREATE","CROSS","CURRENT","CURRENT_DATE","CURRENT_TIME","CURRENT_TIMESTAMP","CURRENT_USER","CURSOR","DATABASE","DATABASES","DATE","DAY_HOUR","DAY_MICROSECOND","DAY_MINUTE","DAY_SECOND","DBCC","DEALLOCATE","DEC","DECIMAL","DECLARE","DEFAULT","DELAYED","DELETE","DENY","DESC","DESCRIBE","DETERMINISTIC","DISK","DISTINCT","DISTINCTROW",
|
||||
"DISTRIBUTED","DIV","DOUBLE","DROP","DUAL","DUMMY","DUMP","EACH","ELSE","ELSEIF","ENCLOSED","END","ENUM","ERRLVL","ESCAPE","ESCAPED","EXCEPT","EXEC","EXECUTE","EXISTS","EXIT","EXPLAIN","FALSE","FETCH","FILE","FILLFACTOR","FLOAT","FLOAT4","FLOAT8","FOR","FORCE","FOREIGN","FREETEXT","FREETEXTTABLE","FROM","FULL","FULLTEXT","FUNCTION","GENERAL","GOTO","GRANT","GROUP","HAVING","HIGH_PRIORITY","HOLDLOCK","HOUR_MICROSECOND","HOUR_MINUTE","HOUR_SECOND","IDENTITY","IDENTITYCOL","IDENTITY_INSERT","IF","IGNORE","IGNORE_SERVER_IDS","IN","INDEX","INFILE","INNER","INOUT","INSENSITIVE","INSERT","INT","INT1","INT2","INT3","INT4","INT8","INTEGER","INTERSECT","INTERVAL","INTO","IS","ITERATE","JOIN","KEY","KEYS","KILL","LEADING","LEAVE","LEFT","LIKE","LIMIT","LINEAR","LINENO","LINES",
|
||||
"LOAD","LOCALTIME","LOCALTIMESTAMP","LOCK","LONG","LONGBLOB","LONGTEXT","LOOP","LOW_PRIORITY","MASTER_HEARTBEAT_PERIOD","MASTER_SSL_VERIFY_SERVER_CERT","MATCH","MAXVALUE","MEDIUMBLOB","MEDIUMINT","MEDIUMTEXT","MIDDLEINT","MINUTE_MICROSECOND","MINUTE_SECOND","MOD","MODIFIES","NATIONAL","NATURAL","NO","NOCHECK","NONCLUSTERED","NOT","NO_WRITE_TO_BINLOG","NULL","NULLIF","NUMERIC","OF","OFF","OFFSETS","ON","OPEN","OPENDATASOURCE","OPENQUERY","OPENROWSET","OPENXML","OPTIMIZE","OPTION","OPTIONALLY","OR","ORDER","OUT","OUTER","OUTFILE","OVER","PERCENT","PLAN","PRECISION","PRIMARY","PRINT","PROC","PROCEDURE","PUBLIC","PURGE","RAISERROR","RANGE","READ","READS","READTEXT","READ_WRITE","REAL","RECONFIGURE","REFERENCES","REGEXP","RELEASE","RENAME","REPEAT","REPLACE",
|
||||
"REPLICATION","REQUIRE","RESIGNAL","RESTORE","RESTRICT","RETURN","REVOKE","RIGHT","RLIKE","ROLLBACK","ROWCOUNT","ROWGUIDCOL","RULE","SAVE","SCHEMA","SCHEMAS","SECOND_MICROSECOND","SELECT","SENSITIVE","SEPARATOR","SESSION_USER","SET","SETUSER","SHOW","SHUTDOWN","SIGNAL","SLOW","SMALLINT","SOME","SPATIAL","SPECIFIC","SQL","SQLEXCEPTION","SQLSTATE","SQLWARNING","SQL_BIG_RESULT","SQL_CALC_FOUND_ROWS","SQL_SMALL_RESULT","SSL","STARTING","STATISTICS","STRAIGHT_JOIN","SYSTEM_USER","TABLE","TERMINATED","TEXT","TEXTSIZE","THEN","TIME","TIMESTAMP","TINYBLOB","TINYINT","TINYTEXT","TO","TOP","TRAILING","TRAN","TRANSACTION","TRIGGER","TRUE","TRUNCATE","TSEQUAL","UNDO","UNION","UNIQUE","UNLOCK","UNSIGNED","UPDATE","UPDATETEXT","USAGE","USE","USER","USING","UTC_DATE","UTC_TIME",
|
||||
"UTC_TIMESTAMP","VALUES","VARBINARY","VARCHAR","VARCHARACTER","VARYING","VIEW","WAITFOR","WHEN","WHERE","WHILE","WITH","WRITE","WRITETEXT","XOR","YEAR_MONTH","ZEROFILL");
|
||||
$reservedWordsSql = [
|
||||
"ACCESSIBLE",
|
||||
"ADD",
|
||||
"ALL",
|
||||
"ALTER",
|
||||
"ANALYZE",
|
||||
"AND",
|
||||
"AS",
|
||||
"ASC",
|
||||
"ASENSITIVE",
|
||||
"AUTHORIZATION",
|
||||
"BEFORE",
|
||||
"BETWEEN",
|
||||
"BIGINT",
|
||||
"BINARY",
|
||||
"BLOB",
|
||||
"BOTH",
|
||||
"BREAK",
|
||||
"BROWSE",
|
||||
"BULK",
|
||||
"BY",
|
||||
"CALL",
|
||||
"CASCADE",
|
||||
"CASE",
|
||||
"CHANGE",
|
||||
"CHAR",
|
||||
"CHARACTER",
|
||||
"CHECK",
|
||||
"CHECKPOINT",
|
||||
"CLUSTERED",
|
||||
"COLLATE",
|
||||
"COLUMN",
|
||||
"COMPUTE",
|
||||
"CONDITION",
|
||||
"CONSTRAINT",
|
||||
"CONTAINSTABLE",
|
||||
"CONTINUE",
|
||||
"CONVERT",
|
||||
"CREATE",
|
||||
"CROSS",
|
||||
"CURRENT_DATE",
|
||||
"CURRENT_TIME",
|
||||
"CURRENT_TIMESTAMP",
|
||||
"CURRENT_USER",
|
||||
"CURSOR",
|
||||
"DATABASE",
|
||||
"DATABASES",
|
||||
"DAY_HOUR",
|
||||
"DAY_MICROSECOND",
|
||||
"DAY_MINUTE",
|
||||
"DAY_SECOND",
|
||||
"DBCC",
|
||||
"DEC",
|
||||
"DECIMAL",
|
||||
"DECLARE",
|
||||
"DEFAULT",
|
||||
"DELAYED",
|
||||
"DELETE",
|
||||
"DENY",
|
||||
"DESC",
|
||||
"DESCRIBE",
|
||||
"DETERMINISTIC",
|
||||
"DISTINCT",
|
||||
"DISTINCTROW",
|
||||
"DISTRIBUTED",
|
||||
"DIV",
|
||||
"DOUBLE",
|
||||
"DROP",
|
||||
"DUAL",
|
||||
"DUMMY",
|
||||
"DUMP",
|
||||
"EACH",
|
||||
"ELSE",
|
||||
"ELSEIF",
|
||||
"ENCLOSED",
|
||||
"ERRLVL",
|
||||
"ESCAPED",
|
||||
"EXCEPT",
|
||||
"EXEC",
|
||||
"EXISTS",
|
||||
"EXIT",
|
||||
"EXPLAIN",
|
||||
"FALSE",
|
||||
"FETCH",
|
||||
"FILLFACTOR",
|
||||
"FLOAT",
|
||||
"FLOAT4",
|
||||
"FLOAT8",
|
||||
"FOR",
|
||||
"FORCE",
|
||||
"FOREIGN",
|
||||
"FREETEXT",
|
||||
"FREETEXTTABLE",
|
||||
"FROM",
|
||||
"FULLTEXT",
|
||||
"GENERATED",
|
||||
"GET",
|
||||
"GOTO",
|
||||
"GRANT",
|
||||
"GROUP",
|
||||
"HAVING",
|
||||
"HIGH_PRIORITY",
|
||||
"HOLDLOCK",
|
||||
"HOUR_MICROSECOND",
|
||||
"HOUR_MINUTE",
|
||||
"HOUR_SECOND",
|
||||
"IDENTITY",
|
||||
"IDENTITYCOL",
|
||||
"IDENTITY_INSERT",
|
||||
"IF",
|
||||
"IGNORE",
|
||||
"IN",
|
||||
"INDEX",
|
||||
"INFILE",
|
||||
"INNER",
|
||||
"INOUT",
|
||||
"INSENSITIVE",
|
||||
"INSERT",
|
||||
"INT",
|
||||
"INT1",
|
||||
"INT2",
|
||||
"INT3",
|
||||
"INT4",
|
||||
"INT8",
|
||||
"INTEGER",
|
||||
"INTERSECT",
|
||||
"INTERVAL",
|
||||
"INTO",
|
||||
"IO_AFTER_GTIDS",
|
||||
"IO_BEFORE_GTIDS",
|
||||
"IS",
|
||||
"ITERATE",
|
||||
"JOIN",
|
||||
"KEY",
|
||||
"KEYS",
|
||||
"KILL",
|
||||
"LEADING",
|
||||
"LEAVE",
|
||||
"LEFT",
|
||||
"LIKE",
|
||||
"LIMIT",
|
||||
"LINEAR",
|
||||
"LINENO",
|
||||
"LINES",
|
||||
"LOAD",
|
||||
"LOCALTIME",
|
||||
"LOCALTIMESTAMP",
|
||||
"LOCK",
|
||||
"LONG",
|
||||
"LONGBLOB",
|
||||
"LONGTEXT",
|
||||
"LOOP",
|
||||
"LOW_PRIORITY",
|
||||
"MASTER_BIND",
|
||||
"MASTER_SSL_VERIFY_SERVER_CERT",
|
||||
"MATCH",
|
||||
"MAXVALUE",
|
||||
"MEDIUMBLOB",
|
||||
"MEDIUMINT",
|
||||
"MEDIUMTEXT",
|
||||
"MIDDLEINT",
|
||||
"MINUTE_MICROSECOND",
|
||||
"MINUTE_SECOND",
|
||||
"MOD",
|
||||
"MODIFIES",
|
||||
"NATURAL",
|
||||
"NOCHECK",
|
||||
"NONCLUSTERED",
|
||||
"NOT",
|
||||
"NO_WRITE_TO_BINLOG",
|
||||
"NULL",
|
||||
"NULLIF",
|
||||
"NUMERIC",
|
||||
"OF",
|
||||
"OFF",
|
||||
"OFFSETS",
|
||||
"ON",
|
||||
"OPENDATASOURCE",
|
||||
"OPENQUERY",
|
||||
"OPENROWSET",
|
||||
"OPENXML",
|
||||
"OPTIMIZE",
|
||||
"OPTIMIZER_COSTS",
|
||||
"OPTION",
|
||||
"OPTIONALLY",
|
||||
"OR",
|
||||
"ORDER",
|
||||
"OUT",
|
||||
"OUTER",
|
||||
"OUTFILE",
|
||||
"OVER",
|
||||
"PARTITION",
|
||||
"PARSE_GCOL_EXPR",
|
||||
"PERCENT",
|
||||
"PLAN",
|
||||
"PRECISION",
|
||||
"PRIMARY",
|
||||
"PRINT",
|
||||
"PROC",
|
||||
"PROCEDURE",
|
||||
"PUBLIC",
|
||||
"PURGE",
|
||||
"RAISERROR",
|
||||
"RANGE",
|
||||
"READ",
|
||||
"READS",
|
||||
"READTEXT",
|
||||
"READ_WRITE",
|
||||
"REAL",
|
||||
"RECONFIGURE",
|
||||
"REFERENCES",
|
||||
"REGEXP",
|
||||
"RELEASE",
|
||||
"RENAME",
|
||||
"REPEAT",
|
||||
"REPLACE",
|
||||
"REQUIRE",
|
||||
"RESIGNAL",
|
||||
"RESTRICT",
|
||||
"RETURN",
|
||||
"REVOKE",
|
||||
"RIGHT",
|
||||
"RLIKE",
|
||||
"ROWCOUNT",
|
||||
"ROWGUIDCOL",
|
||||
"RULE",
|
||||
"SAVE",
|
||||
"SCHEMA",
|
||||
"SCHEMAS",
|
||||
"SECOND_MICROSECOND",
|
||||
"SELECT",
|
||||
"SENSITIVE",
|
||||
"SEPARATOR",
|
||||
"SESSION_USER",
|
||||
"SET",
|
||||
"SETUSER",
|
||||
"SHOW",
|
||||
"SIGNAL",
|
||||
"SMALLINT",
|
||||
"SPATIAL",
|
||||
"SPECIFIC",
|
||||
"SQL",
|
||||
"SQLEXCEPTION",
|
||||
"SQLSTATE",
|
||||
"SQLWARNING",
|
||||
"SQL_AFTER_GTIDS",
|
||||
"SQL_BEFORE_GTIDS",
|
||||
"SQL_BIG_RESULT",
|
||||
"SQL_CALC_FOUND_ROWS",
|
||||
"SQL_SMALL_RESULT",
|
||||
"SSL",
|
||||
"STARTING",
|
||||
"STATISTICS",
|
||||
"STORED",
|
||||
"STRAIGHT_JOIN",
|
||||
"SYSTEM_USER",
|
||||
"TABLE",
|
||||
"TERMINATED",
|
||||
"TEXTSIZE",
|
||||
"THEN",
|
||||
"TINYBLOB",
|
||||
"TINYINT",
|
||||
"TINYTEXT",
|
||||
"TO",
|
||||
"TOP",
|
||||
"TRAILING",
|
||||
"TRAN",
|
||||
"TRIGGER",
|
||||
"TRUE",
|
||||
"TSEQUAL",
|
||||
"UNDO",
|
||||
"UNION",
|
||||
"UNIQUE",
|
||||
"UNLOCK",
|
||||
"UNSIGNED",
|
||||
"UPDATE",
|
||||
"UPDATETEXT",
|
||||
"USAGE",
|
||||
"USE",
|
||||
"USING",
|
||||
"UTC_DATE",
|
||||
"UTC_TIME",
|
||||
"UTC_TIMESTAMP",
|
||||
"VALUES",
|
||||
"VARBINARY",
|
||||
"VARCHAR",
|
||||
"VARCHARACTER",
|
||||
"VARYING",
|
||||
"VIRTUAL",
|
||||
"WAITFOR",
|
||||
"WHEN",
|
||||
"WHERE",
|
||||
"WHILE",
|
||||
"WITH",
|
||||
"WRITE",
|
||||
"WRITETEXT",
|
||||
"XOR",
|
||||
"YEAR_MONTH",
|
||||
"ZEROFILL",
|
||||
"_FILENAME"
|
||||
];
|
||||
|
||||
return $reservedWordsSql;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,13 +25,13 @@ class InputFilter
|
||||
/**
|
||||
* Constructor for inputFilter class. Only first parameter is required.
|
||||
* @access constructor
|
||||
* @param Array $tagsArray - list of user-defined tags
|
||||
* @param Array $attrArray - list of user-defined attributes
|
||||
* @param array $tagsArray - list of user-defined tags
|
||||
* @param array $attrArray - list of user-defined attributes
|
||||
* @param int $tagsMethod - 0= allow just user-defined, 1= allow all but user-defined
|
||||
* @param int $attrMethod - 0= allow just user-defined, 1= allow all but user-defined
|
||||
* @param int $xssAuto - 0= only auto clean essentials, 1= allow clean blacklisted tags/attr
|
||||
*/
|
||||
public function inputFilter($tagsArray = array(), $attrArray = array(), $tagsMethod = 0, $attrMethod = 0, $xssAuto = 1)
|
||||
public function __construct($tagsArray = [], $attrArray = [], $tagsMethod = 0, $attrMethod = 0, $xssAuto = 1)
|
||||
{
|
||||
// make sure user defined arrays are in lowercase
|
||||
for ($i = 0; $i < count($tagsArray); $i++) {
|
||||
|
||||
@@ -44,7 +44,7 @@ class objectTemplate extends Smarty
|
||||
* @return void
|
||||
*/
|
||||
|
||||
function objectTemplate ($templateFile)
|
||||
public function __construct($templateFile)
|
||||
{
|
||||
$this->template_dir = PATH_TPL;
|
||||
$this->compile_dir = PATH_SMARTY_C;
|
||||
|
||||
@@ -201,6 +201,17 @@ class RBAC
|
||||
'unassigned' => ['PM_CASES'],
|
||||
'to_reassign' => ['PM_REASSIGNCASE,PM_REASSIGNCASE_SUPERVISOR'],
|
||||
'to_revise' => ['PM_SUPERVISOR']
|
||||
],
|
||||
'casesList_Ajax.php' => [
|
||||
'userValues' => ['PM_CASES'],
|
||||
'processListExtJs' => ['PM_CASES'],
|
||||
'verifySession' => [],
|
||||
'getUsersToReassign' => ['PM_CASES'],
|
||||
'reassignCase' => ['PM_CASES'],
|
||||
'showHistoryMessage' => ['PM_CASES'],
|
||||
'showDynaformListHistory' => ['PM_CASES'],
|
||||
'dynaformChangeLogViewHistory' => ['PM_CASES'],
|
||||
'historyDynaformGridPreview' => ['PM_CASES'],
|
||||
]
|
||||
];
|
||||
$this->aliasPermissions['PM_CASES'] = [self::PM_GUEST_CASE];
|
||||
@@ -213,7 +224,7 @@ class RBAC
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function &getSingleton()
|
||||
public static function &getSingleton()
|
||||
{
|
||||
if (self::$instance == null) {
|
||||
self::$instance = new RBAC();
|
||||
|
||||
@@ -49,16 +49,16 @@ class Table
|
||||
public $_contexto = '';
|
||||
|
||||
/**
|
||||
* Set conecction using default values
|
||||
* Set connection using default values
|
||||
*
|
||||
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
||||
* @access public
|
||||
* @param string $objConnection connection string
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
public function Table ($objConnection = null)
|
||||
public function __construct($objConnection = null)
|
||||
{
|
||||
$this->SetTo( $objConnection );
|
||||
$this->SetTo($objConnection);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,35 +25,35 @@
|
||||
*
|
||||
*/
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
||||
// +----------------------------------------------------------------------+
|
||||
// | TemplatePower: |
|
||||
// | offers you the ability to separate your PHP code and your HTML |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | |
|
||||
// | Copyright (C) 2001,2002 R.P.J. Velzeboer, The Netherlands |
|
||||
// | |
|
||||
// | This program is free software; you can redistribute it and/or |
|
||||
// | modify it under the terms of the GNU General Public License |
|
||||
// | as published by the Free Software Foundation; either version 2 |
|
||||
// | of the License, or (at your option) any later version. |
|
||||
// | |
|
||||
// | This program is distributed in the hope that it will be useful, |
|
||||
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||
// | GNU General Public License for more details. |
|
||||
// | |
|
||||
// | You should have received a copy of the GNU General Public License |
|
||||
// | along with this program; if not, write to the Free Software |
|
||||
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
|
||||
// | 02111-1307, USA. |
|
||||
// | |
|
||||
// | Author: R.P.J. Velzeboer, rovel@codocad.nl The Netherlands |
|
||||
// | |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | http://templatepower.codocad.com |
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
// $Id: Version 3.0.2$
|
||||
// +----------------------------------------------------------------------+
|
||||
// | TemplatePower: |
|
||||
// | offers you the ability to separate your PHP code and your HTML |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | |
|
||||
// | Copyright (C) 2001,2002 R.P.J. Velzeboer, The Netherlands |
|
||||
// | |
|
||||
// | This program is free software; you can redistribute it and/or |
|
||||
// | modify it under the terms of the GNU General Public License |
|
||||
// | as published by the Free Software Foundation; either version 2 |
|
||||
// | of the License, or (at your option) any later version. |
|
||||
// | |
|
||||
// | This program is distributed in the hope that it will be useful, |
|
||||
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
||||
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
||||
// | GNU General Public License for more details. |
|
||||
// | |
|
||||
// | You should have received a copy of the GNU General Public License |
|
||||
// | along with this program; if not, write to the Free Software |
|
||||
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
|
||||
// | 02111-1307, USA. |
|
||||
// | |
|
||||
// | Author: R.P.J. Velzeboer, rovel@codocad.nl The Netherlands |
|
||||
// | |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | http://templatepower.codocad.com |
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
// $Id: Version 3.0.2$
|
||||
|
||||
|
||||
/**
|
||||
@@ -62,10 +62,10 @@
|
||||
*
|
||||
*/
|
||||
|
||||
define( "T_BYFILE", 0 );
|
||||
define( "T_BYVAR", 1 );
|
||||
define("T_BYFILE", 0);
|
||||
define("T_BYVAR", 1);
|
||||
|
||||
define( "TP_ROOTBLOCK", '_ROOT' );
|
||||
define("TP_ROOTBLOCK", '_ROOT');
|
||||
|
||||
/**
|
||||
* class TemplatePowerParser
|
||||
@@ -76,13 +76,13 @@ define( "TP_ROOTBLOCK", '_ROOT' );
|
||||
class TemplatePowerParser
|
||||
{
|
||||
public $tpl_base;
|
||||
//Array( [filename/varcontent], [T_BYFILE/T_BYVAR] )
|
||||
//Array( [filename/varcontent], [T_BYFILE/T_BYVAR] )
|
||||
public $tpl_include;
|
||||
//Array( [filename/varcontent], [T_BYFILE/T_BYVAR] )
|
||||
//Array( [filename/varcontent], [T_BYFILE/T_BYVAR] )
|
||||
public $tpl_count;
|
||||
public $parent = Array ();
|
||||
// $parent[{blockname}] = {parentblockname}
|
||||
public $defBlock = Array ();
|
||||
public $parent = [];
|
||||
// $parent[{blockname}] = {parentblockname}
|
||||
public $defBlock = [];
|
||||
public $rootBlockName;
|
||||
public $ignore_stack;
|
||||
public $version;
|
||||
@@ -95,116 +95,117 @@ class TemplatePowerParser
|
||||
* @param string $type
|
||||
* @access private
|
||||
*/
|
||||
public function TemplatePowerParser ($tpl_file, $type)
|
||||
public function __construct($tpl_file, $type)
|
||||
{
|
||||
$this->version = '3.0.2';
|
||||
$this->tpl_base = Array ($tpl_file,$type);
|
||||
$this->tpl_base = [$tpl_file, $type];
|
||||
$this->tpl_count = 0;
|
||||
$this->ignore_stack = Array (false);
|
||||
$this->ignore_stack = [false];
|
||||
}
|
||||
|
||||
/**
|
||||
* TemplatePowerParser::__errorAlert()
|
||||
* TemplatePowerParser::errorAlert()
|
||||
*
|
||||
* @param string $message
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
public function __errorAlert ($message)
|
||||
public function errorAlert($message)
|
||||
{
|
||||
print ('<br>' . $message . '<br>' . "\r\n") ;
|
||||
print ('<br>' . $message . '<br>' . "\r\n");
|
||||
}
|
||||
|
||||
/**
|
||||
* TemplatePowerParser::__prepare()
|
||||
* TemplatePowerParser::prepare()
|
||||
*
|
||||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
public function __prepare ()
|
||||
public function prepare()
|
||||
{
|
||||
$this->defBlock[TP_ROOTBLOCK] = Array ();
|
||||
$tplvar = $this->__prepareTemplate( $this->tpl_base[0], $this->tpl_base[1] );
|
||||
$this->defBlock[TP_ROOTBLOCK] = [];
|
||||
$tplvar = $this->prepareTemplate($this->tpl_base[0], $this->tpl_base[1]);
|
||||
$initdev["varrow"] = 0;
|
||||
$initdev["coderow"] = 0;
|
||||
$initdev["index"] = 0;
|
||||
$initdev["ignore"] = false;
|
||||
$this->__parseTemplate( $tplvar, TP_ROOTBLOCK, $initdev );
|
||||
$this->__cleanUp();
|
||||
$this->parseTemplate($tplvar, TP_ROOTBLOCK, $initdev);
|
||||
$this->cleanUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* TemplatePowerParser::__cleanUp()
|
||||
* TemplatePowerParser::cleanUp()
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
public function __cleanUp ()
|
||||
public function cleanUp()
|
||||
{
|
||||
for ($i = 0; $i <= $this->tpl_count; $i ++) {
|
||||
for ($i = 0; $i <= $this->tpl_count; $i++) {
|
||||
$tplvar = 'tpl_rawContent' . $i;
|
||||
unset( $this->{$tplvar} );
|
||||
unset($this->{$tplvar});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* TemplatePowerParser::__prepareTemplate()
|
||||
* TemplatePowerParser::prepareTemplate()
|
||||
*
|
||||
* @param string $tpl_file
|
||||
* @param string $type
|
||||
* @access private
|
||||
*/
|
||||
public function __prepareTemplate ($tpl_file, $type)
|
||||
public function prepareTemplate($tpl_file, $type)
|
||||
{
|
||||
$tplvar = 'tpl_rawContent' . $this->tpl_count;
|
||||
if ($type == T_BYVAR) {
|
||||
$this->{$tplvar}["content"] = preg_split( "/\n/", $tpl_file, - 1, PREG_SPLIT_DELIM_CAPTURE );
|
||||
$this->{$tplvar}["content"] = preg_split("/\r\n/", $tpl_file, -1, PREG_SPLIT_DELIM_CAPTURE);
|
||||
} else {
|
||||
//Trigger the error in the local scope of the function
|
||||
//trigger_error ("Some error", E_USER_WARNING);
|
||||
$this->{$tplvar}["content"] = @file( $tpl_file ) or die( $this->__errorAlert( 'TemplatePower Error: Couldn\'t open [ ' . $tpl_file . ' ]!' ) );
|
||||
$this->{$tplvar}["content"] = @file($tpl_file) or die($this->errorAlert('TemplatePower Error: Couldn\'t open [ ' . $tpl_file . ' ]!'));
|
||||
}
|
||||
$this->{$tplvar}["size"] = sizeof( $this->{$tplvar}["content"] );
|
||||
$this->tpl_count ++;
|
||||
$this->{$tplvar}["size"] = sizeof($this->{$tplvar}["content"]);
|
||||
$this->tpl_count++;
|
||||
return $tplvar;
|
||||
}
|
||||
|
||||
/**
|
||||
* TemplatePowerParser::__parseTemplate()
|
||||
* TemplatePowerParser::parseTemplate()
|
||||
*
|
||||
* @param string $tplvar
|
||||
* @param string $blockname
|
||||
* @param string $initdev
|
||||
* @access private
|
||||
*/
|
||||
public function __parseTemplate ($tplvar, $blockname, $initdev)
|
||||
public function parseTemplate($tplvar, $blockname, $initdev)
|
||||
{
|
||||
$coderow = $initdev["coderow"];
|
||||
$varrow = $initdev["varrow"];
|
||||
$index = $initdev["index"];
|
||||
$ignore = $initdev["ignore"];
|
||||
while ($index < $this->{$tplvar}["size"]) {
|
||||
if (preg_match( '/<!--[ ]?(START|END) IGNORE -->/', $this->{$tplvar}["content"][$index], $ignreg )) {
|
||||
if (preg_match('/<!--[ ]?(START|END) IGNORE -->/', $this->{$tplvar}["content"][$index], $ignreg)) {
|
||||
if ($ignreg[1] == 'START') {
|
||||
//$ignore = true;
|
||||
array_push( $this->ignore_stack, true );
|
||||
//$ignore = true;
|
||||
array_push($this->ignore_stack, true);
|
||||
} else {
|
||||
//$ignore = false;
|
||||
array_pop( $this->ignore_stack );
|
||||
//$ignore = false;
|
||||
array_pop($this->ignore_stack);
|
||||
}
|
||||
} else {
|
||||
if (! end( $this->ignore_stack )) {
|
||||
if (preg_match( '/<!--[ ]?(START|END|INCLUDE|INCLUDESCRIPT|REUSE) BLOCK : (.+)-->/', $this->{$tplvar}["content"][$index], $regs )) {
|
||||
//remove trailing and leading spaces
|
||||
$regs[2] = trim( $regs[2] );
|
||||
if (!end($this->ignore_stack)) {
|
||||
if (preg_match('/<!--[ ]?(START|END|INCLUDE|INCLUDESCRIPT|REUSE) BLOCK : (.+)-->/',
|
||||
$this->{$tplvar}["content"][$index], $regs)) {
|
||||
//remove trailing and leading spaces
|
||||
$regs[2] = trim($regs[2]);
|
||||
if ($regs[1] == 'INCLUDE') {
|
||||
$include_defined = true;
|
||||
//check if the include file is assigned
|
||||
if (isset( $this->tpl_include[$regs[2]] )) {
|
||||
if (isset($this->tpl_include[$regs[2]])) {
|
||||
$tpl_file = $this->tpl_include[$regs[2]][0];
|
||||
$type = $this->tpl_include[$regs[2]][1];
|
||||
} elseif (file_exists( $regs[2] )) {
|
||||
} elseif (file_exists($regs[2])) {
|
||||
//check if defined as constant in template
|
||||
$tpl_file = $regs[2];
|
||||
$type = T_BYFILE;
|
||||
@@ -213,24 +214,24 @@ class TemplatePowerParser
|
||||
}
|
||||
|
||||
if ($include_defined) {
|
||||
//initialize startvalues for recursive call
|
||||
//initialize startvalues for recursive call
|
||||
$initdev["varrow"] = $varrow;
|
||||
$initdev["coderow"] = $coderow;
|
||||
$initdev["index"] = 0;
|
||||
$initdev["ignore"] = false;
|
||||
$tplvar2 = $this->__prepareTemplate( $tpl_file, $type );
|
||||
$initdev = $this->__parseTemplate( $tplvar2, $blockname, $initdev );
|
||||
$tplvar2 = $this->prepareTemplate($tpl_file, $type);
|
||||
$initdev = $this->parseTemplate($tplvar2, $blockname, $initdev);
|
||||
$coderow = $initdev["coderow"];
|
||||
$varrow = $initdev["varrow"];
|
||||
}
|
||||
} elseif ($regs[1] == 'INCLUDESCRIPT') {
|
||||
$include_defined = true;
|
||||
//check if the includescript file is assigned by the assignInclude function
|
||||
if (isset( $this->tpl_include[$regs[2]] )) {
|
||||
//check if the includescript file is assigned by the assignInclude function
|
||||
if (isset($this->tpl_include[$regs[2]])) {
|
||||
$include_file = $this->tpl_include[$regs[2]][0];
|
||||
$type = $this->tpl_include[$regs[2]][1];
|
||||
} elseif (file_exists( $regs[2] )) {
|
||||
//check if defined as constant in template
|
||||
} elseif (file_exists($regs[2])) {
|
||||
//check if defined as constant in template
|
||||
$include_file = $regs[2];
|
||||
$type = T_BYFILE;
|
||||
} else {
|
||||
@@ -239,111 +240,112 @@ class TemplatePowerParser
|
||||
if ($include_defined) {
|
||||
ob_start();
|
||||
if ($type == T_BYFILE) {
|
||||
if (! @include_once ($include_file)) {
|
||||
$this->__errorAlert( 'TemplatePower Error: Couldn\'t include script [ ' . $include_file . ' ]!' );
|
||||
if (!@include_once($include_file)) {
|
||||
$this->errorAlert('TemplatePower Error: Couldn\'t include script [ ' . $include_file . ' ]!');
|
||||
exit();
|
||||
}
|
||||
} else {
|
||||
eval( "?>" . $include_file );
|
||||
eval("?>" . $include_file);
|
||||
}
|
||||
$this->defBlock[$blockname]["_C:$coderow"] = ob_get_contents();
|
||||
$coderow ++;
|
||||
$coderow++;
|
||||
ob_end_clean();
|
||||
}
|
||||
} elseif ($regs[1] == 'REUSE') {
|
||||
//do match for 'AS'
|
||||
if (preg_match( '/(.+) AS (.+)/', $regs[2], $reuse_regs )) {
|
||||
$originalbname = trim( $reuse_regs[1] );
|
||||
$copybname = trim( $reuse_regs[2] );
|
||||
//test if original block exist
|
||||
if (isset( $this->defBlock[$originalbname] )) {
|
||||
//copy block
|
||||
//do match for 'AS'
|
||||
if (preg_match('/(.+) AS (.+)/', $regs[2], $reuse_regs)) {
|
||||
$originalbname = trim($reuse_regs[1]);
|
||||
$copybname = trim($reuse_regs[2]);
|
||||
//test if original block exist
|
||||
if (isset($this->defBlock[$originalbname])) {
|
||||
//copy block
|
||||
$this->defBlock[$copybname] = $this->defBlock[$originalbname];
|
||||
//tell the parent that he has a child block
|
||||
//tell the parent that he has a child block
|
||||
$this->defBlock[$blockname]["_B:" . $copybname] = '';
|
||||
//create index and parent info
|
||||
//create index and parent info
|
||||
$this->index[$copybname] = 0;
|
||||
$this->parent[$copybname] = $blockname;
|
||||
} else {
|
||||
$this->__errorAlert( 'TemplatePower Error: Can\'t find block \'' . $originalbname . '\' to REUSE as \'' . $copybname . '\'' );
|
||||
$this->errorAlert('TemplatePower Error: Can\'t find block \'' . $originalbname . '\' to REUSE as \'' . $copybname . '\'');
|
||||
}
|
||||
} else {
|
||||
//so it isn't a correct REUSE tag, save as code
|
||||
//so it isn't a correct REUSE tag, save as code
|
||||
$this->defBlock[$blockname]["_C:$coderow"] = $this->{$tplvar}["content"][$index];
|
||||
$coderow ++;
|
||||
$coderow++;
|
||||
}
|
||||
} else {
|
||||
if ($regs[2] == $blockname) {
|
||||
//is it the end of a block
|
||||
//is it the end of a block
|
||||
break;
|
||||
} else {
|
||||
//its the start of a block
|
||||
//make a child block and tell the parent that he has a child
|
||||
$this->defBlock[$regs[2]] = Array ();
|
||||
//its the start of a block
|
||||
//make a child block and tell the parent that he has a child
|
||||
$this->defBlock[$regs[2]] = [];
|
||||
$this->defBlock[$blockname]["_B:" . $regs[2]] = '';
|
||||
//set some vars that we need for the assign functions etc.
|
||||
//set some vars that we need for the assign functions etc.
|
||||
$this->index[$regs[2]] = 0;
|
||||
$this->parent[$regs[2]] = $blockname;
|
||||
//prepare for the recursive call
|
||||
$index ++;
|
||||
//prepare for the recursive call
|
||||
$index++;
|
||||
$initdev["varrow"] = 0;
|
||||
$initdev["coderow"] = 0;
|
||||
$initdev["index"] = $index;
|
||||
$initdev["ignore"] = false;
|
||||
$initdev = $this->__parseTemplate( $tplvar, $regs[2], $initdev );
|
||||
$initdev = $this->parseTemplate($tplvar, $regs[2], $initdev);
|
||||
$index = $initdev["index"];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//is it code and/or var(s)
|
||||
//explode current template line on the curly bracket '{'
|
||||
$sstr = explode( '{', $this->{$tplvar}["content"][$index] );
|
||||
reset( $sstr );
|
||||
if (current( $sstr ) != '') {
|
||||
$sstr = explode('{', $this->{$tplvar}["content"][$index]);
|
||||
reset($sstr);
|
||||
if (current($sstr) != '') {
|
||||
//the template didn't start with a '{',
|
||||
//so the first element of the array $sstr is just code
|
||||
$this->defBlock[$blockname]["_C:$coderow"] = current( $sstr );
|
||||
$coderow ++;
|
||||
$this->defBlock[$blockname]["_C:$coderow"] = current($sstr);
|
||||
$coderow++;
|
||||
}
|
||||
while (next( $sstr )) {
|
||||
while (next($sstr)) {
|
||||
//find the position of the end curly bracket '}'
|
||||
$pos = strpos( current( $sstr ), "}" );
|
||||
$pos = strpos(current($sstr), "}");
|
||||
if (($pos !== false) && ($pos > 0)) {
|
||||
//a curly bracket '}' is found
|
||||
//and at least on position 1, to eliminate '{}'
|
||||
//note: position 1 taken without '{', because we did explode on '{'
|
||||
$strlength = strlen( current( $sstr ) );
|
||||
$varname = substr( current( $sstr ), 0, $pos );
|
||||
if (strstr( $varname, ' ' )) {
|
||||
$strlength = strlen(current($sstr));
|
||||
$varname = substr(current($sstr), 0, $pos);
|
||||
if (strstr($varname, ' ')) {
|
||||
//the varname contains one or more spaces
|
||||
//so, it isn't a variable, save as code
|
||||
$this->defBlock[$blockname]["_C:$coderow"] = '{' . current( $sstr );
|
||||
$coderow ++;
|
||||
$this->defBlock[$blockname]["_C:$coderow"] = '{' . current($sstr);
|
||||
$coderow++;
|
||||
} else {
|
||||
//save the variable
|
||||
$this->defBlock[$blockname]["_V:$varrow"] = $varname;
|
||||
$varrow ++;
|
||||
$varrow++;
|
||||
//is there some code after the varname left?
|
||||
if (($pos + 1) != $strlength) {
|
||||
//yes, save that code
|
||||
$this->defBlock[$blockname]["_C:$coderow"] = substr( current( $sstr ), ($pos + 1), ($strlength - ($pos + 1)) );
|
||||
$coderow ++;
|
||||
$this->defBlock[$blockname]["_C:$coderow"] = substr(current($sstr), ($pos + 1),
|
||||
($strlength - ($pos + 1)));
|
||||
$coderow++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//no end curly bracket '}' found
|
||||
//so, the curly bracket is part of the text. Save as code, with the '{'
|
||||
$this->defBlock[$blockname]["_C:$coderow"] = '{' . current( $sstr );
|
||||
$coderow ++;
|
||||
//no end curly bracket '}' found
|
||||
//so, the curly bracket is part of the text. Save as code, with the '{'
|
||||
$this->defBlock[$blockname]["_C:$coderow"] = '{' . current($sstr);
|
||||
$coderow++;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->defBlock[$blockname]["_C:$coderow"] = $this->{$tplvar}["content"][$index];
|
||||
$coderow ++;
|
||||
$coderow++;
|
||||
}
|
||||
}
|
||||
$index ++;
|
||||
$index++;
|
||||
}
|
||||
$initdev["varrow"] = $varrow;
|
||||
$initdev["coderow"] = $coderow;
|
||||
@@ -354,10 +356,10 @@ class TemplatePowerParser
|
||||
/**
|
||||
* TemplatePowerParser::version()
|
||||
*
|
||||
* @return void
|
||||
* @return string
|
||||
* @access public
|
||||
*/
|
||||
public function version ()
|
||||
public function version()
|
||||
{
|
||||
return $this->version;
|
||||
}
|
||||
@@ -371,9 +373,9 @@ class TemplatePowerParser
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
public function assignInclude ($iblockname, $value, $type = T_BYFILE)
|
||||
public function assignInclude($iblockname, $value, $type = T_BYFILE)
|
||||
{
|
||||
$this->tpl_include["$iblockname"] = Array ($value,$type);
|
||||
$this->tpl_include["$iblockname"] = [$value, $type];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -384,67 +386,67 @@ class TemplatePowerParser
|
||||
*/
|
||||
class TemplatePower extends TemplatePowerParser
|
||||
{
|
||||
public $index = Array ();
|
||||
public $index = [];
|
||||
// $index[{blockname}] = {indexnumber}
|
||||
public $content = Array ();
|
||||
public $content = [];
|
||||
public $currentBlock;
|
||||
public $showUnAssigned;
|
||||
public $serialized;
|
||||
public $globalvars = Array ();
|
||||
public $globalvars = [];
|
||||
public $prepared;
|
||||
|
||||
/**
|
||||
* TemplatePower::TemplatePower()
|
||||
* TemplatePower::__construct()
|
||||
*
|
||||
* @param string $tpl_file
|
||||
* @param string $type
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
public function TemplatePower ($tpl_file = '', $type = T_BYFILE)
|
||||
public function __construct($tpl_file = '', $type = T_BYFILE)
|
||||
{
|
||||
TemplatePowerParser::TemplatePowerParser( $tpl_file, $type );
|
||||
TemplatePowerParser::__construct($tpl_file, $type);
|
||||
$this->prepared = false;
|
||||
$this->showUnAssigned = false;
|
||||
$this->serialized = false;
|
||||
//added: 26 April 2002
|
||||
//added: 26 April 2002
|
||||
}
|
||||
|
||||
/**
|
||||
* TemplatePower::__deSerializeTPL()
|
||||
* TemplatePower::deSerializeTPL()
|
||||
*
|
||||
* @param string $stpl_file
|
||||
* @param string $tplvar
|
||||
* @return void
|
||||
* @access private
|
||||
*/
|
||||
public function __deSerializeTPL ($stpl_file, $type)
|
||||
public function deSerializeTPL($stpl_file, $type)
|
||||
{
|
||||
if ($type == T_BYFILE) {
|
||||
$serializedTPL = @file( $stpl_file ) or die( $this->__errorAlert( 'TemplatePower Error: Can\'t open [ ' . $stpl_file . ' ]!' ) );
|
||||
$serializedTPL = @file($stpl_file) or die($this->errorAlert('TemplatePower Error: Can\'t open [ ' . $stpl_file . ' ]!'));
|
||||
} else {
|
||||
$serializedTPL = $stpl_file;
|
||||
}
|
||||
$serializedStuff = unserialize( join( '', $serializedTPL ) );
|
||||
$serializedStuff = unserialize(join('', $serializedTPL));
|
||||
$this->defBlock = $serializedStuff["defBlock"];
|
||||
$this->index = $serializedStuff["index"];
|
||||
$this->parent = $serializedStuff["parent"];
|
||||
}
|
||||
|
||||
/**
|
||||
* TemplatePower::__makeContentRoot()
|
||||
* TemplatePower::makeContentRoot()
|
||||
*
|
||||
* @return void
|
||||
* @access private
|
||||
*/
|
||||
public function __makeContentRoot ()
|
||||
public function makeContentRoot()
|
||||
{
|
||||
$this->content[TP_ROOTBLOCK . "_0"][0] = Array (TP_ROOTBLOCK);
|
||||
$this->content[TP_ROOTBLOCK . "_0"][0] = [TP_ROOTBLOCK];
|
||||
$this->currentBlock = &$this->content[TP_ROOTBLOCK . "_0"][0];
|
||||
}
|
||||
|
||||
/**
|
||||
* TemplatePower::__assign()
|
||||
* TemplatePower::assignPrivate()
|
||||
*
|
||||
* @param string $varname
|
||||
* @param string $value
|
||||
@@ -452,13 +454,13 @@ class TemplatePower extends TemplatePowerParser
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
public function __assign ($varname, $value)
|
||||
public function assignPrivate($varname, $value)
|
||||
{
|
||||
if (sizeof( $regs = explode( '.', $varname ) ) == 2) {
|
||||
if (sizeof($regs = explode('.', $varname)) == 2) {
|
||||
//this is faster then preg_match
|
||||
$ind_blockname = $regs[0] . '_' . $this->index[$regs[0]];
|
||||
$lastitem = sizeof( $this->content[$ind_blockname] );
|
||||
$lastitem > 1 ? $lastitem -- : $lastitem = 0;
|
||||
$lastitem = sizeof($this->content[$ind_blockname]);
|
||||
$lastitem > 1 ? $lastitem-- : $lastitem = 0;
|
||||
$block = &$this->content[$ind_blockname][$lastitem];
|
||||
$varname = $regs[1];
|
||||
} else {
|
||||
@@ -468,48 +470,49 @@ class TemplatePower extends TemplatePowerParser
|
||||
}
|
||||
|
||||
/**
|
||||
* TemplatePower::__assignGlobal()
|
||||
* TemplatePower::assignGlobalPrivate()
|
||||
*
|
||||
* @param string $varname
|
||||
* @param string $value
|
||||
* @return void
|
||||
* @access private
|
||||
*/
|
||||
public function __assignGlobal ($varname, $value)
|
||||
public function assignGlobalPrivate($varname, $value)
|
||||
{
|
||||
$this->globalvars[$varname] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* TemplatePower::__outputContent()
|
||||
* TemplatePower::outputContent()
|
||||
*
|
||||
* @param string $blockname
|
||||
* @return void
|
||||
* @access private
|
||||
*/
|
||||
public function __outputContent ($blockname)
|
||||
public function outputContent($blockname)
|
||||
{
|
||||
$numrows = sizeof( $this->content[$blockname] );
|
||||
for ($i = 0; $i < $numrows; $i ++) {
|
||||
$numrows = sizeof($this->content[$blockname]);
|
||||
for ($i = 0; $i < $numrows; $i++) {
|
||||
$defblockname = $this->content[$blockname][$i][0];
|
||||
for (reset( $this->defBlock[$defblockname] ); $k = key( $this->defBlock[$defblockname] ); next( $this->defBlock[$defblockname] )) {
|
||||
for (reset($this->defBlock[$defblockname]); $k = key($this->defBlock[$defblockname]); next($this->defBlock[$defblockname])) {
|
||||
if ($k[1] == 'C') {
|
||||
print ($this->defBlock[$defblockname][$k]) ;
|
||||
print ($this->defBlock[$defblockname][$k]);
|
||||
} elseif ($k[1] == 'V') {
|
||||
$defValue = $this->defBlock[$defblockname][$k];
|
||||
if (! isset( $this->content[$blockname][$i]["_V:" . $defValue] )) {
|
||||
if (isset( $this->globalvars[$defValue] )) {
|
||||
if (!isset($this->content[$blockname][$i]["_V:" . $defValue])) {
|
||||
if (isset($this->globalvars[$defValue])) {
|
||||
$value = $this->globalvars[$defValue];
|
||||
} else {
|
||||
//Verify if $defValue is like
|
||||
// "xmlfile:ID_LABEL"
|
||||
//if it is load an xml label.
|
||||
//if not continues with non assigned value.
|
||||
if (preg_match( "/(.+):(.+)/", $defValue, $xmlreg )) {
|
||||
$value = G::LoadTranslation(/*$xmlreg[1],*/$xmlreg[2] );
|
||||
//Verify if $defValue is like
|
||||
// "xmlfile:ID_LABEL"
|
||||
//if it is load an xml label.
|
||||
//if not continues with non assigned value.
|
||||
if (preg_match("/(.+):(.+)/", $defValue, $xmlreg)) {
|
||||
$value = G::LoadTranslation(/*$xmlreg[1],*/
|
||||
$xmlreg[2]);
|
||||
} else {
|
||||
if ($this->showUnAssigned) {
|
||||
//$value = '{'. $this->defBlock[ $defblockname ][$k] .'}';
|
||||
//$value = '{'. $this->defBlock[ $defblockname ][$k] .'}';
|
||||
$value = '{' . $defValue . '}';
|
||||
} else {
|
||||
$value = '';
|
||||
@@ -519,12 +522,13 @@ class TemplatePower extends TemplatePowerParser
|
||||
} else {
|
||||
$value = $this->content[$blockname][$i]["_V:" . $defValue];
|
||||
}
|
||||
if ($this->unhtmlentities)
|
||||
$value = G::unhtmlentities( $value );
|
||||
print ($value) ;
|
||||
if ($this->unhtmlentities) {
|
||||
$value = G::unhtmlentities($value);
|
||||
}
|
||||
print ($value);
|
||||
} elseif ($k[1] == 'B') {
|
||||
if (isset( $this->content[$blockname][$i][$k] )) {
|
||||
$this->__outputContent( $this->content[$blockname][$i][$k] );
|
||||
if (isset($this->content[$blockname][$i][$k])) {
|
||||
$this->outputContent($this->content[$blockname][$i][$k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -532,16 +536,16 @@ class TemplatePower extends TemplatePowerParser
|
||||
}
|
||||
|
||||
/**
|
||||
* function __printVars
|
||||
* function printVars
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
public function __printVars ()
|
||||
public function printVars()
|
||||
{
|
||||
var_dump( $this->defBlock );
|
||||
print ("<br>--------------------<br>") ;
|
||||
var_dump( $this->content );
|
||||
var_dump($this->defBlock);
|
||||
print ("<br>--------------------<br>");
|
||||
var_dump($this->content);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -557,10 +561,10 @@ class TemplatePower extends TemplatePowerParser
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function serializedBase ()
|
||||
public function serializedBase()
|
||||
{
|
||||
$this->serialized = true;
|
||||
$this->__deSerializeTPL( $this->tpl_base[0], $this->tpl_base[1] );
|
||||
$this->deSerializeTPL($this->tpl_base[0], $this->tpl_base[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -570,7 +574,7 @@ class TemplatePower extends TemplatePowerParser
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
public function showUnAssigned ($state = true)
|
||||
public function showUnAssigned($state = true)
|
||||
{
|
||||
$this->showUnAssigned = $state;
|
||||
}
|
||||
@@ -581,14 +585,14 @@ class TemplatePower extends TemplatePowerParser
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
public function prepare ()
|
||||
public function prepare()
|
||||
{
|
||||
if (! $this->serialized) {
|
||||
TemplatePowerParser::__prepare();
|
||||
if (!$this->serialized) {
|
||||
TemplatePowerParser::prepare();
|
||||
}
|
||||
$this->prepared = true;
|
||||
$this->index[TP_ROOTBLOCK] = 0;
|
||||
$this->__makeContentRoot();
|
||||
$this->makeContentRoot();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -598,28 +602,29 @@ class TemplatePower extends TemplatePowerParser
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
public function newBlock ($blockname)
|
||||
public function newBlock($blockname)
|
||||
{
|
||||
$parent = &$this->content[$this->parent[$blockname] . '_' . $this->index[$this->parent[$blockname]]];
|
||||
$lastitem = sizeof( $parent );
|
||||
$lastitem > 1 ? $lastitem -- : $lastitem = 0;
|
||||
$lastitem = sizeof($parent);
|
||||
$lastitem > 1 ? $lastitem-- : $lastitem = 0;
|
||||
$ind_blockname = $blockname . '_' . $this->index[$blockname];
|
||||
if (! isset( $parent[$lastitem]["_B:$blockname"] )) {
|
||||
//ok, there is no block found in the parentblock with the name of {$blockname}
|
||||
//so, increase the index counter and create a new {$blockname} block
|
||||
if (!isset($parent[$lastitem]["_B:$blockname"])) {
|
||||
//ok, there is no block found in the parentblock with the name of {$blockname}
|
||||
//so, increase the index counter and create a new {$blockname} block
|
||||
$this->index[$blockname] += 1;
|
||||
$ind_blockname = $blockname . '_' . $this->index[$blockname];
|
||||
if (! isset( $this->content[$ind_blockname] )) {
|
||||
$this->content[$ind_blockname] = Array ();
|
||||
if (!isset($this->content[$ind_blockname])) {
|
||||
$this->content[$ind_blockname] = [];
|
||||
}
|
||||
//tell the parent where his (possible) children are located
|
||||
//tell the parent where his (possible) children are located
|
||||
$parent[$lastitem]["_B:$blockname"] = $ind_blockname;
|
||||
}
|
||||
//now, make a copy of the block defenition
|
||||
$blocksize = sizeof( $this->content[$ind_blockname] );
|
||||
$this->content[$ind_blockname][$blocksize] = Array ($blockname
|
||||
);
|
||||
//link the current block to the block we just created
|
||||
//now, make a copy of the block defenition
|
||||
$blocksize = sizeof($this->content[$ind_blockname]);
|
||||
$this->content[$ind_blockname][$blocksize] = [
|
||||
$blockname
|
||||
];
|
||||
//link the current block to the block we just created
|
||||
$this->currentBlock = &$this->content[$ind_blockname][$blocksize];
|
||||
}
|
||||
|
||||
@@ -632,14 +637,14 @@ class TemplatePower extends TemplatePowerParser
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function assignGlobal ($varname, $value = '')
|
||||
public function assignGlobal($varname, $value = '')
|
||||
{
|
||||
if (is_array( $varname )) {
|
||||
if (is_array($varname)) {
|
||||
foreach ($varname as $var => $value) {
|
||||
$this->__assignGlobal( $var, $value );
|
||||
$this->assignGlobalPrivate($var, $value);
|
||||
}
|
||||
} else {
|
||||
$this->__assignGlobal( $varname, $value );
|
||||
$this->assignGlobalPrivate($varname, $value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -651,14 +656,14 @@ class TemplatePower extends TemplatePowerParser
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
public function assign ($varname, $value = '')
|
||||
public function assign($varname, $value = '')
|
||||
{
|
||||
if (is_array( $varname )) {
|
||||
if (is_array($varname)) {
|
||||
foreach ($varname as $var => $value) {
|
||||
$this->__assign( $var, $value );
|
||||
$this->assignPrivate($var, $value);
|
||||
}
|
||||
} else {
|
||||
$this->__assign( $varname, $value );
|
||||
$this->assignPrivate($varname, $value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -669,14 +674,14 @@ class TemplatePower extends TemplatePowerParser
|
||||
* @param string $blockname
|
||||
* @access public
|
||||
*/
|
||||
public function gotoBlock ($blockname)
|
||||
public function gotoBlock($blockname)
|
||||
{
|
||||
if (isset( $this->defBlock[$blockname] )) {
|
||||
if (isset($this->defBlock[$blockname])) {
|
||||
$ind_blockname = $blockname . '_' . $this->index[$blockname];
|
||||
//get lastitem indexnumber
|
||||
$lastitem = sizeof( $this->content[$ind_blockname] );
|
||||
$lastitem > 1 ? $lastitem -- : $lastitem = 0;
|
||||
//link the current block
|
||||
//get lastitem indexnumber
|
||||
$lastitem = sizeof($this->content[$ind_blockname]);
|
||||
$lastitem > 1 ? $lastitem-- : $lastitem = 0;
|
||||
//link the current block
|
||||
$this->currentBlock = &$this->content[$ind_blockname][$lastitem];
|
||||
}
|
||||
}
|
||||
@@ -688,13 +693,13 @@ class TemplatePower extends TemplatePowerParser
|
||||
* @param string $varname
|
||||
* @access public
|
||||
*/
|
||||
public function getVarValue ($varname)
|
||||
public function getVarValue($varname)
|
||||
{
|
||||
if (sizeof( $regs = explode( '.', $varname ) ) == 2) {
|
||||
//this is faster then preg_match{
|
||||
if (sizeof($regs = explode('.', $varname)) == 2) {
|
||||
//this is faster then preg_match{
|
||||
$ind_blockname = $regs[0] . '_' . $this->index[$regs[0]];
|
||||
$lastitem = sizeof( $this->content[$ind_blockname] );
|
||||
$lastitem > 1 ? $lastitem -- : $lastitem = 0;
|
||||
$lastitem = sizeof($this->content[$ind_blockname]);
|
||||
$lastitem > 1 ? $lastitem-- : $lastitem = 0;
|
||||
$block = &$this->content[$ind_blockname][$lastitem];
|
||||
$varname = $regs[1];
|
||||
} else {
|
||||
@@ -709,12 +714,12 @@ class TemplatePower extends TemplatePowerParser
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
public function printToScreen ()
|
||||
public function printToScreen()
|
||||
{
|
||||
if ($this->prepared) {
|
||||
$this->__outputContent( TP_ROOTBLOCK . '_0' );
|
||||
$this->outputContent(TP_ROOTBLOCK . '_0');
|
||||
} else {
|
||||
$this->__errorAlert( 'TemplatePower Error: Template isn\'t prepared!' );
|
||||
$this->errorAlert('TemplatePower Error: Template isn\'t prepared!');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -724,7 +729,7 @@ class TemplatePower extends TemplatePowerParser
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
public function getOutputContent ()
|
||||
public function getOutputContent()
|
||||
{
|
||||
ob_start();
|
||||
$this->printToScreen();
|
||||
|
||||
@@ -25,9 +25,9 @@ class PmTree extends Xml_Node
|
||||
*
|
||||
* @param array $xmlnode default value NULL
|
||||
*
|
||||
* @return none
|
||||
* @return void
|
||||
*/
|
||||
public function PmTree($xmlnode = null)
|
||||
public function __construct($xmlnode = null)
|
||||
{
|
||||
if (!isset($xmlnode)) {
|
||||
return;
|
||||
|
||||
@@ -48,34 +48,34 @@ class WebResource
|
||||
* @param string $uri
|
||||
* @param string $post
|
||||
*
|
||||
* @return none
|
||||
* @return void
|
||||
*/
|
||||
function WebResource ($uri, $post)
|
||||
public function __construct($uri, $post)
|
||||
{
|
||||
$this->_uri = $uri;
|
||||
if (isset( $post['function'] ) && $post['function'] != '') {
|
||||
if (isset($post['function']) && $post['function'] != '') {
|
||||
/*Call a function*/
|
||||
header( 'Content-Type: text/json' );
|
||||
header('Content-Type: text/json');
|
||||
//$parameters=G::json_decode((urldecode($post['parameters']))); //for %AC
|
||||
$parameters = G::json_decode( ($post['parameters']) );
|
||||
$paramsRef = array ();
|
||||
$parameters = G::json_decode(($post['parameters']));
|
||||
$paramsRef = array();
|
||||
foreach ($parameters as $key => $value) {
|
||||
if (is_string( $key )) {
|
||||
$paramsRef[] = "\$parameters['" . addcslashes( $key, '\\\'' ) . "']";
|
||||
if (is_string($key)) {
|
||||
$paramsRef[] = "\$parameters['" . addcslashes($key, '\\\'') . "']";
|
||||
} else {
|
||||
$paramsRef[] = '$parameters[' . $key . ']';
|
||||
}
|
||||
}
|
||||
|
||||
$paramsRef = implode( ',', $paramsRef );
|
||||
|
||||
$paramsRef = implode(',', $paramsRef);
|
||||
|
||||
$filter = new InputFilter();
|
||||
$post['function'] = $filter->validateInput($post['function']);
|
||||
$paramsRef = $filter->validateInput($paramsRef);
|
||||
|
||||
$res = eval( 'return ($this->' . $post['function'] . '(' . $paramsRef . '));' );
|
||||
$res = G::json_encode( $res );
|
||||
print ($res) ;
|
||||
|
||||
$res = eval('return ($this->' . $post['function'] . '(' . $paramsRef . '));');
|
||||
$res = G::json_encode($res);
|
||||
print ($res);
|
||||
} else {
|
||||
/*Print class definition*/
|
||||
$this->_encode();
|
||||
|
||||
@@ -61,11 +61,11 @@ class XmlFormFieldXmlMenu extends XmlFormField
|
||||
* @param string $home default value ''
|
||||
* @param string $owner
|
||||
*
|
||||
* @return none
|
||||
* @return void
|
||||
*/
|
||||
public function XmlFormFieldXmlMenu ($xmlNode, $lang = 'en', $home = '', $owner = null)
|
||||
public function __construct($xmlNode, $lang = 'en', $home = '', $owner = null)
|
||||
{
|
||||
parent::__construct( $xmlNode, $lang, $home, $owner );
|
||||
parent::__construct($xmlNode, $lang, $home, $owner);
|
||||
$this->home = $home;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,13 +17,13 @@ class xmlformTemplate extends Smarty
|
||||
/**
|
||||
* Function xmlformTemplate
|
||||
*
|
||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||
* @access public
|
||||
* @param string form
|
||||
* @param string templateFile
|
||||
*
|
||||
* @return string
|
||||
* @access public
|
||||
*/
|
||||
public function xmlformTemplate (&$form, $templateFile)
|
||||
public function __construct(&$form, $templateFile)
|
||||
{
|
||||
$this->template_dir = PATH_XMLFORM;
|
||||
$this->compile_dir = PATH_SMARTY_C;
|
||||
|
||||
27
phpunit.xml
27
phpunit.xml
@@ -11,11 +11,17 @@
|
||||
bootstrap="tests/bootstrap.php"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="workflow">
|
||||
<directory>./tests/workflow/engine/src/</directory>
|
||||
<testsuite name="LegacyClasses">
|
||||
<directory>./tests/unit/workflow/engine/classes/</directory>
|
||||
</testsuite>
|
||||
<testsuite name="Classes">
|
||||
<directory>./tests/unit/workflow/engine/src/</directory>
|
||||
</testsuite>
|
||||
<testsuite name="Unit">
|
||||
<directory suffix="Test.php">./tests/Unit</directory>
|
||||
<directory>./tests/unit/</directory>
|
||||
</testsuite>
|
||||
<testsuite name="Performance">
|
||||
<directory>./tests/Performance/</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
@@ -33,6 +39,10 @@
|
||||
</filter>
|
||||
|
||||
<php>
|
||||
<!--Main environment-->
|
||||
<env name="MAIN_SYS_SYS" value="workflow" />
|
||||
<env name="MAIN_TIME_ZONE" value="America/New_York" />
|
||||
<env name="MAIN_SYSTEM_UTC_TIME_ZONE" value="1" />
|
||||
<!--Connection to database-->
|
||||
<env name="DB_HOST" value="127.0.0.1" />
|
||||
<env name="DB_DATABASE" value="test" />
|
||||
@@ -45,6 +55,17 @@
|
||||
<env name="MSSQL_DATABASE" value="testexternal" />
|
||||
<env name="MSSQL_USERNAME" value="test" />
|
||||
<env name="MSSQL_PASSWORD" value="test" />
|
||||
<!--Define if we use a populated database-->
|
||||
<env name="POPULATE_DATABASE" value="false" />
|
||||
<!--Performance Mysql test-->
|
||||
<env name="RUN_MYSQL_PERFORMANCE_TESTS" value="false" />
|
||||
<!--email account-->
|
||||
<env name="emailEngine" value="PHPMAILER" />
|
||||
<env name="emailServer" value="smtp.gmail.com" />
|
||||
<env name="emailPort" value="465" />
|
||||
<env name="emailAccount" value="admin@processmaker.com" />
|
||||
<env name="emailAccountPassword" value="" />
|
||||
<env name="emailSecure" value="ssl" />
|
||||
<!--Php variables-->
|
||||
<var name="APP_ENV" value="testing" />
|
||||
<var name="SYS_SYS" value="test" />
|
||||
|
||||
106
tests/CreateTestSite.php
Normal file
106
tests/CreateTestSite.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace Tests;
|
||||
|
||||
use G;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use ProcessMaker\Core\Installer;
|
||||
use ProcessMaker\Core\System;
|
||||
|
||||
trait CreateTestSite
|
||||
{
|
||||
private $timezone;
|
||||
private $baseUri;
|
||||
private $user;
|
||||
private $password;
|
||||
private $workspace;
|
||||
|
||||
/**
|
||||
* 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";
|
||||
if (!file_exists($pathData) && method_exists($this, 'markTestSkipped')) {
|
||||
$this->markTestSkipped('Please define an active workspace.');
|
||||
}
|
||||
$content = file_get_contents($pathData);
|
||||
$serverInfo = unserialize($content);
|
||||
|
||||
return $serverInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method creates a test workspace so that the endpoints can be functional,
|
||||
* it is necessary to change the permissions of the directory so that other
|
||||
* users can access and write to the directory, these users can be for
|
||||
* example: apache2, www-data, httpd, etc...
|
||||
* This method finds the license file of the active site and uses it to register
|
||||
* this license in the LICENSE_MANAGER table. If there is no license file in
|
||||
* the active workspace, an asersion failure will be notified.
|
||||
*/
|
||||
private function createTestSite()
|
||||
{
|
||||
//We copy the license, otherwise you will not be able to lift the site
|
||||
$pathTest = PATH_DATA . "sites" . PATH_SEP . $this->workspace;
|
||||
File::copyDirectory(PATH_DATA . "sites" . PATH_SEP . config("system.workspace"), $pathTest);
|
||||
|
||||
//Write permission for other users for example: apache2, www-data, httpd.
|
||||
passthru('chmod 775 -R ' . $pathTest . ' >> .log 2>&1');
|
||||
|
||||
$installer = new Installer();
|
||||
$options = [
|
||||
'isset' => true,
|
||||
'name' => $this->workspace,
|
||||
'admin' => [
|
||||
'username' => $this->user,
|
||||
'password' => $this->password
|
||||
],
|
||||
'advanced' => [
|
||||
'ao_db_drop' => true,
|
||||
'ao_db_wf' => $this->workspace,
|
||||
'ao_db_rb' => $this->workspace,
|
||||
'ao_db_rp' => $this->workspace
|
||||
]
|
||||
];
|
||||
//The false option creates a connection to the database, necessary to create a site.
|
||||
$installer->create_site($options, false);
|
||||
//Now create site
|
||||
$installer->create_site($options, true);
|
||||
|
||||
//Important so that the dates are stored in the same timezone
|
||||
file_put_contents($pathTest . "/env.ini", "time_zone ='{$this->timezone}'", FILE_APPEND);
|
||||
|
||||
$matchingFiles = File::glob("{$pathTest}/*.dat");
|
||||
$this->assertNotEmpty($matchingFiles);
|
||||
|
||||
//set license
|
||||
$licensePath = array_pop($matchingFiles);
|
||||
DB::Table("LICENSE_MANAGER")->insert([
|
||||
"LICENSE_UID" => G::generateUniqueID(),
|
||||
"LICENSE_USER" => "ProcessMaker Inc",
|
||||
"LICENSE_START" => "1490932800",
|
||||
"LICENSE_END" => 0,
|
||||
"LICENSE_SPAN" => 0,
|
||||
"LICENSE_STATUS" => "ACTIVE",
|
||||
"LICENSE_DATA" => file_get_contents($licensePath),
|
||||
"LICENSE_PATH" => $licensePath,
|
||||
"LICENSE_WORKSPACE" => $this->workspace,
|
||||
"LICENSE_TYPE" => ""
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
namespace tests;
|
||||
|
||||
namespace Tests;
|
||||
|
||||
use Illuminate\Contracts\Console\Kernel;
|
||||
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the execution of a common SQL statement.
|
||||
* @test
|
||||
*/
|
||||
public function testStandardExecuteQuery()
|
||||
{
|
||||
$results = executeQuery("SELECT * FROM USERS WHERE USR_UID = '00000000000000000000000000000001'");
|
||||
$this->assertCount(1, $results);
|
||||
// Note, we check index 1 because results from executeQuery are 1 indexed, not 0 indexed.
|
||||
$this->assertArraySubset([
|
||||
$expected = [
|
||||
'USR_UID' => '00000000000000000000000000000001',
|
||||
'USR_USERNAME' => 'admin'
|
||||
], $results[1]);
|
||||
];
|
||||
$this->assertArraySubset($expected, $results[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the existence of the admin user.
|
||||
* @test
|
||||
*/
|
||||
public function testDBFacadeQuery()
|
||||
{
|
||||
$record = DB::table('USERS')->where([
|
||||
'USR_UID' => '00000000000000000000000000000001'
|
||||
])->first();
|
||||
$record = DB::table('USERS')->where('USR_UID', '=', '00000000000000000000000000000001')->first();
|
||||
$this->assertEquals('admin', $record->USR_USERNAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the execution of a SQL statement common to an MySQL external database.
|
||||
* @test
|
||||
*/
|
||||
public function testStandardExecuteQueryWithExternalMySQLDatabase()
|
||||
{
|
||||
// Our test external database is created in our tests/bootstrap.php file
|
||||
@@ -45,12 +58,12 @@ class DBQueryTest extends TestCase
|
||||
$process = factory(Process::class)->create();
|
||||
// Let's create an external DB to ourselves
|
||||
$externalDB = factory(DbSource::class)->create([
|
||||
'DBS_SERVER' => 'localhost',
|
||||
'DBS_SERVER' => config('database.connections.testexternal.host'),
|
||||
'DBS_PORT' => '3306',
|
||||
'DBS_USERNAME' => env('DB_USERNAME'),
|
||||
'DBS_USERNAME' => config('database.connections.testexternal.username'),
|
||||
// Remember, we have to do some encryption here @see DbSourceFactory.php
|
||||
'DBS_PASSWORD' => \G::encrypt( env('DB_PASSWORD'), 'testexternal') . "_2NnV3ujj3w",
|
||||
'DBS_DATABASE_NAME' => 'testexternal',
|
||||
'DBS_PASSWORD' => \G::encrypt(env('DB_PASSWORD'), config('database.connections.testexternal.database')) . "_2NnV3ujj3w",
|
||||
'DBS_DATABASE_NAME' => config('database.connections.testexternal.database'),
|
||||
'PRO_UID' => $process->PRO_UID
|
||||
]);
|
||||
|
||||
@@ -65,9 +78,13 @@ class DBQueryTest extends TestCase
|
||||
$this->assertEquals('testvalue', $results[1]['value']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify the execution of a SQL statement common to an MSSQL external database.
|
||||
* @test
|
||||
*/
|
||||
public function testStandardExecuteQueryWithExternalMSSqlDatabase()
|
||||
{
|
||||
if(!env('RUN_MSSQL_TESTS')) {
|
||||
if (!env('RUN_MSSQL_TESTS')) {
|
||||
$this->markTestSkipped('MSSQL Related Test Skipped');
|
||||
}
|
||||
// Our test external database is created in our tests/bootstrap.php file
|
||||
@@ -80,8 +97,8 @@ class DBQueryTest extends TestCase
|
||||
'DBS_TYPE' => 'mssql',
|
||||
'DBS_USERNAME' => env('MSSQL_USERNAME'),
|
||||
// Remember, we have to do some encryption here @see DbSourceFactory.php
|
||||
'DBS_PASSWORD' => \G::encrypt( env('MSSQL_PASSWORD'), 'testexternal') . "_2NnV3ujj3w",
|
||||
'DBS_DATABASE_NAME' => 'testexternal',
|
||||
'DBS_PASSWORD' => \G::encrypt(env('MSSQL_PASSWORD'), env('MSSQL_DATABASE')) . "_2NnV3ujj3w",
|
||||
'DBS_DATABASE_NAME' => env('MSSQL_DATABASE'),
|
||||
'PRO_UID' => $process->PRO_UID
|
||||
]);
|
||||
// Now set our process ID
|
||||
@@ -94,4 +111,4 @@ class DBQueryTest extends TestCase
|
||||
$this->assertCount(1, $results);
|
||||
$this->assertEquals('testvalue', $results[1]['value']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,514 @@
|
||||
<?php
|
||||
namespace Tests\Perfomance\workflow\src\ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use ProcessMaker\Model\AppAssignSelfServiceValue;
|
||||
use ProcessMaker\Model\AppAssignSelfServiceValueGroup;
|
||||
use ProcessMaker\Model\Application;
|
||||
use ProcessMaker\Model\Delegation;
|
||||
use ProcessMaker\Model\GroupUser;
|
||||
use ProcessMaker\Model\Groupwf;
|
||||
use ProcessMaker\Model\Process;
|
||||
use ProcessMaker\Model\Task;
|
||||
use ProcessMaker\Model\TaskUser;
|
||||
use ProcessMaker\Model\User;
|
||||
use Tests\TestCase;
|
||||
|
||||
class DelegationTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
//This parameter is used for performance test, It has to be divisible by 4, because we have 4 types of self-service
|
||||
private $totalCases;
|
||||
//This parameter is used for performance test, It the maximum time in seconds
|
||||
private $maximumExecutionTime;
|
||||
|
||||
/**
|
||||
* Define values of some parameters of the test
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
if (!env('RUN_MYSQL_PERFORMANCE_TESTS')) {
|
||||
$this->markTestSkipped('Test related to the performance are disabled for this server configuration');
|
||||
} else {
|
||||
$this->totalCases = (int)env('TOTAL_CASES', 120);
|
||||
$this->maximumExecutionTime = (int)env('MAX_EXECUTION_TIME', 60);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks the counters is working properly in self-service user assigned
|
||||
* @covers Delegation::countSelfService
|
||||
* @test
|
||||
*/
|
||||
public function it_should_count_cases_by_user_with_self_service_user_assigned()
|
||||
{
|
||||
//Define the total of cases to create
|
||||
$total = $this->totalCases;
|
||||
//Define the maximum time of execution
|
||||
$maximumTime = $this->maximumExecutionTime;
|
||||
//Create process
|
||||
$process = factory(Process::class)->create();
|
||||
//Create user
|
||||
$user = factory(User::class)->create();
|
||||
//Create a task self service
|
||||
$task = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
|
||||
'TAS_GROUP_VARIABLE' => '',
|
||||
'PRO_UID' => $process->PRO_UID
|
||||
]);
|
||||
//Assign a user in the task
|
||||
factory(TaskUser::class)->create([
|
||||
'TAS_UID' => $task->TAS_UID,
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'TU_RELATION' => 1, //Related to the user
|
||||
'TU_TYPE' => 1
|
||||
]);
|
||||
//Create the register in delegation relate to self-service
|
||||
factory(Delegation::class, $total)->create([
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_ID' => 0,
|
||||
]);
|
||||
//Review the count self-service
|
||||
$timeStart = microtime(true);
|
||||
Delegation::countSelfService($user->USR_UID);
|
||||
$timeEnd = microtime(true);
|
||||
$time = $timeEnd - $timeStart;
|
||||
//Compare if the time of execution is minor than the time defined in the .env
|
||||
$this->assertLessThan($maximumTime, $time);
|
||||
error_log('it_should_count_cases_by_user_with_self_service_user_assigned took [' . $total . ']--->' . $time);
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks the counters is working properly in self-service-value-based when the variable has a value related with the USR_UID
|
||||
* When the value assigned in the variable @@ARRAY_OF_USERS = [USR_UID]
|
||||
* @covers Delegation::countSelfService
|
||||
* @test
|
||||
*/
|
||||
public function it_should_count_cases_by_user_with_self_service_value_based_usr_uid()
|
||||
{
|
||||
//Define the total of cases to create
|
||||
$total = $this->totalCases;
|
||||
//Define the maximum time of execution
|
||||
$maximumTime = $this->maximumExecutionTime;
|
||||
//Create process
|
||||
$process = factory(Process::class)->create();
|
||||
//Create a case
|
||||
$application = factory(Application::class)->create();
|
||||
//Create user
|
||||
$user = factory(User::class)->create();
|
||||
//Create a task self service value based
|
||||
$task = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
|
||||
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
|
||||
'PRO_UID' => $process->PRO_UID
|
||||
]);
|
||||
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
|
||||
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'DEL_INDEX' => 2,
|
||||
'TAS_ID' => $task->TAS_ID
|
||||
]);
|
||||
factory(AppAssignSelfServiceValueGroup::class)->create([
|
||||
'ID' => $appSelfValue->ID,
|
||||
'GRP_UID' => $user->USR_UID,
|
||||
'ASSIGNEE_ID' => $user->USR_ID, //The usrId or grpId
|
||||
'ASSIGNEE_TYPE' => 1 //Related to the user=1 related to the group=2
|
||||
]);
|
||||
//Create the register in self-service
|
||||
factory(Delegation::class, $total)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'DEL_INDEX' => $appSelfValue->DEL_INDEX,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_ID' => 0,
|
||||
]);
|
||||
//Review the count self-service
|
||||
$timeStart = microtime(true);
|
||||
Delegation::countSelfService($user->USR_UID);
|
||||
$timeEnd = microtime(true);
|
||||
$time = $timeEnd - $timeStart;
|
||||
//Compare if the time of execution is minor than the time defined in the .env
|
||||
$this->assertLessThan($maximumTime, $time);
|
||||
error_log('it_should_count_cases_by_user_with_self_service_value_based_usr_uid took [' . $total . ']--->' . $time);
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks the counters is working properly in self-service and self-service value based
|
||||
* @covers Delegation::countSelfService
|
||||
* @test
|
||||
*/
|
||||
public function it_should_count_cases_by_user_with_self_service_mixed_with_self_service_value_based()
|
||||
{
|
||||
//Define the total of cases to create
|
||||
$total = $this->totalCases;
|
||||
//Define the maximum time of execution
|
||||
$maximumTime = $this->maximumExecutionTime;
|
||||
//Create process
|
||||
$process = factory(Process::class)->create();
|
||||
//Create a case
|
||||
$application = factory(Application::class)->create();
|
||||
//Create user
|
||||
$user = factory(User::class)->create();
|
||||
//Create a task self service
|
||||
$task = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
|
||||
'TAS_GROUP_VARIABLE' => '',
|
||||
'PRO_UID' => $process->PRO_UID
|
||||
]);
|
||||
//Assign a user in the task
|
||||
factory(TaskUser::class)->create([
|
||||
'TAS_UID' => $task->TAS_UID,
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'TU_RELATION' => 1, //Related to the user
|
||||
'TU_TYPE' => 1
|
||||
]);
|
||||
//Create the register in self service
|
||||
factory(Delegation::class, $total / 2)->create([
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_ID' => 0,
|
||||
]);
|
||||
//Create a task self service value based
|
||||
$task1 = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
|
||||
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
|
||||
'PRO_UID' => $process->PRO_UID
|
||||
]);
|
||||
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
|
||||
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'DEL_INDEX' => 2,
|
||||
'TAS_ID' => $task1->TAS_ID
|
||||
]);
|
||||
factory(AppAssignSelfServiceValueGroup::class)->create([
|
||||
'ID' => $appSelfValue->ID,
|
||||
'GRP_UID' => $user->USR_UID,
|
||||
'ASSIGNEE_ID' => $user->USR_ID, //The usrId or grpId
|
||||
'ASSIGNEE_TYPE' => 1 //Related to the user=1 related to the group=2
|
||||
]);
|
||||
//Create the register in self service value based
|
||||
factory(Delegation::class, $total / 2)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'DEL_INDEX' => $appSelfValue->DEL_INDEX,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_ID' => 0,
|
||||
]);
|
||||
//Review the count self-service
|
||||
$timeStart = microtime(true);
|
||||
Delegation::countSelfService($user->USR_UID);
|
||||
$timeEnd = microtime(true);
|
||||
$time = $timeEnd - $timeStart;
|
||||
//Compare if the time of execution is minor than the time defined in the .env
|
||||
$this->assertLessThan($maximumTime, $time);
|
||||
error_log('it_should_count_cases_by_user_with_self_service_mixed_with_self_service_value_based took [' . $total . ']--->' . $time);
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks the counters is working properly in self-service group assigned
|
||||
* @covers Delegation::countSelfService
|
||||
* @test
|
||||
*/
|
||||
public function it_should_count_cases_by_user_with_self_service_group_assigned()
|
||||
{
|
||||
//Define the total of cases to create
|
||||
$total = $this->totalCases;
|
||||
//Define the maximum time of execution
|
||||
$maximumTime = $this->maximumExecutionTime;
|
||||
//Create process
|
||||
$process = factory(Process::class)->create();
|
||||
//Create group
|
||||
$group = factory(Groupwf::class)->create();
|
||||
//Create user
|
||||
$user = factory(User::class)->create();
|
||||
//Assign a user in the group
|
||||
factory(GroupUser::class)->create([
|
||||
'GRP_UID' => $group->GRP_UID,
|
||||
'GRP_ID' => $group->GRP_ID,
|
||||
'USR_UID' => $user->USR_UID
|
||||
]);
|
||||
//Create a task self service
|
||||
$task = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
|
||||
'TAS_GROUP_VARIABLE' => '',
|
||||
'PRO_UID' => $process->PRO_UID
|
||||
]);
|
||||
//Assign a user in the task
|
||||
factory(TaskUser::class)->create([
|
||||
'TAS_UID' => $task->TAS_UID,
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'TU_RELATION' => 2, //Related to the group
|
||||
'TU_TYPE' => 1
|
||||
]);
|
||||
//Create the register in self-service
|
||||
factory(Delegation::class, $total)->create([
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_ID' => 0,
|
||||
]);
|
||||
//Review the count self-service
|
||||
$timeStart = microtime(true);
|
||||
Delegation::countSelfService($user->USR_UID);
|
||||
$timeEnd = microtime(true);
|
||||
$time = $timeEnd - $timeStart;
|
||||
//Compare if the time of execution is minor than the time defined in the .env
|
||||
$this->assertLessThan($maximumTime, $time);
|
||||
error_log('it_should_count_cases_by_user_with_self_service_group_assigned took [' . $total . ']--->' . $time);
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks the counters is working properly in self-service-value-based when the variable has a value related with the GRP_UID
|
||||
* When the value assigned in the variable @@ARRAY_OF_USERS = [GRP_UID]
|
||||
* @covers Delegation::countSelfService
|
||||
* @test
|
||||
*/
|
||||
public function it_should_count_cases_by_user_with_self_service_value_based_grp_uid()
|
||||
{
|
||||
//Define the total of cases to create
|
||||
$total = $this->totalCases;
|
||||
//Define the maximum time of execution
|
||||
$maximumTime = $this->maximumExecutionTime;
|
||||
//Create process
|
||||
$process = factory(Process::class)->create();
|
||||
//Create a task self service value based
|
||||
$task = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
|
||||
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
|
||||
'PRO_UID' => $process->PRO_UID
|
||||
]);
|
||||
//Create a case
|
||||
$application = factory(Application::class)->create();
|
||||
//Create group
|
||||
$group = factory(Groupwf::class)->create();
|
||||
//Create user
|
||||
$user = factory(User::class)->create([
|
||||
'USR_USERNAME' => 'gary',
|
||||
'USR_LASTNAME' => 'Gary',
|
||||
'USR_FIRSTNAME' => 'Bailey',
|
||||
]);
|
||||
//Assign a user in the group
|
||||
factory(GroupUser::class)->create([
|
||||
'GRP_UID' => $group->GRP_UID,
|
||||
'GRP_ID' => $group->GRP_ID,
|
||||
'USR_UID' => $user->USR_UID,
|
||||
]);
|
||||
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
|
||||
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'APP_UID' => $application->APP_UID,
|
||||
'DEL_INDEX' => 2,
|
||||
'TAS_ID' => $task->TAS_ID
|
||||
]);
|
||||
factory(AppAssignSelfServiceValueGroup::class)->create([
|
||||
'ID' => $appSelfValue->ID,
|
||||
'GRP_UID' => $group->GRP_UID,
|
||||
'ASSIGNEE_ID' => $group->GRP_ID, //The usrId or grpId
|
||||
'ASSIGNEE_TYPE' => 2 //Related to the user=1 related to the group=2
|
||||
]);
|
||||
//Create the register in self-service
|
||||
factory(Delegation::class, $total)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'DEL_INDEX' => 2,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_ID' => 0,
|
||||
]);
|
||||
//Review the count self-service
|
||||
$timeStart = microtime(true);
|
||||
Delegation::countSelfService($user->USR_UID);
|
||||
$timeEnd = microtime(true);
|
||||
$time = $timeEnd - $timeStart;
|
||||
//Compare if the time of execution is minor than the time defined in the .env
|
||||
$this->assertLessThan($maximumTime, $time);
|
||||
error_log('it_should_count_cases_by_user_with_self_service_value_based_grp_uid took [' . $total . ']--->' . $time);
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks the counters is working properly in self-service user and group assigned in parallel task
|
||||
* @covers Delegation::countSelfService
|
||||
* @test
|
||||
*/
|
||||
public function it_should_count_cases_by_user_with_self_service_user_and_group_assigned_parallel_task()
|
||||
{
|
||||
//Define the total of cases to create
|
||||
$total = $this->totalCases;
|
||||
//Define the maximum time of execution
|
||||
$maximumTime = $this->maximumExecutionTime;
|
||||
//Create process
|
||||
$process = factory(Process::class)->create();
|
||||
//Create group
|
||||
$group = factory(Groupwf::class)->create();
|
||||
//Create user
|
||||
$user = factory(User::class)->create();
|
||||
//Assign a user in the group
|
||||
factory(GroupUser::class)->create([
|
||||
'GRP_UID' => $group->GRP_UID,
|
||||
'GRP_ID' => $group->GRP_ID,
|
||||
'USR_UID' => $user->USR_UID
|
||||
]);
|
||||
//Create a task self service
|
||||
$task1 = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
|
||||
'TAS_GROUP_VARIABLE' => '',
|
||||
'PRO_UID' => $process->PRO_UID
|
||||
]);
|
||||
//Assign a user in the task1
|
||||
factory(TaskUser::class)->create([
|
||||
'TAS_UID' => $task1->TAS_UID,
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'TU_RELATION' => 1, //Related to the user
|
||||
'TU_TYPE' => 1
|
||||
]);
|
||||
//Create a task self service
|
||||
$task2 = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
|
||||
'TAS_GROUP_VARIABLE' => '',
|
||||
'PRO_UID' => $process->PRO_UID
|
||||
]);
|
||||
//Assign a user in the task2
|
||||
factory(TaskUser::class)->create([
|
||||
'TAS_UID' => $task2->TAS_UID,
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'TU_RELATION' => 1, //Related to the user
|
||||
'TU_TYPE' => 1
|
||||
]);
|
||||
//Create a task self service
|
||||
$task3 = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
|
||||
'TAS_GROUP_VARIABLE' => '',
|
||||
'PRO_UID' => $process->PRO_UID
|
||||
]);
|
||||
//Assign a user in the task
|
||||
factory(TaskUser::class)->create([
|
||||
'TAS_UID' => $task3->TAS_UID,
|
||||
'USR_UID' => $group->GRP_UID,
|
||||
'TU_RELATION' => 2, //Related to the group
|
||||
'TU_TYPE' => 1
|
||||
]);
|
||||
//Create a task self service
|
||||
$task4 = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
|
||||
'TAS_GROUP_VARIABLE' => '',
|
||||
'PRO_UID' => $process->PRO_UID
|
||||
]);
|
||||
//Assign a user in the task
|
||||
factory(TaskUser::class)->create([
|
||||
'TAS_UID' => $task4->TAS_UID,
|
||||
'USR_UID' => $group->GRP_UID,
|
||||
'TU_RELATION' => 2, //Related to the group
|
||||
'TU_TYPE' => 1
|
||||
]);
|
||||
//Create the register in self-service related to the task1
|
||||
factory(Delegation::class, $total / 4)->create([
|
||||
'TAS_ID' => $task1->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_ID' => 0,
|
||||
]);
|
||||
//Create the register in self-service related to the task2
|
||||
factory(Delegation::class, $total / 4)->create([
|
||||
'TAS_ID' => $task2->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_ID' => 0,
|
||||
]);
|
||||
//Create the register in self-service related to the task3
|
||||
factory(Delegation::class, $total / 4)->create([
|
||||
'TAS_ID' => $task3->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_ID' => 0,
|
||||
]);
|
||||
//Create the register in self-service related to the task4
|
||||
factory(Delegation::class, $total / 4)->create([
|
||||
'TAS_ID' => $task4->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_ID' => 0,
|
||||
]);
|
||||
//Review the count self-service
|
||||
$timeStart = microtime(true);
|
||||
Delegation::countSelfService($user->USR_UID);
|
||||
$timeEnd = microtime(true);
|
||||
$time = $timeEnd - $timeStart;
|
||||
//Compare if the time of execution is minor than the time defined in the .env
|
||||
$this->assertLessThan($maximumTime, $time);
|
||||
error_log('it_should_count_cases_by_user_with_self_service_user_and_group_assigned_parallel_task took [' . $total . ']--->' . $time);
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks the counters is working properly in self-service-value-based with GRP_UID and USR_UID in parallel task
|
||||
* When the value assigned in the variable @@ARRAY_OF_USERS = [GRP_UID, USR_UID]
|
||||
* @covers Delegation::countSelfService
|
||||
* @test
|
||||
*/
|
||||
public function it_should_count_cases_by_user_with_self_service_value_based_usr_uid_and_grp_uid()
|
||||
{
|
||||
//Define the total of cases to create
|
||||
$total = $this->totalCases;
|
||||
//Define the maximum time of execution
|
||||
$maximumTime = $this->maximumExecutionTime;
|
||||
//Create process
|
||||
$process = factory(Process::class)->create();
|
||||
//Create a case
|
||||
$application = factory(Application::class)->create();
|
||||
//Create user
|
||||
$user = factory(User::class)->create();
|
||||
//Create a task1 self service value based
|
||||
$task1 = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
|
||||
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
|
||||
'PRO_UID' => $process->PRO_UID
|
||||
]);
|
||||
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
|
||||
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'TAS_ID' => $task1->TAS_ID
|
||||
]);
|
||||
factory(AppAssignSelfServiceValueGroup::class)->create([
|
||||
'ID' => $appSelfValue->ID,
|
||||
'GRP_UID' => $user->USR_UID,
|
||||
'ASSIGNEE_ID' => $user->USR_ID, //The usrId or grpId
|
||||
'ASSIGNEE_TYPE' => 1 //Related to the user=1 related to the group=2
|
||||
]);
|
||||
//Create the register in self-service
|
||||
factory(Delegation::class, $total / 2)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'DEL_INDEX' => $appSelfValue->DEL_INDEX,
|
||||
'TAS_ID' => $task1->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_ID' => 0,
|
||||
]);
|
||||
//Create a task2 self service value based
|
||||
$task2 = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
|
||||
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
|
||||
'PRO_UID' => $process->PRO_UID
|
||||
]);
|
||||
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
|
||||
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'TAS_ID' => $task2->TAS_ID
|
||||
]);
|
||||
factory(AppAssignSelfServiceValueGroup::class)->create([
|
||||
'ID' => $appSelfValue->ID,
|
||||
'GRP_UID' => $user->USR_UID,
|
||||
'ASSIGNEE_ID' => $user->USR_ID, //The usrId or grpId
|
||||
'ASSIGNEE_TYPE' => 1 //Related to the user=1 related to the group=2
|
||||
]);
|
||||
//Create the register in self-service
|
||||
factory(Delegation::class, $total / 2)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'DEL_INDEX' => $appSelfValue->DEL_INDEX,
|
||||
'TAS_ID' => $task2->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_ID' => 0,
|
||||
]);
|
||||
//Review the count self-service
|
||||
$timeStart = microtime(true);
|
||||
Delegation::countSelfService($user->USR_UID);
|
||||
$timeEnd = microtime(true);
|
||||
$time = $timeEnd - $timeStart;
|
||||
//Compare if the time of execution is minor than the time defined in the .env
|
||||
$this->assertLessThan($maximumTime, $time);
|
||||
error_log('it_should_count_cases_by_user_with_self_service_value_based_usr_uid_and_grp_uid took [' . $total . ']--->' . $time);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
namespace Tests;
|
||||
|
||||
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
||||
@@ -7,6 +8,67 @@ use Propel;
|
||||
|
||||
abstract class TestCase extends BaseTestCase
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $currentConfig;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $currentArgv;
|
||||
|
||||
/**
|
||||
* Create application
|
||||
*/
|
||||
use CreatesApplication;
|
||||
|
||||
/**
|
||||
* Constructs a test case with the given name.
|
||||
*
|
||||
* @param string $name
|
||||
* @param array $data
|
||||
* @param string $dataName
|
||||
*/
|
||||
public function __construct($name = null, array $data = [], $dataName = '')
|
||||
{
|
||||
/**
|
||||
* Method Tests\CreatesApplication::createApplication() restarts the application
|
||||
* and the values loaded in bootstrap.php have been lost, for this reason
|
||||
* it is necessary to save the following values.
|
||||
*/
|
||||
$this->currentConfig = app('config');
|
||||
$this->currentArgv = $_SERVER['argv'];
|
||||
parent::__construct($name, $data, $dataName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the fixture, for example, opens a network connection.
|
||||
* This method is called before a test is executed.
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
/**
|
||||
* Lost argv are restored.
|
||||
*/
|
||||
if (empty($_SERVER['argv'])) {
|
||||
$_SERVER['argv'] = $this->currentArgv;
|
||||
}
|
||||
parent::setUp();
|
||||
/**
|
||||
* Lost config are restored.
|
||||
*/
|
||||
app()->instance('config', $this->currentConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tears down the fixture, for example, closes a network connection.
|
||||
* This method is called after a test is executed.
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,42 +3,85 @@
|
||||
/**
|
||||
* Test harness bootstrap that sets up initial defines and builds up the initial database schema
|
||||
*/
|
||||
// Bring in our standard bootstrap
|
||||
|
||||
include_once(__DIR__ . '/../bootstrap/autoload.php');
|
||||
|
||||
use Illuminate\Contracts\Console\Kernel;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
// Setup our required defines
|
||||
/**
|
||||
* @todo Migrate to configuration parameters
|
||||
*/
|
||||
|
||||
define('PATH_TRUNK', dirname(__DIR__));
|
||||
define('PATH_CORE', PATH_TRUNK.'/workflow/engine/');
|
||||
define('PATH_CORE', PATH_TRUNK . '/workflow/engine/');
|
||||
define('PATH_CONFIG', PATH_CORE . 'config/');
|
||||
define('PATH_RBAC_CORE',dirname(__DIR__).'/rbac/engine/');
|
||||
define('PATH_DB', dirname(__DIR__).'/shared/sites/');
|
||||
define('PATH_DATA', dirname(__DIR__).'/shared/rbac/');
|
||||
$pathData = PATH_CONFIG . 'paths_installed.php';
|
||||
if (file_exists($pathData)) {
|
||||
require_once $pathData;
|
||||
} else {
|
||||
define('PATH_DATA', dirname(__DIR__) . '/shared/rbac/');
|
||||
}
|
||||
define('PATH_RBAC_CORE', dirname(__DIR__) . '/rbac/engine/');
|
||||
if (file_exists($pathData)) {
|
||||
define('PATH_DB', PATH_DATA . 'sites/');
|
||||
} else {
|
||||
define('PATH_DB', dirname(__DIR__) . '/shared/sites/');
|
||||
}
|
||||
define('PATH_SEP', '/');
|
||||
define('PATH_METHODS', dirname(__DIR__).'/workflow/engine/methods/');
|
||||
define('PATH_METHODS', dirname(__DIR__) . '/workflow/engine/methods/');
|
||||
define('SYS_LANG', 'en');
|
||||
define('DB_ADAPTER', 'mysql');
|
||||
define('SYS_SKIN', 'neoclassic');
|
||||
define('SYS_SYS', 'workflow');
|
||||
define('PATH_WORKSPACE',PATH_TRUNK.'/shared/sites/' . SYS_SYS . '/');
|
||||
define('PMTABLE_KEY','pmtable');
|
||||
define('SYS_SYS', env('MAIN_SYS_SYS', 'workflow'));
|
||||
define('PATH_WORKSPACE', PATH_TRUNK . '/shared/sites/' . SYS_SYS . '/');
|
||||
define('PMTABLE_KEY', 'pmtable');
|
||||
define('PATH_WORKFLOW_MYSQL_DATA', PATH_TRUNK . '/workflow/engine/data/mysql/');
|
||||
define('PATH_RBAC_MYSQL_DATA', PATH_TRUNK . '/rbac/engine/data/mysql/');
|
||||
define('PATH_LANGUAGECONT', PATH_DATA . '/META-INF/');
|
||||
define('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/");
|
||||
|
||||
// Set Time Zone
|
||||
$_SESSION['__SYSTEM_UTC_TIME_ZONE__'] = (int)(env('MAIN_SYSTEM_UTC_TIME_ZONE', 'workflow')) == 1;
|
||||
ini_set('date.timezone', $_SESSION['__SYSTEM_UTC_TIME_ZONE__'] ? 'UTC' : env('MAIN_TIME_ZONE', 'America/New_York'));
|
||||
define('TIME_ZONE', ini_get('date.timezone'));
|
||||
|
||||
// Setup basic app services
|
||||
$app = require __DIR__ . '/../bootstrap/app.php';
|
||||
$app->make(Kernel::class)->bootstrap();
|
||||
|
||||
// Setup our testexternal database
|
||||
config(['database.connections.testexternal' => [
|
||||
// Overwrite with the ProcessMaker env.ini configuration used in production environments
|
||||
//@todo: move env.ini configuration to .env
|
||||
ini_set('date.timezone', TIME_ZONE); //Set Time Zone
|
||||
date_default_timezone_set(TIME_ZONE);
|
||||
// Configuration values
|
||||
config(['app.timezone' => TIME_ZONE]);
|
||||
config([
|
||||
"system.workspace" => SYS_SYS
|
||||
]);
|
||||
// Defining constants related to the workspace
|
||||
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();
|
||||
|
||||
/**
|
||||
* Database configurations
|
||||
*/
|
||||
// Setup connection to database SQLServer
|
||||
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', ''),
|
||||
@@ -47,31 +90,25 @@ config(['database.connections.testexternal' => [
|
||||
'prefix' => '',
|
||||
'strict' => true,
|
||||
'engine' => null
|
||||
]]);
|
||||
|
||||
// Now, drop all test tables and repopulate with schema
|
||||
Schema::connection('testexternal')->dropIfExists('test');
|
||||
|
||||
Schema::connection('testexternal')->create('test', function($table) {
|
||||
$table->increments('id');
|
||||
$table->string('value');
|
||||
});
|
||||
DB::connection('testexternal')->table('test')->insert([
|
||||
'value' => 'testvalue'
|
||||
]
|
||||
]);
|
||||
|
||||
// Only do if we are supporting MSSql tests
|
||||
/**
|
||||
* Configuration for MSSQL
|
||||
*/
|
||||
if (env('RUN_MSSQL_TESTS')) {
|
||||
config(['database.connections.mssql' => [
|
||||
config([
|
||||
'database.connections.mssql' => [
|
||||
'driver' => 'sqlsrv',
|
||||
'host' => env('MSSQL_HOST', '127.0.0.1'),
|
||||
'database' => env('MSSQL_DATABASE', 'testexternal'),
|
||||
'username' => env('MSSQL_USERNAME', 'root'),
|
||||
'password' => env('MSSQL_PASSWORD', 'password'),
|
||||
]]);
|
||||
]
|
||||
]);
|
||||
|
||||
Schema::connection('mssql')->dropIfExists('test');
|
||||
Schema::connection('mssql')->create('test', function($table) {
|
||||
Schema::connection('mssql')->create('test', function ($table) {
|
||||
$table->increments('id');
|
||||
$table->string('value');
|
||||
});
|
||||
@@ -80,50 +117,63 @@ if (env('RUN_MSSQL_TESTS')) {
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is for standard ProcessMaker tables
|
||||
*/
|
||||
if (!env('POPULATE_DATABASE')) {
|
||||
// Create a table for define the connection
|
||||
Schema::connection('testexternal')->dropIfExists('test');
|
||||
Schema::connection('testexternal')->create('test', function ($table) {
|
||||
$table->increments('id');
|
||||
$table->string('value');
|
||||
});
|
||||
DB::connection('testexternal')->table('test')->insert([
|
||||
'value' => 'testvalue'
|
||||
]);
|
||||
|
||||
// THIS IS FOR STANDARD PROCESSMAKER TABLES
|
||||
// Now, drop all test tables and repopulate with schema
|
||||
DB::unprepared('SET FOREIGN_KEY_CHECKS = 0');
|
||||
$colname = 'Tables_in_' . env('DB_DATABASE');
|
||||
$tables = DB::select('SHOW TABLES');
|
||||
$drop = [];
|
||||
foreach ($tables as $table) {
|
||||
$drop[] = $table->$colname;
|
||||
// Now, drop all test tables and repopulate with schema
|
||||
DB::unprepared('SET FOREIGN_KEY_CHECKS = 0');
|
||||
$colname = 'Tables_in_' . env('DB_DATABASE', 'test');
|
||||
$tables = DB::select('SHOW TABLES');
|
||||
$drop = [];
|
||||
foreach ($tables as $table) {
|
||||
$drop[] = $table->$colname;
|
||||
}
|
||||
if (count($drop)) {
|
||||
$drop = implode(',', $drop);
|
||||
DB::statement("DROP TABLE $drop");
|
||||
DB::unprepared('SET FOREIGN_KEY_CHECKS = 1');
|
||||
}
|
||||
|
||||
// Repopulate with schema and standard inserts
|
||||
DB::unprepared(file_get_contents(PATH_CORE . 'data/mysql/schema.sql'));
|
||||
DB::unprepared(file_get_contents(PATH_RBAC_CORE . 'data/mysql/schema.sql'));
|
||||
DB::unprepared(file_get_contents(PATH_CORE . 'data/mysql/insert.sql'));
|
||||
DB::unprepared(file_get_contents(PATH_RBAC_CORE . 'data/mysql/insert.sql'));
|
||||
|
||||
// Set our APP_SEQUENCE val
|
||||
DB::table('APP_SEQUENCE')->insert([
|
||||
'ID' => 1
|
||||
]);
|
||||
|
||||
// Setup our initial oauth client for our web designer
|
||||
DB::table('OAUTH_CLIENTS')->insert([
|
||||
'CLIENT_ID' => 'x-pm-local-client',
|
||||
'CLIENT_SECRET' => '179ad45c6ce2cb97cf1029e212046e81',
|
||||
'CLIENT_NAME' => 'PM Web Designer',
|
||||
'CLIENT_DESCRIPTION' => 'ProcessMaker Web Designer App',
|
||||
'CLIENT_WEBSITE' => 'www.processmaker.com',
|
||||
'REDIRECT_URI' => config('app.url') . '/sys' . config('system.workspace') . '/en/neoclassic/oauth2/grant',
|
||||
'USR_UID' => '00000000000000000000000000000001'
|
||||
]);
|
||||
DB::table('OAUTH_ACCESS_TOKENS')->insert([
|
||||
'ACCESS_TOKEN' => '39704d17049f5aef45e884e7b769989269502f83',
|
||||
'CLIENT_ID' => 'x-pm-local-client',
|
||||
'USER_ID' => '00000000000000000000000000000001',
|
||||
'EXPIRES' => '2017-06-15 17:55:19',
|
||||
'SCOPE' => 'view_processes edit_processes *'
|
||||
]);
|
||||
}
|
||||
if (count($drop)) {
|
||||
$drop = implode(',', $drop);
|
||||
DB::statement("DROP TABLE $drop");
|
||||
DB::unprepared('SET FOREIGN_KEY_CHECKS = 1');
|
||||
}
|
||||
|
||||
// Repopulate with schema and standard inserts
|
||||
DB::unprepared(file_get_contents(PATH_CORE . 'data/mysql/schema.sql'));
|
||||
DB::unprepared(file_get_contents(PATH_RBAC_CORE . 'data/mysql/schema.sql'));
|
||||
DB::unprepared(file_get_contents(PATH_CORE . 'data/mysql/insert.sql'));
|
||||
DB::unprepared(file_get_contents(PATH_RBAC_CORE . 'data/mysql/insert.sql'));
|
||||
|
||||
// Set our APP_SEQUENCE val
|
||||
DB::table('APP_SEQUENCE')->insert([
|
||||
'ID' => 1
|
||||
]);
|
||||
|
||||
// Setup our initial oauth client for our web designer
|
||||
DB::table('OAUTH_CLIENTS')->insert([
|
||||
'CLIENT_ID' => 'x-pm-local-client',
|
||||
'CLIENT_SECRET' => '179ad45c6ce2cb97cf1029e212046e81',
|
||||
'CLIENT_NAME' => 'PM Web Designer',
|
||||
'CLIENT_DESCRIPTION' => 'ProcessMaker Web Designer App',
|
||||
'CLIENT_WEBSITE' => 'www.processmaker.com',
|
||||
'REDIRECT_URI' => config('app.url') . '/sys' . config('system.workspace') . '/en/neoclassic/oauth2/grant',
|
||||
'USR_UID' => '00000000000000000000000000000001'
|
||||
]);
|
||||
DB::table('OAUTH_ACCESS_TOKENS')->insert([
|
||||
'ACCESS_TOKEN' => '39704d17049f5aef45e884e7b769989269502f83',
|
||||
'CLIENT_ID' => 'x-pm-local-client',
|
||||
'USER_ID' => '00000000000000000000000000000001',
|
||||
'EXPIRES' => '2017-06-15 17:55:19',
|
||||
'SCOPE' => 'view_processes edit_processes *'
|
||||
]);
|
||||
|
||||
// We need to manually initialize Propel with our test database
|
||||
Propel::initConfiguration([
|
||||
|
||||
73
tests/unit/app/CustomizeFormatterTest.php
Normal file
73
tests/unit/app/CustomizeFormatterTest.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?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()
|
||||
{
|
||||
parent::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);
|
||||
}
|
||||
}
|
||||
@@ -5,276 +5,164 @@ use Tests\TestCase;
|
||||
class ReplaceDataFieldTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* This checks that strings with HTML reserved characters are replaced with entities
|
||||
* Check that the value of "@q" followed by a string is not being set as empty when using "@#" to identify a variable
|
||||
*
|
||||
* @test
|
||||
* @covers G::replaceDataField
|
||||
*/
|
||||
public function it_should_replace_entities()
|
||||
public function it_should_not_set_empty_when_calling_a_variable_with_hashtag_symbol()
|
||||
{
|
||||
// Initializing Faker instance
|
||||
$faker = Faker\Factory::create();
|
||||
$string = '<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<p>THIS IS ONLY A TEST OF THE VARIABLE @#var_supplierEmail </p>
|
||||
</body>
|
||||
</html>';
|
||||
|
||||
// Initializing variables to use that will not change
|
||||
$stringWithVariablesToReplace = 'Hello @@var1 the @#var2 is @=var3 not @&var4->value';
|
||||
$dbEngine = 'mysql'; // This only affects the way to escape the variables with "@@" prefix
|
||||
$applyEntities = true; // If a value to replace is a not valid HTML and have HTML reserved characters, entities should be applied
|
||||
|
||||
// Initializing variables to test the assertions, entities should be applied in variable with @@
|
||||
$var4 = new stdClass();
|
||||
$var4->value = $faker->words(1, true);
|
||||
$valuesToReplace = [
|
||||
'var1' => 'Java < PHP & Python',
|
||||
'var2' => $faker->words(1, true),
|
||||
'var3' => $faker->words(1, true),
|
||||
'var4' => $var4
|
||||
$result = [
|
||||
'var_supplierEmail' => 'asa@qq.fds',
|
||||
'var_supplierEmail_label' => 'asa@qq.fds',
|
||||
];
|
||||
|
||||
// Replace variables in the string
|
||||
$stringToCheck = G::replaceDataField($stringWithVariablesToReplace, $valuesToReplace, $dbEngine, $applyEntities);
|
||||
$dbEngine = 'mysql';
|
||||
$recursive = false;
|
||||
|
||||
// Assertions
|
||||
$this->assertRegExp('/</', $stringToCheck);
|
||||
$this->assertRegExp('/&/', $stringToCheck);
|
||||
// Replace variables in the string, $recursive is false because is don't needed replace recursively the same value
|
||||
$stringToCheck = G::replaceDataField($string, $result, $dbEngine, $recursive);
|
||||
|
||||
// Initializing variables to test the assertions, entities should be applied in variable with @#
|
||||
$var4 = new stdClass();
|
||||
$var4->value = $faker->words(1, true);
|
||||
$valuesToReplace = [
|
||||
'var1' => $faker->words(1, true),
|
||||
'var2' => 'Java < PHP & Python',
|
||||
'var3' => $faker->words(1, true),
|
||||
'var4' => $var4
|
||||
// Assert the @qq is not being set as an empty value
|
||||
$this->assertRegExp("/asa@qq.fds/", $stringToCheck);
|
||||
|
||||
// Testing with a "@qstring" value
|
||||
$result = [
|
||||
'var_supplierEmail' => '@qstring',
|
||||
'var_supplierEmail_label' => '@qstring',
|
||||
];
|
||||
|
||||
// Replace variables in the string
|
||||
$stringToCheck = G::replaceDataField($stringWithVariablesToReplace, $valuesToReplace, $dbEngine, $applyEntities);
|
||||
$dbEngine = 'mysql';
|
||||
$recursive = false;
|
||||
|
||||
// Assertions
|
||||
$this->assertRegExp('/</', $stringToCheck);
|
||||
$this->assertRegExp('/&/', $stringToCheck);
|
||||
// Replace variables in the string, $recursive is false because is don't needed replace recursively the same value
|
||||
$stringToCheck = G::replaceDataField($string, $result, $dbEngine, $recursive);
|
||||
|
||||
// Initializing variables to test the assertions, entities should be applied in variable with @=
|
||||
$var4 = new stdClass();
|
||||
$var4->value = $faker->words(1, true);
|
||||
$valuesToReplace = [
|
||||
'var1' => $faker->words(1, true),
|
||||
'var2' => $faker->words(1, true),
|
||||
'var3' => 'Java < PHP & Python',
|
||||
'var4' => $var4
|
||||
];
|
||||
|
||||
// Replace variables in the string
|
||||
$stringToCheck = G::replaceDataField($stringWithVariablesToReplace, $valuesToReplace, $dbEngine, $applyEntities);
|
||||
|
||||
// Assertions
|
||||
$this->assertRegExp('/</', $stringToCheck);
|
||||
$this->assertRegExp('/&/', $stringToCheck);
|
||||
|
||||
// Initializing variables to test the assertions, entities should be applied in variable with @&
|
||||
$var4 = new stdClass();
|
||||
$var4->value = 'Java < PHP & Python';
|
||||
$valuesToReplace = [
|
||||
'var1' => $faker->words(1, true),
|
||||
'var2' => $faker->words(1, true),
|
||||
'var3' => $faker->words(1, true),
|
||||
'var4' => $var4
|
||||
];
|
||||
|
||||
// Replace variables in the string
|
||||
$stringToCheck = G::replaceDataField($stringWithVariablesToReplace, $valuesToReplace, $dbEngine, $applyEntities);
|
||||
|
||||
// Assertions
|
||||
$this->assertRegExp('/</', $stringToCheck);
|
||||
$this->assertRegExp('/&/', $stringToCheck);
|
||||
// Assert the @qstring is not being set as an empty value
|
||||
$this->assertRegExp("/@qstring/", $stringToCheck);
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks that strings with HTML reserved characters are NOT replaced with entities
|
||||
* Check that the value of "@q" followed by a string is not being set as empty when using "@=" to identify a variable
|
||||
*
|
||||
* @test
|
||||
* @covers G::replaceDataField
|
||||
*/
|
||||
public function it_should_no_replace_entities()
|
||||
public function it_should_not_set_empty_when_calling_a_variable_with_equals_symbol()
|
||||
{
|
||||
// Initializing Faker instance
|
||||
$faker = Faker\Factory::create();
|
||||
$string = '<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
|
||||
<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
<p>THIS IS ONLY A TEST OF THE VARIABLE @=var_supplierEmail </p>
|
||||
</body>
|
||||
</html>';
|
||||
|
||||
// Initializing variables to use that will not change
|
||||
$stringWithVariablesToReplace = 'Hello @@var1 the @#var2 is @=var3 not @&var4->value';
|
||||
$dbEngine = 'mysql'; // This only affects the way to escape the variables with "@@" prefix
|
||||
$applyEntities = false; // The values should not be replaced with entities
|
||||
|
||||
// Initializing variables to test the assertions, entities should be applied in variable with @@
|
||||
$var4 = new stdClass();
|
||||
$var4->value = $faker->words(1, true);
|
||||
$valuesToReplace = [
|
||||
'var1' => 'Java < PHP & Python',
|
||||
'var2' => $faker->words(1, true),
|
||||
'var3' => $faker->words(1, true),
|
||||
'var4' => $var4
|
||||
$result = [
|
||||
'var_supplierEmail' => 'asa@qq.fds',
|
||||
'var_supplierEmail_label' => 'asa@qq.fds',
|
||||
];
|
||||
|
||||
// Replace variables in the string
|
||||
$stringToCheck = G::replaceDataField($stringWithVariablesToReplace, $valuesToReplace, $dbEngine, $applyEntities);
|
||||
$dbEngine = 'mysql';
|
||||
$recursive = false;
|
||||
|
||||
// Assertions
|
||||
$this->assertRegExp('/</', $stringToCheck);
|
||||
$this->assertRegExp('/&/', $stringToCheck);
|
||||
// Replace variables in the string, $recursive is false because is don't needed replace recursively the same value
|
||||
$stringToCheck = G::replaceDataField($string, $result, $dbEngine, $recursive);
|
||||
|
||||
// Initializing variables to test the assertions, entities should be applied in variable with @#
|
||||
$var4 = new stdClass();
|
||||
$var4->value = $faker->words(1, true);
|
||||
$valuesToReplace = [
|
||||
'var1' => $faker->words(1, true),
|
||||
'var2' => 'Java < PHP & Python',
|
||||
'var3' => $faker->words(1, true),
|
||||
'var4' => $var4
|
||||
// Assert the @qq is not being set as an empty value
|
||||
$this->assertRegExp("/asa@qq.fds/", $stringToCheck);
|
||||
|
||||
// Testing with a "@qstring" value
|
||||
$result = [
|
||||
'var_supplierEmail' => '@qstring',
|
||||
'var_supplierEmail_label' => '@qstring',
|
||||
];
|
||||
|
||||
// Replace variables in the string
|
||||
$stringToCheck = G::replaceDataField($stringWithVariablesToReplace, $valuesToReplace, $dbEngine, $applyEntities);
|
||||
$dbEngine = 'mysql';
|
||||
$recursive = false;
|
||||
|
||||
// Assertions
|
||||
$this->assertRegExp('/</', $stringToCheck);
|
||||
$this->assertRegExp('/&/', $stringToCheck);
|
||||
// Replace variables in the string, $recursive is false because is don't needed replace recursively the same value
|
||||
$stringToCheck = G::replaceDataField($string, $result, $dbEngine, $recursive);
|
||||
|
||||
// Initializing variables to test the assertions, entities should be applied in variable with @=
|
||||
$var4 = new stdClass();
|
||||
$var4->value = $faker->words(1, true);
|
||||
$valuesToReplace = [
|
||||
'var1' => $faker->words(1, true),
|
||||
'var2' => $faker->words(1, true),
|
||||
'var3' => 'Java < PHP & Python',
|
||||
'var4' => $var4
|
||||
];
|
||||
|
||||
// Replace variables in the string
|
||||
$stringToCheck = G::replaceDataField($stringWithVariablesToReplace, $valuesToReplace, $dbEngine, $applyEntities);
|
||||
|
||||
// Assertions
|
||||
$this->assertRegExp('/</', $stringToCheck);
|
||||
$this->assertRegExp('/&/', $stringToCheck);
|
||||
|
||||
// Initializing variables to test the assertions, entities should be applied in variable with @&
|
||||
$var4 = new stdClass();
|
||||
$var4->value = 'Java < PHP & Python';
|
||||
$valuesToReplace = [
|
||||
'var1' => $faker->words(1, true),
|
||||
'var2' => $faker->words(1, true),
|
||||
'var3' => $faker->words(1, true),
|
||||
'var4' => $var4
|
||||
];
|
||||
|
||||
// Replace variables in the string
|
||||
$stringToCheck = G::replaceDataField($stringWithVariablesToReplace, $valuesToReplace, $dbEngine, $applyEntities);
|
||||
|
||||
// Assertions
|
||||
$this->assertRegExp('/</', $stringToCheck);
|
||||
$this->assertRegExp('/&/', $stringToCheck);
|
||||
// Assert the @qstring is not being set as an empty value
|
||||
$this->assertRegExp("/@qstring/", $stringToCheck);
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks that strings with HTML reserved characters are NOT replaced with entities if is a valid HTML, because
|
||||
* PS team sometimes build a HTML string to insert in templates (output documents or emails), Ex.- A table to list
|
||||
* users or results from a query
|
||||
* Check that the variable using "@#" will be replaced recursively or not according to the parameters sent
|
||||
*
|
||||
* @test
|
||||
* @covers G::replaceDataField
|
||||
*/
|
||||
public function it_should_no_replace_entities_if_exists_valid_html()
|
||||
public function it_should_replace_recursively_a_variable_inside_another_variable_with_hashtag_symbol()
|
||||
{
|
||||
// Initializing Faker instance
|
||||
$faker = Faker\Factory::create();
|
||||
// Initialize variables
|
||||
$string = '@#upload_New';
|
||||
$variables = ['upload_New' => "javascript:uploadInputDocument('@#DOC_UID');",
|
||||
'DOC_UID' => '1988828025cc89aba0cd2b8079038028'];
|
||||
|
||||
// Initializing variables to use
|
||||
$stringWithVariablesToReplace = 'bla @#var1 bla @=listHtml bla @@var2 bla';
|
||||
$valuesToReplace = [
|
||||
'var1' => $faker->words(1, true),
|
||||
'listHtml' => '<table>
|
||||
<tr>
|
||||
<th>t1</th>
|
||||
<th>t2</th>
|
||||
<th>t3</th>
|
||||
<th>t4</th>
|
||||
<th>t5</th>
|
||||
<th>t6</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>c1</td>
|
||||
<td>c2</td>
|
||||
<td>c3</td>
|
||||
<td>c4</td>
|
||||
<td>c5</td>
|
||||
<td>c6</td>
|
||||
</tr>
|
||||
</table>',
|
||||
'var2' => $faker->words(1, true)
|
||||
];
|
||||
$dbEngine = 'mysql'; // This only affects the way to escape the variables with "@@" prefix
|
||||
$applyEntities = true; // Is true because the string will b used in a output document or a email template
|
||||
// Set parameters to test the method
|
||||
$dbEngine = 'mysql';
|
||||
$recursive = false;
|
||||
|
||||
// Replace variables in the string
|
||||
$stringToCheck = G::replaceDataField($stringWithVariablesToReplace, $valuesToReplace, $dbEngine, $applyEntities);
|
||||
// Replace variables in the string, $recursive is false because is don't needed replace recursively the same value
|
||||
$stringToCheck = G::replaceDataField($string, $variables, $dbEngine, $recursive);
|
||||
|
||||
// Assertions
|
||||
$this->assertRegExp('/<table>/', $stringToCheck);
|
||||
$this->assertRegExp('/<tr>/', $stringToCheck);
|
||||
$this->assertRegExp('/<th>/', $stringToCheck);
|
||||
$this->assertRegExp('/<td>/', $stringToCheck);
|
||||
// The variable @#DOC_UID inside in the variable "@#upload_New" shouldn't be replaced
|
||||
$this->assertRegExp("/@#DOC_UID/", $stringToCheck);
|
||||
|
||||
// Set parameters to test the method
|
||||
$dbEngine = 'mysql';
|
||||
$recursive = true;
|
||||
|
||||
// Replace variables in the string, $recursive is true because is required replace recursively the same value
|
||||
$stringToCheck = G::replaceDataField($string, $variables, $dbEngine, $recursive);
|
||||
|
||||
// The variable @#DOC_UID inside in the variable "@#upload_New" should be replaced correctly
|
||||
$this->assertRegExp("/1988828025cc89aba0cd2b8079038028/", $stringToCheck);
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks that strings with tag <br /> should not be replaced, because is a valid tag
|
||||
* Check that the variable using "@=" will be replaced recursively or not according to the parameters sent
|
||||
*
|
||||
* @test
|
||||
* @covers G::replaceDataField
|
||||
*/
|
||||
public function it_should_no_replace_tag_br()
|
||||
public function it_should_replace_recursively_a_variable_inside_another_variable_with_equals_symbol()
|
||||
{
|
||||
// Initializing variables to use
|
||||
$stringWithTagBr = nl2br("prospection auprès d'entreprises de CA < 10 M euros
|
||||
test
|
||||
<a
|
||||
>a
|
||||
&a
|
||||
\"a
|
||||
'a
|
||||
¢a
|
||||
£a
|
||||
¥a
|
||||
€a
|
||||
©a
|
||||
®a
|
||||
test");
|
||||
$valuesToReplace = [];
|
||||
$dbEngine = 'mysql'; // This only affects the way to escape the variables with "@@" prefix
|
||||
$applyEntities = true; // Is true because the string will be used in a output document or a email template
|
||||
// Initialize variables
|
||||
$string = '@=upload_New';
|
||||
$variables = ['upload_New' => "javascript:uploadInputDocument('@=DOC_UID');",
|
||||
'DOC_UID' => '1988828025cc89aba0cd2b8079038028'];
|
||||
|
||||
// Replace variables in the string
|
||||
$stringToCheck = G::replaceDataField($stringWithTagBr, $valuesToReplace, $dbEngine, $applyEntities);
|
||||
// Set parameters to test the method
|
||||
$dbEngine = 'mysql';
|
||||
$recursive = false;
|
||||
|
||||
// Assertions
|
||||
$this->assertRegExp("/<br \/>/", $stringToCheck);
|
||||
}
|
||||
// Replace variables in the string, $recursive is false because is don't needed replace recursively the same value
|
||||
$stringToCheck = G::replaceDataField($string, $variables, $dbEngine, $recursive);
|
||||
|
||||
/**
|
||||
* Check that the value for the System variable "__ABE__" should not be replaced never
|
||||
* @test
|
||||
* @covers G::replaceDataField
|
||||
*/
|
||||
public function it_should_no_replace_entities_for_var_abe()
|
||||
{
|
||||
// Initializing variables to use
|
||||
$string = "bla @#__ABE__ bla @#anotherVar bla";
|
||||
$valuesToReplace = [// Add a value for reserved system variable "__ABE__" used in Actions By Email feature
|
||||
'__ABE__' => 'Java < PHP', // The value for System variable "__ABE__" shouldn't be changed never
|
||||
'anotherVar' => '.NET < Java' // The value for another variables should be validated/replaced normally
|
||||
];
|
||||
$dbEngine = 'mysql'; // This only affects the way to escape the variables with "@@" prefix
|
||||
$applyEntities = true; // Is true because the string will be used in a output document or a email template
|
||||
// The variable @=DOC_UID inside in the variable "@=upload_New" shouldn't be replaced
|
||||
$this->assertRegExp("/@=DOC_UID/", $stringToCheck);
|
||||
|
||||
// Replace variables in the string
|
||||
$stringToCheck = G::replaceDataField($string, $valuesToReplace, $dbEngine, $applyEntities);
|
||||
// Set parameters to test the method
|
||||
$dbEngine = 'mysql';
|
||||
$recursive = true;
|
||||
|
||||
// Assertions
|
||||
$this->assertRegExp("/Java < PHP/", $stringToCheck);
|
||||
$this->assertRegExp("/.NET < Java/", $stringToCheck);
|
||||
// Replace variables in the string, $recursive is true because is required replace recursively the same value
|
||||
$stringToCheck = G::replaceDataField($string, $variables, $dbEngine, $recursive);
|
||||
|
||||
// The variable @=DOC_UID inside in the variable "@=upload_New" should be replaced correctly
|
||||
$this->assertRegExp("/1988828025cc89aba0cd2b8079038028/", $stringToCheck);
|
||||
}
|
||||
}
|
||||
|
||||
353
tests/unit/gulliver/system/gTest.php
Normal file
353
tests/unit/gulliver/system/gTest.php
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
279
tests/unit/workflow/engine/bin/tasks/CliWorkspacesTest.php
Normal file
279
tests/unit/workflow/engine/bin/tasks/CliWorkspacesTest.php
Normal file
@@ -0,0 +1,279 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\bin\tasks;
|
||||
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use ProcessMaker\Model\Dynaform;
|
||||
use ProcessMaker\Model\Process;
|
||||
use ProcessMaker\Model\ProcessVariables;
|
||||
use ProcessMaker\Model\Triggers;
|
||||
use Tests\TestCase;
|
||||
|
||||
class CliWorkspacesTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->markTestIncomplete();//@todo: Please correct this unit test
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that the deprecated files are removed successfully
|
||||
*
|
||||
* @covers WorkspaceTools::removeDeprecatedFiles
|
||||
* @test
|
||||
*/
|
||||
public function it_should_delete_the_deprecated_files()
|
||||
{
|
||||
include(PATH_TRUNK . PATH_SEP . 'workflow/engine/bin/tasks/cliWorkspaces.php');
|
||||
if (!file_exists(PATH_TRUNK . PATH_SEP . 'workflow/engine/methods/users/data_usersList.php')) {
|
||||
$filename = PATH_TRUNK . PATH_SEP . 'workflow/engine/methods/users/data_usersList.php';
|
||||
$handle = fopen($filename, 'w');
|
||||
fclose($handle);
|
||||
}
|
||||
|
||||
// This assert the data_usersList.php file do exists before being deleted
|
||||
$this->assertTrue(file_exists(PATH_TRUNK . PATH_SEP . 'workflow/engine/methods/users/data_usersList.php'));
|
||||
|
||||
$path = PATH_TRUNK . PATH_SEP . 'workflow/engine/methods/users/';
|
||||
|
||||
if (getmyuid() == fileowner($path)) {
|
||||
if (substr($this->getPermissions(PATH_TRUNK . PATH_SEP . 'workflow/engine/methods/users/data_usersList.php'),
|
||||
1, 2) == 'rw' &&
|
||||
substr($this->getPermissions(PATH_TRUNK . PATH_SEP . 'workflow/engine/methods/users/'), 2, 1) == 'w' &&
|
||||
substr($this->getPermissions(PATH_TRUNK . PATH_SEP . 'workflow/engine/methods/'), 3, 1) == 'x' &&
|
||||
substr($this->getPermissions(PATH_TRUNK . PATH_SEP . 'workflow/engine/'), 3, 1) == 'x' &&
|
||||
substr($this->getPermissions(PATH_TRUNK . PATH_SEP . 'workflow/'), 3, 1) == 'x'
|
||||
) {
|
||||
remove_deprecated_files();
|
||||
} else {
|
||||
dd("Could not delete the file. Please, make sure the file have write permission for the direct parent directory and
|
||||
execute permission for all parent directories.");
|
||||
}
|
||||
} else {
|
||||
if (getmygid() == filegroup($path)) {
|
||||
if (substr($this->getPermissions(PATH_TRUNK . PATH_SEP . 'workflow/engine/methods/users/data_usersList.php'),
|
||||
4, 2) == 'rw' &&
|
||||
substr($this->getPermissions(PATH_TRUNK . PATH_SEP . 'workflow/engine/methods/users/'), 5,
|
||||
1) == 'w' &&
|
||||
substr($this->getPermissions(PATH_TRUNK . PATH_SEP . 'workflow/engine/methods/'), 6, 1) == 'x' &&
|
||||
substr($this->getPermissions(PATH_TRUNK . PATH_SEP . 'workflow/engine/'), 6, 1) == 'x' &&
|
||||
substr($this->getPermissions(PATH_TRUNK . PATH_SEP . 'workflow/'), 6, 1) == 'x'
|
||||
) {
|
||||
remove_deprecated_files();
|
||||
} else {
|
||||
dd("Could not delete the file. Please, make sure the file have write permission for the direct parent directory and
|
||||
execute permission for all parent directories.");
|
||||
}
|
||||
|
||||
} else {
|
||||
if (substr($this->getPermissions(PATH_TRUNK . PATH_SEP . 'workflow/engine/methods/users/data_usersList.php'),
|
||||
7, 2) == 'rw' &&
|
||||
substr($this->getPermissions(PATH_TRUNK . PATH_SEP . 'workflow/engine/methods/users/'), 8,
|
||||
1) == 'w' &&
|
||||
substr($this->getPermissions(PATH_TRUNK . PATH_SEP . 'workflow/engine/methods/'), 9, 1) == 'x' &&
|
||||
substr($this->getPermissions(PATH_TRUNK . PATH_SEP . 'workflow/engine/'), 9, 1) == 'x' &&
|
||||
substr($this->getPermissions(PATH_TRUNK . PATH_SEP . 'workflow/'), 9, 1) == 'x'
|
||||
) {
|
||||
remove_deprecated_files();
|
||||
} else {
|
||||
dd("Could not delete the file. Please, make sure the file have write permission for the direct parent directory and
|
||||
execute permission for all parent directories.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This assert the data_usersList.php does not exist anymore
|
||||
$this->assertFalse(file_exists(PATH_TRUNK . PATH_SEP . 'workflow/engine/methods/users/data_usersList.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the permissions of a file or directory
|
||||
*
|
||||
* @param string $path
|
||||
* @return string
|
||||
*/
|
||||
public function getPermissions($path)
|
||||
{
|
||||
$per = fileperms($path);
|
||||
switch ($per & 0xF000) {
|
||||
case 0xC000: // socket
|
||||
$permissions = 's';
|
||||
break;
|
||||
case 0xA000: // symbolic link
|
||||
$permissions = 'l';
|
||||
break;
|
||||
case 0x8000: // regular
|
||||
$permissions = '-';
|
||||
break;
|
||||
case 0x6000: // block special
|
||||
$permissions = 'b';
|
||||
break;
|
||||
case 0x4000: // directory
|
||||
$permissions = 'd';
|
||||
break;
|
||||
case 0x2000: // character special
|
||||
$permissions = 'c';
|
||||
break;
|
||||
case 0x1000: // FIFO pipe
|
||||
$permissions = 'p';
|
||||
break;
|
||||
default: // unknown
|
||||
$permissions = 'u';
|
||||
}
|
||||
|
||||
// Owner
|
||||
$permissions .= (($per & 0x0100) ? 'r' : '-');
|
||||
$permissions .= (($per & 0x0080) ? 'w' : '-');
|
||||
$permissions .= (($per & 0x0040) ?
|
||||
(($per & 0x0800) ? 's' : 'x') :
|
||||
(($per & 0x0800) ? 'S' : '-'));
|
||||
|
||||
// Group
|
||||
$permissions .= (($per & 0x0020) ? 'r' : '-');
|
||||
$permissions .= (($per & 0x0010) ? 'w' : '-');
|
||||
$permissions .= (($per & 0x0008) ?
|
||||
(($per & 0x0400) ? 's' : 'x') :
|
||||
(($per & 0x0400) ? 'S' : '-'));
|
||||
|
||||
// Others
|
||||
$permissions .= (($per & 0x0004) ? 'r' : '-');
|
||||
$permissions .= (($per & 0x0002) ? 'w' : '-');
|
||||
$permissions .= (($per & 0x0001) ?
|
||||
(($per & 0x0200) ? 't' : 'x') :
|
||||
(($per & 0x0200) ? 'T' : '-'));
|
||||
|
||||
return $permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the queries incompatibilities in dynaforms
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_the_incompatibilities_in_the_dynaforms_queries()
|
||||
{
|
||||
config(["system.workspace" => 'workflow']);
|
||||
|
||||
$process = factory(Process::class, 2)->create();
|
||||
|
||||
factory(Dynaform::class)->create(
|
||||
[
|
||||
'PRO_UID' => $process[0]['PRO_UID'],
|
||||
'DYN_CONTENT' => '{"name":"2","description":"","items":[{"type":"form","variable":"","var_uid":"","dataType":"","id":"6170264265d1b544bebdbd5098250194","name":"2","description":"","mode":"edit","script":"","language":"en","externalLibs":"","printable":false,"items":[[{"type":"title","id":"title0000000001","label":"title_1","colSpan":12}],[{"type":"text","variable":"textVar002","var_uid":"9778460595d1b545088dd69091601043","dataType":"string","protectedValue":false,"id":"textVar002","name":"textVar002","label":"text_1","defaultValue":"","placeholder":"","hint":"","required":false,"requiredFieldErrorMessage":"","textTransform":"none","validate":"","validateMessage":"","maxLength":1000,"formula":"","mode":"parent","operation":"","dbConnection":"workflow","dbConnectionLabel":"PM Database","sql":"","var_name":"textVar002","colSpan":12}],[{"type":"textarea","variable":"textareaVar001","var_uid":"2934510045d1b5453f21373072798412","dataType":"string","protectedValue":false,"id":"textareaVar001","name":"textareaVar001","label":"textarea_1","defaultValue":"","placeholder":"","hint":"","required":false,"requiredFieldErrorMessage":"","validate":"","validateMessage":"","mode":"parent","dbConnection":"workflow","dbConnectionLabel":"PM Database","sql":"","rows":"5","var_name":"textareaVar001","colSpan":12}],[{"type":"datetime","variable":"datetimeVar001","var_uid":"9780823375d1b5455e9c3a2064729484","dataType":"datetime","protectedValue":false,"id":"datetimeVar001","name":"datetimeVar001","label":"datetime_1","placeholder":"","hint":"","required":false,"requiredFieldErrorMessage":"","mode":"parent","format":"YYYY-MM-DD","dayViewHeaderFormat":"MMMM YYYY","extraFormats":false,"stepping":1,"minDate":"","maxDate":"","useCurrent":"false","collapse":true,"locale":"","defaultDate":"","disabledDates":false,"enabledDates":false,"icons":{"time":"glyphicon glyphicon-time","date":"glyphicon glyphicon-calendar","up":"glyphicon glyphicon-chevron-up","down":"glyphicon glyphicon-chevron-down","previous":"glyphicon glyphicon-chevron-left","next":"glyphicon glyphicon-chevron-right","today":"glyphicon glyphicon-screenshot","clear":"glyphicon glyphicon-trash"},"useStrict":false,"sideBySide":false,"daysOfWeekDisabled":false,"calendarWeeks":false,"viewMode":"days","toolbarPlacement":"default","showTodayButton":false,"showClear":"false","widgetPositioning":{"horizontal":"auto","vertical":"auto"},"widgetParent":null,"keepOpen":false,"var_name":"datetimeVar001","colSpan":12}],[{"type":"submit","id":"submit0000000001","name":"submit0000000001","label":"submit_1","colSpan":12}]],"variables":[{"var_uid":"9778460595d1b545088dd69091601043","prj_uid":"5139642915ccb3fca429a36061714972","var_name":"textVar002","var_field_type":"string","var_field_size":10,"var_label":"string","var_dbconnection":"workflow","var_dbconnection_label":"PM Database","var_sql":"","var_null":0,"var_default":"","var_accepted_values":"[]","inp_doc_uid":""},{"var_uid":"2934510045d1b5453f21373072798412","prj_uid":"5139642915ccb3fca429a36061714972","var_name":"textareaVar001","var_field_type":"string","var_field_size":10,"var_label":"string","var_dbconnection":"workflow","var_dbconnection_label":"PM Database","var_sql":"","var_null":0,"var_default":"","var_accepted_values":"[]","inp_doc_uid":""},{"var_uid":"9780823375d1b5455e9c3a2064729484","prj_uid":"5139642915ccb3fca429a36061714972","var_name":"datetimeVar001","var_field_type":"datetime","var_field_size":10,"var_label":"datetime","var_dbconnection":"workflow","var_dbconnection_label":"PM Database","var_sql":"","var_null":0,"var_default":"","var_accepted_values":"[]","inp_doc_uid":""}]}]}'
|
||||
]
|
||||
);
|
||||
|
||||
$dynaform = factory(Dynaform::class)->create(
|
||||
[
|
||||
'PRO_UID' => $process[1]['PRO_UID'],
|
||||
'DYN_CONTENT' => '{"name":"1","description":"","items":[{"type":"form","variable":"","var_uid":"","dataType":"","id":"6817532755d16225629cb05061521548","name":"1","description":"","mode":"edit","script":"","language":"en","externalLibs":"","printable":false,"items":[[{"type":"text","variable":"textVar001","var_uid":"4746221155d1622658943d1014840579","dataType":"string","protectedValue":false,"id":"textVar001","name":"textVar001","label":"text_1","defaultValue":"","placeholder":"","hint":"","required":false,"requiredFieldErrorMessage":"","textTransform":"none","validate":"","validateMessage":"","maxLength":1000,"formula":"","mode":"parent","operation":"","dbConnection":"workflow","dbConnectionLabel":"PM Database","sql":"SELECT * FROM USERS WHERE \nUSR_UID=\'$UID\' UNION SELECT * from PROCESS","var_name":"textVar001","colSpan":12}]],"variables":[{"var_uid":"4746221155d1622658943d1014840579","prj_uid":"5139642915ccb3fca429a36061714972","var_name":"textVar001","var_field_type":"string","var_field_size":10,"var_label":"string","var_dbconnection":"workflow","var_dbconnection_label":"PM Database","var_sql":"","var_null":0,"var_default":"","var_accepted_values":"[]","inp_doc_uid":""}]}]}'
|
||||
]
|
||||
);
|
||||
|
||||
check_queries_incompatibilities('workflow');
|
||||
|
||||
$result = ob_get_contents();
|
||||
|
||||
// This assert that the message contains the second process name
|
||||
$this->assertRegExp('/'.$process[1]['PRO_TITLE'].'/',$result);
|
||||
|
||||
// This assert that the message contains the second dynaform with the UNION query
|
||||
$this->assertRegExp('/'.$dynaform['DYN_TITLE'].'/',$result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the queries incompatibilities in variables
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_the_incompatibilities_in_the_variables_queries()
|
||||
{
|
||||
config(["system.workspace" => 'workflow']);
|
||||
|
||||
$process = factory(Process::class, 2)->create();
|
||||
|
||||
$variables = factory(ProcessVariables::class)->create(
|
||||
[
|
||||
'PRJ_UID' => $process[0]['PRO_UID'],
|
||||
'VAR_SQL' => 'SELECT * FROM USERS WHERE USR_UID="213" UNION SELECT * from PROCESS'
|
||||
]
|
||||
);
|
||||
|
||||
factory(ProcessVariables::class)->create(
|
||||
[
|
||||
'PRJ_UID' => $process[1]['PRO_UID'],
|
||||
'VAR_SQL' => ''
|
||||
]
|
||||
);
|
||||
|
||||
check_queries_incompatibilities('workflow');
|
||||
|
||||
$result = ob_get_contents();
|
||||
|
||||
// This assert that the message contains the first process name
|
||||
$this->assertRegExp('/'.$process[0]['PRO_TITLE'].'/',$result);
|
||||
|
||||
// This assert that the message contains the first dynaform with the UNION query
|
||||
$this->assertRegExp('/'.$variables['VAR_TITLE'].'/',$result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the queries incompatibilities in triggers
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_the_incompatibilities_in_the_triggers_queries()
|
||||
{
|
||||
config(["system.workspace" => 'workflow']);
|
||||
|
||||
$process = factory(Process::class, 3)->create();
|
||||
$trigger = factory(Triggers::class)->create(
|
||||
[
|
||||
'PRO_UID' => $process[0]['PRO_UID'],
|
||||
'TRI_WEBBOT' => '$text=222;
|
||||
$var1= executeQuery("SELECT *
|
||||
FROM USERS WHERE
|
||||
USR_UID=\'$UID\' UNION SELECT * from PROCESS");
|
||||
|
||||
$var1= executeQuery("SELECT *
|
||||
FROM USERS WHERE
|
||||
USR_UID=\'$UID\' UNION SELECT * from PROCESS");
|
||||
|
||||
$query = "SELECT * FROM USERS UNION
|
||||
|
||||
SELECT * FROM TASKS";
|
||||
|
||||
$QUERY2 = "select * from USERS union SELECT * from GROUPS";
|
||||
|
||||
$s1 = "select * from USER";
|
||||
$s2 = "select * from TASK";
|
||||
|
||||
$query3 = $s1. " UNION " . $s2;
|
||||
|
||||
executeQuery($query3);'
|
||||
]
|
||||
);
|
||||
|
||||
factory(Triggers::class)->create(
|
||||
[
|
||||
'PRO_UID' => $process[1]['PRO_UID'],
|
||||
'TRI_WEBBOT' => 'die();'
|
||||
]
|
||||
);
|
||||
|
||||
factory(Triggers::class)->create(
|
||||
[
|
||||
'PRO_UID' => $process[2]['PRO_UID'],
|
||||
'TRI_WEBBOT' => 'executeQuery("select * from USERS");'
|
||||
]
|
||||
);
|
||||
|
||||
check_queries_incompatibilities('workflow');
|
||||
$result = ob_get_contents();
|
||||
|
||||
// This assert that the message contains the first process name
|
||||
$this->assertRegExp('/'.$process[0]['PRO_TITLE'].'/',$result);
|
||||
|
||||
// This assert that the message contains the first trigger with the UNION query
|
||||
$this->assertRegExp('/'.$trigger['TRI_TITLE'].'/',$result);
|
||||
}
|
||||
}
|
||||
81
tests/unit/workflow/engine/classes/ConfigurationsTest.php
Normal file
81
tests/unit/workflow/engine/classes/ConfigurationsTest.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\classes;
|
||||
|
||||
use Configurations;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use ProcessMaker\Model\Configuration;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ConfigurationsTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
/**
|
||||
* Review the user preferences when the user does not save filters
|
||||
* @covers Configurations::getUserPreferences
|
||||
* @test
|
||||
*/
|
||||
public function it_should_return_empty_preferences()
|
||||
{
|
||||
//Define a user preferences empty
|
||||
$configuration = factory(Configuration::class)->states('userPreferencesEmpty')->create();
|
||||
|
||||
//Get the user preferences
|
||||
$conf = new Configurations();
|
||||
$response = $conf->getUserPreferences('FILTERS', $configuration->USR_UID);
|
||||
|
||||
//Compare filters
|
||||
$this->assertEquals($response, ['advanced' => []]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Review the user preferences when the user save filters
|
||||
* @covers Configurations::getUserPreferences
|
||||
* @test
|
||||
*/
|
||||
public function it_should_return_filters_saved()
|
||||
{
|
||||
//Define a user preferences related to the advanced search
|
||||
$conf = new Configurations();
|
||||
$filter = [];
|
||||
$filter['category'] = ''; //Dropdown: Category id
|
||||
$filter['columnSearch'] = 'APP_TITLE'; //Dropdown: filter by value
|
||||
$filter['dateFrom'] = '2019-07-01'; //Date picker
|
||||
$filter['dateTo'] = '2020-07-01'; //Date picker
|
||||
$filter['dir'] = 'DESC';
|
||||
$filter['limit'] = 15;
|
||||
$filter['filterStatus'] = 3; //Dropdown: Status id
|
||||
$filter['process'] = ''; //Suggest: Process id
|
||||
$filter['process_label'] = ''; //Suggest: Process label
|
||||
$filter['search'] = ''; //Text search
|
||||
$filter['sort'] = 'APP_NUMBER';
|
||||
$filter['start'] = 0;
|
||||
$filter['user'] = ''; //Suggest: User id
|
||||
$filter['user_label'] = ''; //Suggest: User label
|
||||
$filters['advanced'] = $filter;
|
||||
|
||||
//Save the user preferences
|
||||
$conf->aConfig['FILTERS']['advanced'] = $filter;
|
||||
$conf->saveConfig('USER_PREFERENCES', '', '', '00000000000000000000000000000001');
|
||||
$response = $conf->getUserPreferences('FILTERS', '00000000000000000000000000000001');
|
||||
|
||||
//Compare filters
|
||||
$this->assertEquals($response, $filters);
|
||||
//Review if some keys exist
|
||||
$this->assertArrayHasKey('category', $response['advanced']);
|
||||
$this->assertArrayHasKey('columnSearch', $response['advanced']);
|
||||
$this->assertArrayHasKey('dateFrom', $response['advanced']);
|
||||
$this->assertArrayHasKey('dateTo', $response['advanced']);
|
||||
$this->assertArrayHasKey('dir', $response['advanced']);
|
||||
$this->assertArrayHasKey('limit', $response['advanced']);
|
||||
$this->assertArrayHasKey('filterStatus', $response['advanced']);
|
||||
$this->assertArrayHasKey('process', $response['advanced']);
|
||||
$this->assertArrayHasKey('process_label', $response['advanced']);
|
||||
$this->assertArrayHasKey('search', $response['advanced']);
|
||||
$this->assertArrayHasKey('sort', $response['advanced']);
|
||||
$this->assertArrayHasKey('start', $response['advanced']);
|
||||
$this->assertArrayHasKey('user', $response['advanced']);
|
||||
$this->assertArrayHasKey('user_label', $response['advanced']);
|
||||
}
|
||||
}
|
||||
@@ -13,9 +13,34 @@ class PmDynaformTest extends TestCase
|
||||
/**
|
||||
* Constructor of the class.
|
||||
*/
|
||||
function __construct()
|
||||
public function __construct($name = null, array $data = [], $dataName = '')
|
||||
{
|
||||
parent::__construct($name, $data, $dataName);
|
||||
$_SERVER["REQUEST_URI"] = "";
|
||||
if (!defined("DB_ADAPTER")) {
|
||||
define("DB_ADAPTER", "mysql");
|
||||
}
|
||||
if (!defined("DB_HOST")) {
|
||||
define("DB_HOST", env('DB_HOST'));
|
||||
}
|
||||
if (!defined("DB_NAME")) {
|
||||
define("DB_NAME", env('DB_DATABASE'));
|
||||
}
|
||||
if (!defined("DB_USER")) {
|
||||
define("DB_USER", env('DB_USERNAME'));
|
||||
}
|
||||
if (!defined("DB_PASS")) {
|
||||
define("DB_PASS", env('DB_PASSWORD'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the fixture, for example, opens a network connection.
|
||||
* This method is called before a test is executed.
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -532,4 +557,271 @@ class PmDynaformTest extends TestCase
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests that the json file is getting the defined values when the grid has one undefined control
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_should_add_the_correct_fields_with_a_single_undefined_control()
|
||||
{
|
||||
//Creates the PmDynaform object
|
||||
$pmDynaform = new PmDynaform();
|
||||
|
||||
//A json that contains the text control data and columns
|
||||
$jsonData = (object)(
|
||||
[
|
||||
"data" => (object)([
|
||||
"1" => [
|
||||
["value" => "textControl1", "label" => "textControl1"],
|
||||
["value" => "textControl2", "label" => "textControl2"],
|
||||
["value" => "", "label" => ""]
|
||||
]
|
||||
]),
|
||||
|
||||
"columns" => (object)([
|
||||
0 => (object)([
|
||||
"id" => "text0000000001",
|
||||
"name" => "text0000000001",
|
||||
]),
|
||||
1 => (object)([
|
||||
"id" => "textarea0000000001",
|
||||
"name" => "textarea0000000001",
|
||||
]),
|
||||
2 => (object)([
|
||||
"id" => "text0000000002",
|
||||
"name" => "text0000000002",
|
||||
])
|
||||
])
|
||||
]
|
||||
);
|
||||
|
||||
// An array that contains the variables stored on the App Data
|
||||
$appData = [
|
||||
"1" => [
|
||||
"text0000000001" => "",
|
||||
"text0000000001_label" => "",
|
||||
"textarea0000000001" => "",
|
||||
"textarea0000000001_label" => ""
|
||||
]
|
||||
];
|
||||
|
||||
//Calls the setDataSchema method
|
||||
$resultText = $pmDynaform->setDataSchema($jsonData, $appData);
|
||||
|
||||
//This assert the result is null
|
||||
$this->assertNull($resultText);
|
||||
|
||||
//Assert the 'dataSchema' field was added
|
||||
$this->assertObjectHasAttribute('dataSchema', $jsonData);
|
||||
|
||||
//It asserts the first control is defined
|
||||
$this->assertTrue($jsonData->dataSchema['1'][0]['defined']);
|
||||
|
||||
//It asserts the second control is defined
|
||||
$this->assertTrue($jsonData->dataSchema['1'][1]['defined']);
|
||||
|
||||
//It asserts the second control is undefined
|
||||
$this->assertFalse($jsonData->dataSchema['1'][2]['defined']);
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests that the json file is getting the defined values when the grid has more than one undefined control
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_should_add_the_correct_fields_with_more_than_one_undefined_control()
|
||||
{
|
||||
//Creates the PmDynaform object
|
||||
$pmDynaform = new PmDynaform();
|
||||
|
||||
//A json that contains the text control data and columns
|
||||
$jsonData = (object)(
|
||||
[
|
||||
"data" => (object)([
|
||||
"1" => [
|
||||
["value" => "textControl1", "label" => "textControl1"],
|
||||
["value" => "textAreaControl2", "label" => "textAreaControl2"],
|
||||
["value" => "dropdowncontrol1", "label" => "dropdowncontrol1"],
|
||||
["value" => "", "label" => ""],
|
||||
["value" => "", "label" => ""]
|
||||
]
|
||||
]),
|
||||
"columns" => (object)([
|
||||
0 => (object)([
|
||||
"id" => "text0000000001",
|
||||
"name" => "text0000000001",
|
||||
]),
|
||||
1 => (object)([
|
||||
"id" => "textarea0000000001",
|
||||
"name" => "textarea0000000001",
|
||||
]),
|
||||
2 => (object)([
|
||||
"id" => "dropdown0000000001",
|
||||
"name" => "dropdown0000000001",
|
||||
]),
|
||||
3 => (object)([
|
||||
"id" => "text0000000002",
|
||||
"name" => "text0000000002",
|
||||
]),
|
||||
4 => (object)([
|
||||
"id" => "text0000000003",
|
||||
"name" => "text0000000003",
|
||||
])
|
||||
])
|
||||
]
|
||||
);
|
||||
|
||||
// An array that contains the variables stored on the App Data
|
||||
$appData = [
|
||||
"1" => [
|
||||
"text0000000001" => "",
|
||||
"text0000000001_label" => "",
|
||||
"textarea0000000001" => "",
|
||||
"textarea0000000001_label" => "",
|
||||
"dropdown0000000001" => "",
|
||||
"dropdown0000000001_label" => ""
|
||||
]
|
||||
];
|
||||
|
||||
//Calls the setDataSchema method
|
||||
$resultText = $pmDynaform->setDataSchema($jsonData, $appData);
|
||||
|
||||
//This assert the result is null
|
||||
$this->assertNull($resultText);
|
||||
|
||||
//Assert the 'dataSchema' field was added
|
||||
$this->assertObjectHasAttribute('dataSchema', $jsonData);
|
||||
|
||||
//It asserts the first control is defined
|
||||
$this->assertTrue($jsonData->dataSchema['1'][0]['defined']);
|
||||
|
||||
//It asserts the second control is defined
|
||||
$this->assertTrue($jsonData->dataSchema['1'][1]['defined']);
|
||||
|
||||
//It asserts the third control is defined
|
||||
$this->assertTrue($jsonData->dataSchema['1'][2]['defined']);
|
||||
|
||||
//It asserts the fourth control is undefined
|
||||
$this->assertFalse($jsonData->dataSchema['1'][3]['defined']);
|
||||
|
||||
//It asserts the fifth control is undefined
|
||||
$this->assertFalse($jsonData->dataSchema['1'][4]['defined']);
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests that the json file is getting the defined and undefined values when the grid has more than one row
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_should_add_the_correct_fields_with_more_than_one_rows()
|
||||
{
|
||||
//Creates the PmDynaform object
|
||||
$pmDynaform = new PmDynaform();
|
||||
|
||||
//A json that contains the text control data and columns
|
||||
$jsonData = (object)(
|
||||
[
|
||||
"data" => (object)([
|
||||
"1" => [
|
||||
["value" => "textControl1", "label" => "textControl1"],
|
||||
["value" => "textAreaControl2", "label" => "textAreaControl2"],
|
||||
["value" => "dropdowncontrol1", "label" => "dropdowncontrol1"],
|
||||
["value" => "", "label" => ""],
|
||||
["value" => "", "label" => ""]
|
||||
],
|
||||
"2" => [
|
||||
["value" => "textControl1", "label" => "textControl1"],
|
||||
["value" => "textAreaControl2", "label" => "textAreaControl2"],
|
||||
["value" => "dropdowncontrol1", "label" => "dropdowncontrol1"],
|
||||
["value" => "", "label" => ""],
|
||||
["value" => "", "label" => ""]
|
||||
],
|
||||
"3" => [
|
||||
["value" => "textControl1", "label" => "textControl1"],
|
||||
["value" => "textAreaControl2", "label" => "textAreaControl2"],
|
||||
["value" => "dropdowncontrol1", "label" => "dropdowncontrol1"],
|
||||
["value" => "", "label" => ""],
|
||||
["value" => "", "label" => ""]
|
||||
]
|
||||
]),
|
||||
"columns" => (object)([
|
||||
0 => (object)([
|
||||
"id" => "text0000000001",
|
||||
"name" => "text0000000001",
|
||||
]),
|
||||
1 => (object)([
|
||||
"id" => "textarea0000000001",
|
||||
"name" => "textarea0000000001",
|
||||
]),
|
||||
2 => (object)([
|
||||
"id" => "dropdown0000000001",
|
||||
"name" => "dropdown0000000001",
|
||||
]),
|
||||
3 => (object)([
|
||||
"id" => "text0000000002",
|
||||
"name" => "text0000000002",
|
||||
]),
|
||||
4 => (object)([
|
||||
"id" => "text0000000003",
|
||||
"name" => "text0000000003",
|
||||
])
|
||||
])
|
||||
]
|
||||
);
|
||||
|
||||
// An array that contains the variables stored on the App Data
|
||||
$appData = [
|
||||
"1" => [
|
||||
"text0000000001" => "",
|
||||
"text0000000001_label" => "",
|
||||
"textarea0000000001" => "",
|
||||
"textarea0000000001_label" => "",
|
||||
"dropdown0000000001" => "",
|
||||
"dropdown0000000001_label" => ""
|
||||
],
|
||||
"2" => [
|
||||
"text0000000001" => "",
|
||||
"text0000000001_label" => "",
|
||||
"textarea0000000001" => "",
|
||||
"textarea0000000001_label" => "",
|
||||
"dropdown0000000001" => "",
|
||||
"dropdown0000000001_label" => ""
|
||||
],
|
||||
"3" => [
|
||||
"text0000000001" => "",
|
||||
"text0000000001_label" => "",
|
||||
"textarea0000000001" => "",
|
||||
"textarea0000000001_label" => "",
|
||||
"dropdown0000000001" => "",
|
||||
"dropdown0000000001_label" => ""
|
||||
]
|
||||
];
|
||||
|
||||
//Calls the setDataSchema method
|
||||
$resultText = $pmDynaform->setDataSchema($jsonData, $appData);
|
||||
|
||||
//This assert the result is null
|
||||
$this->assertNull($resultText);
|
||||
|
||||
//Assert the 'dataSchema' field was added
|
||||
$this->assertObjectHasAttribute('dataSchema', $jsonData);
|
||||
|
||||
foreach ($jsonData->dataSchema as $key => $value) {
|
||||
//It asserts the first control is defined
|
||||
$this->assertTrue($jsonData->dataSchema[$key][0]['defined']);
|
||||
|
||||
//It asserts the second control is defined
|
||||
$this->assertTrue($jsonData->dataSchema[$key][1]['defined']);
|
||||
|
||||
//It asserts the third control is defined
|
||||
$this->assertTrue($jsonData->dataSchema[$key][2]['defined']);
|
||||
|
||||
//It asserts the fourth control is undefined
|
||||
$this->assertFalse($jsonData->dataSchema[$key][3]['defined']);
|
||||
|
||||
//It asserts the fifth control is undefined
|
||||
$this->assertFalse($jsonData->dataSchema[$key][4]['defined']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
419
tests/unit/workflow/engine/classes/ProcessesTest.php
Normal file
419
tests/unit/workflow/engine/classes/ProcessesTest.php
Normal file
@@ -0,0 +1,419 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\classes;
|
||||
|
||||
use Faker\Factory;
|
||||
use G;
|
||||
use Processes;
|
||||
use ProcessMaker\Model\Dynaform;
|
||||
use ProcessMaker\Model\InputDocument;
|
||||
use ProcessMaker\Model\OutputDocument;
|
||||
use ProcessMaker\Model\Process;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ProcessesTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* This is using instead of DatabaseTransactions
|
||||
* @todo DatabaseTransactions is having conflicts with propel
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
$this->markTestIncomplete();//@todo: Please correct this unit test
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort array of array by column.
|
||||
* @param array $data
|
||||
* @param string $columnName
|
||||
*/
|
||||
public function sortArrayByColumn(&$data, $columnName)
|
||||
{
|
||||
usort($data, function($a, $b) use($columnName) {
|
||||
return strnatcmp($a[$columnName], $b[$columnName]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks if the returned dynaforms are correct with the different parameters.
|
||||
* @test
|
||||
* @covers \Processes::getDynaformRows()
|
||||
*/
|
||||
public function it_should_return_dynaforms()
|
||||
{
|
||||
$process = factory(Process::class)->create()->first();
|
||||
$proUid = $process->PRO_UID;
|
||||
|
||||
$dynaforms = factory(Dynaform::class, 6)
|
||||
->create([
|
||||
'PRO_UID' => $proUid
|
||||
])
|
||||
->sortBy('DYN_UID')
|
||||
->values();
|
||||
|
||||
//test with parameter false
|
||||
$expected = $dynaforms->toArray();
|
||||
|
||||
$processes = new Processes();
|
||||
$actual = $processes->getDynaformRows($proUid, false);
|
||||
$this->sortArrayByColumn($actual, 'DYN_UID');
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
|
||||
//by default the method getDynaformRows removed DYN_ID column
|
||||
$dynaforms->transform(function($item, $key) {
|
||||
unset($item->DYN_ID);
|
||||
return $item;
|
||||
});
|
||||
|
||||
//test with parameter default
|
||||
$expected = $dynaforms->toArray();
|
||||
|
||||
$processes = new Processes();
|
||||
$actual = $processes->getDynaformRows($proUid);
|
||||
$this->sortArrayByColumn($actual, 'DYN_UID');
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
|
||||
//test with parameter true
|
||||
$expected = $dynaforms->toArray();
|
||||
|
||||
$processes = new Processes();
|
||||
$actual = $processes->getDynaformRows($proUid, true);
|
||||
$this->sortArrayByColumn($actual, 'DYN_UID');
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* This check if the returned input documents are correct with the different
|
||||
* parameters.
|
||||
* @test
|
||||
* @covers \Processes::getInputRows()
|
||||
*/
|
||||
public function it_should_return_input_documents()
|
||||
{
|
||||
$process = factory(Process::class)->create()->first();
|
||||
$proUid = $process->PRO_UID;
|
||||
|
||||
$inputDocument = factory(InputDocument::class, 6)
|
||||
->create([
|
||||
'PRO_UID' => $proUid
|
||||
])
|
||||
->sortBy('INP_DOC_UID')
|
||||
->values();
|
||||
|
||||
//test with parameter false
|
||||
$expected = $inputDocument->toArray();
|
||||
|
||||
$processes = new Processes();
|
||||
$actual = $processes->getInputRows($proUid, false);
|
||||
$this->sortArrayByColumn($actual, 'INP_DOC_UID');
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
|
||||
//by default the mnethod getInputRows removed INP_DOC_ID column
|
||||
$inputDocument->transform(function($item, $key) {
|
||||
unset($item->INP_DOC_ID);
|
||||
return $item;
|
||||
});
|
||||
|
||||
//test with parameter default
|
||||
$expected = $inputDocument->toArray();
|
||||
|
||||
$processes = new Processes();
|
||||
$actual = $processes->getInputRows($proUid);
|
||||
$this->sortArrayByColumn($actual, 'INP_DOC_UID');
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
|
||||
//test with the parameter true
|
||||
$expected = $inputDocument->toArray();
|
||||
|
||||
$processes = new Processes();
|
||||
$actual = $processes->getInputRows($proUid, true);
|
||||
$this->sortArrayByColumn($actual, 'INP_DOC_UID');
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks fi the returned output documents are correct with the differect
|
||||
* parameters.
|
||||
* @test
|
||||
* @covers Processes::getOutputRows()
|
||||
*/
|
||||
public function it_should_return_output_documents()
|
||||
{
|
||||
$process = factory(Process::class)->create()->first();
|
||||
$proUid = $process->PRO_UID;
|
||||
|
||||
$outputDocument = factory(OutputDocument::class, 6)
|
||||
->create([
|
||||
'PRO_UID' => $proUid
|
||||
])
|
||||
->sortBy('OUT_DOC_UID')
|
||||
->values();
|
||||
|
||||
//test with parameter false
|
||||
$expected = $outputDocument->toArray();
|
||||
|
||||
$processes = new Processes();
|
||||
$actual = $processes->getOutputRows($proUid, false);
|
||||
$this->sortArrayByColumn($actual, 'OUT_DOC_UID');
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
|
||||
//by default the method getOutoutRows removed OUT_DOC_ID column
|
||||
$outputDocument->transform(function($item, $key) {
|
||||
unset($item->OUT_DOC_ID);
|
||||
return $item;
|
||||
});
|
||||
|
||||
//test with parameter default
|
||||
$expected = $outputDocument->toArray();
|
||||
|
||||
$processes = new Processes();
|
||||
$actual = $processes->getOutputRows($proUid);
|
||||
$this->sortArrayByColumn($actual, 'OUT_DOC_UID');
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
|
||||
//test with parameter true
|
||||
$expected = $outputDocument->toArray();
|
||||
|
||||
$processes = new Processes();
|
||||
$actual = $processes->getOutputRows($proUid, true);
|
||||
$this->sortArrayByColumn($actual, 'OUT_DOC_UID');
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks if the dynaforms structure is saved with the different parameters.
|
||||
* @test
|
||||
* @covers Processes::createDynaformRows()
|
||||
*/
|
||||
public function it_sholud_create_dynaform()
|
||||
{
|
||||
$faker = Factory::create();
|
||||
$date = $faker->datetime();
|
||||
$proUid = G::generateUniqueID();
|
||||
$expected = [
|
||||
[
|
||||
'DYN_ID' => $faker->unique()->numberBetween(1, 10000000),
|
||||
'DYN_UID' => G::generateUniqueID(),
|
||||
'DYN_TITLE' => $faker->sentence(2),
|
||||
'DYN_DESCRIPTION' => $faker->sentence(5),
|
||||
'PRO_UID' => $proUid,
|
||||
'DYN_TYPE' => 'xmlform',
|
||||
'DYN_FILENAME' => '',
|
||||
'DYN_CONTENT' => '',
|
||||
'DYN_LABEL' => '',
|
||||
'DYN_VERSION' => 2,
|
||||
'DYN_UPDATE_DATE' => $date->format('Y-m-d H:i:s'),
|
||||
'__DYN_ID_UPDATE__' => false,
|
||||
],
|
||||
[
|
||||
'DYN_ID' => $faker->unique()->numberBetween(1, 10000000),
|
||||
'DYN_UID' => G::generateUniqueID(),
|
||||
'DYN_TITLE' => $faker->sentence(2),
|
||||
'DYN_DESCRIPTION' => $faker->sentence(5),
|
||||
'PRO_UID' => $proUid,
|
||||
'DYN_TYPE' => 'xmlform',
|
||||
'DYN_FILENAME' => '',
|
||||
'DYN_CONTENT' => '',
|
||||
'DYN_LABEL' => '',
|
||||
'DYN_VERSION' => 2,
|
||||
'DYN_UPDATE_DATE' => $date->format('Y-m-d H:i:s'),
|
||||
'__DYN_ID_UPDATE__' => false,
|
||||
],
|
||||
];
|
||||
$this->sortArrayByColumn($expected, 'DYN_UID');
|
||||
|
||||
$processes = new Processes();
|
||||
$processes->createDynaformRows($expected);
|
||||
foreach ($expected as &$value) {
|
||||
ksort($value);
|
||||
unset($value['__DYN_ID_UPDATE__']);
|
||||
}
|
||||
|
||||
$dynaforms = Dynaform::getByProUid($proUid)
|
||||
->sortBy('DYN_UID')
|
||||
->values();
|
||||
$dynaforms->transform(function($item, $key) {
|
||||
return (array) $item;
|
||||
});
|
||||
$actual = $dynaforms->toArray();
|
||||
foreach ($actual as $value) {
|
||||
ksort($value);
|
||||
}
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks if the input documents structure is saved with the different
|
||||
* parameters.
|
||||
* @test
|
||||
* @covers Processes::createInputRows()
|
||||
*/
|
||||
public function it_should_create_input_document()
|
||||
{
|
||||
$faker = Factory::create();
|
||||
$date = $faker->datetime();
|
||||
$proUid = G::generateUniqueID();
|
||||
$expected = [
|
||||
[
|
||||
'INP_DOC_UID' => G::generateUniqueID(),
|
||||
'INP_DOC_ID' => $faker->unique()->numberBetween(1, 10000),
|
||||
'PRO_UID' => $proUid,
|
||||
'INP_DOC_TITLE' => $faker->sentence(2),
|
||||
'INP_DOC_DESCRIPTION' => $faker->sentence(10),
|
||||
'INP_DOC_FORM_NEEDED' => 'VIRTUAL',
|
||||
'INP_DOC_ORIGINAL' => 'ORIGINAL',
|
||||
'INP_DOC_PUBLISHED' => 'PRIVATE',
|
||||
'INP_DOC_VERSIONING' => 0,
|
||||
'INP_DOC_DESTINATION_PATH' => '',
|
||||
'INP_DOC_TAGS' => 'INPUT',
|
||||
'INP_DOC_TYPE_FILE' => '.*',
|
||||
'INP_DOC_MAX_FILESIZE' => 0,
|
||||
'INP_DOC_MAX_FILESIZE_UNIT' => 'KB',
|
||||
'__INP_DOC_ID_UPDATE__' => false,
|
||||
],
|
||||
[
|
||||
'INP_DOC_UID' => G::generateUniqueID(),
|
||||
'INP_DOC_ID' => $faker->unique()->numberBetween(1, 10000),
|
||||
'PRO_UID' => $proUid,
|
||||
'INP_DOC_TITLE' => $faker->sentence(2),
|
||||
'INP_DOC_DESCRIPTION' => $faker->sentence(10),
|
||||
'INP_DOC_FORM_NEEDED' => 'VIRTUAL',
|
||||
'INP_DOC_ORIGINAL' => 'ORIGINAL',
|
||||
'INP_DOC_PUBLISHED' => 'PRIVATE',
|
||||
'INP_DOC_VERSIONING' => 0,
|
||||
'INP_DOC_DESTINATION_PATH' => '',
|
||||
'INP_DOC_TAGS' => 'INPUT',
|
||||
'INP_DOC_TYPE_FILE' => '.*',
|
||||
'INP_DOC_MAX_FILESIZE' => 0,
|
||||
'INP_DOC_MAX_FILESIZE_UNIT' => 'KB',
|
||||
'__INP_DOC_ID_UPDATE__' => false,
|
||||
],
|
||||
];
|
||||
$this->sortArrayByColumn($expected, 'INP_DOC_UID');
|
||||
|
||||
$processes = new Processes();
|
||||
$processes->createInputRows($expected);
|
||||
foreach ($expected as &$value) {
|
||||
ksort($value);
|
||||
unset($value['__INP_DOC_ID_UPDATE__']);
|
||||
}
|
||||
|
||||
$inputDocuments = InputDocument::getByProUid($proUid)
|
||||
->sortBy('INP_DOC_UID')
|
||||
->values();
|
||||
$inputDocuments->transform(function($item, $key) {
|
||||
return $item->attributesToArray();
|
||||
});
|
||||
$actual = $inputDocuments->toArray();
|
||||
foreach ($actual as &$value) {
|
||||
ksort($value);
|
||||
}
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks if the output documents structure is saved with the different
|
||||
* parameters.
|
||||
* @test
|
||||
* @covers Processes::createOutputRows()
|
||||
*/
|
||||
public function it_should_create_output_document()
|
||||
{
|
||||
$faker = Factory::create();
|
||||
$date = $faker->datetime();
|
||||
$proUid = G::generateUniqueID();
|
||||
$expected = [
|
||||
[
|
||||
'OUT_DOC_UID' => G::generateUniqueID(),
|
||||
'OUT_DOC_ID' => $faker->unique()->numberBetween(1, 10000),
|
||||
'OUT_DOC_TITLE' => $faker->sentence(2),
|
||||
'OUT_DOC_DESCRIPTION' => $faker->sentence(10),
|
||||
'OUT_DOC_FILENAME' => $faker->sentence(2),
|
||||
'OUT_DOC_TEMPLATE' => '',
|
||||
'PRO_UID' => $proUid,
|
||||
'OUT_DOC_REPORT_GENERATOR' => 'TCPDF',
|
||||
'OUT_DOC_LANDSCAPE' => 0,
|
||||
'OUT_DOC_MEDIA' => 'Letter',
|
||||
'OUT_DOC_LEFT_MARGIN' => 20,
|
||||
'OUT_DOC_RIGHT_MARGIN' => 20,
|
||||
'OUT_DOC_TOP_MARGIN' => 20,
|
||||
'OUT_DOC_BOTTOM_MARGIN' => 20,
|
||||
'OUT_DOC_GENERATE' => 'BOTH',
|
||||
'OUT_DOC_TYPE' => 'HTML',
|
||||
'OUT_DOC_CURRENT_REVISION' => 0,
|
||||
'OUT_DOC_FIELD_MAPPING' => '',
|
||||
'OUT_DOC_VERSIONING' => 1,
|
||||
'OUT_DOC_DESTINATION_PATH' => '',
|
||||
'OUT_DOC_TAGS' => '',
|
||||
'OUT_DOC_PDF_SECURITY_ENABLED' => 0,
|
||||
'OUT_DOC_PDF_SECURITY_OPEN_PASSWORD' => '',
|
||||
'OUT_DOC_PDF_SECURITY_OWNER_PASSWORD' => '',
|
||||
'OUT_DOC_PDF_SECURITY_PERMISSIONS' => '',
|
||||
'OUT_DOC_OPEN_TYPE' => 1,
|
||||
'__OUT_DOC_ID_UPDATE__' => false,
|
||||
],
|
||||
[
|
||||
'OUT_DOC_UID' => G::generateUniqueID(),
|
||||
'OUT_DOC_ID' => $faker->unique()->numberBetween(1, 10000),
|
||||
'OUT_DOC_TITLE' => $faker->sentence(2),
|
||||
'OUT_DOC_DESCRIPTION' => $faker->sentence(10),
|
||||
'OUT_DOC_FILENAME' => $faker->sentence(2),
|
||||
'OUT_DOC_TEMPLATE' => '',
|
||||
'PRO_UID' => $proUid,
|
||||
'OUT_DOC_REPORT_GENERATOR' => 'TCPDF',
|
||||
'OUT_DOC_LANDSCAPE' => 0,
|
||||
'OUT_DOC_MEDIA' => 'Letter',
|
||||
'OUT_DOC_LEFT_MARGIN' => 20,
|
||||
'OUT_DOC_RIGHT_MARGIN' => 20,
|
||||
'OUT_DOC_TOP_MARGIN' => 20,
|
||||
'OUT_DOC_BOTTOM_MARGIN' => 20,
|
||||
'OUT_DOC_GENERATE' => 'BOTH',
|
||||
'OUT_DOC_TYPE' => 'HTML',
|
||||
'OUT_DOC_CURRENT_REVISION' => 0,
|
||||
'OUT_DOC_FIELD_MAPPING' => '',
|
||||
'OUT_DOC_VERSIONING' => 1,
|
||||
'OUT_DOC_DESTINATION_PATH' => '',
|
||||
'OUT_DOC_TAGS' => '',
|
||||
'OUT_DOC_PDF_SECURITY_ENABLED' => 0,
|
||||
'OUT_DOC_PDF_SECURITY_OPEN_PASSWORD' => '',
|
||||
'OUT_DOC_PDF_SECURITY_OWNER_PASSWORD' => '',
|
||||
'OUT_DOC_PDF_SECURITY_PERMISSIONS' => '',
|
||||
'OUT_DOC_OPEN_TYPE' => 1,
|
||||
'__OUT_DOC_ID_UPDATE__' => false,
|
||||
]
|
||||
];
|
||||
$this->sortArrayByColumn($expected, 'OUT_DOC_UID');
|
||||
|
||||
$processes = new Processes();
|
||||
$processes->createOutputRows($expected);
|
||||
foreach ($expected as &$value) {
|
||||
ksort($value);
|
||||
unset($value['__OUT_DOC_ID_UPDATE__']);
|
||||
}
|
||||
|
||||
$outputDocuments = OutputDocument::getByProUid($proUid)
|
||||
->sortBy('OUT_DOC_UID')
|
||||
->values();
|
||||
$outputDocuments->transform(function($item, $key) {
|
||||
return $item->attributestoArray();
|
||||
});
|
||||
$actual = $outputDocuments->toArray();
|
||||
foreach ($actual as &$value) {
|
||||
ksort($value);
|
||||
}
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
}
|
||||
@@ -9,16 +9,17 @@ 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()
|
||||
{
|
||||
$this->markTestIncomplete();//@todo: Please correct this unit test
|
||||
$_SERVER["REQUEST_URI"] = "";
|
||||
}
|
||||
|
||||
|
||||
69
tests/unit/workflow/engine/classes/SpoolRunTest.php
Normal file
69
tests/unit/workflow/engine/classes/SpoolRunTest.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
use Faker\Factory;
|
||||
use Tests\TestCase;
|
||||
|
||||
class SpoolRunTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Constructor of the class.
|
||||
*/
|
||||
public function __construct($name = null, array $data = [], $dataName = '')
|
||||
{
|
||||
parent::__construct($name, $data, $dataName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if "envelope_cc" and "envelope_bcc" was set correctly in consecutive calls
|
||||
*
|
||||
* @covers SpoolRun::setData()
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_should_check_if_cc_and_bcc_set_correctly_in_consecutive_calls()
|
||||
{
|
||||
// Initializing Faker instance
|
||||
$faker = Factory::create();
|
||||
|
||||
// Instancing SpoolRun class
|
||||
$spoolRun = new SpoolRun();
|
||||
|
||||
// Set a first set of data
|
||||
$spoolRun->setData(
|
||||
G::generateUniqueID(),
|
||||
$faker->words(3, true),
|
||||
$faker->companyEmail,
|
||||
$faker->freeEmail,
|
||||
$faker->text(),
|
||||
$faker->dateTime()->format('Y-m-d H:i:s'),
|
||||
$faker->companyEmail,
|
||||
$faker->freeEmail
|
||||
);
|
||||
|
||||
// Build the "to", "cc" an "bcc" values
|
||||
$spoolRun->runHandleEnvelopeTo();
|
||||
|
||||
// Set a second set of data
|
||||
$spoolRun->setData(
|
||||
G::generateUniqueID(),
|
||||
$faker->words(3, true),
|
||||
$faker->companyEmail,
|
||||
$faker->freeEmail,
|
||||
$faker->text(),
|
||||
$faker->dateTime()->format('Y-m-d H:i:s'),
|
||||
$faker->companyEmail,
|
||||
$faker->freeEmail
|
||||
);
|
||||
|
||||
// Build the "to", "cc" an "bcc" values
|
||||
$spoolRun->runHandleEnvelopeTo();
|
||||
|
||||
// Get data to check
|
||||
$fileData = $spoolRun->getFileData();
|
||||
|
||||
// Asserts
|
||||
$this->assertCount(1, $fileData['envelope_to']);
|
||||
$this->assertCount(1, $fileData['envelope_cc']);
|
||||
$this->assertCount(1, $fileData['envelope_bcc']);
|
||||
}
|
||||
}
|
||||
484
tests/unit/workflow/engine/classes/WsBaseTest.php
Normal file
484
tests/unit/workflow/engine/classes/WsBaseTest.php
Normal file
@@ -0,0 +1,484 @@
|
||||
<?php
|
||||
|
||||
use App\Jobs\EmailEvent;
|
||||
use Faker\Factory;
|
||||
use Illuminate\Support\Facades\Queue;
|
||||
use ProcessMaker\Model\Application;
|
||||
use ProcessMaker\Model\EmailServer;
|
||||
use ProcessMaker\Model\Process;
|
||||
use ProcessMaker\Model\Task;
|
||||
use ProcessMaker\Model\User;
|
||||
use Tests\CreateTestSite;
|
||||
use Tests\TestCase;
|
||||
|
||||
class WsBaseTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* This trait allows obtaining a test site that makes use of the database
|
||||
* mentioned for the test.
|
||||
*/
|
||||
use CreateTestSite;
|
||||
|
||||
public function __construct($name = null, array $data = [], $dataName = '')
|
||||
{
|
||||
parent::__construct($name, $data, $dataName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up the fixture, for example, opens a network connection.
|
||||
* This method is called before a test is executed.
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->timezone = config('app.timezone');
|
||||
$_SESSION['USR_TIME_ZONE'] = $this->timezone;
|
||||
$this->baseUri = $this->getBaseUri();
|
||||
$this->user = 'admin';
|
||||
$this->password = 'admin';
|
||||
$this->workspace = env("DB_DATABASE", "test");
|
||||
$this->createTestSite();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tears down the fixture, for example, closes a network connection.
|
||||
* This method is called after a test is executed.
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an application.
|
||||
*
|
||||
* @param int $applicationNumber
|
||||
* @return \stdClass
|
||||
*/
|
||||
private function createNewCase($applicationNumber = null)
|
||||
{
|
||||
if (empty($applicationNumber)) {
|
||||
$faker = Factory::create();
|
||||
$applicationNumber = $faker->unique()->numberBetween(1, 10000000);
|
||||
}
|
||||
$userUid = G::generateUniqueID();
|
||||
$processUid = G::generateUniqueID();
|
||||
$taskUid = G::generateUniqueID();
|
||||
$applicationUid = G::generateUniqueID();
|
||||
|
||||
$appData = [
|
||||
'SYS_LANG' => 'en',
|
||||
'SYS_SKIN' => 'neoclassic',
|
||||
'SYS_SYS' => 'workflow',
|
||||
'APPLICATION' => G::generateUniqueID(),
|
||||
'PROCESS' => G::generateUniqueID(),
|
||||
'TASK' => '',
|
||||
'INDEX' => 2,
|
||||
'USER_LOGGED' => $userUid,
|
||||
'USR_USERNAME' => 'admin',
|
||||
'APP_NUMBER' => $applicationNumber,
|
||||
'PIN' => '97ZN'
|
||||
];
|
||||
|
||||
$user = factory(User::class)->create([
|
||||
'USR_UID' => $userUid
|
||||
]);
|
||||
|
||||
$process = factory(Process::class)->create([
|
||||
'PRO_UID' => $processUid
|
||||
]);
|
||||
|
||||
$task = factory(Task::class)->create([
|
||||
'PRO_UID' => $process->PRO_UID
|
||||
]);
|
||||
|
||||
$application = factory(Application::class)->create([
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'APP_UID' => $applicationUid,
|
||||
'APP_NUMBER' => $applicationNumber,
|
||||
'APP_DATA' => serialize($appData)
|
||||
]);
|
||||
|
||||
$result = new stdClass();
|
||||
$result->userUid = $userUid;
|
||||
$result->processUid = $processUid;
|
||||
$result->taskUid = $taskUid;
|
||||
$result->applicationUid = $applicationUid;
|
||||
$result->applicationNumber = $applicationNumber;
|
||||
$result->appData = $appData;
|
||||
$result->user = $user;
|
||||
$result->process = $process;
|
||||
$result->task = $task;
|
||||
$result->application = $application;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a email server configuration.
|
||||
*
|
||||
* @return ProcessMaker\Model\EmailServer;
|
||||
*/
|
||||
private function createEmailServer()
|
||||
{
|
||||
$passwordEnv = env('emailAccountPassword');
|
||||
$password = G::encrypt("hash:" . $passwordEnv, 'EMAILENCRYPT');
|
||||
$emailServer = factory(EmailServer::class)->create([
|
||||
'MESS_ENGINE' => env('emailEngine'),
|
||||
'MESS_SERVER' => env('emailServer'),
|
||||
'MESS_PORT' => env('emailPort'),
|
||||
'MESS_INCOMING_SERVER' => '',
|
||||
'MESS_INCOMING_PORT' => 0,
|
||||
'MESS_RAUTH' => 1,
|
||||
'MESS_ACCOUNT' => env('emailAccount'),
|
||||
'MESS_PASSWORD' => $password,
|
||||
'MESS_FROM_MAIL' => env('emailAccount'),
|
||||
'MESS_FROM_NAME' => '',
|
||||
'SMTPSECURE' => 'ssl',
|
||||
'MESS_TRY_SEND_INMEDIATLY' => 1,
|
||||
'MAIL_TO' => $password,
|
||||
'MESS_DEFAULT' => 1,
|
||||
]);
|
||||
return $emailServer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new template for send email.
|
||||
*
|
||||
* @param string $proUid
|
||||
* @param string $usrUid
|
||||
* @return \ProcessMaker\Model\ProcessFiles
|
||||
*/
|
||||
private function createTemplate($proUid, $usrUid)
|
||||
{
|
||||
$path1 = PATH_DATA . "sites" . PATH_SEP . config("system.workspace") . PATH_SEP . "mailTemplates" . PATH_SEP . "{$proUid}";
|
||||
mkdir($path1);
|
||||
$path2 = $path1 . PATH_SEP . "emailEvent_" . G::generateUniqueID() . ".html";
|
||||
|
||||
$htmlContent = $this->createDefaultHtmlContent('Test');
|
||||
file_put_contents($path2, $htmlContent);
|
||||
|
||||
$template = factory(\ProcessMaker\Model\ProcessFiles::class)->create([
|
||||
'PRO_UID' => $proUid,
|
||||
'USR_UID' => $usrUid,
|
||||
'PRF_PATH' => $path2
|
||||
]);
|
||||
return $template;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create empty html.
|
||||
*
|
||||
* @param string $content
|
||||
* @return string
|
||||
*/
|
||||
private function createDefaultHtmlContent($content = '')
|
||||
{
|
||||
$string = ''
|
||||
. '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
|
||||
. '<html>'
|
||||
. '<head>'
|
||||
. '</head>'
|
||||
. '<body>'
|
||||
. $content
|
||||
. '</body>'
|
||||
. '</html>';
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* This represents a collection of "messageType" for queue elements.
|
||||
*/
|
||||
public function messageTypesWithQueue()
|
||||
{
|
||||
return [
|
||||
[WsBase::MESSAGE_TYPE_EMAIL_EVENT],
|
||||
[WsBase::MESSAGE_TYPE_PM_FUNCTION],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* This represents a collection of "messageType" for no queueable elements.
|
||||
*/
|
||||
public function messageTypesWithoutQueue()
|
||||
{
|
||||
return [
|
||||
[WsBase::MESSAGE_TYPE_ACTIONS_BY_EMAIL],
|
||||
[WsBase::MESSAGE_TYPE_CASE_NOTE],
|
||||
[WsBase::MESSAGE_TYPE_EXTERNAL_REGISTRATION],
|
||||
[WsBase::MESSAGE_TYPE_RETRIEVE_PASSWORD],
|
||||
[WsBase::MESSAGE_TYPE_SOAP],
|
||||
[WsBase::MESSAGE_TYPE_TASK_NOTIFICATION],
|
||||
[WsBase::MESSAGE_TYPE_TEST_EMAIL],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* This should send an email of types elements to the work queue jobs.
|
||||
* Queue-fake has been used, see more at: https://laravel.com/docs/5.7/mocking#queue-fake
|
||||
* @test
|
||||
* @dataProvider messageTypesWithQueue
|
||||
* @covers WsBase::sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $template, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType)
|
||||
*/
|
||||
public function it_should_send_an_sendMessage_with_queue_jobs($messageType)
|
||||
{
|
||||
//data
|
||||
$emailServer = $this->createEmailServer();
|
||||
$case = $this->createNewCase();
|
||||
$template = $this->createTemplate($case->process->PRO_UID, $case->user->USR_UID);
|
||||
|
||||
//parameters
|
||||
$appUid = $case->applicationUid;
|
||||
$from = $emailServer->MESS_ACCOUNT;
|
||||
$to = $emailServer->MESS_ACCOUNT;
|
||||
$cc = "";
|
||||
$bcc = "";
|
||||
$subject = "test";
|
||||
$templateName = basename($template->PRF_PATH);
|
||||
$appFields = [];
|
||||
$attachment = [];
|
||||
$showMessage = true;
|
||||
$delIndex = 0;
|
||||
$config = $emailServer->toArray();
|
||||
$gmail = 0;
|
||||
$appMsgType = $messageType;
|
||||
|
||||
//assertions
|
||||
Queue::fake();
|
||||
Queue::assertNothingPushed();
|
||||
|
||||
$wsBase = new WsBase();
|
||||
$wsBase->sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $templateName, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType);
|
||||
Queue::assertPushed(EmailEvent::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* This should send an email of types elements without work queue jobs.
|
||||
* Queue-fake has been used, see more at: https://laravel.com/docs/5.7/mocking#queue-fake
|
||||
* @test
|
||||
* @dataProvider messageTypesWithoutQueue
|
||||
* @covers WsBase::sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $template, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType)
|
||||
*/
|
||||
public function it_should_execute_an_sendMessage_without_queue_jobs($messageTypes)
|
||||
{
|
||||
//data
|
||||
$emailServer = $this->createEmailServer();
|
||||
$case = $this->createNewCase();
|
||||
$template = $this->createTemplate($case->process->PRO_UID, $case->user->USR_UID);
|
||||
|
||||
//parameters
|
||||
$appUid = $case->applicationUid;
|
||||
$from = $emailServer->MESS_ACCOUNT;
|
||||
$to = "";
|
||||
$cc = "";
|
||||
$bcc = "";
|
||||
$subject = "test";
|
||||
$templateName = basename($template->PRF_PATH);
|
||||
$appFields = [];
|
||||
$attachment = [];
|
||||
$showMessage = true;
|
||||
$delIndex = 0;
|
||||
$config = $emailServer->toArray();
|
||||
$gmail = 0;
|
||||
$appMsgType = $messageTypes;
|
||||
|
||||
//assertions
|
||||
Queue::fake();
|
||||
Queue::assertNothingPushed();
|
||||
|
||||
$wsBase = new WsBase();
|
||||
$wsBase->sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $templateName, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType);
|
||||
Queue::assertNotPushed(EmailEvent::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* It should send an sendMessage with queue jobs and empty config parameter.
|
||||
* @test
|
||||
* @dataProvider messageTypesWithQueue
|
||||
* @covers WsBase::sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $template, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType)
|
||||
*/
|
||||
public function it_should_send_an_sendMessage_with_queue_jobs_and_empty_config_parameter($messageTypes)
|
||||
{
|
||||
//data
|
||||
$emailServer = $this->createEmailServer();
|
||||
$case = $this->createNewCase();
|
||||
$template = $this->createTemplate($case->process->PRO_UID, $case->user->USR_UID);
|
||||
|
||||
//parameters
|
||||
$appUid = $case->applicationUid;
|
||||
$from = $emailServer->MESS_ACCOUNT;
|
||||
$to = $emailServer->MESS_ACCOUNT;
|
||||
$cc = "";
|
||||
$bcc = "";
|
||||
$subject = "test";
|
||||
$templateName = basename($template->PRF_PATH);
|
||||
$appFields = [];
|
||||
$attachment = [];
|
||||
$showMessage = true;
|
||||
$delIndex = 0;
|
||||
$config = []; //with empty configuration
|
||||
$gmail = 0;
|
||||
$appMsgType = $messageTypes;
|
||||
|
||||
//assertions
|
||||
Queue::fake();
|
||||
Queue::assertNothingPushed();
|
||||
|
||||
$wsBase = new WsBase();
|
||||
$wsBase->sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $templateName, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType);
|
||||
Queue::assertPushed(EmailEvent::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* It should send an sendMessage without queue jobs and empty config parameter.
|
||||
* @test
|
||||
* @dataProvider messageTypesWithoutQueue
|
||||
* @covers WsBase::sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $template, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType)
|
||||
*/
|
||||
public function it_should_send_an_sendMessage_without_queue_jobs_and_empty_config_parameter($messageTypes)
|
||||
{
|
||||
//data
|
||||
$emailServer = $this->createEmailServer();
|
||||
$case = $this->createNewCase();
|
||||
$template = $this->createTemplate($case->process->PRO_UID, $case->user->USR_UID);
|
||||
|
||||
//parameters
|
||||
$appUid = $case->applicationUid;
|
||||
$from = $emailServer->MESS_ACCOUNT;
|
||||
$to = "";
|
||||
$cc = "";
|
||||
$bcc = "";
|
||||
$subject = "test";
|
||||
$templateName = basename($template->PRF_PATH);
|
||||
$appFields = [];
|
||||
$attachment = [];
|
||||
$showMessage = true;
|
||||
$delIndex = 0;
|
||||
$config = []; //with empty configuration
|
||||
$gmail = 0;
|
||||
$appMsgType = $messageTypes;
|
||||
|
||||
//assertions
|
||||
Queue::fake();
|
||||
Queue::assertNothingPushed();
|
||||
|
||||
$wsBase = new WsBase();
|
||||
$wsBase->sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $templateName, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType);
|
||||
Queue::assertNotPushed(EmailEvent::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* It should send an sendMessage with queue jobs and config parameter like id.
|
||||
* @test
|
||||
* @dataProvider messageTypesWithQueue
|
||||
* @covers WsBase::sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $template, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType)
|
||||
*/
|
||||
public function it_should_send_an_sendMessage_with_queue_jobs_and_config_parameter_like_id($messageTypes)
|
||||
{
|
||||
//data
|
||||
$emailServer = $this->createEmailServer();
|
||||
$case = $this->createNewCase();
|
||||
$template = $this->createTemplate($case->process->PRO_UID, $case->user->USR_UID);
|
||||
|
||||
//parameters
|
||||
$appUid = $case->applicationUid;
|
||||
$from = $emailServer->MESS_ACCOUNT;
|
||||
$to = $emailServer->MESS_ACCOUNT;
|
||||
$cc = "";
|
||||
$bcc = "";
|
||||
$subject = "test";
|
||||
$templateName = basename($template->PRF_PATH);
|
||||
$appFields = [];
|
||||
$attachment = [];
|
||||
$showMessage = true;
|
||||
$delIndex = 0;
|
||||
$config = $emailServer->MESS_UID; //With a valid Email Server Uid
|
||||
$gmail = 0;
|
||||
$appMsgType = $messageTypes;
|
||||
|
||||
//assertions
|
||||
Queue::fake();
|
||||
Queue::assertNothingPushed();
|
||||
|
||||
$wsBase = new WsBase();
|
||||
$wsBase->sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $templateName, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType);
|
||||
Queue::assertPushed(EmailEvent::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* It should send an sendMessage without queue jobs and config parameter like id.
|
||||
* @test
|
||||
* @dataProvider messageTypesWithoutQueue
|
||||
* @covers WsBase::sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $template, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType)
|
||||
*/
|
||||
public function it_should_send_an_sendMessage_without_queue_jobs_and_config_parameter_like_id($messageTypes)
|
||||
{
|
||||
//data
|
||||
$emailServer = $this->createEmailServer();
|
||||
$case = $this->createNewCase();
|
||||
$template = $this->createTemplate($case->process->PRO_UID, $case->user->USR_UID);
|
||||
|
||||
//parameters
|
||||
$appUid = $case->applicationUid;
|
||||
$from = $emailServer->MESS_ACCOUNT;
|
||||
$to = "";
|
||||
$cc = "";
|
||||
$bcc = "";
|
||||
$subject = "test";
|
||||
$templateName = basename($template->PRF_PATH);
|
||||
$appFields = [];
|
||||
$attachment = [];
|
||||
$showMessage = true;
|
||||
$delIndex = 0;
|
||||
$config = $emailServer->MESS_UID; //With a valid Email Server Uid
|
||||
$gmail = 0;
|
||||
$appMsgType = $messageTypes;
|
||||
|
||||
//assertions
|
||||
Queue::fake();
|
||||
Queue::assertNothingPushed();
|
||||
|
||||
$wsBase = new WsBase();
|
||||
$wsBase->sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $templateName, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType);
|
||||
Queue::assertNotPushed(EmailEvent::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* It should send an sendMessage without queue jobs and gmail parameter like one.
|
||||
* @test
|
||||
* @dataProvider messageTypesWithoutQueue
|
||||
* @covers WsBase::sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $template, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType)
|
||||
*/
|
||||
public function it_should_send_an_sendMessage_without_queue_jobs_and_gmail_parameter_like_one($messageTypes)
|
||||
{
|
||||
//data
|
||||
$emailServer = $this->createEmailServer();
|
||||
$case = $this->createNewCase();
|
||||
$template = $this->createTemplate($case->process->PRO_UID, $case->user->USR_UID);
|
||||
|
||||
//parameters
|
||||
$appUid = $case->applicationUid;
|
||||
$from = $emailServer->MESS_ACCOUNT;
|
||||
$to = "";
|
||||
$cc = "";
|
||||
$bcc = "";
|
||||
$subject = "test";
|
||||
$templateName = basename($template->PRF_PATH);
|
||||
$appFields = [];
|
||||
$attachment = [];
|
||||
$showMessage = true;
|
||||
$delIndex = 0;
|
||||
$config = $emailServer->MESS_UID;
|
||||
$gmail = 1; //GMail flag enabled
|
||||
$appMsgType = $messageTypes;
|
||||
|
||||
//assertions
|
||||
Queue::fake();
|
||||
Queue::assertNothingPushed();
|
||||
|
||||
$wsBase = new WsBase();
|
||||
$wsBase->sendMessage($appUid, $from, $to, $cc, $bcc, $subject, $templateName, $appFields, $attachment, $showMessage, $delIndex, $config, $gmail, $appMsgType);
|
||||
Queue::assertNotPushed(EmailEvent::class);
|
||||
}
|
||||
}
|
||||
41
tests/unit/workflow/engine/classes/model/IsoCountryTest.php
Normal file
41
tests/unit/workflow/engine/classes/model/IsoCountryTest.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\classes\model;
|
||||
|
||||
use IsoCountry;
|
||||
use Tests\TestCase;
|
||||
|
||||
class IsoCountryTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* It tests the search for an isocountry
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_should_search_for_an_iso_country()
|
||||
{
|
||||
//Call the findById method
|
||||
$res = IsoCountry::findById('BO');
|
||||
//Assert the result is the expected
|
||||
$this->assertEquals('Bolivia', $res['IC_NAME']);
|
||||
|
||||
//Call the findById method
|
||||
$res = IsoCountry::findById('DE');
|
||||
//Assert the result is the expected
|
||||
$this->assertEquals('Germany', $res['IC_NAME']);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the result is null if the country does not exist
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_should_return_null_if_the_country_does_not_exist()
|
||||
{
|
||||
//Call the findById method
|
||||
$res = IsoCountry::findById('ZZ');
|
||||
//Assert the result is null
|
||||
$this->assertNull($res);
|
||||
}
|
||||
}
|
||||
41
tests/unit/workflow/engine/classes/model/IsoLocationTest.php
Normal file
41
tests/unit/workflow/engine/classes/model/IsoLocationTest.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\classes\model;
|
||||
|
||||
use IsoLocation;
|
||||
use Tests\TestCase;
|
||||
|
||||
class IsoLocationTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* It tests the search for an iso location
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_should_search_for_an_iso_location()
|
||||
{
|
||||
//Call the findById method
|
||||
$res = IsoLocation::findById('BO', 'C', 'CBB');
|
||||
//Assert the result is the expected
|
||||
$this->assertEquals('Cochabamba', $res['IL_NAME']);
|
||||
|
||||
//Call the findById method
|
||||
$res = IsoLocation::findById('DE', 'NW', 'DUN');
|
||||
//Assert the result is the expected
|
||||
$this->assertEquals('Dulmen', $res['IL_NAME']);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the result is null if the location does not exist
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_should_return_null_if_the_location_does_not_exist()
|
||||
{
|
||||
//Call the findById method
|
||||
$res = IsoLocation::findById('ZZ', 'ZZ', 'ZZ');
|
||||
//Assert the result is null
|
||||
$this->assertNull($res);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\classes\model;
|
||||
|
||||
use IsoSubdivision;
|
||||
use Tests\TestCase;
|
||||
|
||||
class IsoSubdivisionTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* It tests the search for an iso subdivision
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_should_search_for_an_iso_subdivision()
|
||||
{
|
||||
//Call the findById method
|
||||
$res = IsoSubdivision::findById('BO', 'L');
|
||||
//Assert the result is the expected
|
||||
$this->assertEquals('La Paz', $res['IS_NAME']);
|
||||
|
||||
//Call the findById method
|
||||
$res = IsoSubdivision::findById('DE', 'BE');
|
||||
//Assert the result is the expected
|
||||
$this->assertEquals('Berlin', $res['IS_NAME']);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the result is null if the subdivision does not exist
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_should_return_null_if_the_subdivision_does_not_exist()
|
||||
{
|
||||
//Call the findById method
|
||||
$res = IsoSubdivision::findById('ZZ', 'ZZ');
|
||||
//Assert the result is null
|
||||
$this->assertNull($res);
|
||||
}
|
||||
}
|
||||
71
tests/unit/workflow/engine/methods/users/UsersAjaxTest.php
Normal file
71
tests/unit/workflow/engine/methods/users/UsersAjaxTest.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\methods\users;
|
||||
|
||||
use ProcessMaker\Model\Configuration;
|
||||
use ProcessMaker\Model\User;
|
||||
use RBAC;
|
||||
use Tests\TestCase;
|
||||
|
||||
class UsersAjaxTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Set up the deprecated errors
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the user ajax file with the userData action
|
||||
* @test
|
||||
*/
|
||||
public function it_tests_the_user_ajax_file()
|
||||
{
|
||||
//Declare the global variable
|
||||
global $RBAC;
|
||||
//Creates the user factory
|
||||
$user = factory(User::class)->create();
|
||||
//Creates the configuration factory
|
||||
factory(Configuration::class)->create([
|
||||
'CFG_UID' => 'USER_PREFERENCES',
|
||||
'OBJ_UID' => '',
|
||||
'CFG_VALUE' => 'a:3:{s:12:"DEFAULT_LANG";s:0:"";s:12:"DEFAULT_MENU";s:8:"PM_SETUP";s:18:"DEFAULT_CASES_MENU";s:0:"";}',
|
||||
'PRO_UID' => '',
|
||||
'USR_UID' => $user['USR_UID'],
|
||||
'APP_UID' => '',
|
||||
]);
|
||||
|
||||
//Sets the needed variables
|
||||
$_SESSION['USER_LOGGED'] = $user['USR_UID'];
|
||||
$_POST['action'] = 'userData';
|
||||
$_POST['USR_UID'] = $user['USR_UID'];
|
||||
$RBAC = RBAC::getSingleton(PATH_DATA, session_id());
|
||||
$RBAC->initRBAC();
|
||||
$RBAC->loadUserRolePermission('PROCESSMAKER', $_SESSION['USER_LOGGED']);
|
||||
|
||||
//Turn on output buffering
|
||||
ob_start();
|
||||
|
||||
//Call the tested file
|
||||
require_once PATH_TRUNK . PATH_SEP . 'workflow/engine/methods/users/usersAjax.php';
|
||||
|
||||
//Return the contents of the output buffer
|
||||
$outputBuffer = ob_get_contents();
|
||||
//Clean the output buffer and turn off output buffering
|
||||
ob_end_clean();
|
||||
|
||||
//Decode the JSON string
|
||||
$res = json_decode($outputBuffer);
|
||||
|
||||
//Assert the call was success
|
||||
$this->assertTrue($res->success);
|
||||
//Assert the result corresponds to the user logged
|
||||
$this->assertEquals($user['USR_UID'], $res->user->USR_UID);
|
||||
//Assert the default menu is set
|
||||
$this->assertEquals('PM_EDIT_USER_PROFILE_DEFAULT_MAIN_MENU_OPTIONS',
|
||||
$res->permission->PREF_DEFAULT_MENUSELECTED);
|
||||
}
|
||||
}
|
||||
@@ -38,12 +38,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());
|
||||
}
|
||||
|
||||
@@ -99,8 +93,16 @@ class GroupTest extends TestCase
|
||||
*/
|
||||
public function testGetUsersAvailable($groupUid)
|
||||
{
|
||||
$result = \ProcessMaker\Model\User::where('USERS.USR_STATUS', '<>', 'CLOSED')
|
||||
->whereNotIn('USERS.USR_UID', function($query) {
|
||||
$query->select('GROUP_USER.USR_UID')
|
||||
->from('GROUP_USER');
|
||||
})
|
||||
->whereNotIn('USERS.USR_UID', ['00000000000000000000000000000002'])
|
||||
->get()
|
||||
->toArray();
|
||||
$response = $this->getInstanceGroup()->getUsers('AVAILABLE-USERS', $groupUid);
|
||||
$this->assertCount(1, $response);
|
||||
$this->assertCount(count($result), $response);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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,36 @@ class LanguageTest extends \WorkflowTestCase
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
$this->setupDB();
|
||||
$this->markTestIncomplete();//@todo: Please correct this unit test
|
||||
$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 +63,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 +78,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 +105,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 +120,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,8 @@ class SkinsTest extends \WorkflowTestCase
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
$this->cleanShared();
|
||||
$this->setupDB();
|
||||
$this->object = new Skins;
|
||||
parent::setUp();
|
||||
$this->object = new Skins();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -27,8 +29,9 @@ class SkinsTest extends \WorkflowTestCase
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
$this->cleanShared();
|
||||
$this->dropDB();
|
||||
parent::tearDown();
|
||||
G::rm_dir(PATH_DATA . 'skins');
|
||||
mkdir(PATH_DATA . 'skins');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,12 +64,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,151 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\Core;
|
||||
|
||||
use Tests\TestCase;
|
||||
|
||||
class JobsManagerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var JobsManager
|
||||
*/
|
||||
protected $object;
|
||||
|
||||
/**
|
||||
* Sets up the fixture, for example, opens a network connection.
|
||||
* This method is called before a test is executed.
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->object = new JobsManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tears down the fixture, for example, closes a network connection.
|
||||
* This method is called after a test is executed.
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* This should return the configured value of delay in env.ini
|
||||
*
|
||||
* @test
|
||||
* @covers ProcessMaker\Core\JobsManager::getDelay
|
||||
*/
|
||||
public function testGetDelay()
|
||||
{
|
||||
$this->object->init();
|
||||
$actual = $this->object->getDelay();
|
||||
|
||||
$envs = System::getSystemConfiguration('', '', config("system.workspace"));
|
||||
|
||||
$this->assertEquals($envs['delay'], $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* This should return the configured value of tries in env.ini
|
||||
*
|
||||
* @test
|
||||
* @covers ProcessMaker\Core\JobsManager::getTries
|
||||
*/
|
||||
public function testGetTries()
|
||||
{
|
||||
$this->object->init();
|
||||
$actual = $this->object->getTries();
|
||||
|
||||
$envs = System::getSystemConfiguration('', '', config("system.workspace"));
|
||||
|
||||
$this->assertEquals($envs['tries'], $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* This should return the configured value of retry_after in env.ini
|
||||
*
|
||||
* @test
|
||||
* @covers ProcessMaker\Core\JobsManager::getRetryAfter
|
||||
*/
|
||||
public function testGetRetryAfter()
|
||||
{
|
||||
$this->object->init();
|
||||
$actual = $this->object->getRetryAfter();
|
||||
|
||||
$envs = System::getSystemConfiguration('', '', config("system.workspace"));
|
||||
|
||||
$this->assertEquals($envs['retry_after'], $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* This returns a single instance of the object (this is a singleton).
|
||||
* @test
|
||||
* @covers ProcessMaker\Core\JobsManager::getSingleton
|
||||
*/
|
||||
public function testGetSingleton()
|
||||
{
|
||||
$object1 = $this->object->getSingleton();
|
||||
$this->assertEquals($this->object, $object1);
|
||||
|
||||
$object2 = $this->object->getSingleton();
|
||||
$this->assertEquals($this->object, $object2);
|
||||
}
|
||||
|
||||
/**
|
||||
* If the object was started correctly returns the instance of this object.
|
||||
*
|
||||
* @test
|
||||
* @covers ProcessMaker\Core\JobsManager::init
|
||||
*/
|
||||
public function testInit()
|
||||
{
|
||||
$actual = $this->object->init();
|
||||
|
||||
$this->assertEquals($this->object, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* This must return the instance of the object that prepares the work for dispatch.
|
||||
*
|
||||
* @test
|
||||
* @covers ProcessMaker\Core\JobsManager::dispatch
|
||||
*/
|
||||
public function testDispatch()
|
||||
{
|
||||
$callback = function() {
|
||||
};
|
||||
|
||||
$actual = $this->object->dispatch('Email', $callback);
|
||||
|
||||
$this->assertInstanceOf(\Illuminate\Foundation\Bus\PendingDispatch::class, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* This gets the value of the option specified in the second parameter from an
|
||||
* array that represents the arguments.
|
||||
*
|
||||
* @test
|
||||
* @covers ProcessMaker\Core\JobsManager::getOptionValueFromArguments
|
||||
*/
|
||||
public function testGetOptionValueFromArguments()
|
||||
{
|
||||
$optionName = "--workspace";
|
||||
$valueOption = "workflow";
|
||||
$allocationSeparator = "=";
|
||||
|
||||
$parameter0 = "queue:work";
|
||||
$parameter1 = $optionName . $allocationSeparator . $valueOption;
|
||||
|
||||
$arguments = [$parameter0, $parameter1];
|
||||
|
||||
$actual = $this->object->getOptionValueFromArguments($arguments, $optionName);
|
||||
$this->assertEquals($valueOption, $actual);
|
||||
|
||||
$actual = $this->object->getOptionValueFromArguments($arguments, $optionName, $allocationSeparator);
|
||||
$this->assertEquals($valueOption, $actual);
|
||||
|
||||
$actual = $this->object->getOptionValueFromArguments($arguments, "missing");
|
||||
$this->assertEquals(false, $actual);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?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()
|
||||
{
|
||||
$this->markTestIncomplete();//@todo: Please correct this unit test
|
||||
$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'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,539 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\src\ProcessMaker\Importer;
|
||||
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use ProcessMaker\Importer\Importer;
|
||||
use ProcessMaker\Model\BpmnProject;
|
||||
use ProcessMaker\Model\Process;
|
||||
use ReflectionClass;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ImporterTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
/**
|
||||
* Declared to avoid the incompatibility exception
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
$this->markTestIncomplete();//@todo: Please correct this unit test
|
||||
error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets protected property on an object using reflection
|
||||
*
|
||||
* @param object $object
|
||||
* @param string $property
|
||||
* @param array $value
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function setProtectedProperty($object, $property, $value)
|
||||
{
|
||||
$reflection = new ReflectionClass($object);
|
||||
$reflection_property = $reflection->getProperty($property);
|
||||
$reflection_property->setAccessible(true);
|
||||
$reflection_property->setValue($object, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the import method when importing a process with a new uid
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_the_import_method_when_importing_a_process_with_a_new_uid()
|
||||
{
|
||||
// Create the existing process
|
||||
$process = factory(Process::class)->create(
|
||||
['PRO_CREATE_DATE' => '2019-07-10 10:00:00']
|
||||
);
|
||||
|
||||
// Mock the abstract class
|
||||
$importer = $this
|
||||
->getMockBuilder('ProcessMaker\Importer\Importer')
|
||||
->getMockForAbstractClass();
|
||||
|
||||
// create the array that will be passed to the load method
|
||||
$array = [];
|
||||
|
||||
$array["files"]["workflow"] = [];
|
||||
|
||||
$array['tables'] = [
|
||||
'bpmn' =>
|
||||
[
|
||||
'activity' =>
|
||||
[],
|
||||
'artifact' =>
|
||||
[],
|
||||
'bound' =>
|
||||
[],
|
||||
'data' =>
|
||||
[],
|
||||
'diagram' =>
|
||||
[
|
||||
0 =>
|
||||
[
|
||||
'dia_uid' => '9367735405d247f616ed440021337333',
|
||||
'prj_uid' => $process['PRO_UID'],
|
||||
'dia_name' => 'Custom',
|
||||
'dia_is_closable' => '0',
|
||||
|
||||
],
|
||||
],
|
||||
'documentation' =>
|
||||
[],
|
||||
'event' =>
|
||||
[],
|
||||
'extension' =>
|
||||
[],
|
||||
'flow' =>
|
||||
[],
|
||||
'gateway' =>
|
||||
[],
|
||||
'lane' =>
|
||||
[],
|
||||
'laneset' =>
|
||||
[],
|
||||
'participant' =>
|
||||
[],
|
||||
'process' =>
|
||||
[
|
||||
0 =>
|
||||
[
|
||||
'pro_uid' => '3209565785d247f618b6235074913840',
|
||||
'prj_uid' => $process['PRO_UID'],
|
||||
'dia_uid' => '9367735405d247f616ed440021337333',
|
||||
'pro_name' => 'Custom',
|
||||
'pro_type' => 'NONE',
|
||||
'pro_is_executable' => '0',
|
||||
'pro_is_closed' => '0',
|
||||
'pro_is_subprocess' => '0',
|
||||
],
|
||||
],
|
||||
'project' =>
|
||||
[
|
||||
0 =>
|
||||
[
|
||||
'prj_uid' => $process['PRO_UID'],
|
||||
'prj_name' => 'Custom',
|
||||
'prj_description' => '',
|
||||
'prj_target_namespace' => '',
|
||||
'prj_expresion_language' => '',
|
||||
'prj_type_language' => '',
|
||||
'prj_exporter' => '',
|
||||
'prj_exporter_version' => '',
|
||||
'prj_create_date' => '2019-07-09 11:49:53',
|
||||
'prj_update_date' => '',
|
||||
'prj_author' => '00000000000000000000000000000001',
|
||||
'prj_author_version' => '',
|
||||
'prj_original_source' => '',
|
||||
],
|
||||
],
|
||||
],
|
||||
'workflow' =>
|
||||
[
|
||||
'stepSupervisor' =>
|
||||
[],
|
||||
'processUser' =>
|
||||
[],
|
||||
'groupwfs' =>
|
||||
[],
|
||||
'objectPermissions' =>
|
||||
[],
|
||||
'dbconnections' =>
|
||||
[],
|
||||
'filesManager' =>
|
||||
[],
|
||||
'reportTablesDefinition' =>
|
||||
[],
|
||||
'reportTablesFields' =>
|
||||
[],
|
||||
'steptriggers' =>
|
||||
[],
|
||||
'triggers' =>
|
||||
[],
|
||||
'steps' =>
|
||||
[],
|
||||
'outputs' =>
|
||||
[],
|
||||
'inputs' =>
|
||||
[],
|
||||
'dynaforms' =>
|
||||
[],
|
||||
'processVariables' =>
|
||||
[],
|
||||
'tasks' =>
|
||||
[],
|
||||
'taskusers' =>
|
||||
[],
|
||||
'routes' =>
|
||||
[],
|
||||
'lanes' =>
|
||||
[],
|
||||
'gateways' =>
|
||||
[],
|
||||
'subProcess' =>
|
||||
[],
|
||||
'caseTracker' =>
|
||||
[],
|
||||
'caseTrackerObject' =>
|
||||
[],
|
||||
'stage' =>
|
||||
[],
|
||||
'fieldCondition' =>
|
||||
[],
|
||||
'event' =>
|
||||
[],
|
||||
'caseScheduler' =>
|
||||
[],
|
||||
'processCategory' =>
|
||||
[],
|
||||
'taskExtraProperties' =>
|
||||
[],
|
||||
'webEntry' =>
|
||||
[],
|
||||
'webEntryEvent' =>
|
||||
[],
|
||||
'messageType' =>
|
||||
[],
|
||||
'messageTypeVariable' =>
|
||||
[],
|
||||
'messageEventDefinition' =>
|
||||
[],
|
||||
'scriptTask' =>
|
||||
[],
|
||||
'timerEvent' =>
|
||||
[],
|
||||
'emailEvent' =>
|
||||
[],
|
||||
'abeConfiguration' =>
|
||||
[],
|
||||
'process' =>
|
||||
[
|
||||
0 =>
|
||||
[
|
||||
'PRO_UID' => $process['PRO_UID'],
|
||||
'PRO_TITLE' => 'Custom',
|
||||
'PRO_DESCRIPTION' => '',
|
||||
'PRO_PARENT' => $process['PRO_UID'],
|
||||
'PRO_TIME' => '1',
|
||||
'PRO_TIMEUNIT' => 'DAYS',
|
||||
'PRO_STATUS' => 'ACTIVE',
|
||||
'PRO_TYPE_DAY' => '',
|
||||
'PRO_TYPE' => 'NORMAL',
|
||||
'PRO_ASSIGNMENT' => 'FALSE',
|
||||
'PRO_SHOW_MAP' => '0',
|
||||
'PRO_SHOW_MESSAGE' => '0',
|
||||
'PRO_SUBPROCESS' => '0',
|
||||
'PRO_TRI_CREATE' => '',
|
||||
'PRO_TRI_OPEN' => '',
|
||||
'PRO_TRI_DELETED' => '',
|
||||
'PRO_TRI_CANCELED' => '',
|
||||
'PRO_TRI_PAUSED' => '',
|
||||
'PRO_TRI_REASSIGNED' => '',
|
||||
'PRO_TRI_UNPAUSED' => '',
|
||||
'PRO_TYPE_PROCESS' => 'PUBLIC',
|
||||
'PRO_SHOW_DELEGATE' => '0',
|
||||
'PRO_SHOW_DYNAFORM' => '0',
|
||||
'PRO_CATEGORY' => '',
|
||||
'PRO_SUB_CATEGORY' => '',
|
||||
'PRO_INDUSTRY' => '0',
|
||||
'PRO_UPDATE_DATE' => '',
|
||||
'PRO_CREATE_DATE' => '2019-07-09 11:49:53',
|
||||
'PRO_CREATE_USER' => '00000000000000000000000000000001',
|
||||
'PRO_HEIGHT' => '5000',
|
||||
'PRO_WIDTH' => '10000',
|
||||
'PRO_TITLE_X' => '0',
|
||||
'PRO_TITLE_Y' => '0',
|
||||
'PRO_DEBUG' => '0',
|
||||
'PRO_DYNAFORMS' => '',
|
||||
'PRO_DERIVATION_SCREEN_TPL' => '',
|
||||
'PRO_COST' => '0',
|
||||
'PRO_UNIT_COST' => '',
|
||||
'PRO_ITEE' => '1',
|
||||
'PRO_ACTION_DONE' => '',
|
||||
'PRO_CATEGORY_LABEL' => 'No Category',
|
||||
'PRO_BPMN' => '1',
|
||||
],
|
||||
],
|
||||
'reportTables' =>
|
||||
[],
|
||||
'reportTablesVars' =>
|
||||
[],
|
||||
],
|
||||
'plugins' =>
|
||||
[],
|
||||
];
|
||||
|
||||
// Mock the load method
|
||||
$importer->method("load")
|
||||
->willReturn($array);
|
||||
|
||||
// Call the import method
|
||||
$res = $importer->import(Importer::IMPORT_OPTION_KEEP_WITHOUT_CHANGING_AND_CREATE_NEW,
|
||||
Importer::GROUP_IMPORT_OPTION_CREATE_NEW, true);
|
||||
|
||||
// Query the new process created
|
||||
$query = Process::query();
|
||||
$query->select()->where('PRO_UID', $res);
|
||||
$result = $query->get()->values()->toArray();
|
||||
|
||||
// Assert the created date is the same as the updated date
|
||||
$this->assertEquals($result[0]['PRO_CREATE_DATE'], $result[0]['PRO_UPDATE_DATE']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the import method when importing a process with a new uid
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_the_import_method_when_importing_a_process_without_change_the_uid()
|
||||
{
|
||||
// Create the existing process
|
||||
$process = factory(Process::class)->create(
|
||||
['PRO_CREATE_DATE' => '2019-07-10 10:00:00']
|
||||
);
|
||||
factory(BpmnProject::class)->create(
|
||||
['PRJ_UID' => $process['PRO_UID']]
|
||||
);
|
||||
|
||||
// Mock the abstract class
|
||||
$importer = $this
|
||||
->getMockBuilder('ProcessMaker\Importer\Importer')
|
||||
->getMockForAbstractClass();
|
||||
|
||||
// create the array that will be passed to the load method
|
||||
$array = [];
|
||||
|
||||
$array["files"]["workflow"] = [];
|
||||
|
||||
$array['tables'] = [
|
||||
'bpmn' =>
|
||||
[
|
||||
'activity' =>
|
||||
[],
|
||||
'artifact' =>
|
||||
[],
|
||||
'bound' =>
|
||||
[],
|
||||
'data' =>
|
||||
[],
|
||||
'diagram' =>
|
||||
[
|
||||
0 =>
|
||||
[
|
||||
'dia_uid' => '9367735405d247f616ed440021337333',
|
||||
'prj_uid' => $process['PRO_UID'],
|
||||
'dia_name' => 'Custom',
|
||||
'dia_is_closable' => '0',
|
||||
|
||||
],
|
||||
],
|
||||
'documentation' =>
|
||||
[],
|
||||
'event' =>
|
||||
[],
|
||||
'extension' =>
|
||||
[],
|
||||
'flow' =>
|
||||
[],
|
||||
'gateway' =>
|
||||
[],
|
||||
'lane' =>
|
||||
[],
|
||||
'laneset' =>
|
||||
[],
|
||||
'participant' =>
|
||||
[],
|
||||
'process' =>
|
||||
[
|
||||
0 =>
|
||||
[
|
||||
'pro_uid' => '3209565785d247f618b6235074913840',
|
||||
'prj_uid' => $process['PRO_UID'],
|
||||
'dia_uid' => '9367735405d247f616ed440021337333',
|
||||
'pro_name' => 'Custom',
|
||||
'pro_type' => 'NONE',
|
||||
'pro_is_executable' => '0',
|
||||
'pro_is_closed' => '0',
|
||||
'pro_is_subprocess' => '0',
|
||||
],
|
||||
],
|
||||
'project' =>
|
||||
[
|
||||
0 =>
|
||||
[
|
||||
'prj_uid' => $process['PRO_UID'],
|
||||
'prj_name' => 'Custom',
|
||||
'prj_description' => '',
|
||||
'prj_target_namespace' => '',
|
||||
'prj_expresion_language' => '',
|
||||
'prj_type_language' => '',
|
||||
'prj_exporter' => '',
|
||||
'prj_exporter_version' => '',
|
||||
'prj_create_date' => '2019-07-09 11:49:53',
|
||||
'prj_update_date' => '',
|
||||
'prj_author' => '00000000000000000000000000000001',
|
||||
'prj_author_version' => '',
|
||||
'prj_original_source' => '',
|
||||
],
|
||||
],
|
||||
],
|
||||
'workflow' =>
|
||||
[
|
||||
'stepSupervisor' =>
|
||||
[],
|
||||
'processUser' =>
|
||||
[],
|
||||
'groupwfs' =>
|
||||
[],
|
||||
'objectPermissions' =>
|
||||
[],
|
||||
'dbconnections' =>
|
||||
[],
|
||||
'filesManager' =>
|
||||
[],
|
||||
'reportTablesDefinition' =>
|
||||
[],
|
||||
'reportTablesFields' =>
|
||||
[],
|
||||
'steptriggers' =>
|
||||
[],
|
||||
'triggers' =>
|
||||
[],
|
||||
'steps' =>
|
||||
[],
|
||||
'outputs' =>
|
||||
[],
|
||||
'inputs' =>
|
||||
[],
|
||||
'dynaforms' =>
|
||||
[],
|
||||
'processVariables' =>
|
||||
[],
|
||||
'tasks' =>
|
||||
[],
|
||||
'taskusers' =>
|
||||
[],
|
||||
'routes' =>
|
||||
[],
|
||||
'lanes' =>
|
||||
[],
|
||||
'gateways' =>
|
||||
[],
|
||||
'subProcess' =>
|
||||
[],
|
||||
'caseTracker' =>
|
||||
[],
|
||||
'caseTrackerObject' =>
|
||||
[],
|
||||
'stage' =>
|
||||
[],
|
||||
'fieldCondition' =>
|
||||
[],
|
||||
'event' =>
|
||||
[],
|
||||
'caseScheduler' =>
|
||||
[],
|
||||
'processCategory' =>
|
||||
[],
|
||||
'taskExtraProperties' =>
|
||||
[],
|
||||
'webEntry' =>
|
||||
[],
|
||||
'webEntryEvent' =>
|
||||
[],
|
||||
'messageType' =>
|
||||
[],
|
||||
'messageTypeVariable' =>
|
||||
[],
|
||||
'messageEventDefinition' =>
|
||||
[],
|
||||
'scriptTask' =>
|
||||
[],
|
||||
'timerEvent' =>
|
||||
[],
|
||||
'emailEvent' =>
|
||||
[],
|
||||
'abeConfiguration' =>
|
||||
[],
|
||||
'process' =>
|
||||
[
|
||||
0 =>
|
||||
[
|
||||
'PRO_UID' => $process['PRO_UID'],
|
||||
'PRO_TITLE' => 'Custom',
|
||||
'PRO_DESCRIPTION' => '',
|
||||
'PRO_PARENT' => $process['PRO_UID'],
|
||||
'PRO_TIME' => '1',
|
||||
'PRO_TIMEUNIT' => 'DAYS',
|
||||
'PRO_STATUS' => 'ACTIVE',
|
||||
'PRO_TYPE_DAY' => '',
|
||||
'PRO_TYPE' => 'NORMAL',
|
||||
'PRO_ASSIGNMENT' => 'FALSE',
|
||||
'PRO_SHOW_MAP' => '0',
|
||||
'PRO_SHOW_MESSAGE' => '0',
|
||||
'PRO_SUBPROCESS' => '0',
|
||||
'PRO_TRI_CREATE' => '',
|
||||
'PRO_TRI_OPEN' => '',
|
||||
'PRO_TRI_DELETED' => '',
|
||||
'PRO_TRI_CANCELED' => '',
|
||||
'PRO_TRI_PAUSED' => '',
|
||||
'PRO_TRI_REASSIGNED' => '',
|
||||
'PRO_TRI_UNPAUSED' => '',
|
||||
'PRO_TYPE_PROCESS' => 'PUBLIC',
|
||||
'PRO_SHOW_DELEGATE' => '0',
|
||||
'PRO_SHOW_DYNAFORM' => '0',
|
||||
'PRO_CATEGORY' => '',
|
||||
'PRO_SUB_CATEGORY' => '',
|
||||
'PRO_INDUSTRY' => '0',
|
||||
'PRO_UPDATE_DATE' => '',
|
||||
'PRO_CREATE_DATE' => '2019-07-09 11:49:53',
|
||||
'PRO_CREATE_USER' => '00000000000000000000000000000001',
|
||||
'PRO_HEIGHT' => '5000',
|
||||
'PRO_WIDTH' => '10000',
|
||||
'PRO_TITLE_X' => '0',
|
||||
'PRO_TITLE_Y' => '0',
|
||||
'PRO_DEBUG' => '0',
|
||||
'PRO_DYNAFORMS' => '',
|
||||
'PRO_DERIVATION_SCREEN_TPL' => '',
|
||||
'PRO_COST' => '0',
|
||||
'PRO_UNIT_COST' => '',
|
||||
'PRO_ITEE' => '1',
|
||||
'PRO_ACTION_DONE' => '',
|
||||
'PRO_CATEGORY_LABEL' => 'No Category',
|
||||
'PRO_BPMN' => '1',
|
||||
],
|
||||
],
|
||||
'reportTables' =>
|
||||
[],
|
||||
'reportTablesVars' =>
|
||||
[],
|
||||
],
|
||||
'plugins' =>
|
||||
[],
|
||||
];
|
||||
|
||||
// Mock the load method
|
||||
$importer->method("load")
|
||||
->willReturn($array);
|
||||
|
||||
// Call the setProtectedProperty method
|
||||
$this->setProtectedProperty($importer, 'metadata', ['uid' => $process['PRO_UID']]);
|
||||
|
||||
// Call the import method
|
||||
$res = $importer->import(Importer::IMPORT_OPTION_OVERWRITE,
|
||||
Importer::GROUP_IMPORT_OPTION_CREATE_NEW, false);
|
||||
|
||||
// Query the new process created
|
||||
$query = Process::query();
|
||||
$query->select()->where('PRO_UID', $res);
|
||||
$result = $query->get()->values()->toArray();
|
||||
|
||||
// Assert the created date is the same as the updated date
|
||||
$this->assertNotEquals($result[0]['PRO_CREATE_DATE'], $result[0]['PRO_UPDATE_DATE']);
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,26 @@
|
||||
<?php
|
||||
namespace Tests\unit\workflow\src\ProcessMaker\Model;
|
||||
|
||||
use Faker\Factory;
|
||||
use G;
|
||||
use Faker;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use ProcessMaker\Model\AppAssignSelfServiceValue;
|
||||
use ProcessMaker\Model\AppAssignSelfServiceValueGroup;
|
||||
use ProcessMaker\Model\Application;
|
||||
use ProcessMaker\Model\Delegation;
|
||||
use ProcessMaker\Model\GroupUser;
|
||||
use ProcessMaker\Model\Groupwf;
|
||||
use ProcessMaker\Model\Process;
|
||||
use ProcessMaker\Model\ProcessCategory;
|
||||
use ProcessMaker\Model\Task;
|
||||
use ProcessMaker\Model\TaskUser;
|
||||
use ProcessMaker\Model\User;
|
||||
use Tests\TestCase;
|
||||
|
||||
class DelegationTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
/**
|
||||
* This checks to make sure pagination is working properly
|
||||
* @test
|
||||
@@ -216,86 +221,91 @@ 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']);
|
||||
}
|
||||
|
||||
/**
|
||||
* This ensures searching by case number and review the page
|
||||
* This ensures searching by case number and review the order
|
||||
* @test
|
||||
*/
|
||||
public function it_should_search_by_case_id_and_pages_of_data()
|
||||
public function it_should_search_by_case_id_and_order_of_data()
|
||||
{
|
||||
factory(User::class, 100)->create();
|
||||
factory(Process::class)->create();
|
||||
$application = factory(Application::class)->create([
|
||||
'APP_NUMBER' => 2001
|
||||
'APP_NUMBER' => 11
|
||||
]);
|
||||
factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER
|
||||
]);
|
||||
$application = factory(Application::class)->create([
|
||||
'APP_NUMBER' => 2010
|
||||
'APP_NUMBER' => 111
|
||||
]);
|
||||
factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER
|
||||
]);
|
||||
$application = factory(Application::class)->create([
|
||||
'APP_NUMBER' => 2011
|
||||
'APP_NUMBER' => 1111
|
||||
]);
|
||||
factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER
|
||||
]);
|
||||
$application = factory(Application::class)->create([
|
||||
'APP_NUMBER' => 2012
|
||||
'APP_NUMBER' => 11111
|
||||
]);
|
||||
factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER
|
||||
]);
|
||||
$application = factory(Application::class)->create([
|
||||
'APP_NUMBER' => 2013
|
||||
'APP_NUMBER' => 111111
|
||||
]);
|
||||
factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER
|
||||
]);
|
||||
$application = factory(Application::class)->create([
|
||||
'APP_NUMBER' => 2014
|
||||
'APP_NUMBER' => 1111111
|
||||
]);
|
||||
factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER
|
||||
]);
|
||||
$application = factory(Application::class)->create([
|
||||
'APP_NUMBER' => 2015
|
||||
'APP_NUMBER' => 11111111
|
||||
]);
|
||||
factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER
|
||||
]);
|
||||
// Get first page, the major case id
|
||||
$results = Delegation::search(null, 0, 10, 1, null, null, 'DESC',
|
||||
// Searching by a existent case number, result ordered in DESC mode
|
||||
$results = Delegation::search(null, 0, 10, 11, null, null, 'DESC',
|
||||
'APP_NUMBER', null, null, null, 'APP_NUMBER');
|
||||
$this->assertCount(7, $results['data']);
|
||||
$this->assertEquals(2015, $results['data'][0]['APP_NUMBER']);
|
||||
// Get first page, the minor case id
|
||||
$results = Delegation::search(null, 0, 10, 1, null, null, 'ASC',
|
||||
$this->assertCount(1, $results['data']);
|
||||
$this->assertEquals(11, $results['data'][0]['APP_NUMBER']);
|
||||
// Searching by another existent case number, result ordered in ASC mode
|
||||
$results = Delegation::search(null, 0, 10, 11111, null, null, 'ASC',
|
||||
'APP_NUMBER', null, null, null, 'APP_NUMBER');
|
||||
$this->assertCount(7, $results['data']);
|
||||
$this->assertEquals(2001, $results['data'][0]['APP_NUMBER']);
|
||||
//Check the pagination
|
||||
$results = Delegation::search(null, 0, 5, 1, null, null, 'DESC',
|
||||
$this->assertCount(1, $results['data']);
|
||||
$this->assertEquals(11111, $results['data'][0]['APP_NUMBER']);
|
||||
// Searching by another existent case number, result ordered in DESC mode
|
||||
$results = Delegation::search(null, 0, 10, 1111111, null, null, 'DESC',
|
||||
'APP_NUMBER', null, null, null, 'APP_NUMBER');
|
||||
$this->assertCount(5, $results['data']);
|
||||
$results = Delegation::search(null, 5, 2, 1, null, null, 'DESC',
|
||||
$this->assertCount(1, $results['data']);
|
||||
$this->assertEquals(1111111, $results['data'][0]['APP_NUMBER']);
|
||||
// Searching by a not existent case number, result ordered in DESC mode
|
||||
$results = Delegation::search(null, 0, 10, 1000, null, null, 'DESC',
|
||||
'APP_NUMBER', null, null, null, 'APP_NUMBER');
|
||||
$this->assertCount(2, $results['data']);
|
||||
$this->assertCount(0, $results['data']);
|
||||
// Searching by a not existent case number, result ordered in ASC mode
|
||||
$results = Delegation::search(null, 0, 10, 99999, null, null, 'ASC',
|
||||
'APP_NUMBER', null, null, null, 'APP_NUMBER');
|
||||
$this->assertCount(0, $results['data']);
|
||||
}
|
||||
|
||||
/**
|
||||
* This ensures searching by case title and review the page
|
||||
* case title contain the case number, ex: APP_TITLE = 'Request # @=APP_NUMBER'
|
||||
* @test
|
||||
*/
|
||||
public function it_should_search_by_case_title_and_pages_of_data_app_number_matches_case_title()
|
||||
@@ -338,32 +348,42 @@ class DelegationTest extends TestCase
|
||||
'APP_NUMBER' => $application->APP_NUMBER
|
||||
]);
|
||||
$application = factory(Application::class)->create([
|
||||
'APP_TITLE' => 3014,
|
||||
'APP_NUMBER' => 3014,
|
||||
'APP_TITLE' => 'Request # 3014'
|
||||
]);
|
||||
factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER
|
||||
]);
|
||||
|
||||
// We need to commit the records inserted because is needed for the "fulltext" index
|
||||
DB::commit();
|
||||
|
||||
// Get first page, the major case id
|
||||
$results = Delegation::search(null, 0, 10, '1', null, null, 'DESC',
|
||||
$results = Delegation::search(null, 0, 10, 'Request', null, null, 'DESC',
|
||||
'APP_NUMBER', null, null, null, 'APP_TITLE');
|
||||
$this->assertCount(6, $results['data']);
|
||||
$this->assertEquals(3014, $results['data'][0]['APP_NUMBER']);
|
||||
$this->assertEquals('Request # 3014', $results['data'][0]['APP_TITLE']);
|
||||
|
||||
// Get first page, the minor case id
|
||||
$results = Delegation::search(null, 0, 10, '1', null, null, 'ASC',
|
||||
$results = Delegation::search(null, 0, 10, 'Request', null, null, 'ASC',
|
||||
'APP_NUMBER', null, null, null, 'APP_TITLE');
|
||||
$this->assertCount(6, $results['data']);
|
||||
$this->assertEquals(3001, $results['data'][0]['APP_NUMBER']);
|
||||
$this->assertEquals('Request # 3001', $results['data'][0]['APP_TITLE']);
|
||||
//Check the pagination
|
||||
$results = Delegation::search(null, 0, 5, '1', null, null, 'ASC',
|
||||
|
||||
// Check the pagination
|
||||
$results = Delegation::search(null, 0, 5, 'Request', null, null, 'ASC',
|
||||
'APP_NUMBER', null, null, null, 'APP_TITLE');
|
||||
$this->assertCount(5, $results['data']);
|
||||
$results = Delegation::search(null, 5, 2, '1', null, null, 'ASC',
|
||||
$results = Delegation::search(null, 5, 2, 'Request', null, null, 'ASC',
|
||||
'APP_NUMBER', null, null, null, 'APP_TITLE');
|
||||
$this->assertCount(1, $results['data']);
|
||||
|
||||
// We need to clean the tables manually
|
||||
// @todo: The "Delegation" factory should be improved, the create method always is creating a record in application table
|
||||
DB::unprepared("TRUNCATE APPLICATION;");
|
||||
DB::unprepared("TRUNCATE APP_DELEGATION;");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -416,7 +436,6 @@ class DelegationTest extends TestCase
|
||||
|
||||
/**
|
||||
* This ensures searching by case title and review the page
|
||||
* case title does not match with case number (hertland use case)
|
||||
* @test
|
||||
*/
|
||||
public function it_should_search_by_case_title_and_pages_of_data_app_number_no_matches_case_title()
|
||||
@@ -465,20 +484,29 @@ class DelegationTest extends TestCase
|
||||
factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER
|
||||
]);
|
||||
|
||||
// We need to commit the records inserted because is needed for the "fulltext" index
|
||||
DB::commit();
|
||||
|
||||
// Get first page, the major case title
|
||||
$results = Delegation::search(null, 0, 10, '1', null, null, 'ASC',
|
||||
$results = Delegation::search(null, 0, 10, 'Abigail', null, null, 'ASC',
|
||||
'APP_NUMBER', null, null, null, 'APP_TITLE');
|
||||
$this->assertCount(6, $results['data']);
|
||||
$this->assertEquals(2001, $results['data'][0]['APP_NUMBER']);
|
||||
$this->assertEquals('Request from Abigail check nro 25001', $results['data'][0]['APP_TITLE']);
|
||||
|
||||
//Check the pagination
|
||||
$results = Delegation::search(null, 0, 5, '1', null, null, 'ASC',
|
||||
// Check the pagination
|
||||
$results = Delegation::search(null, 0, 5, 'Abigail', null, null, 'ASC',
|
||||
'APP_NUMBER', null, null, null, 'APP_TITLE');
|
||||
$this->assertCount(5, $results['data']);
|
||||
$results = Delegation::search(null, 5, 2, '1', null, null, 'ASC',
|
||||
$results = Delegation::search(null, 5, 2, 'Abigail', null, null, 'ASC',
|
||||
'APP_NUMBER', null, null, null, 'APP_TITLE');
|
||||
$this->assertCount(1, $results['data']);
|
||||
|
||||
// We need to clean the tables manually
|
||||
// @todo: The "Delegation" factory should be improved, the create method always is creating a record in application table
|
||||
DB::unprepared("TRUNCATE APPLICATION;");
|
||||
DB::unprepared("TRUNCATE APP_DELEGATION;");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -553,23 +581,24 @@ class DelegationTest extends TestCase
|
||||
*/
|
||||
public function it_should_sort_by_process()
|
||||
{
|
||||
$faker = Factory::create();
|
||||
factory(User::class, 100)->create();
|
||||
$process = factory(Process::class)->create([
|
||||
'PRO_ID' => 2,
|
||||
'PRO_ID' => $faker->unique()->numberBetween(1, 10000000),
|
||||
'PRO_TITLE' => 'Egypt Supplier Payment Proposal'
|
||||
]);
|
||||
factory(Delegation::class)->create([
|
||||
'PRO_ID' => $process->id
|
||||
]);
|
||||
$process = factory(Process::class)->create([
|
||||
'PRO_ID' => 1,
|
||||
'PRO_ID' => $faker->unique()->numberBetween(1, 10000000),
|
||||
'PRO_TITLE' => 'China Supplier Payment Proposal'
|
||||
]);
|
||||
factory(Delegation::class)->create([
|
||||
'PRO_ID' => $process->id
|
||||
]);
|
||||
$process = factory(Process::class)->create([
|
||||
'PRO_ID' => 3,
|
||||
'PRO_ID' => $faker->unique()->numberBetween(1, 10000000),
|
||||
'PRO_TITLE' => 'Russia Supplier Payment Proposal'
|
||||
]);
|
||||
factory(Delegation::class)->create([
|
||||
@@ -640,7 +669,7 @@ class DelegationTest extends TestCase
|
||||
// Create a new delegation, but for this specific user
|
||||
factory(Delegation::class)->create([
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'USR_ID' => $user->id
|
||||
'USR_ID' => $user->USR_ID
|
||||
]);
|
||||
$user = factory(User::class)->create([
|
||||
'USR_USERNAME' => 'paul',
|
||||
@@ -650,7 +679,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');
|
||||
@@ -1107,12 +1136,15 @@ class DelegationTest extends TestCase
|
||||
factory(User::class, 100)->create();
|
||||
$process = factory(Process::class)->create();
|
||||
$application = factory(Application::class)->create([
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'APP_UID' => G::generateUniqueID()
|
||||
]);
|
||||
factory(Delegation::class)->states('closed')->create([
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'APP_UID' => $application->APP_UID
|
||||
]);
|
||||
factory(Delegation::class)->states('open')->create([
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'APP_UID' => $application->APP_UID,
|
||||
'DEL_INDEX' => 2
|
||||
]);
|
||||
@@ -1136,4 +1168,596 @@ class DelegationTest extends TestCase
|
||||
// Check the information returned
|
||||
$this->assertEmpty($results);
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks the counters is working properly in self-service user assigned
|
||||
* @covers Delegation::countSelfService
|
||||
* @test
|
||||
*/
|
||||
public function it_should_count_cases_by_user_with_self_service_user_assigned()
|
||||
{
|
||||
//Create process
|
||||
$process = factory(Process::class)->create();
|
||||
//Create user
|
||||
$user = factory(User::class)->create();
|
||||
//Create a task self service
|
||||
$task = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
|
||||
'TAS_GROUP_VARIABLE' => '',
|
||||
'PRO_UID' => $process->PRO_UID
|
||||
]);
|
||||
//Assign a user in the task
|
||||
factory(TaskUser::class)->create([
|
||||
'TAS_UID' => $task->TAS_UID,
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'TU_RELATION' => 1, //Related to the user
|
||||
'TU_TYPE' => 1
|
||||
]);
|
||||
//Create the register in delegation relate to self-service
|
||||
factory(Delegation::class, 25)->create([
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_ID' => 0,
|
||||
]);
|
||||
//Review the count self-service
|
||||
$result = Delegation::countSelfService($user->USR_UID);
|
||||
$this->assertEquals(25, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks the counters is working properly in self-service-value-based when the variable has a value related with the USR_UID
|
||||
* When the value assigned in the variable @@ARRAY_OF_USERS = [USR_UID]
|
||||
* @covers Delegation::countSelfService
|
||||
* @test
|
||||
*/
|
||||
public function it_should_count_cases_by_user_with_self_service_value_based_usr_uid()
|
||||
{
|
||||
//Create process
|
||||
$process = factory(Process::class)->create();
|
||||
//Create a case
|
||||
$application = factory(Application::class)->create();
|
||||
//Create user
|
||||
$user = factory(User::class)->create();
|
||||
//Create a task self service value based
|
||||
$task = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
|
||||
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
|
||||
'PRO_UID' => $process->PRO_UID
|
||||
]);
|
||||
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
|
||||
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'DEL_INDEX' => 2,
|
||||
'TAS_ID' => $task->TAS_ID
|
||||
]);
|
||||
factory(AppAssignSelfServiceValueGroup::class)->create([
|
||||
'ID' => $appSelfValue->ID,
|
||||
'GRP_UID' => $user->USR_UID,
|
||||
'ASSIGNEE_ID' => $user->USR_ID, //The usrId or grpId
|
||||
'ASSIGNEE_TYPE' => 1 //Related to the user=1 related to the group=2
|
||||
]);
|
||||
//Create the register in self-service
|
||||
factory(Delegation::class, 25)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'DEL_INDEX' => $appSelfValue->DEL_INDEX,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_ID' => 0,
|
||||
]);
|
||||
//Review the count self-service
|
||||
$result = Delegation::countSelfService($user->USR_UID);
|
||||
$this->assertEquals(25, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks the counters is working properly in self-service and self-service value based
|
||||
* @covers Delegation::countSelfService
|
||||
* @test
|
||||
*/
|
||||
public function it_should_count_cases_by_user_with_self_service_mixed_with_self_service_value_based()
|
||||
{
|
||||
//Create process
|
||||
$process = factory(Process::class)->create();
|
||||
//Create a case
|
||||
$application = factory(Application::class)->create();
|
||||
//Create user
|
||||
$user = factory(User::class)->create();
|
||||
//Create a task self service
|
||||
$task = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
|
||||
'TAS_GROUP_VARIABLE' => '',
|
||||
'PRO_UID' => $process->PRO_UID
|
||||
]);
|
||||
//Assign a user in the task
|
||||
factory(TaskUser::class)->create([
|
||||
'TAS_UID' => $task->TAS_UID,
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'TU_RELATION' => 1, //Related to the user
|
||||
'TU_TYPE' => 1
|
||||
]);
|
||||
//Create the register in self service
|
||||
factory(Delegation::class, 15)->create([
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_ID' => 0,
|
||||
]);
|
||||
//Create a task self service value based
|
||||
$task1 = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
|
||||
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
|
||||
'PRO_UID' => $process->PRO_UID
|
||||
]);
|
||||
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
|
||||
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'DEL_INDEX' => 2,
|
||||
'TAS_ID' => $task1->TAS_ID
|
||||
]);
|
||||
factory(AppAssignSelfServiceValueGroup::class)->create([
|
||||
'ID' => $appSelfValue->ID,
|
||||
'GRP_UID' => $user->USR_UID,
|
||||
'ASSIGNEE_ID' => $user->USR_ID, //The usrId or grpId
|
||||
'ASSIGNEE_TYPE' => 1 //Related to the user=1 related to the group=2
|
||||
]);
|
||||
//Create the register in self service value based
|
||||
factory(Delegation::class, 15)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'DEL_INDEX' => $appSelfValue->DEL_INDEX,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_ID' => 0,
|
||||
]);
|
||||
//Review the count self-service
|
||||
$result = Delegation::countSelfService($user->USR_UID);
|
||||
$this->assertEquals(30, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks the counters is working properly in self-service group assigned
|
||||
* @covers Delegation::countSelfService
|
||||
* @test
|
||||
*/
|
||||
public function it_should_count_cases_by_user_with_self_service_group_assigned()
|
||||
{
|
||||
//Create process
|
||||
$process = factory(Process::class)->create();
|
||||
//Create group
|
||||
$group = factory(Groupwf::class)->create();
|
||||
//Create user
|
||||
$user = factory(User::class)->create();
|
||||
//Assign a user in the group
|
||||
factory(GroupUser::class)->create([
|
||||
'GRP_UID' => $group->GRP_UID,
|
||||
'GRP_ID' => $group->GRP_ID,
|
||||
'USR_UID' => $user->USR_UID
|
||||
]);
|
||||
//Create a task self service
|
||||
$task = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
|
||||
'TAS_GROUP_VARIABLE' => '',
|
||||
'PRO_UID' => $process->PRO_UID
|
||||
]);
|
||||
//Assign a user in the task
|
||||
factory(TaskUser::class)->create([
|
||||
'TAS_UID' => $task->TAS_UID,
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'TU_RELATION' => 2, //Related to the group
|
||||
'TU_TYPE' => 1
|
||||
]);
|
||||
//Create the register in self-service
|
||||
factory(Delegation::class, 25)->create([
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_ID' => 0,
|
||||
]);
|
||||
//Review the count self-service
|
||||
$result = Delegation::countSelfService($user->USR_UID);
|
||||
$this->assertEquals(25, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks the counters is working properly in self-service-value-based when the variable has a value related with the GRP_UID
|
||||
* When the value assigned in the variable @@ARRAY_OF_USERS = [GRP_UID]
|
||||
* @covers Delegation::countSelfService
|
||||
* @test
|
||||
*/
|
||||
public function it_should_count_cases_by_user_with_self_service_value_based_grp_uid()
|
||||
{
|
||||
//Create process
|
||||
$process = factory(Process::class)->create();
|
||||
//Create a task self service value based
|
||||
$task = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
|
||||
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
|
||||
'PRO_UID' => $process->PRO_UID
|
||||
]);
|
||||
//Create a case
|
||||
$application = factory(Application::class)->create();
|
||||
//Create group
|
||||
$group = factory(Groupwf::class)->create();
|
||||
//Create user
|
||||
$user = factory(User::class)->create([
|
||||
'USR_USERNAME' => 'gary',
|
||||
'USR_LASTNAME' => 'Gary',
|
||||
'USR_FIRSTNAME' => 'Bailey',
|
||||
]);
|
||||
//Assign a user in the group
|
||||
factory(GroupUser::class)->create([
|
||||
'GRP_UID' => $group->GRP_UID,
|
||||
'GRP_ID' => $group->GRP_ID,
|
||||
'USR_UID' => $user->USR_UID,
|
||||
]);
|
||||
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
|
||||
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'APP_UID' => $application->APP_UID,
|
||||
'DEL_INDEX' => 2,
|
||||
'TAS_ID' => $task->TAS_ID
|
||||
]);
|
||||
factory(AppAssignSelfServiceValueGroup::class)->create([
|
||||
'ID' => $appSelfValue->ID,
|
||||
'GRP_UID' => $group->GRP_UID,
|
||||
'ASSIGNEE_ID' => $group->GRP_ID, //The usrId or grpId
|
||||
'ASSIGNEE_TYPE' => 2 //Related to the user=1 related to the group=2
|
||||
]);
|
||||
//Create the register in self-service
|
||||
factory(Delegation::class, 25)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'DEL_INDEX' => 2,
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_ID' => 0,
|
||||
]);
|
||||
//Review the count self-service
|
||||
$result = Delegation::countSelfService($user->USR_UID);
|
||||
$this->assertEquals(25, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks the counters is working properly in self-service user and group assigned in parallel task
|
||||
* @covers Delegation::countSelfService
|
||||
* @test
|
||||
*/
|
||||
public function it_should_count_cases_by_user_with_self_service_user_and_group_assigned_parallel_task()
|
||||
{
|
||||
//Create process
|
||||
$process = factory(Process::class)->create();
|
||||
//Create group
|
||||
$group = factory(Groupwf::class)->create();
|
||||
//Create user
|
||||
$user = factory(User::class)->create();
|
||||
//Assign a user in the group
|
||||
factory(GroupUser::class)->create([
|
||||
'GRP_UID' => $group->GRP_UID,
|
||||
'GRP_ID' => $group->GRP_ID,
|
||||
'USR_UID' => $user->USR_UID
|
||||
]);
|
||||
//Create a task self service
|
||||
$task1 = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
|
||||
'TAS_GROUP_VARIABLE' => '',
|
||||
'PRO_UID' => $process->PRO_UID
|
||||
]);
|
||||
//Assign a user in the task1
|
||||
factory(TaskUser::class)->create([
|
||||
'TAS_UID' => $task1->TAS_UID,
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'TU_RELATION' => 1, //Related to the user
|
||||
'TU_TYPE' => 1
|
||||
]);
|
||||
//Create a task self service
|
||||
$task2 = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
|
||||
'TAS_GROUP_VARIABLE' => '',
|
||||
'PRO_UID' => $process->PRO_UID
|
||||
]);
|
||||
//Assign a user in the task2
|
||||
factory(TaskUser::class)->create([
|
||||
'TAS_UID' => $task2->TAS_UID,
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'TU_RELATION' => 1, //Related to the user
|
||||
'TU_TYPE' => 1
|
||||
]);
|
||||
//Create a task self service
|
||||
$task3 = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
|
||||
'TAS_GROUP_VARIABLE' => '',
|
||||
'PRO_UID' => $process->PRO_UID
|
||||
]);
|
||||
//Assign a user in the task
|
||||
factory(TaskUser::class)->create([
|
||||
'TAS_UID' => $task3->TAS_UID,
|
||||
'USR_UID' => $group->GRP_UID,
|
||||
'TU_RELATION' => 2, //Related to the group
|
||||
'TU_TYPE' => 1
|
||||
]);
|
||||
//Create a task self service
|
||||
$task4 = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
|
||||
'TAS_GROUP_VARIABLE' => '',
|
||||
'PRO_UID' => $process->PRO_UID
|
||||
]);
|
||||
//Assign a user in the task
|
||||
factory(TaskUser::class)->create([
|
||||
'TAS_UID' => $task4->TAS_UID,
|
||||
'USR_UID' => $group->GRP_UID,
|
||||
'TU_RELATION' => 2, //Related to the group
|
||||
'TU_TYPE' => 1
|
||||
]);
|
||||
//Create the register in self-service related to the task1
|
||||
factory(Delegation::class, 10)->create([
|
||||
'TAS_ID' => $task1->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_ID' => 0,
|
||||
]);
|
||||
//Create the register in self-service related to the task2
|
||||
factory(Delegation::class, 10)->create([
|
||||
'TAS_ID' => $task2->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_ID' => 0,
|
||||
]);
|
||||
//Create the register in self-service related to the task3
|
||||
factory(Delegation::class, 10)->create([
|
||||
'TAS_ID' => $task3->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_ID' => 0,
|
||||
]);
|
||||
//Create the register in self-service related to the task4
|
||||
factory(Delegation::class, 10)->create([
|
||||
'TAS_ID' => $task4->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_ID' => 0,
|
||||
]);
|
||||
//Review the count self-service
|
||||
$result = Delegation::countSelfService($user->USR_UID);
|
||||
$this->assertEquals(40, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks the counters is working properly in self-service-value-based with GRP_UID and USR_UID in parallel task
|
||||
* When the value assigned in the variable @@ARRAY_OF_USERS = [GRP_UID, USR_UID]
|
||||
* @covers Delegation::countSelfService
|
||||
* @test
|
||||
*/
|
||||
public function it_should_count_cases_by_user_with_self_service_value_based_usr_uid_and_grp_uid()
|
||||
{
|
||||
//Create process
|
||||
$process = factory(Process::class)->create();
|
||||
//Create a case
|
||||
$application = factory(Application::class)->create();
|
||||
//Create user
|
||||
$user = factory(User::class)->create();
|
||||
//Create a task1 self service value based
|
||||
$task1 = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
|
||||
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
|
||||
'PRO_UID' => $process->PRO_UID
|
||||
]);
|
||||
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
|
||||
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'TAS_ID' => $task1->TAS_ID
|
||||
]);
|
||||
factory(AppAssignSelfServiceValueGroup::class)->create([
|
||||
'ID' => $appSelfValue->ID,
|
||||
'GRP_UID' => $user->USR_UID,
|
||||
'ASSIGNEE_ID' => $user->USR_ID, //The usrId or grpId
|
||||
'ASSIGNEE_TYPE' => 1 //Related to the user=1 related to the group=2
|
||||
]);
|
||||
//Create the register in self-service
|
||||
factory(Delegation::class, 10)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'DEL_INDEX' => $appSelfValue->DEL_INDEX,
|
||||
'TAS_ID' => $task1->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_ID' => 0,
|
||||
]);
|
||||
//Create a task2 self service value based
|
||||
$task2 = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
|
||||
'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS',
|
||||
'PRO_UID' => $process->PRO_UID
|
||||
]);
|
||||
//Create the relation for the value assigned in the TAS_GROUP_VARIABLE
|
||||
$appSelfValue = factory(AppAssignSelfServiceValue::class)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'TAS_ID' => $task2->TAS_ID
|
||||
]);
|
||||
factory(AppAssignSelfServiceValueGroup::class)->create([
|
||||
'ID' => $appSelfValue->ID,
|
||||
'GRP_UID' => $user->USR_UID,
|
||||
'ASSIGNEE_ID' => $user->USR_ID, //The usrId or grpId
|
||||
'ASSIGNEE_TYPE' => 1 //Related to the user=1 related to the group=2
|
||||
]);
|
||||
//Create the register in self-service
|
||||
factory(Delegation::class, 15)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'DEL_INDEX' => $appSelfValue->DEL_INDEX,
|
||||
'TAS_ID' => $task2->TAS_ID,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'USR_ID' => 0,
|
||||
]);
|
||||
//Review the count self-service
|
||||
$result = Delegation::countSelfService($user->USR_UID);
|
||||
$this->assertEquals(25, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This check if return the USR_UID assigned in the thread OPEN
|
||||
*
|
||||
* @covers Delegation::getCurrentUser
|
||||
* @test
|
||||
*/
|
||||
public function it_should_return_current_user_for_thread_open()
|
||||
{
|
||||
//Create process
|
||||
$process = factory(Process::class)->create();
|
||||
//Create a case
|
||||
$application = factory(Application::class)->create();
|
||||
//Create user
|
||||
$user = factory(User::class)->create();
|
||||
//Create a delegation
|
||||
factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'DEL_INDEX' => 2,
|
||||
'USR_UID' => $user->USR_UID,
|
||||
]);
|
||||
factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'DEL_THREAD_STATUS' => 'CLOSED',
|
||||
'DEL_INDEX' => 1,
|
||||
'USR_UID' => $user->USR_UID,
|
||||
]);
|
||||
|
||||
//Get the current user assigned in the open thread
|
||||
$result = Delegation::getCurrentUser($application->APP_NUMBER, 2, 'OPEN');
|
||||
$this->assertEquals($user->USR_UID, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This check if return the USR_UID assigned in the thread CLOSED
|
||||
*
|
||||
* @covers Delegation::getCurrentUser
|
||||
* @test
|
||||
*/
|
||||
public function it_should_return_current_user_for_thread_closed()
|
||||
{
|
||||
//Create process
|
||||
$process = factory(Process::class)->create();
|
||||
//Create a case
|
||||
$application = factory(Application::class)->create();
|
||||
//Create user
|
||||
$user = factory(User::class)->create();
|
||||
//Create a delegation
|
||||
factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'DEL_THREAD_STATUS' => 'CLOSED',
|
||||
'DEL_INDEX' => 1,
|
||||
'USR_UID' => $user->USR_UID,
|
||||
]);
|
||||
factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'DEL_INDEX' => 2,
|
||||
'USR_UID' => $user->USR_UID,
|
||||
]);
|
||||
|
||||
//Get the current user assigned in the open thread
|
||||
$result = Delegation::getCurrentUser($application->APP_NUMBER, 1, 'CLOSED');
|
||||
$this->assertEquals($user->USR_UID, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This check if return empty when the data does not exits
|
||||
*
|
||||
* @covers Delegation::getCurrentUser
|
||||
* @test
|
||||
*/
|
||||
public function it_should_return_empty_when_row_does_not_exist()
|
||||
{
|
||||
//Create process
|
||||
$process = factory(Process::class)->create();
|
||||
//Create a case
|
||||
$application = factory(Application::class)->create();
|
||||
//Create user
|
||||
$user = factory(User::class)->create();
|
||||
//Create a delegation
|
||||
factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'DEL_THREAD_STATUS' => 'CLOSED',
|
||||
'DEL_INDEX' => 1,
|
||||
'USR_UID' => $user->USR_UID,
|
||||
]);
|
||||
factory(Delegation::class)->create([
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'DEL_INDEX' => 2,
|
||||
'USR_UID' => $user->USR_UID,
|
||||
]);
|
||||
|
||||
//Get the current user assigned in the open thread
|
||||
$result = Delegation::getCurrentUser($application->APP_NUMBER, 3, 'CLOSED');
|
||||
$this->assertEmpty($result);
|
||||
|
||||
$result = Delegation::getCurrentUser($application->APP_NUMBER, 3, 'OPEN');
|
||||
$this->assertEmpty($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks if return the open thread
|
||||
*
|
||||
* @covers Delegation::getOpenThreads
|
||||
* @test
|
||||
*/
|
||||
public function it_should_return_thread_open()
|
||||
{
|
||||
//Create process
|
||||
$process = factory(Process::class)->create();
|
||||
//Create a case
|
||||
$application = factory(Application::class)->create();
|
||||
//Create user
|
||||
$user = factory(User::class)->create();
|
||||
//Create task
|
||||
$task = factory(Task::class)->create();
|
||||
//Create a delegation
|
||||
factory(Delegation::class)->create([
|
||||
'DEL_THREAD_STATUS' => 'OPEN',
|
||||
'DEL_FINISH_DATE' => null,
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'TAS_UID' => $task->TAS_UID,
|
||||
]);
|
||||
$result = Delegation::getOpenThreads($application->APP_NUMBER, $task->TAS_UID);
|
||||
$this->assertEquals($application->APP_NUMBER, $result['APP_NUMBER']);
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks if return empty when the thread is CLOSED
|
||||
*
|
||||
* @covers Delegation::getOpenThreads
|
||||
* @test
|
||||
*/
|
||||
public function it_should_return_empty_when_thread_is_closed()
|
||||
{
|
||||
//Create process
|
||||
$process = factory(Process::class)->create();
|
||||
//Create a case
|
||||
$application = factory(Application::class)->create();
|
||||
//Create task
|
||||
$task = factory(Task::class)->create();
|
||||
//Create a delegation
|
||||
factory(Delegation::class)->create([
|
||||
'DEL_THREAD_STATUS' => 'CLOSED',
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'TAS_UID' => $task->TAS_UID,
|
||||
]);
|
||||
$result = Delegation::getOpenThreads($application->APP_NUMBER, $task->TAS_UID);
|
||||
$this->assertEmpty($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks if return empty when the data is not null
|
||||
*
|
||||
* @covers Delegation::getOpenThreads
|
||||
* @test
|
||||
*/
|
||||
public function it_should_return_empty_when_thread_finish_date_is_not_null()
|
||||
{
|
||||
//Create process
|
||||
$process = factory(Process::class)->create();
|
||||
//Create a case
|
||||
$application = factory(Application::class)->create();
|
||||
//Create user
|
||||
$user = factory(User::class)->create();
|
||||
//Create task
|
||||
$task = factory(Task::class)->create();
|
||||
//Create a delegation
|
||||
factory(Delegation::class)->create([
|
||||
'DEL_THREAD_STATUS' => 'CLOSED',
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'TAS_UID' => $task->TAS_UID,
|
||||
]);
|
||||
$result = Delegation::getOpenThreads($application->APP_NUMBER, $task->TAS_UID);
|
||||
$this->assertEmpty($result);
|
||||
}
|
||||
}
|
||||
@@ -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']);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,155 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
|
||||
|
||||
use G;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use ProcessMaker\Model\Process;
|
||||
use ProcessMaker\Model\User;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass ProcessMaker\BusinessModel\Model\Process
|
||||
*/
|
||||
|
||||
class ProcessTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
/**
|
||||
* Test it returns all the processes for an specific user
|
||||
* @covers ::getProcessList
|
||||
* @test
|
||||
*/
|
||||
public function it_should_return_all_the_processes_for_an_specific_user()
|
||||
{
|
||||
//Create user
|
||||
$user1 = factory(User::class)->create();
|
||||
$user2 = factory(User::class)->create();
|
||||
//Create process
|
||||
$process1 = factory(Process::class)->create(
|
||||
['PRO_CREATE_USER' => $user1['USR_UID']]
|
||||
);
|
||||
$process2 = factory(Process::class)->create(
|
||||
['PRO_CREATE_USER' => $user2['USR_UID']]
|
||||
);
|
||||
|
||||
//Create a Process object
|
||||
$process = new Process();
|
||||
//Call the getProcessList() method
|
||||
$res = $process->getProcessList('', $user2['USR_UID']);
|
||||
|
||||
//Assert the result is not empty
|
||||
$this->assertNotEmpty($res);
|
||||
//Assert there's one result
|
||||
$this->assertCount(1, $res);
|
||||
//Assert that the process returned is the one looked for
|
||||
$this->assertEquals($process2['PRO_UID'], $res[0]['PRO_UID']);
|
||||
//Assert the process that was not searched is not in the result
|
||||
$this->assertNotEquals($process1['PRO_UID'], $res[0]['PRO_UID']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that it returns the processes in an specific category
|
||||
* @covers ::getProcessList
|
||||
* @test
|
||||
*/
|
||||
public function it_should_return_the_processes_in_an_specific_category()
|
||||
{
|
||||
$catUid1 = G::generateUniqueID();
|
||||
$catUid2 = G::generateUniqueID();
|
||||
|
||||
//Create user
|
||||
$user = factory(User::class)->create();
|
||||
//Create process
|
||||
$process1 = factory(Process::class)->create(
|
||||
[
|
||||
'PRO_CREATE_USER' => $user['USR_UID'],
|
||||
'PRO_CATEGORY' => $catUid1
|
||||
]
|
||||
);
|
||||
$process2 = factory(Process::class)->create(
|
||||
[
|
||||
'PRO_CREATE_USER' => $user['USR_UID'],
|
||||
'PRO_CATEGORY' => $catUid2
|
||||
]
|
||||
);
|
||||
|
||||
//Create a Process object
|
||||
$process = new Process();
|
||||
//Call the getProcessList() method
|
||||
$res = $process->getProcessList($process1['PRO_CATEGORY'], $user['USR_UID']);
|
||||
|
||||
//Assert the result is not empty
|
||||
$this->assertNotEmpty($res);
|
||||
//Assert there's one result
|
||||
$this->assertCount(1, $res);
|
||||
//Assert that the process returned belong to the category searched
|
||||
$this->assertEquals($process1['PRO_UID'], $res[0]['PRO_UID']);
|
||||
//Assert the process which their category was not searched is not in the result
|
||||
$this->assertNotEquals($process2['PRO_UID'], $res[0]['PRO_UID']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that it returns an empty array if no processes where found
|
||||
* @covers ::getProcessList
|
||||
* @test
|
||||
*/
|
||||
public function it_should_return_empty_if_no_processes_where_found()
|
||||
{
|
||||
//Create user
|
||||
$user = factory(User::class)->create();
|
||||
//Create a Process object
|
||||
$process = new Process();
|
||||
//Call the getProcessList() method
|
||||
$res = $process->getProcessList('', $user['USR_UID']);
|
||||
|
||||
//Assert the result is not empty
|
||||
$this->assertEmpty($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test it returns all the processes in status active
|
||||
* @covers ::getProcessList
|
||||
* @test
|
||||
*/
|
||||
public function it_should_return_all_the_processes_in_status_active()
|
||||
{
|
||||
//Create user
|
||||
$user = factory(User::class)->create();
|
||||
//Create process
|
||||
$process1 = factory(Process::class)->create(
|
||||
[
|
||||
'PRO_CREATE_USER' => $user['USR_UID'],
|
||||
'PRO_STATUS' => 'ACTIVE'
|
||||
]
|
||||
);
|
||||
$process2 = factory(Process::class)->create(
|
||||
[
|
||||
'PRO_CREATE_USER' => $user['USR_UID'],
|
||||
'PRO_STATUS' => 'INACTIVE'
|
||||
]
|
||||
);
|
||||
$process3 = factory(Process::class)->create(
|
||||
[
|
||||
'PRO_CREATE_USER' => $user['USR_UID'],
|
||||
'PRO_STATUS' => 'DISABLED'
|
||||
]
|
||||
);
|
||||
|
||||
//Create a Process object
|
||||
$process = new Process();
|
||||
//Call the getProcessList() method
|
||||
$res = $process->getProcessList('', $user['USR_UID']);
|
||||
|
||||
//Assert the result is not empty
|
||||
$this->assertNotEmpty($res);
|
||||
//Assert there's one result
|
||||
$this->assertCount(1, $res);
|
||||
//Assert that the process returned is the one that has ACTIVE status
|
||||
$this->assertEquals($process1['PRO_UID'], $res[0]['PRO_UID']);
|
||||
//Assert the processes that have not ACTIVE status are not in the result
|
||||
$this->assertNotEquals($process2['PRO_UID'], $res[0]['PRO_UID']);
|
||||
$this->assertNotEquals($process3['PRO_UID'], $res[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']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
|
||||
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use ProcessMaker\Model\User;
|
||||
use Tests\TestCase;
|
||||
|
||||
class UserTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
/**
|
||||
* Tests the users filters scope with the usr uid filter
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_the_users_filters_scope_with_usr_uid()
|
||||
{
|
||||
$user = factory(User::class, 4)->create();
|
||||
$filters = ['USR_UID' => $user[0]['USR_UID']];
|
||||
|
||||
$userQuery = User::query()->select();
|
||||
$userQuery->userFilters($filters);
|
||||
$result = $userQuery->get()->values()->toArray();
|
||||
|
||||
// Assert the expected numbers of rows in the result
|
||||
$this->assertCount(1, $result);
|
||||
|
||||
// Assert the filter has been set successful
|
||||
$this->assertEquals($user[0]['USR_UID'], $result[0]['USR_UID']);
|
||||
$this->assertNotEquals($user[1]['USR_UID'], $result[0]['USR_UID']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the users filters scope with the usr id filter
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_the_users_filters_scope_with_usr_id()
|
||||
{
|
||||
$user = factory(User::class, 4)->create();
|
||||
$filters = ['USR_ID' => $user[0]['USR_ID']];
|
||||
$userQuery = User::query()->select();
|
||||
$userQuery->userFilters($filters);
|
||||
|
||||
$result = $userQuery->get()->values()->toArray();
|
||||
|
||||
// Assert the expected numbers of rows in the result
|
||||
$this->assertCount(1, $result);
|
||||
|
||||
// Assert the filter has been set successful
|
||||
$this->assertEquals($user[0]['USR_ID'], $result[0]['USR_ID']);
|
||||
$this->assertNotEquals($user[1]['USR_ID'], $result[0]['USR_ID']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the exception in the users filters scope
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_the_exception_in_users_filters_scope()
|
||||
{
|
||||
factory(User::class, 4)->create();
|
||||
$filters = [];
|
||||
$userQuery = User::query()->select();
|
||||
|
||||
//Expect an exception message
|
||||
$this->expectExceptionMessage("There are no filter for loading a user model");
|
||||
|
||||
//Call the userFilters scope
|
||||
$userQuery->userFilters($filters);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,362 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\src\ProcessMaker\Services\Api;
|
||||
|
||||
use G;
|
||||
use GuzzleHttp\Client;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\File;
|
||||
use ProcessMaker\Core\Installer;
|
||||
use ProcessMaker\Core\System;
|
||||
use ProcessMaker\Model\ListUnassigned;
|
||||
use ProcessMaker\Model\Process;
|
||||
use ProcessMaker\Model\Task;
|
||||
use ProcessMaker\Model\TaskUser;
|
||||
use ProcessMaker\Model\User;
|
||||
use ProcessMaker\Util\DateTime;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* To do: This only works if the test database is the same where ProcessMaker is
|
||||
* installed, improvements must be made so that the method "Installer::create_site()"
|
||||
* can create the connection file (/processmaker/shared/sites/{workspace}/db.php)
|
||||
* to different instances of MySql.
|
||||
*/
|
||||
class LightTest extends TestCase
|
||||
{
|
||||
private $http;
|
||||
private $baseUri;
|
||||
private $workspace;
|
||||
private $clientId;
|
||||
private $clientSecret;
|
||||
private $user;
|
||||
private $password;
|
||||
private $authorization;
|
||||
private $optionsForConvertDatetime;
|
||||
private $timezone;
|
||||
|
||||
/**
|
||||
* This is using instead of DatabaseTransactions
|
||||
* @todo DatabaseTransactions is having conflicts with propel
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
$this->markTestIncomplete();//@todo: Please correct this unit test
|
||||
$this->timezone = config('app.timezone');
|
||||
$_SESSION['USR_TIME_ZONE'] = $this->timezone;
|
||||
$this->baseUri = $this->getBaseUri();
|
||||
$this->workspace = env("DB_DATABASE", "test");
|
||||
$this->clientId = config("oauthClients.pm.clientId");
|
||||
$this->clientSecret = config("oauthClients.pm.clientSecret");
|
||||
$this->user = "admin";
|
||||
$this->password = "admin";
|
||||
$this->createTestSite();
|
||||
$this->http = new Client([
|
||||
"base_uri" => $this->baseUri
|
||||
]);
|
||||
$this->optionsForConvertDatetime = [
|
||||
'newerThan',
|
||||
'oldestthan',
|
||||
'date',
|
||||
'delegateDate',
|
||||
'dueDate',
|
||||
'delRiskDate'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get base uri for rest applications.
|
||||
* @return string
|
||||
*/
|
||||
private function getBaseUri()
|
||||
{
|
||||
$_SERVER = $this->getServerInformation();
|
||||
$baseUri = System::getServerProtocolHost();
|
||||
|
||||
return $baseUri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get server information.
|
||||
* @return object
|
||||
*/
|
||||
private function getServerInformation()
|
||||
{
|
||||
$pathData = PATH_DATA . "sites" . PATH_SEP . config("system.workspace") . PATH_SEP . ".server_info";
|
||||
$content = file_get_contents($pathData);
|
||||
$serverInfo = unserialize($content);
|
||||
|
||||
return $serverInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method creates a test workspace so that the endpoints can be functional,
|
||||
* it is necessary to change the permissions of the directory so that other
|
||||
* users can access and write to the directory, these users can be for
|
||||
* example: apache2, www-data, httpd, etc...
|
||||
* This method finds the license file of the active site and uses it to register
|
||||
* this license in the LICENSE_MANAGER table. If there is no license file in
|
||||
* the active workspace, an asersion failure will be notified.
|
||||
*/
|
||||
private function createTestSite()
|
||||
{
|
||||
//We copy the license, otherwise you will not be able to lift the site
|
||||
$pathTest = PATH_DATA . "sites" . PATH_SEP . $this->workspace;
|
||||
File::copyDirectory(PATH_DATA . "sites" . PATH_SEP . config("system.workspace"), $pathTest);
|
||||
|
||||
//Write permission for other users for example: apache2, www-data, httpd.
|
||||
passthru('chmod 777 -R ' . $pathTest . ' >> .log 2>&1');
|
||||
|
||||
$installer = new Installer();
|
||||
$options = [
|
||||
'isset' => true,
|
||||
'name' => $this->workspace,
|
||||
'admin' => [
|
||||
'username' => $this->user,
|
||||
'password' => $this->password
|
||||
],
|
||||
'advanced' => [
|
||||
'ao_db_drop' => true,
|
||||
'ao_db_wf' => $this->workspace,
|
||||
'ao_db_rb' => $this->workspace,
|
||||
'ao_db_rp' => $this->workspace
|
||||
]
|
||||
];
|
||||
//The false option creates a connection to the database, necessary to create a site.
|
||||
$installer->create_site($options, false);
|
||||
//Now create site
|
||||
$installer->create_site($options, true);
|
||||
|
||||
//Important so that the dates are stored in the same timezone
|
||||
file_put_contents($pathTest . "/env.ini", "time_zone ='{$this->timezone}'", FILE_APPEND);
|
||||
|
||||
$matchingFiles = File::glob("{$pathTest}/*.dat");
|
||||
$this->assertNotEmpty($matchingFiles);
|
||||
|
||||
//set license
|
||||
$licensePath = array_pop($matchingFiles);
|
||||
DB::Table("LICENSE_MANAGER")->insert([
|
||||
"LICENSE_UID" => G::generateUniqueID(),
|
||||
"LICENSE_USER" => "ProcessMaker Inc",
|
||||
"LICENSE_START" => "1490932800",
|
||||
"LICENSE_END" => 0,
|
||||
"LICENSE_SPAN" => 0,
|
||||
"LICENSE_STATUS" => "ACTIVE",
|
||||
"LICENSE_DATA" => file_get_contents($licensePath),
|
||||
"LICENSE_PATH" => $licensePath,
|
||||
"LICENSE_WORKSPACE" => $this->workspace,
|
||||
"LICENSE_TYPE" => ""
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get authorization values.
|
||||
*/
|
||||
private function getAuthorization()
|
||||
{
|
||||
$request = $this->http->request("POST", "{$this->workspace}/oauth2/token", [
|
||||
"form_params" => [
|
||||
"grant_type" => "password",
|
||||
"scope" => "*",
|
||||
"client_id" => $this->clientId,
|
||||
"client_secret" => $this->clientSecret,
|
||||
"username" => $this->user,
|
||||
"password" => $this->password
|
||||
]
|
||||
]);
|
||||
|
||||
//Here is to verify if the connection to the endpoint was satisfactory,
|
||||
//so the connection status should be 200.
|
||||
$statusCode = $request->getStatusCode();
|
||||
$this->assertEquals(200, $statusCode);
|
||||
|
||||
//If the endpoint has responded we can obtain the data and verify if it
|
||||
//is what we expected.
|
||||
$contents = $request->getBody()->getContents();
|
||||
$credentials = json_decode($contents);
|
||||
|
||||
$this->assertNotNull($credentials);
|
||||
$this->assertObjectHasAttribute('access_token', $credentials);
|
||||
$this->assertObjectHasAttribute('expires_in', $credentials);
|
||||
$this->assertObjectHasAttribute('refresh_token', $credentials);
|
||||
$this->assertObjectHasAttribute('scope', $credentials);
|
||||
$this->assertObjectHasAttribute('token_type', $credentials);
|
||||
|
||||
$this->authorization = ucwords($credentials->token_type) . " {$credentials->access_token}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current collection list unassigned.
|
||||
* @return collection
|
||||
*/
|
||||
private function getCollectionListUnassigned()
|
||||
{
|
||||
//Create process
|
||||
$process = factory(Process::class)->create();
|
||||
|
||||
//Get user
|
||||
$user = User::select()
|
||||
->where('USR_USERNAME', '=', $this->user)
|
||||
->first();
|
||||
|
||||
//Create a task self service
|
||||
$task = factory(Task::class)->create([
|
||||
'TAS_ASSIGN_TYPE' => 'SELF_SERVICE',
|
||||
'TAS_GROUP_VARIABLE' => '',
|
||||
'PRO_UID' => $process->PRO_UID
|
||||
]);
|
||||
|
||||
//Assign a user in the task
|
||||
factory(TaskUser::class, 1)->create([
|
||||
'TAS_UID' => $task->TAS_UID,
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'TU_RELATION' => 1, //Related to the user
|
||||
'TU_TYPE' => 1
|
||||
]);
|
||||
|
||||
//Create a record in list unassigned
|
||||
$listUnassigned = factory(ListUnassigned::class, 15)->create([
|
||||
'TAS_ID' => $task->TAS_ID,
|
||||
'DEL_PREVIOUS_USR_UID' => $user->USR_UID
|
||||
]);
|
||||
|
||||
$result = $listUnassigned->sortByDesc('DEL_DELEGATE_DATE');
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the data to the format returned by REST API.
|
||||
* @param array $collection
|
||||
* @return array
|
||||
*/
|
||||
private function normalizeData($collection)
|
||||
{
|
||||
$result = [];
|
||||
$collection->transform(function ($item, $key) use (&$result) {
|
||||
$value = [
|
||||
'caseId' => $item->APP_UID,
|
||||
//The current EndPoint returns this value as a string, an Eloquent
|
||||
//collection takes into account the string and numeric types.
|
||||
'delIndex' => (string) $item->DEL_INDEX,
|
||||
'task' => [
|
||||
'taskId' => $item->TAS_UID,
|
||||
'name' => $item->APP_TAS_TITLE
|
||||
],
|
||||
'process' => [
|
||||
'processId' => $item->PRO_UID,
|
||||
'name' => $item->APP_PRO_TITLE
|
||||
],
|
||||
//The current EndPoint returns this value as a string, an Eloquent
|
||||
//collection takes into account the string and numeric types.
|
||||
'caseNumber' => (string) $item->APP_NUMBER,
|
||||
'caseTitle' => $item->APP_TITLE,
|
||||
'date' => $item->APP_UPDATE_DATE->format('Y-m-d H:i:s'),
|
||||
'delegateDate' => $item->DEL_DELEGATE_DATE->format('Y-m-d H:i:s'),
|
||||
'prevUser' => [
|
||||
'userId' => $item->DEL_PREVIOUS_USR_UID,
|
||||
'userName' => $item->DEL_PREVIOUS_USR_USERNAME,
|
||||
'firstName' => $item->DEL_PREVIOUS_USR_FIRSTNAME,
|
||||
'lastName' => $item->DEL_PREVIOUS_USR_LASTNAME
|
||||
],
|
||||
'dueDate' => $item->DEL_DUE_DATE->format('Y-m-d H:i:s'),
|
||||
];
|
||||
$result[] = $value;
|
||||
});
|
||||
|
||||
$converted = DateTime::convertUtcToIso8601($result, $this->optionsForConvertDatetime);
|
||||
|
||||
//Convert the elements to an object
|
||||
$object = json_decode(json_encode($converted));
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* This returns an array of arrays to test the $start and $limit parameters.
|
||||
* The values correspond to the following structure:
|
||||
* [
|
||||
* [$page, $size, $start, $limit],
|
||||
* [$page, $size, $start, $limit],
|
||||
* [$page, $size, $start, $limit],
|
||||
* ]
|
||||
* $page and $size are necessary to test the pages we expect to have from the
|
||||
* model collection.
|
||||
* @return array
|
||||
*/
|
||||
public function pagesProvider()
|
||||
{
|
||||
return [
|
||||
[1, 5, 0, 5],
|
||||
[2, 5, 5, 5],
|
||||
[3, 5, 10, 5],
|
||||
[4, 5, 15, 5],
|
||||
[5, 5, 20, 5],
|
||||
[6, 5, 25, 5]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* This check if the endpoint {workspace}/light/unassigned, is returning all data.
|
||||
* @test
|
||||
* @covers ProcessMaker\Services\Api\Light::doGetCasesListUnassigned
|
||||
*/
|
||||
public function it_should_get_all_data_without_start_and_limit_values()
|
||||
{
|
||||
$listUnassigned = $this->getCollectionListUnassigned();
|
||||
|
||||
$this->getAuthorization();
|
||||
$request = $this->http->request("GET", "api/1.0/{$this->workspace}/light/unassigned", [
|
||||
"headers" => [
|
||||
"Authorization" => $this->authorization
|
||||
]
|
||||
]);
|
||||
|
||||
//Here is to verify if the connection to the endpoint was satisfactory,
|
||||
//so the connection status should be 200.
|
||||
$statusCode = $request->getStatusCode();
|
||||
$this->assertEquals(200, $statusCode);
|
||||
|
||||
//If the endpoint has responded we can obtain the data and verify if it
|
||||
//is what we expected.
|
||||
$expected = $this->normalizeData($listUnassigned);
|
||||
$contents = $request->getBody()->getContents();
|
||||
$content = json_decode($contents);
|
||||
|
||||
$this->assertEquals($expected, $content);
|
||||
}
|
||||
|
||||
/**
|
||||
* This check if the endpoint {workspace}/light/unassigned, is returning the
|
||||
* requested data set according to the start and limit parameters. The $start
|
||||
* and $limit test values are obtained from the data provider pagesProvider().
|
||||
* @test
|
||||
* @covers ProcessMaker\Services\Api\Light::doGetCasesListUnassigned
|
||||
* @dataProvider pagesProvider
|
||||
*/
|
||||
public function it_should_get_data_with_start_and_limit($page, $size, $start, $limit)
|
||||
{
|
||||
$listUnassigned = $this->getCollectionListUnassigned();
|
||||
$result = $listUnassigned->forPage($page, $size);
|
||||
|
||||
$this->getAuthorization();
|
||||
$request = $this->http->request("GET", "api/1.0/{$this->workspace}/light/unassigned?start={$start}&limit={$limit}", [
|
||||
"headers" => [
|
||||
"Authorization" => $this->authorization
|
||||
]
|
||||
]);
|
||||
|
||||
//Here is to verify if the connection to the endpoint was satisfactory,
|
||||
//so the connection status should be 200.
|
||||
$statusCode = $request->getStatusCode();
|
||||
$this->assertEquals(200, $statusCode);
|
||||
|
||||
//If the endpoint has responded we can obtain the data and verify if it
|
||||
//is what we expected.
|
||||
$expected = $this->normalizeData($result);
|
||||
$contents = $request->getBody()->getContents();
|
||||
$content = json_decode($contents);
|
||||
|
||||
$this->assertEquals($expected, $content);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\src\ProcessMaker\Util\Helpers;
|
||||
|
||||
use Tests\TestCase;
|
||||
|
||||
class ChangeAbbreviationOfDirectives extends TestCase
|
||||
{
|
||||
/**
|
||||
* Provider to define different types of configurations in the php.ini and the result expected
|
||||
*/
|
||||
public function provider()
|
||||
{
|
||||
return [
|
||||
['1024K','1024KB'],
|
||||
['600M','600MB'],
|
||||
['5G','5GB'],
|
||||
['10T','10Bytes'],
|
||||
['250','250Bytes']
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the function is changed correctly the possibles directives defined in the php.ini
|
||||
*
|
||||
* @link https://www.php.net/manual/es/faq.using.php#faq.using.shorthandbytes
|
||||
*
|
||||
* @param string $configuration
|
||||
* @param string $expected
|
||||
*
|
||||
* @dataProvider provider
|
||||
* @test
|
||||
*/
|
||||
public function it_should_change_abbreviation_of_directives($configuration, $expected)
|
||||
{
|
||||
$this->assertEquals($expected, changeAbbreviationOfDirectives($configuration));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\src\ProcessMaker\Util\Helpers;
|
||||
|
||||
use ProcessMaker\Model\User;
|
||||
use Tests\TestCase;
|
||||
|
||||
class UpdateUserLastLoginTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* It tests the updateUserLastLogin function
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_the_update_last_login_date_function_when_it_does_not_fail()
|
||||
{
|
||||
$user = factory(User::class)->create();
|
||||
|
||||
$userLog = ['USR_UID' => $user['USR_UID'], 'LOG_INIT_DATE' => date('Y-m-d H:i:s')];
|
||||
|
||||
// Call the updateUserLastLogin function
|
||||
$result = updateUserLastLogin($userLog);
|
||||
|
||||
// Asserts the update has been successful
|
||||
$this->assertEquals(1, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the updateUserLastLogin function exception
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_the_update_last_login_date_function_when_it_fails()
|
||||
{
|
||||
$user = factory(User::class)->create();
|
||||
|
||||
$userLog = ['USR_UID' => $user['USR_UID']];
|
||||
|
||||
// Assert the expected exception
|
||||
$this->expectExceptionMessage("Undefined index: LOG_INIT_DATE");
|
||||
|
||||
// Call the updateUserLastLogin function
|
||||
updateUserLastLogin($userLog);
|
||||
|
||||
$userLog = null;
|
||||
|
||||
// Assert the expected exception
|
||||
$this->expectExceptionMessage("There are no filter for loading a user model");
|
||||
|
||||
// Call the updateUserLastLogin function
|
||||
updateUserLastLogin($userLog);
|
||||
|
||||
$userLog = '';
|
||||
|
||||
// Assert the expected exception
|
||||
$this->expectExceptionMessage("Illegal string offset 'USR_UID'");
|
||||
|
||||
// Call the updateUserLastLogin function
|
||||
updateUserLastLogin($userLog);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -98,7 +98,7 @@ class MySQLiResultSet extends ResultSetCommon implements ResultSet {
|
||||
*/
|
||||
public function close()
|
||||
{
|
||||
if (is_resource($this->result)) {
|
||||
if ($this->result instanceof mysqli_result) {
|
||||
@mysqli_free_result($this->result);
|
||||
}
|
||||
$this->fields = array();
|
||||
|
||||
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('');
|
||||
}
|
||||
}
|
||||
|
||||
6
thirdparty/pear/Console/Getopt.php
vendored
6
thirdparty/pear/Console/Getopt.php
vendored
@@ -63,7 +63,7 @@ class Console_Getopt {
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
function getopt2($args, $short_options, $long_options = null)
|
||||
public static function getopt2($args, $short_options, $long_options = null)
|
||||
{
|
||||
return Console_Getopt::doGetopt(2, $args, $short_options, $long_options);
|
||||
}
|
||||
@@ -72,7 +72,7 @@ class Console_Getopt {
|
||||
* This function expects $args to start with the script name (POSIX-style).
|
||||
* Preserved for backwards compatibility.
|
||||
* @see getopt2()
|
||||
*/
|
||||
*/
|
||||
function getopt($args, $short_options, $long_options = null)
|
||||
{
|
||||
return Console_Getopt::doGetopt(1, $args, $short_options, $long_options);
|
||||
@@ -81,7 +81,7 @@ class Console_Getopt {
|
||||
/**
|
||||
* The actual implementation of the argument parsing code.
|
||||
*/
|
||||
function doGetopt($version, $args, $short_options, $long_options = null)
|
||||
public static function doGetopt($version, $args, $short_options, $long_options = null)
|
||||
{
|
||||
// in case you pass directly readPHPArgv() as the first arg
|
||||
if (PEAR::isError($args)) {
|
||||
|
||||
4
thirdparty/pear/Log.php
vendored
4
thirdparty/pear/Log.php
vendored
@@ -126,7 +126,7 @@ class Log
|
||||
* @access public
|
||||
* @since Log 1.0
|
||||
*/
|
||||
function &factory($handler, $name = '', $ident = '', $conf = array(),
|
||||
public static function &factory($handler, $name = '', $ident = '', $conf = array(),
|
||||
$level = PEAR_LOG_DEBUG)
|
||||
{
|
||||
$handler = strtolower($handler);
|
||||
@@ -188,7 +188,7 @@ class Log
|
||||
* @access public
|
||||
* @since Log 1.0
|
||||
*/
|
||||
function &singleton($handler, $name = '', $ident = '', $conf = array(),
|
||||
public static function &singleton($handler, $name = '', $ident = '', $conf = array(),
|
||||
$level = PEAR_LOG_DEBUG)
|
||||
{
|
||||
static $instances;
|
||||
|
||||
2
workflow/engine/bin/actionsByEmailEmailResponse.php
Normal file
2
workflow/engine/bin/actionsByEmailEmailResponse.php
Normal file
@@ -0,0 +1,2 @@
|
||||
<?php
|
||||
require_once("cron.php");
|
||||
@@ -12,11 +12,15 @@
|
||||
*/
|
||||
|
||||
use Illuminate\Foundation\Http\Kernel;
|
||||
/*----------------------------------********---------------------------------*/
|
||||
use ProcessMaker\BusinessModel\ActionsByEmail\ResponseReader;
|
||||
/*----------------------------------********---------------------------------*/
|
||||
|
||||
require_once __DIR__ . '/../../../gulliver/system/class.g.php';
|
||||
require_once __DIR__ . '/../../../bootstrap/autoload.php';
|
||||
require_once __DIR__ . '/../../../bootstrap/app.php';
|
||||
|
||||
use ProcessMaker\Core\JobsManager;
|
||||
use ProcessMaker\Core\System;
|
||||
use ProcessMaker\Plugins\PluginRegistry;
|
||||
|
||||
@@ -170,7 +174,8 @@ try {
|
||||
} else {
|
||||
eprintln('WARNING! No server info found!', 'red');
|
||||
}
|
||||
|
||||
//load Processmaker translations
|
||||
Bootstrap::LoadTranslationObject(SYS_LANG);
|
||||
//DB
|
||||
$phpCode = '';
|
||||
|
||||
@@ -250,6 +255,11 @@ try {
|
||||
|
||||
//Processing
|
||||
eprintln('Processing workspace: ' . $workspace, 'green');
|
||||
|
||||
/**
|
||||
* JobsManager
|
||||
*/
|
||||
JobsManager::getSingleton()->init();
|
||||
|
||||
// We load plugins' pmFunctions
|
||||
$oPluginRegistry = PluginRegistry::loadSingleton();
|
||||
@@ -280,6 +290,11 @@ try {
|
||||
case 'sendnotificationscron':
|
||||
sendNotifications();
|
||||
break;
|
||||
/*----------------------------------********---------------------------------*/
|
||||
case 'actionsByEmailEmailResponse':
|
||||
(new ResponseReader)->actionsByEmailEmailResponse();
|
||||
break;
|
||||
/*----------------------------------********---------------------------------*/
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$token = strtotime("now");
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user