diff --git a/.circleci/config.yml b/.circleci/config.yml index c520c3d69..e7918c315 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,10 +3,10 @@ jobs: build: working_directory: ~/processmaker docker: - - image: devopsstacks/pm:n275-phpunit + - image: devopsstacks/pm:n285-phpunit - image: circleci/mysql:8.0.13-ram command: | - mysqld --default-authentication-plugin='mysql_native_password' --optimizer-switch='derived_merge=off' --sql-mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION' + mysqld --default-authentication-plugin='mysql_native_password' --optimizer-switch='derived_merge=off' --sql-mode='NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION' --collation-server='utf8mb4_unicode_ci' --character-set-server='utf8mb4' environment: MYSQL_HOST: 127.0.0.1 MYSQL_ROOT_PASSWORD: 'password' @@ -27,7 +27,7 @@ jobs: - run: name: Run Test Units command: | - mkdir coverage + mkdir -p coverage vendor/phpunit/phpunit/phpunit --stop-on-error --testdox-html coverage/result.html --coverage-html coverage --verbose tests/unit/ - store_artifacts: path: coverage diff --git a/.gitignore b/.gitignore index 115961f95..8ce5011e7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ nbproject/* workflow/engine/config/paths_installed.php -gulliver/thirdparty/html2ps_pdf/cache workflow/engine/content/languages/translations.environments *~ workflow/engine/js/labels/ diff --git a/app/Console/Commands/RestartCommand.php b/app/Console/Commands/RestartCommand.php index e76915779..032a2b15f 100644 --- a/app/Console/Commands/RestartCommand.php +++ b/app/Console/Commands/RestartCommand.php @@ -2,6 +2,7 @@ namespace App\Console\Commands; +use Illuminate\Contracts\Cache\Repository as Cache; use Illuminate\Queue\Console\RestartCommand as BaseRestartCommand; class RestartCommand extends BaseRestartCommand @@ -17,4 +18,15 @@ class RestartCommand extends BaseRestartCommand * This contains the necessary code to add parameters. */ use AddParametersTrait; + + /** + * Create a new queue restart command. + * + * @param Cache $cache + * @return void + */ + public function __construct(Cache $cache) + { + parent::__construct($cache); + } } diff --git a/app/Console/Commands/ScheduleRunCommand.php b/app/Console/Commands/ScheduleRunCommand.php index c0d2a0354..bb5f88bb7 100755 --- a/app/Console/Commands/ScheduleRunCommand.php +++ b/app/Console/Commands/ScheduleRunCommand.php @@ -4,20 +4,23 @@ namespace App\Console\Commands; use Bootstrap; use Illuminate\Support\Carbon; +use Illuminate\Console\Scheduling\Schedule; use Illuminate\Console\Scheduling\ScheduleRunCommand as BaseCommand; +use Illuminate\Contracts\Events\Dispatcher; +use Illuminate\Contracts\Debug\ExceptionHandler; use Maveriks\WebApplication; use ProcessMaker\Model\TaskScheduler; class ScheduleRunCommand extends BaseCommand { use AddParametersTrait; + /** * Create a new command instance. - * - * @param \Illuminate\Console\Scheduling\Schedule $schedule + * * @return void */ - public function __construct(\Illuminate\Console\Scheduling\Schedule $schedule) + public function __construct() { $this->startedAt = Carbon::now(); $this->signature = "schedule:run"; @@ -27,24 +30,27 @@ class ScheduleRunCommand extends BaseCommand {--processmakerPath=./ : ProcessMaker path.} "; $this->description .= ' (ProcessMaker has extended this command)'; - parent::__construct($schedule); + parent::__construct(); } + /** * Execute the console command. - * + * + * @param Schedule $schedule + * @param Dispatcher $dispatcher + * @param ExceptionHandler $handler * @return void */ - public function handle() + public function handle(Schedule $schedule, Dispatcher $dispatcher, ExceptionHandler $handler) { - $that = $this; $workspace = $this->option('workspace'); - $user = $this->option('user'); + $user = $this->option('user'); if (!empty($workspace)) { $webApplication = new WebApplication(); $webApplication->setRootDir($this->option('processmakerPath')); $webApplication->loadEnvironment($workspace, false); } - TaskScheduler::all()->each(function ($p) use ($that, $user) { + TaskScheduler::all()->each(function ($p) use ($schedule, $user) { $win = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'; if ($p->enable == 1) { $starting = isset($p->startingTime) ? $p->startingTime : "0:00"; @@ -52,7 +58,7 @@ class ScheduleRunCommand extends BaseCommand $timezone = isset($p->timezone) && $p->timezone != "" ? $p->timezone : date_default_timezone_get(); $body = $p->body; if (!$win) { - $body = str_replace(" -c"," " . $user . " -c", $p->body); + $body = str_replace(" -c", " " . $user . " -c", $p->body); } //for init date and finish date parameters @@ -71,7 +77,7 @@ class ScheduleRunCommand extends BaseCommand $body = str_replace("report_by_process", "report_by_process +init-date'{$oneMonthAgo}' +finish-date'{$currentDate}'", $body); } - $schedule = $that->schedule->exec($body)->cron($p->expression)->between($starting, $ending)->timezone($timezone)->when(function () use ($p) { + $schedule->exec($body)->cron($p->expression)->between($starting, $ending)->timezone($timezone)->when(function () use ($p) { $now = Carbon::now(); $result = false; $datework = Carbon::createFromFormat('Y-m-d H:i:s', $p->last_update); @@ -116,6 +122,6 @@ class ScheduleRunCommand extends BaseCommand } } }); - parent::handle(); + parent::handle($schedule, $dispatcher, $handler); } -} \ No newline at end of file +} diff --git a/app/Console/Commands/WorkCommand.php b/app/Console/Commands/WorkCommand.php index bd59bc4bf..92426dad8 100644 --- a/app/Console/Commands/WorkCommand.php +++ b/app/Console/Commands/WorkCommand.php @@ -2,6 +2,7 @@ namespace App\Console\Commands; +use Illuminate\Contracts\Cache\Repository as Cache; use Illuminate\Support\Facades\File; use Illuminate\Queue\Console\WorkCommand as BaseWorkCommand; use Illuminate\Queue\Events\JobProcessing; @@ -9,7 +10,6 @@ use Illuminate\Queue\Worker; class WorkCommand extends BaseWorkCommand { - use AddParametersTrait; /** @@ -19,7 +19,7 @@ class WorkCommand extends BaseWorkCommand * * @return void */ - public function __construct(Worker $worker) + public function __construct(Worker $worker, Cache $cache) { $this->signature .= ' {--workspace=workflow : ProcessMaker Indicates the workspace to be processed.} @@ -28,7 +28,7 @@ class WorkCommand extends BaseWorkCommand $this->description .= ' (ProcessMaker has extended this command)'; - parent::__construct($worker); + parent::__construct($worker, $cache); } /** @@ -62,14 +62,14 @@ class WorkCommand extends BaseWorkCommand require_once $file; } //load the classes of the plugins when is required dynamically. - $closure = function($className) { + $closure = function ($className) { if (class_exists($className)) { return; } if (!defined('PATH_PLUGINS')) { return; } - $searchFiles = function($path) use(&$searchFiles, $className) { + $searchFiles = function ($path) use (&$searchFiles, $className) { $directories = File::directories($path); foreach ($directories as $directory) { $omittedDirectories = [ diff --git a/app/Factories/Factory.php b/app/Factories/Factory.php new file mode 100644 index 000000000..5c022db46 --- /dev/null +++ b/app/Factories/Factory.php @@ -0,0 +1,70 @@ +model ?: $resolver($this); + } +} diff --git a/app/Factories/HasFactory.php b/app/Factories/HasFactory.php new file mode 100644 index 000000000..fac4a1af0 --- /dev/null +++ b/app/Factories/HasFactory.php @@ -0,0 +1,28 @@ +count(is_numeric($parameters[0] ?? null) ? $parameters[0] : null) + ->state(is_array($parameters[0] ?? null) ? $parameters[0] : ($parameters[1] ?? [])); + } +} diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 2daad662c..6e9fc777d 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -2,8 +2,9 @@ namespace App\Providers; -use App\Helpers\Workspace; +use App\Console\Commands\WorkCommand; use App\Log\LogManager; +use Illuminate\Queue\Worker; use Illuminate\Support\Facades\App; use Illuminate\Support\ServiceProvider; @@ -17,8 +18,11 @@ class AppServiceProvider extends ServiceProvider */ public function register() { - App::bind('workspace', function() { - return new Workspace(); + $this->app->bind(WorkCommand::class, function ($app) { + $isDownForMaintenance = function () { + return $this->app->isDownForMaintenance(); + }; + return new WorkCommand(App::make(Worker::class, ['isDownForMaintenance' => $isDownForMaintenance]), $app['cache.store']); }); $this->app->singleton('log', function ($app) { diff --git a/composer.json b/composer.json index 14795b15f..ee098800c 100644 --- a/composer.json +++ b/composer.json @@ -31,8 +31,8 @@ "minimum-stability": "dev", "prefer-stable": true, "require": { - "php": ">=7.1", - "laravel/framework": "5.7.*", + "php": ">=7.4", + "laravel/framework": "8.83.*", "luracast/restler": "3.0", "bshaffer/oauth2-server-php": "v1.0", "colosa/pmui": "release/3.7.5-dev", @@ -41,8 +41,8 @@ "colosa/taskscheduler": "release/1.0.3-dev", "google/apiclient": "1.1.6", "dapphp/securimage": "^3.6", - "psr/log": "1.0.0", - "monolog/monolog": "1.19.0", + "psr/log": "1.0.1", + "monolog/monolog": "^2.1", "geshi/geshi": "dev-master", "libchart/libchart": "1.4.0", "phpmailer/phpmailer": "^6.4", @@ -52,25 +52,23 @@ "ralouphie/getallheaders": "^2.0", "smarty/smarty": "2.6.31", "pdepend/pdepend": "@stable", - "chumper/zipper": "^1.0", "php-imap/php-imap": "^3.0", - "nikic/php-parser": "3.1.5", - "laravel/tinker": "^1.0", + "nikic/php-parser": "4.14", + "laravel/tinker": "^2.0", "league/oauth2-client": "^2.4", "league/oauth2-google": "^3.0", - "tecnickcom/tcpdf": "6.3.*", - "fzaninotto/faker": "^1.7", + "tecnickcom/tcpdf": "6.4.*", + "fzaninotto/faker": "dev-master", "predis/predis": "1.1.1", "phpmyadmin/sql-parser": "^5.3", "aws/aws-sdk-php": "~3.0", - "cretueusebiu/laravel-javascript": "^0.2.1", "stevenmaguire/oauth2-microsoft": "^2.2", "phpseclib/mcrypt_compat": "^2.0", "microsoft/microsoft-graph": "^1.7" }, "require-dev": { "guzzlehttp/guzzle": "^6.3", - "phpunit/phpunit": "~5.7", + "phpunit/phpunit": "9.5", "filp/whoops": "~2.0", "behat/behat": "^3.3", "behat/mink-selenium2-driver": "^1.3", @@ -83,6 +81,7 @@ }, "psr-4": { "App\\": "app/", + "Database\\Factories\\": "database/factories/", "Maveriks\\": "framework/src/Maveriks/", "Tests\\": "tests/" }, @@ -95,7 +94,6 @@ "workflow/engine/includes/", "thirdparty/jsmin/jsmin.php", "thirdparty/pear", - "thirdparty/html2ps_pdf", "thirdparty/phing", "thirdparty/pake", "rbac/engine/classes/" diff --git a/config/app.php b/config/app.php index 1ffcf358c..956946042 100644 --- a/config/app.php +++ b/config/app.php @@ -27,12 +27,10 @@ return [ Illuminate\Bus\BusServiceProvider::class, Illuminate\Redis\RedisServiceProvider::class, App\Providers\AppServiceProvider::class, - App\Providers\ViewServiceProvider::class, - Eusebiu\JavaScript\JavaScriptServiceProvider::class + App\Providers\ViewServiceProvider::class ], 'aliases' => [ 'Crypt' => Illuminate\Support\Facades\Crypt::class, - 'ScriptVariables' => Eusebiu\JavaScript\Facades\ScriptVariables::class, 'View' => Illuminate\Support\Facades\View::class ], ]; diff --git a/config/deprecatedFiles.lst b/config/deprecatedFiles.lst index fcefceef2..0b7c65018 100644 --- a/config/deprecatedFiles.lst +++ b/config/deprecatedFiles.lst @@ -1,6 +1,7 @@ checksum.txt features/backend/projects/database_connections/main_tests_database_connections_sqlserver.feature features/backend/projects/project_export_import/main_tests_project_export_import.feature +gulliver/bin/tasks/pakeTest.php gulliver/core/Session/PmSessionHandler.php gulliver/js/codemirror/addon/hint/pig-hint.js gulliver/js/codemirror/addon/hint/python-hint.js @@ -37,6 +38,7 @@ rbac/engine/xmlform rbac/public_html/skins/JSForms.js virtualhost.conf.example workflow/engine/classes/class.jrml.php +workflow/engine/classes/class.webdav.php workflow/engine/classes/entities/AppSolrQueue.php workflow/engine/classes/entities/Base.php workflow/engine/classes/entities/FacetGroup.php @@ -130,4 +132,53 @@ workflow/engine/xmlform/users/users_List.xml workflow/engine/xmlform/users/users_Options.xml workflow/public_html/skins/JSForms.js workflow/public_html/skins/ajax.js +thirdparty/geshi +thirdparty/html2ps_pdf +thirdparty/libchart +thirdparty/lime +thirdparty/pear/Benchmark +thirdparty/pear/Console +thirdparty/pear/HTTP +thirdparty/pear/Net +thirdparty/pear/Numbers +thirdparty/pear/OLE +thirdparty/pear/SOAP +thirdparty/pear/Spreadsheet +thirdparty/pear/XML +thirdparty/pear/DB/dbase.php +thirdparty/pear/DB/fbsql.php +thirdparty/pear/DB/ibase.php +thirdparty/pear/DB/ifx.php +thirdparty/pear/DB/msql.php +thirdparty/pear/DB/mssql.php +thirdparty/pear/DB/mysql.php +thirdparty/pear/DB/sqlite.php +thirdparty/pear/DB/storage.php +thirdparty/pear/DB/sybase.php +thirdparty/pear/Log/sqlite.php +thirdparty/pear/catalog +thirdparty/pear/CODING_STANDARDS +thirdparty/pear/class.soap_fault.php +thirdparty/pear/class.soap_parser.php +thirdparty/pear/class.soap_server.php +thirdparty/pear/class.soap_transport_http.php +thirdparty/pear/class.soap_val.php +thirdparty/pear/class.wsdl.php +thirdparty/pear/class.wsdlcache.php +thirdparty/pear/class.xmlschema.php +thirdparty/pear/CMD.php +thirdparty/pear/install-pear.php +thirdparty/pear/install-pear.txt +thirdparty/pear/nusoap.colosa.php +thirdparty/pear/nusoap.php +thirdparty/pear/nusoapmime.php +thirdparty/pear/package-Archive_Tar.xml +thirdparty/pear/package-Console_Getopt.xml +thirdparty/pear/package.dtd +thirdparty/pear/package-PEAR.xml +thirdparty/pear/README +thirdparty/pear/template.spec +thirdparty/pear/UDDI.php +thirdparty/propel-generator/classes/propel/engine/builder/sql/sqlite/SqliteDataSQLBuilder.php +thirdparty/propel-generator/classes/propel/engine/platform/SqlitePlatform.php thirdparty/tcpdf \ No newline at end of file diff --git a/database/factories/AbeConfigurationFactory.php b/database/factories/AbeConfigurationFactory.php index 50f34ab21..09b4b4f49 100644 --- a/database/factories/AbeConfigurationFactory.php +++ b/database/factories/AbeConfigurationFactory.php @@ -1,35 +1,50 @@ define(\ProcessMaker\Model\AbeConfiguration::class, function (Faker $faker) { - $process = factory(\ProcessMaker\Model\Process::class)->create(); - $dynaform = factory(\ProcessMaker\Model\Dynaform::class)->create([ - 'PRO_UID' => $process->PRO_UID - ]); - $task = factory(\ProcessMaker\Model\Task::class)->create([ - 'PRO_UID' => $process->PRO_UID - ]); - $emailServer = factory(\ProcessMaker\Model\EmailServerModel::class)->create(); - return [ - 'ABE_UID' => G::generateUniqueID(), - 'PRO_UID' => $process->PRO_UID, - 'TAS_UID' => $task->TAS_UID, - 'ABE_TYPE' => $faker->randomElement(['', 'LINK']), - 'ABE_TEMPLATE' => 'actionByEmail.html', - 'ABE_DYN_TYPE' => 'NORMAL', - 'DYN_UID' => $dynaform->DYN_UID, - 'ABE_EMAIL_FIELD' => 'admin@processmaker.com', - 'ABE_ACTION_FIELD' => '', - 'ABE_CASE_NOTE_IN_RESPONSE' => $faker->randomElement(['0', '1']), - 'ABE_FORCE_LOGIN' => $faker->randomElement(['0', '1']), - 'ABE_CREATE_DATE' => $faker->dateTime(), - 'ABE_UPDATE_DATE' => $faker->dateTime(), - 'ABE_SUBJECT_FIELD' => '', - 'ABE_MAILSERVER_OR_MAILCURRENT' => 0, - 'ABE_CUSTOM_GRID' => serialize([]), - 'ABE_EMAIL_SERVER_UID' => $emailServer->MESS_UID, - 'ABE_ACTION_BODY_FIELD' => '', - 'ABE_EMAIL_SERVER_RECEIVER_UID' => '' - ]; -}); +use App\Factories\Factory; +use G; +use Illuminate\Support\Str; + +class AbeConfigurationFactory extends Factory +{ + + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + $process = \ProcessMaker\Model\Process::factory()->create(); + $dynaform = \ProcessMaker\Model\Dynaform::factory()->create([ + 'PRO_UID' => $process->PRO_UID + ]); + $task = \ProcessMaker\Model\Task::factory()->create([ + 'PRO_UID' => $process->PRO_UID + ]); + $emailServer = \ProcessMaker\Model\EmailServerModel::factory()->create(); + return [ + 'ABE_UID' => G::generateUniqueID(), + 'PRO_UID' => $process->PRO_UID, + 'TAS_UID' => $task->TAS_UID, + 'ABE_TYPE' => $this->faker->randomElement(['', 'LINK']), + 'ABE_TEMPLATE' => 'actionByEmail.html', + 'ABE_DYN_TYPE' => 'NORMAL', + 'DYN_UID' => $dynaform->DYN_UID, + 'ABE_EMAIL_FIELD' => 'admin@processmaker.com', + 'ABE_ACTION_FIELD' => '', + 'ABE_CASE_NOTE_IN_RESPONSE' => $this->faker->randomElement(['0', '1']), + 'ABE_FORCE_LOGIN' => $this->faker->randomElement(['0', '1']), + 'ABE_CREATE_DATE' => $this->faker->dateTime(), + 'ABE_UPDATE_DATE' => $this->faker->dateTime(), + 'ABE_SUBJECT_FIELD' => '', + 'ABE_MAILSERVER_OR_MAILCURRENT' => 0, + 'ABE_CUSTOM_GRID' => serialize([]), + 'ABE_EMAIL_SERVER_UID' => $emailServer->MESS_UID, + 'ABE_ACTION_BODY_FIELD' => '', + 'ABE_EMAIL_SERVER_RECEIVER_UID' => '' + ]; + } + +} diff --git a/database/factories/AbeRequestFactory.php b/database/factories/AbeRequestFactory.php index 387f10357..458451287 100644 --- a/database/factories/AbeRequestFactory.php +++ b/database/factories/AbeRequestFactory.php @@ -1,25 +1,40 @@ define(\ProcessMaker\Model\AbeRequest::class, function (Faker $faker) { - $process = factory(\ProcessMaker\Model\Process::class)->create(); - $abeConfiguration = factory(\ProcessMaker\Model\AbeConfiguration::class)->create([ - 'PRO_UID' => $process->PRO_UID - ]); - $application = factory(\ProcessMaker\Model\Application::class)->create([ - 'PRO_UID' => $process->PRO_UID - ]); - return [ - 'ABE_REQ_UID' => G::generateUniqueID(), - 'ABE_UID' => $abeConfiguration->ABE_UID, - 'APP_UID' => $application->APP_UID, - 'DEL_INDEX' => 0, - 'ABE_REQ_SENT_TO' => $faker->email, - 'ABE_REQ_SUBJECT' => '', - 'ABE_REQ_BODY' => '', - 'ABE_REQ_DATE' => $faker->date(), - 'ABE_REQ_STATUS' => '', - 'ABE_REQ_ANSWERED' => $faker->numberBetween(1, 9) - ]; -}); +use App\Factories\Factory; +use G; +use Illuminate\Support\Str; + +class AbeRequestFactory extends Factory +{ + + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + $process = \ProcessMaker\Model\Process::factory()->create(); + $abeConfiguration = \ProcessMaker\Model\AbeConfiguration::factory()->create([ + 'PRO_UID' => $process->PRO_UID + ]); + $application = \ProcessMaker\Model\Application::factory()->create([ + 'PRO_UID' => $process->PRO_UID + ]); + return [ + 'ABE_REQ_UID' => G::generateUniqueID(), + 'ABE_UID' => $abeConfiguration->ABE_UID, + 'APP_UID' => $application->APP_UID, + 'DEL_INDEX' => 0, + 'ABE_REQ_SENT_TO' => $this->faker->email, + 'ABE_REQ_SUBJECT' => '', + 'ABE_REQ_BODY' => '', + 'ABE_REQ_DATE' => $this->faker->date(), + 'ABE_REQ_STATUS' => '', + 'ABE_REQ_ANSWERED' => $this->faker->numberBetween(1, 9) + ]; + } + +} diff --git a/database/factories/AdditionalTablesFactory.php b/database/factories/AdditionalTablesFactory.php index 184bfe1b3..be67f30cf 100644 --- a/database/factories/AdditionalTablesFactory.php +++ b/database/factories/AdditionalTablesFactory.php @@ -1,29 +1,44 @@ define(\ProcessMaker\Model\AdditionalTables::class, function(Faker $faker) { - $name = $faker->regexify("/[a-zA-Z]{6}/"); - return [ - 'ADD_TAB_UID' => G::generateUniqueID(), - 'ADD_TAB_NAME' => 'PMT_' . strtoupper($name), - 'ADD_TAB_CLASS_NAME' => 'Pmt' . $name, - 'ADD_TAB_DESCRIPTION' => $faker->text, - 'ADD_TAB_SDW_LOG_INSERT' => 0, - 'ADD_TAB_SDW_LOG_UPDATE' => 0, - 'ADD_TAB_SDW_LOG_DELETE' => 0, - 'ADD_TAB_SDW_LOG_SELECT' => 0, - 'ADD_TAB_SDW_MAX_LENGTH' => 0, - 'ADD_TAB_SDW_AUTO_DELETE' => 0, - 'ADD_TAB_PLG_UID' => '', - 'DBS_UID' => 'workflow', - 'PRO_UID' => function() { - return factory(\ProcessMaker\Model\Process::class)->create()->PRO_UID; - }, - 'ADD_TAB_TYPE' => '', - 'ADD_TAB_GRID' => '', - 'ADD_TAB_TAG' => '', - 'ADD_TAB_OFFLINE' => 0, - 'ADD_TAB_UPDATE_DATE' => $faker->dateTime() - ]; -}); +use App\Factories\Factory; +use G; +use Illuminate\Support\Str; + +class AdditionalTablesFactory extends Factory +{ + + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + $name = $this->faker->regexify("/[a-zA-Z]{6}/"); + return [ + 'ADD_TAB_UID' => G::generateUniqueID(), + 'ADD_TAB_NAME' => 'PMT_' . strtoupper($name), + 'ADD_TAB_CLASS_NAME' => 'Pmt' . $name, + 'ADD_TAB_DESCRIPTION' => $this->faker->text, + 'ADD_TAB_SDW_LOG_INSERT' => 0, + 'ADD_TAB_SDW_LOG_UPDATE' => 0, + 'ADD_TAB_SDW_LOG_DELETE' => 0, + 'ADD_TAB_SDW_LOG_SELECT' => 0, + 'ADD_TAB_SDW_MAX_LENGTH' => 0, + 'ADD_TAB_SDW_AUTO_DELETE' => 0, + 'ADD_TAB_PLG_UID' => '', + 'DBS_UID' => 'workflow', + 'PRO_UID' => function () { + return \ProcessMaker\Model\Process::factory()->create()->PRO_UID; + }, + 'ADD_TAB_TYPE' => '', + 'ADD_TAB_GRID' => '', + 'ADD_TAB_TAG' => '', + 'ADD_TAB_OFFLINE' => 0, + 'ADD_TAB_UPDATE_DATE' => $this->faker->dateTime() + ]; + } + +} diff --git a/database/factories/AppAssignSelfServiceValueFactory.php b/database/factories/AppAssignSelfServiceValueFactory.php index e2ca710f4..30f504bc3 100644 --- a/database/factories/AppAssignSelfServiceValueFactory.php +++ b/database/factories/AppAssignSelfServiceValueFactory.php @@ -1,18 +1,30 @@ define(\ProcessMaker\Model\AppAssignSelfServiceValue::class, function(Faker $faker) { - return [ - 'ID' => $faker->unique()->numberBetween(5000), - 'APP_UID' => G::generateUniqueID(), - 'DEL_INDEX' => 2, - 'PRO_UID' => G::generateUniqueID(), - 'TAS_UID' => G::generateUniqueID(), - 'TAS_ID' => $faker->unique()->numberBetween(1, 2000), - 'GRP_UID' => G::generateUniqueID(), - ]; -}); +namespace Database\Factories; +use App\Factories\Factory; +use G; +use Illuminate\Support\Str; + +class AppAssignSelfServiceValueFactory extends Factory +{ + + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + return [ + 'ID' => $this->faker->unique()->numberBetween(5000), + 'APP_UID' => G::generateUniqueID(), + 'DEL_INDEX' => 2, + 'PRO_UID' => G::generateUniqueID(), + 'TAS_UID' => G::generateUniqueID(), + 'TAS_ID' => $this->faker->unique()->numberBetween(1, 2000), + 'GRP_UID' => G::generateUniqueID(), + ]; + } + +} diff --git a/database/factories/AppAssignSelfServiceValueGroupFactory.php b/database/factories/AppAssignSelfServiceValueGroupFactory.php index 85a96729a..805736bbe 100644 --- a/database/factories/AppAssignSelfServiceValueGroupFactory.php +++ b/database/factories/AppAssignSelfServiceValueGroupFactory.php @@ -1,15 +1,27 @@ define(\ProcessMaker\Model\AppAssignSelfServiceValueGroup::class, function(Faker $faker) { - return [ - 'ID' => $faker->unique()->numberBetween(5000), - 'GRP_UID' => G::generateUniqueID(), - 'ASSIGNEE_ID' => $faker->unique()->numberBetween(1, 2000), - 'ASSIGNEE_TYPE' => $faker->unique()->numberBetween(1, 2000), - ]; -}); +namespace Database\Factories; +use App\Factories\Factory; +use G; +use Illuminate\Support\Str; + +class AppAssignSelfServiceValueGroupFactory extends Factory +{ + + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + return [ + 'ID' => $this->faker->unique()->numberBetween(5000), + 'GRP_UID' => G::generateUniqueID(), + 'ASSIGNEE_ID' => $this->faker->unique()->numberBetween(1, 2000), + 'ASSIGNEE_TYPE' => $this->faker->unique()->numberBetween(1, 2000), + ]; + } + +} diff --git a/database/factories/AppDelayFactory.php b/database/factories/AppDelayFactory.php index fee432649..acfeba695 100644 --- a/database/factories/AppDelayFactory.php +++ b/database/factories/AppDelayFactory.php @@ -1,62 +1,84 @@ define(\ProcessMaker\Model\AppDelay::class, function (Faker $faker) { - $actions = ['CANCEL', 'PAUSE', 'REASSIGN']; - return [ - 'APP_DELAY_UID' => G::generateUniqueID(), - 'PRO_UID' => G::generateUniqueID(), - 'APP_UID' => G::generateUniqueID(), - 'APP_NUMBER' => $faker->unique()->numberBetween(1000), - 'APP_THREAD_INDEX' => $faker->unique()->numberBetween(100), - 'APP_DEL_INDEX' => $faker->unique()->numberBetween(100), - 'APP_TYPE' => $faker->randomElement($actions), - 'APP_STATUS' => 'TO_DO', - 'APP_NEXT_TASK' => 0, - 'APP_DELEGATION_USER' => G::generateUniqueID(), - 'APP_ENABLE_ACTION_USER' => G::generateUniqueID(), - 'APP_ENABLE_ACTION_DATE' => $faker->dateTime(), - 'APP_DISABLE_ACTION_USER' => G::generateUniqueID(), - 'APP_DISABLE_ACTION_DATE' => $faker->dateTime(), - 'APP_AUTOMATIC_DISABLED_DATE' => '', - 'APP_DELEGATION_USER_ID' => $faker->unique()->numberBetween(1000), - 'PRO_ID' => $faker->unique()->numberBetween(1000), - ]; -}); +use App\Factories\Factory; +use G; +use Illuminate\Support\Str; -// Create a delegation with the foreign keys -$factory->state(\ProcessMaker\Model\AppDelay::class, 'paused_foreign_keys', function (Faker $faker) { - // Create values in the foreign key relations - $delegation1 = factory(\ProcessMaker\Model\Delegation::class)->states('closed')->create(); - $delegation2 = factory(\ProcessMaker\Model\Delegation::class)->states('foreign_keys')->create([ - 'PRO_UID' => $delegation1->PRO_UID, - 'PRO_ID' => $delegation1->PRO_ID, - 'TAS_UID' => $delegation1->TAS_UID, - 'TAS_ID' => $delegation1->TAS_ID, - 'APP_NUMBER' => $delegation1->APP_NUMBER, - 'APP_UID' => $delegation1->APP_UID, - 'DEL_THREAD_STATUS' => 'OPEN', - 'USR_UID' => $delegation1->USR_UID, - 'USR_ID' => $delegation1->USR_ID, - 'DEL_PREVIOUS' => $delegation1->DEL_INDEX, - 'DEL_INDEX' => $faker->unique()->numberBetween(2000), - ]); +class AppDelayFactory extends Factory +{ - // Return with default values - return [ - 'APP_DELAY_UID' => G::generateUniqueID(), - 'PRO_UID' => $delegation2->PRO_UID, - 'PRO_ID' => $delegation2->PRO_ID, - 'APP_UID' => $delegation2->APP_UID, - 'APP_NUMBER' => $delegation2->APP_NUMBER, - 'APP_DEL_INDEX' => $delegation2->DEL_INDEX, - 'APP_TYPE' => 'PAUSE', - 'APP_STATUS' => 'TO_DO', - 'APP_DELEGATION_USER' => $delegation2->USR_UID, - 'APP_DELEGATION_USER_ID' => $delegation2->USR_ID, - 'APP_ENABLE_ACTION_USER' => G::generateUniqueID(), - 'APP_ENABLE_ACTION_DATE' => $faker->dateTime(), - 'APP_DISABLE_ACTION_USER' => 0, - ]; -}); + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + $actions = ['CANCEL', 'PAUSE', 'REASSIGN']; + return [ + 'APP_DELAY_UID' => G::generateUniqueID(), + 'PRO_UID' => G::generateUniqueID(), + 'APP_UID' => G::generateUniqueID(), + 'APP_NUMBER' => $this->faker->unique()->numberBetween(1000), + 'APP_THREAD_INDEX' => $this->faker->unique()->numberBetween(100), + 'APP_DEL_INDEX' => $this->faker->unique()->numberBetween(100), + 'APP_TYPE' => $this->faker->randomElement($actions), + 'APP_STATUS' => 'TO_DO', + 'APP_NEXT_TASK' => 0, + 'APP_DELEGATION_USER' => G::generateUniqueID(), + 'APP_ENABLE_ACTION_USER' => G::generateUniqueID(), + 'APP_ENABLE_ACTION_DATE' => $this->faker->dateTime(), + 'APP_DISABLE_ACTION_USER' => G::generateUniqueID(), + 'APP_DISABLE_ACTION_DATE' => $this->faker->dateTime(), + 'APP_AUTOMATIC_DISABLED_DATE' => '', + 'APP_DELEGATION_USER_ID' => $this->faker->unique()->numberBetween(1000), + 'PRO_ID' => $this->faker->unique()->numberBetween(1000), + ]; + } + + /** + * Create a delegation with the foreign keys + * @return type + */ + public function paused_foreign_keys() + { + $state = function (array $attributes) { + // Create values in the foreign key relations + $delegation1 = \ProcessMaker\Model\Delegation::factory()->closed()->create(); + $delegation2 = \ProcessMaker\Model\Delegation::factory()->foreign_keys()->create([ + 'PRO_UID' => $delegation1->PRO_UID, + 'PRO_ID' => $delegation1->PRO_ID, + 'TAS_UID' => $delegation1->TAS_UID, + 'TAS_ID' => $delegation1->TAS_ID, + 'APP_NUMBER' => $delegation1->APP_NUMBER, + 'APP_UID' => $delegation1->APP_UID, + 'DEL_THREAD_STATUS' => 'OPEN', + 'USR_UID' => $delegation1->USR_UID, + 'USR_ID' => $delegation1->USR_ID, + 'DEL_PREVIOUS' => $delegation1->DEL_INDEX, + 'DEL_INDEX' => $this->faker->unique()->numberBetween(2000), + ]); + + // Return with default values + return [ + 'APP_DELAY_UID' => G::generateUniqueID(), + 'PRO_UID' => $delegation2->PRO_UID, + 'PRO_ID' => $delegation2->PRO_ID, + 'APP_UID' => $delegation2->APP_UID, + 'APP_NUMBER' => $delegation2->APP_NUMBER, + 'APP_DEL_INDEX' => $delegation2->DEL_INDEX, + 'APP_TYPE' => 'PAUSE', + 'APP_STATUS' => 'TO_DO', + 'APP_DELEGATION_USER' => $delegation2->USR_UID, + 'APP_DELEGATION_USER_ID' => $delegation2->USR_ID, + 'APP_ENABLE_ACTION_USER' => G::generateUniqueID(), + 'APP_ENABLE_ACTION_DATE' => $this->faker->dateTime(), + 'APP_DISABLE_ACTION_USER' => 0, + ]; + }; + return $this->state($state); + } + +} diff --git a/database/factories/AppMessageFactory.php b/database/factories/AppMessageFactory.php index 3c7a1a997..96ff470bf 100644 --- a/database/factories/AppMessageFactory.php +++ b/database/factories/AppMessageFactory.php @@ -1,37 +1,52 @@ define(\ProcessMaker\Model\AppMessage::class, function(Faker $faker) { - return [ - 'APP_MSG_UID' => G::generateUniqueID(), - 'MSG_UID' => '', - 'APP_UID' => function() { - return factory(\ProcessMaker\Model\Application::class)->create()->APP_UID; - }, - 'DEL_INDEX' => 1, - 'APP_MSG_TYPE' => 'ROUTING', - 'APP_MSG_TYPE_ID' => 0, - 'APP_MSG_SUBJECT' => $faker->title, - 'APP_MSG_FROM' => $faker->email, - 'APP_MSG_TO' => $faker->email, - 'APP_MSG_BODY' => $faker->text, - 'APP_MSG_DATE' => $faker->dateTime(), - 'APP_MSG_CC' => '', - 'APP_MSG_BCC' => '', - 'APP_MSG_TEMPLATE' => '', - 'APP_MSG_STATUS' => 'pending', - 'APP_MSG_STATUS_ID' => 1, - 'APP_MSG_ATTACH' => '', - 'APP_MSG_SEND_DATE' => $faker->dateTime(), - 'APP_MSG_SHOW_MESSAGE' => 1, - 'APP_MSG_ERROR' => '', - 'PRO_ID' => function() { - return factory(\ProcessMaker\Model\Process::class)->create()->PRO_ID; - }, - 'TAS_ID' => function() { - return factory(\ProcessMaker\Model\Task::class)->create()->TAS_ID; - }, - 'APP_NUMBER' => 1 - ]; -}); +use App\Factories\Factory; +use G; +use Illuminate\Support\Str; + +class AppMessageFactory extends Factory +{ + + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + return [ + 'APP_MSG_UID' => G::generateUniqueID(), + 'MSG_UID' => '', + 'APP_UID' => function () { + return \ProcessMaker\Model\Application::factory()->create()->APP_UID; + }, + 'DEL_INDEX' => 1, + 'APP_MSG_TYPE' => 'ROUTING', + 'APP_MSG_TYPE_ID' => 0, + 'APP_MSG_SUBJECT' => $this->faker->title, + 'APP_MSG_FROM' => $this->faker->email, + 'APP_MSG_TO' => $this->faker->email, + 'APP_MSG_BODY' => $this->faker->text, + 'APP_MSG_DATE' => $this->faker->dateTime(), + 'APP_MSG_CC' => '', + 'APP_MSG_BCC' => '', + 'APP_MSG_TEMPLATE' => '', + 'APP_MSG_STATUS' => 'pending', + 'APP_MSG_STATUS_ID' => 1, + 'APP_MSG_ATTACH' => '', + 'APP_MSG_SEND_DATE' => $this->faker->dateTime(), + 'APP_MSG_SHOW_MESSAGE' => 1, + 'APP_MSG_ERROR' => '', + 'PRO_ID' => function () { + return \ProcessMaker\Model\Process::factory()->create()->PRO_ID; + }, + 'TAS_ID' => function () { + return \ProcessMaker\Model\Task::factory()->create()->TAS_ID; + }, + 'APP_NUMBER' => 1 + ]; + } + +} diff --git a/database/factories/AppNotesFactory.php b/database/factories/AppNotesFactory.php index c034a285e..c135fb4ea 100644 --- a/database/factories/AppNotesFactory.php +++ b/database/factories/AppNotesFactory.php @@ -1,42 +1,63 @@ define(\ProcessMaker\Model\AppNotes::class, function (Faker $faker) { - return [ - 'APP_UID' => G::generateUniqueID(), - 'APP_NUMBER' => $faker->unique()->numberBetween(5000), - 'USR_UID' => G::generateUniqueID(), - 'NOTE_DATE' => $faker->dateTime(), - 'NOTE_CONTENT' => $faker->sentence(3), - 'NOTE_TYPE' => 'USER', - 'NOTE_AVAILABILITY' => 'PUBLIC', - 'NOTE_ORIGIN_OBJ' => '', - 'NOTE_AFFECTED_OBJ1' => '', - 'NOTE_AFFECTED_OBJ2' => '', - 'NOTE_RECIPIENTS' => '', - ]; -}); +use App\Factories\Factory; +use G; +use Illuminate\Support\Str; -// Create a case notes with the foreign keys -$factory->state(\ProcessMaker\Model\AppNotes::class, 'foreign_keys', function (Faker $faker) { - // Create values in the foreign key relations - $application = factory(\ProcessMaker\Model\Application::class)->create(); - $user = factory(\ProcessMaker\Model\User::class)->create(); +class AppNotesFactory extends Factory +{ - // Return with default values - return [ - 'APP_UID' => $application->APP_UID, - 'APP_NUMBER' => $application->APP_NUMBER, - 'USR_UID' => $user->USR_UID, - 'NOTE_DATE' => $faker->dateTime(), - 'NOTE_CONTENT' => $faker->sentence(3), - 'NOTE_TYPE' => 'USER', - 'NOTE_AVAILABILITY' => 'PUBLIC', - 'NOTE_ORIGIN_OBJ' => '', - 'NOTE_AFFECTED_OBJ1' => '', - 'NOTE_AFFECTED_OBJ2' => '', - 'NOTE_RECIPIENTS' => '', - ]; -}); + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + return [ + 'APP_UID' => G::generateUniqueID(), + 'APP_NUMBER' => $this->faker->unique()->numberBetween(5000), + 'USR_UID' => G::generateUniqueID(), + 'NOTE_DATE' => $this->faker->dateTime(), + 'NOTE_CONTENT' => $this->faker->sentence(3), + 'NOTE_TYPE' => 'USER', + 'NOTE_AVAILABILITY' => 'PUBLIC', + 'NOTE_ORIGIN_OBJ' => '', + 'NOTE_AFFECTED_OBJ1' => '', + 'NOTE_AFFECTED_OBJ2' => '', + 'NOTE_RECIPIENTS' => '', + ]; + } + /** + * Create a case notes with the foreign keys + * @return type + */ + public function foreign_keys() + { + $state = function (array $attributes) { + // Create values in the foreign key relations + $application = \ProcessMaker\Model\Application::factory()->create(); + $user = \ProcessMaker\Model\User::factory()->create(); + + // Return with default values + return [ + 'APP_UID' => $application->APP_UID, + 'APP_NUMBER' => $application->APP_NUMBER, + 'USR_UID' => $user->USR_UID, + 'NOTE_DATE' => $this->faker->dateTime(), + 'NOTE_CONTENT' => $this->faker->sentence(3), + 'NOTE_TYPE' => 'USER', + 'NOTE_AVAILABILITY' => 'PUBLIC', + 'NOTE_ORIGIN_OBJ' => '', + 'NOTE_AFFECTED_OBJ1' => '', + 'NOTE_AFFECTED_OBJ2' => '', + 'NOTE_RECIPIENTS' => '', + ]; + }; + return $this->state($state); + } + +} diff --git a/database/factories/AppThreadFactory.php b/database/factories/AppThreadFactory.php index 33590b0d8..326ff3c3c 100644 --- a/database/factories/AppThreadFactory.php +++ b/database/factories/AppThreadFactory.php @@ -1,16 +1,28 @@ define(\ProcessMaker\Model\AppThread::class, function (Faker $faker) { - return [ - 'APP_UID' => G::generateUniqueID(), - 'APP_THREAD_INDEX' => $faker->unique()->numberBetween(1, 2000), - 'APP_THREAD_PARENT' => $faker->unique()->numberBetween(1, 2000), - 'APP_THREAD_STATUS' => $faker->randomElement(['OPEN', 'CLOSED']), - 'DEL_INDEX' => $faker->unique()->numberBetween(1, 2000) - ]; -}); \ No newline at end of file +use App\Factories\Factory; +use G; +use Illuminate\Support\Str; + +class AppThreadFactory extends Factory +{ + + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + return [ + 'APP_UID' => G::generateUniqueID(), + 'APP_THREAD_INDEX' => $this->faker->unique()->numberBetween(1, 2000), + 'APP_THREAD_PARENT' => $this->faker->unique()->numberBetween(1, 2000), + 'APP_THREAD_STATUS' => $this->faker->randomElement(['OPEN', 'CLOSED']), + 'DEL_INDEX' => $this->faker->unique()->numberBetween(1, 2000) + ]; + } + +} diff --git a/database/factories/AppTimeoutActionFactory.php b/database/factories/AppTimeoutActionFactory.php index c9a120d07..b51318d38 100644 --- a/database/factories/AppTimeoutActionFactory.php +++ b/database/factories/AppTimeoutActionFactory.php @@ -1,12 +1,27 @@ define(\ProcessMaker\Model\AppTimeoutAction::class, function (Faker $faker) { - $index = $faker->unique()->numberBetween(20); - return [ - 'APP_UID' => G::generateUniqueID(), - 'DEL_INDEX' => $index, - 'EXECUTION_DATE' => $faker->dateTime() - ]; -}); +use App\Factories\Factory; +use G; +use Illuminate\Support\Str; + +class AppTimeoutActionFactory extends Factory +{ + + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + $index = $this->faker->unique()->numberBetween(20); + return [ + 'APP_UID' => G::generateUniqueID(), + 'DEL_INDEX' => $index, + 'EXECUTION_DATE' => $this->faker->dateTime() + ]; + } + +} diff --git a/database/factories/ApplicationFactory.php b/database/factories/ApplicationFactory.php index 74ba1720d..91944ee88 100644 --- a/database/factories/ApplicationFactory.php +++ b/database/factories/ApplicationFactory.php @@ -1,147 +1,233 @@ define(\ProcessMaker\Model\Application::class, function(Faker $faker) { - $user = factory(\ProcessMaker\Model\User::class)->create(); - $appNumber = $faker->unique()->numberBetween(1000); - // APP_TITLE field is used in 'MYSQL: MATCH() AGAINST()' function, string size should not be less than 3. - $appTitle = $faker->lexify(str_repeat('?', rand(3, 5)) . ' ' . str_repeat('?', rand(3, 5))); - return [ - 'APP_UID' => G::generateUniqueID(), - 'APP_TITLE' => $appTitle, - 'APP_DESCRIPTION' => $faker->text, - 'APP_NUMBER' => $appNumber, - 'APP_STATUS' => 'TO_DO', - 'APP_STATUS_ID' => 2, - 'PRO_UID' => function() { - return factory(\ProcessMaker\Model\Process::class)->create()->PRO_UID; - }, - 'APP_PROC_STATUS' => '', - 'APP_PROC_CODE' => '', - 'APP_PARALLEL' => 'N', - 'APP_INIT_USER' => $user->USR_UID, - 'APP_CUR_USER' => $user->USR_UID, - 'APP_PIN' => G::generateUniqueID(), - 'APP_CREATE_DATE' => $faker->dateTimeBetween('now', '+30 minutes'), - 'APP_INIT_DATE' => $faker->dateTimeBetween('now', '+30 minutes'), - 'APP_UPDATE_DATE' => $faker->dateTimeBetween('now', '+30 minutes'), - 'APP_FINISH_DATE' => $faker->dateTimeBetween('now', '+30 minutes'), - 'APP_DATA' => serialize(['APP_NUMBER' => $appNumber]) - ]; -}); +use App\Factories\Factory; +use G; +use Illuminate\Support\Str; -// Create a delegation with the foreign keys -$factory->state(\ProcessMaker\Model\Application::class, 'foreign_keys', function (Faker $faker) { - // Create values in the foreign key relations - $process = factory(\ProcessMaker\Model\Process::class)->create(); - $user = factory(\ProcessMaker\Model\User::class)->create(); - $appNumber = $faker->unique()->numberBetween(1000); +class ApplicationFactory extends Factory +{ - // APP_TITLE field is used in 'MYSQL: MATCH() AGAINST()' function, string size should not be less than 3. - $appTitle = $faker->lexify(str_repeat('?', rand(3, 5)) . ' ' . str_repeat('?', rand(3, 5))); + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + $user = \ProcessMaker\Model\User::factory()->create(); + $appNumber = $this->faker->unique()->numberBetween(1000); + // APP_TITLE field is used in 'MYSQL: MATCH() AGAINST()' function, string size should not be less than 3. + $appTitle = $this->faker->lexify(str_repeat('?', rand(3, 5)) . ' ' . str_repeat('?', rand(3, 5))); + return [ + 'APP_UID' => G::generateUniqueID(), + 'APP_TITLE' => $appTitle, + 'APP_DESCRIPTION' => $this->faker->text, + 'APP_NUMBER' => $appNumber, + 'APP_STATUS' => 'TO_DO', + 'APP_STATUS_ID' => 2, + 'PRO_UID' => function () { + return \ProcessMaker\Model\Process::factory()->create()->PRO_UID; + }, + 'APP_PROC_STATUS' => '', + 'APP_PROC_CODE' => '', + 'APP_PARALLEL' => 'N', + 'APP_INIT_USER' => $user->USR_UID, + 'APP_CUR_USER' => $user->USR_UID, + 'APP_PIN' => G::generateUniqueID(), + 'APP_CREATE_DATE' => $this->faker->dateTimeBetween('now', '+30 minutes'), + 'APP_INIT_DATE' => $this->faker->dateTimeBetween('now', '+30 minutes'), + 'APP_UPDATE_DATE' => $this->faker->dateTimeBetween('now', '+30 minutes'), + 'APP_FINISH_DATE' => $this->faker->dateTimeBetween('now', '+30 minutes'), + 'APP_DATA' => serialize(['APP_NUMBER' => $appNumber]) + ]; + } - $statuses = ['DRAFT', 'TO_DO', 'COMPLETED', 'CANCELLED']; - $status = $faker->randomElement($statuses); - $statusId = array_search($status, $statuses) + 1; + /** + * Create a delegation with the foreign keys + * @return type + */ + public function foreign_keys() + { + $state = function (array $attributes) { + // Create values in the foreign key relations + $process = \ProcessMaker\Model\Process::factory()->create(); + $user = \ProcessMaker\Model\User::factory()->create(); + $appNumber = $this->faker->unique()->numberBetween(1000); - return [ - 'APP_UID' => G::generateUniqueID(), - 'APP_TITLE' => $appTitle, - 'APP_NUMBER' => $appNumber, - 'APP_STATUS' => $status, - 'APP_STATUS_ID' => $statusId, - 'PRO_UID' => $process->PRO_UID, - 'APP_PROC_STATUS' => '', - 'APP_PROC_CODE' => '', - 'APP_PARALLEL' => 'N', - 'APP_INIT_USER' => $user->USR_UID, - 'APP_INIT_USER_ID' => $user->USR_ID, - 'APP_CUR_USER' => $user->USR_UID, - 'APP_PIN' => G::generateUniqueID(), - 'APP_CREATE_DATE' => $faker->dateTime(), - 'APP_INIT_DATE' => $faker->dateTime(), - 'APP_UPDATE_DATE' => $faker->dateTime(), - 'APP_FINISH_DATE' => $faker->dateTime(), - 'APP_DATA' => serialize(['APP_NUMBER' => $appNumber]) - ]; -}); + // APP_TITLE field is used in 'MYSQL: MATCH() AGAINST()' function, string size should not be less than 3. + $appTitle = $this->faker->lexify(str_repeat('?', rand(3, 5)) . ' ' . str_repeat('?', rand(3, 5))); -$factory->state(\ProcessMaker\Model\Application::class, 'web_entry', function (Faker $faker) { - $appNumber = $faker->unique()->numberBetween(5000); - return [ - 'APP_NUMBER' => $appNumber * -1, - 'APP_STATUS_ID' => 2, - 'APP_STATUS' => 'TO_DO' - ]; -}); + $statuses = ['DRAFT', 'TO_DO', 'COMPLETED', 'CANCELLED']; + $status = $this->faker->randomElement($statuses); + $statusId = array_search($status, $statuses) + 1; -$factory->state(\ProcessMaker\Model\Application::class, 'todo', function (Faker $faker) { - return [ - 'APP_NUMBER' => $faker->unique()->numberBetween(1000), - 'APP_STATUS_ID' => 2, - 'APP_STATUS' => 'TO_DO' - ]; -}); + return [ + 'APP_UID' => G::generateUniqueID(), + 'APP_TITLE' => $appTitle, + 'APP_NUMBER' => $appNumber, + 'APP_STATUS' => $status, + 'APP_STATUS_ID' => $statusId, + 'PRO_UID' => $process->PRO_UID, + 'APP_PROC_STATUS' => '', + 'APP_PROC_CODE' => '', + 'APP_PARALLEL' => 'N', + 'APP_INIT_USER' => $user->USR_UID, + 'APP_INIT_USER_ID' => $user->USR_ID, + 'APP_CUR_USER' => $user->USR_UID, + 'APP_PIN' => G::generateUniqueID(), + 'APP_CREATE_DATE' => $this->faker->dateTime(), + 'APP_INIT_DATE' => $this->faker->dateTime(), + 'APP_UPDATE_DATE' => $this->faker->dateTime(), + 'APP_FINISH_DATE' => $this->faker->dateTime(), + 'APP_DATA' => serialize(['APP_NUMBER' => $appNumber]) + ]; + }; + return $this->state($state); + } -$factory->state(\ProcessMaker\Model\Application::class, 'draft', function (Faker $faker) { - $user = factory(\ProcessMaker\Model\User::class)->create(); + /** + * + * @return type + */ + public function web_entry() + { + $state = function (array $attributes) { + $appNumber = $this->faker->unique()->numberBetween(5000); + return [ + 'APP_NUMBER' => $appNumber * -1, + 'APP_STATUS_ID' => 2, + 'APP_STATUS' => 'TO_DO' + ]; + }; + return $this->state($state); + } - return [ - 'APP_NUMBER' => $faker->unique()->numberBetween(1000), - 'APP_STATUS_ID' => 1, - 'APP_STATUS' => 'DRAFT', - 'APP_INIT_USER' => $user->USR_UID, - 'APP_INIT_USER_ID' => $user->USR_ID, - ]; -}); + /** + * + * @return type + */ + public function todo() + { + $state = function (array $attributes) { + return [ + 'APP_NUMBER' => $this->faker->unique()->numberBetween(1000), + 'APP_STATUS_ID' => 2, + 'APP_STATUS' => 'TO_DO' + ]; + }; + return $this->state($state); + } -$factory->state(\ProcessMaker\Model\Application::class, 'paused', function (Faker $faker) { - $user = factory(\ProcessMaker\Model\User::class)->create(); + /** + * + * @return type + */ + public function draft() + { + $state = function (array $attributes) { + $user = \ProcessMaker\Model\User::factory()->create(); - return [ - 'APP_NUMBER' => $faker->unique()->numberBetween(1000), - 'APP_STATUS_ID' => 1, - 'APP_STATUS' => 'PAUSED', - 'APP_INIT_USER' => $user->USR_UID, - 'APP_INIT_USER_ID' => $user->USR_ID, - ]; -}); + return [ + 'APP_NUMBER' => $this->faker->unique()->numberBetween(1000), + 'APP_STATUS_ID' => 1, + 'APP_STATUS' => 'DRAFT', + 'APP_INIT_USER' => $user->USR_UID, + 'APP_INIT_USER_ID' => $user->USR_ID, + ]; + }; + return $this->state($state); + } -$factory->state(\ProcessMaker\Model\Application::class, 'completed', function (Faker $faker) { - return [ - 'APP_NUMBER' => $faker->unique()->numberBetween(1000), - 'APP_STATUS_ID' => 3, - 'APP_STATUS' => 'COMPLETED' - ]; -}); + /** + * + * @return type + */ + public function paused() + { + $state = function (array $attributes) { + $user = \ProcessMaker\Model\User::factory()->create(); -$factory->state(\ProcessMaker\Model\Application::class, 'canceled', function (Faker $faker) { - return [ - 'APP_NUMBER' => $faker->unique()->numberBetween(1000), - 'APP_STATUS_ID' => 4, - 'APP_STATUS' => 'CANCELLED' - ]; -}); + return [ + 'APP_NUMBER' => $this->faker->unique()->numberBetween(1000), + 'APP_STATUS_ID' => 1, + 'APP_STATUS' => 'PAUSED', + 'APP_INIT_USER' => $user->USR_UID, + 'APP_INIT_USER_ID' => $user->USR_ID, + ]; + }; + return $this->state($state); + } -$factory->state(\ProcessMaker\Model\Application::class, 'draft_minor_case', function (Faker $faker) { - $caseNumber = $faker->unique()->numberBetween(1, 1000); - return [ - 'APP_NUMBER' => $caseNumber, - 'APP_TITLE' => 'Case # ' . $caseNumber, - 'APP_STATUS_ID' => 1, - 'APP_STATUS' => 'DRAFT', - 'APP_UPDATE_DATE' => $faker->dateTimeBetween('-2 year', '-1 year') - ]; -}); + /** + * + * @return type + */ + public function completed() + { + $state = function (array $attributes) { + return [ + 'APP_NUMBER' => $this->faker->unique()->numberBetween(1000), + 'APP_STATUS_ID' => 3, + 'APP_STATUS' => 'COMPLETED' + ]; + }; + return $this->state($state); + } -$factory->state(\ProcessMaker\Model\Application::class, 'draft_major_case', function (Faker $faker) { - $caseNumber = $faker->unique()->numberBetween(2000, 3000); - return [ - 'APP_NUMBER' => $caseNumber, - 'APP_TITLE' => 'Case # ' . $caseNumber, - 'APP_STATUS_ID' => 1, - 'APP_STATUS' => 'DRAFT', - 'APP_UPDATE_DATE' => $faker->dateTimeBetween('now', '+1 year') - ]; -}); + /** + * + * @return type + */ + public function canceled() + { + $state = function (array $attributes) { + return [ + 'APP_NUMBER' => $this->faker->unique()->numberBetween(1000), + 'APP_STATUS_ID' => 4, + 'APP_STATUS' => 'CANCELLED' + ]; + }; + return $this->state($state); + } + + /** + * + * @return type + */ + public function draft_minor_case() + { + $state = function (array $attributes) { + $caseNumber = $this->faker->unique()->numberBetween(1, 1000); + return [ + 'APP_NUMBER' => $caseNumber, + 'APP_TITLE' => 'Case # ' . $caseNumber, + 'APP_STATUS_ID' => 1, + 'APP_STATUS' => 'DRAFT', + 'APP_UPDATE_DATE' => $this->faker->dateTimeBetween('-2 year', '-1 year') + ]; + }; + return $this->state($state); + } + + /** + * + * @return type + */ + public function draft_major_case() + { + $state = function (array $attributes) { + $caseNumber = $this->faker->unique()->numberBetween(2000, 3000); + return [ + 'APP_NUMBER' => $caseNumber, + 'APP_TITLE' => 'Case # ' . $caseNumber, + 'APP_STATUS_ID' => 1, + 'APP_STATUS' => 'DRAFT', + 'APP_UPDATE_DATE' => $this->faker->dateTimeBetween('now', '+1 year') + ]; + }; + return $this->state($state); + } + +} diff --git a/database/factories/BpmnDiagramFactory.php b/database/factories/BpmnDiagramFactory.php index 817fe6d3c..72d8a2bdf 100644 --- a/database/factories/BpmnDiagramFactory.php +++ b/database/factories/BpmnDiagramFactory.php @@ -1,14 +1,28 @@ define(\ProcessMaker\Model\BpmnDiagram::class, function(Faker $faker) { - return [ - 'DIA_UID' => $faker->regexify("/[a-zA-Z]{32}/"), - 'PRJ_UID' => function() { - return factory(\ProcessMaker\Model\BpmnProject::class)->create()->PRJ_UID; - }, - 'DIA_NAME' => $faker->name, - 'DIA_IS_CLOSABLE' => 0, - ]; -}); +use App\Factories\Factory; +use Illuminate\Support\Str; + +class BpmnDiagramFactory extends Factory +{ + + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + return [ + 'DIA_UID' => $this->faker->regexify("/[a-zA-Z]{32}/"), + 'PRJ_UID' => function () { + return \ProcessMaker\Model\BpmnProject::factory()->create()->PRJ_UID; + }, + 'DIA_NAME' => $this->faker->name, + 'DIA_IS_CLOSABLE' => 0, + ]; + } + +} diff --git a/database/factories/BpmnEventFactory.php b/database/factories/BpmnEventFactory.php index 5f411972d..77936c6fe 100644 --- a/database/factories/BpmnEventFactory.php +++ b/database/factories/BpmnEventFactory.php @@ -1,32 +1,46 @@ define(\ProcessMaker\Model\BpmnEvent::class, function(Faker $faker) { - $bpmnProcess = factory(\ProcessMaker\Model\BpmnProcess::class)->create(); - return [ - 'EVN_UID' => $faker->regexify("/[a-zA-Z]{32}/"), - 'PRJ_UID' => $bpmnProcess->PRJ_UID, - 'PRO_UID' => $bpmnProcess->PRO_UID, - 'EVN_NAME' => $faker->name, - 'EVN_TYPE' => 'START', - 'EVN_MARKER' => 'EMPTY', - 'EVN_IS_INTERRUPTING' => 1, - 'EVN_ATTACHED_TO' => '', - 'EVN_CANCEL_ACTIVITY' => 0, - 'EVN_ACTIVITY_REF' => null, - 'EVN_WAIT_FOR_COMPLETION' => 0, - 'EVN_ERROR_NAME' => null, - 'EVN_ERROR_CODE' => null, - 'EVN_ESCALATION_NAME' => null, - 'EVN_ESCALATION_CODE' => null, - 'EVN_CONDITION' => null, - 'EVN_MESSAGE' => '', - 'EVN_OPERATION_NAME' => null, - 'EVN_OPERATION_IMPLEMENTATION_REF' => null, - 'EVN_TIME_DATE' => null, - 'EVN_TIME_CYCLE' => null, - 'EVN_TIME_DURATION' => null, - 'EVN_BEHAVIOR' => 'THROW', - ]; -}); +use App\Factories\Factory; +use Illuminate\Support\Str; + +class BpmnEventFactory extends Factory +{ + + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + $bpmnProcess = \ProcessMaker\Model\BpmnProcess::factory()->create(); + return [ + 'EVN_UID' => $this->faker->regexify("/[a-zA-Z]{32}/"), + 'PRJ_UID' => $bpmnProcess->PRJ_UID, + 'PRO_UID' => $bpmnProcess->PRO_UID, + 'EVN_NAME' => $this->faker->name, + 'EVN_TYPE' => 'START', + 'EVN_MARKER' => 'EMPTY', + 'EVN_IS_INTERRUPTING' => 1, + 'EVN_ATTACHED_TO' => '', + 'EVN_CANCEL_ACTIVITY' => 0, + 'EVN_ACTIVITY_REF' => null, + 'EVN_WAIT_FOR_COMPLETION' => 0, + 'EVN_ERROR_NAME' => null, + 'EVN_ERROR_CODE' => null, + 'EVN_ESCALATION_NAME' => null, + 'EVN_ESCALATION_CODE' => null, + 'EVN_CONDITION' => null, + 'EVN_MESSAGE' => '', + 'EVN_OPERATION_NAME' => null, + 'EVN_OPERATION_IMPLEMENTATION_REF' => null, + 'EVN_TIME_DATE' => null, + 'EVN_TIME_CYCLE' => null, + 'EVN_TIME_DURATION' => null, + 'EVN_BEHAVIOR' => 'THROW', + ]; + } + +} diff --git a/database/factories/BpmnProcessFactory.php b/database/factories/BpmnProcessFactory.php index f63304f7c..3bb13e2fa 100644 --- a/database/factories/BpmnProcessFactory.php +++ b/database/factories/BpmnProcessFactory.php @@ -1,21 +1,34 @@ define(\ProcessMaker\Model\BpmnProcess::class, function(Faker $faker) { - return [ - 'PRO_UID' => $faker->regexify("/[a-zA-Z]{32}/"), - 'PRJ_UID' => function() { - return factory(\ProcessMaker\Model\BpmnProject::class)->create()->PRJ_UID; - }, - 'DIA_UID' => function() { - return factory(\ProcessMaker\Model\BpmnDiagram::class)->create()->DIA_UID; - }, - 'PRO_NAME' => $faker->title, - 'PRO_TYPE' => 'NONE', - 'PRO_IS_EXECUTABLE' => 0, - 'PRO_IS_CLOSED' => 0, - 'PRO_IS_SUBPROCESS' => 0, - ]; -}); +use App\Factories\Factory; +use Illuminate\Support\Str; +class BpmnProcessFactory extends Factory +{ + + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + return [ + 'PRO_UID' => $this->faker->regexify("/[a-zA-Z]{32}/"), + 'PRJ_UID' => function () { + return \ProcessMaker\Model\BpmnProject::factory()->create()->PRJ_UID; + }, + 'DIA_UID' => function () { + return \ProcessMaker\Model\BpmnDiagram::factory()->create()->DIA_UID; + }, + 'PRO_NAME' => $this->faker->title, + 'PRO_TYPE' => 'NONE', + 'PRO_IS_EXECUTABLE' => 0, + 'PRO_IS_CLOSED' => 0, + 'PRO_IS_SUBPROCESS' => 0, + ]; + } + +} diff --git a/database/factories/BpmnProjectFactory.php b/database/factories/BpmnProjectFactory.php index 2433c3fe9..048dd9764 100644 --- a/database/factories/BpmnProjectFactory.php +++ b/database/factories/BpmnProjectFactory.php @@ -1,25 +1,40 @@ define(\ProcessMaker\Model\BpmnProject::class, function (Faker $faker) { - // Create user - $user = factory(\ProcessMaker\Model\User::class)->create(); - // Create process - $process = factory(\ProcessMaker\Model\Process::class)->create(); +use App\Factories\Factory; +use G; +use Illuminate\Support\Str; - return [ - 'PRJ_UID' => G::generateUniqueID(), - 'PRJ_NAME' => $faker->sentence(5), - 'PRJ_DESCRIPTION' => $faker->text, - 'PRJ_EXPRESION_LANGUAGE' => '', - 'PRJ_TYPE_LANGUAGE' => '', - 'PRJ_EXPORTER' => '', - 'PRJ_EXPORTER_VERSION' => '', - 'PRJ_CREATE_DATE' => $faker->dateTime(), - 'PRJ_UPDATE_DATE' => $faker->dateTime(), - 'PRJ_AUTHOR' => $user->USR_UID, - 'PRJ_AUTHOR_VERSION' => '', - 'PRJ_ORIGINAL_SOURCE' => '', - ]; -}); +class BpmnProjectFactory extends Factory +{ + + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + // Create user + $user = \ProcessMaker\Model\User::factory()->create(); + // Create process + $process = \ProcessMaker\Model\Process::factory()->create(); + + return [ + 'PRJ_UID' => G::generateUniqueID(), + 'PRJ_NAME' => $this->faker->sentence(5), + 'PRJ_DESCRIPTION' => $this->faker->text, + 'PRJ_EXPRESION_LANGUAGE' => '', + 'PRJ_TYPE_LANGUAGE' => '', + 'PRJ_EXPORTER' => '', + 'PRJ_EXPORTER_VERSION' => '', + 'PRJ_CREATE_DATE' => $this->faker->dateTime(), + 'PRJ_UPDATE_DATE' => $this->faker->dateTime(), + 'PRJ_AUTHOR' => $user->USR_UID, + 'PRJ_AUTHOR_VERSION' => '', + 'PRJ_ORIGINAL_SOURCE' => '', + ]; + } + +} diff --git a/database/factories/CaseListFactory.php b/database/factories/CaseListFactory.php index 3da4352f4..866e8a7ea 100644 --- a/database/factories/CaseListFactory.php +++ b/database/factories/CaseListFactory.php @@ -1,26 +1,40 @@ define(\ProcessMaker\Model\CaseList::class, function (Faker $faker) { - return [ - 'CAL_ID' => $faker->unique()->numberBetween(1, 5000), - 'CAL_TYPE' => 'inbox', - 'CAL_NAME' => $faker->title, - 'CAL_DESCRIPTION' => $faker->text, - 'ADD_TAB_UID' => function () { - $table = factory(\ProcessMaker\Model\AdditionalTables::class)->create(); - return $table->ADD_TAB_UID; - }, - 'CAL_COLUMNS' => '[]', - 'USR_ID' => function () { - $user = factory(\ProcessMaker\Model\User::class)->create(); - return $user->USR_ID; - }, - 'CAL_ICON_LIST' => 'deafult.png', - 'CAL_ICON_COLOR' => 'red', - 'CAL_ICON_COLOR_SCREEN' => 'blue', - 'CAL_CREATE_DATE' => $faker->dateTime(), - 'CAL_UPDATE_DATE' => $faker->dateTime() - ]; -}); +use App\Factories\Factory; +use Illuminate\Support\Str; + +class CaseListFactory extends Factory +{ + + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + return [ + 'CAL_ID' => $this->faker->unique()->numberBetween(1, 5000), + 'CAL_TYPE' => 'inbox', + 'CAL_NAME' => $this->faker->title, + 'CAL_DESCRIPTION' => $this->faker->text, + 'ADD_TAB_UID' => function () { + $table = \ProcessMaker\Model\AdditionalTables::factory()->create(); + return $table->ADD_TAB_UID; + }, + 'CAL_COLUMNS' => '[]', + 'USR_ID' => function () { + $user = \ProcessMaker\Model\User::factory()->create(); + return $user->USR_ID; + }, + 'CAL_ICON_LIST' => 'deafult.png', + 'CAL_ICON_COLOR' => 'red', + 'CAL_ICON_COLOR_SCREEN' => 'blue', + 'CAL_CREATE_DATE' => $this->faker->dateTime(), + 'CAL_UPDATE_DATE' => $this->faker->dateTime() + ]; + } + +} diff --git a/database/factories/ConfigurationFactory.php b/database/factories/ConfigurationFactory.php index c21d20c87..d0c52dfc1 100644 --- a/database/factories/ConfigurationFactory.php +++ b/database/factories/ConfigurationFactory.php @@ -1,37 +1,57 @@ 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(), - ]; -}); +class ConfigurationFactory extends Factory +{ -$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(); + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + return [ + 'CFG_UID' => $this->faker->randomElement(['AUDIT_LOG', 'EE']), + 'OBJ_UID' => '', + 'CFG_VALUE' => '', + 'PRO_UID' => G::generateUniqueID(), + 'USR_UID' => G::generateUniqueID(), + 'APP_UID' => G::generateUniqueID(), + ]; } - return [ - 'CFG_UID' => 'USER_PREFERENCES', - 'OBJ_UID' => '', - 'CFG_VALUE' => '', - 'PRO_UID' => '', - 'USR_UID' => $user->USR_UID, - 'APP_UID' => '', - ]; -}); + /** + * + * @return type + */ + public function userPreferencesEmpty() + { + $state = function (array $attributes) { + // Grab a user if random + $users = User::all(); + if (!empty($users)) { + $user = User::factory()->create(); + } else { + $user = $users->random(); + } + return [ + 'CFG_UID' => 'USER_PREFERENCES', + 'OBJ_UID' => '', + 'CFG_VALUE' => '', + 'PRO_UID' => '', + 'USR_UID' => $user->USR_UID, + 'APP_UID' => '', + ]; + }; + return $this->state($state); + } + +} diff --git a/database/factories/ConsolidatedFactory.php b/database/factories/ConsolidatedFactory.php index 53884b01e..2828e7f20 100644 --- a/database/factories/ConsolidatedFactory.php +++ b/database/factories/ConsolidatedFactory.php @@ -1,24 +1,46 @@ define(\ProcessMaker\Model\Consolidated::class, function (Faker $faker) { - return [ - 'TAS_UID' => G::generateUniqueID(), - 'DYN_UID' => G::generateUniqueID(), - 'REP_TAB_UID' => G::generateUniqueID(), - 'CON_STATUS' => 'ACTIVE', - ]; -}); +use App\Factories\Factory; +use G; +use Illuminate\Support\Str; -// Create a consolidated task with the foreign keys -$factory->state(\ProcessMaker\Model\Consolidated::class, 'foreign_keys', function (Faker $faker) { - $task = factory(\ProcessMaker\Model\Task::class)->create(); - $dynaform = factory(\ProcessMaker\Model\Dynaform::class)->create(); - return [ - 'TAS_UID' => $task->TAS_UID, - 'DYN_UID' => $dynaform->DYN_UID, - 'REP_TAB_UID' => G::generateUniqueID(), - 'CON_STATUS' => 'ACTIVE', - ]; -}); \ No newline at end of file +class ConsolidatedFactory extends Factory +{ + + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + return [ + 'TAS_UID' => G::generateUniqueID(), + 'DYN_UID' => G::generateUniqueID(), + 'REP_TAB_UID' => G::generateUniqueID(), + 'CON_STATUS' => 'ACTIVE', + ]; + } + + /** + * Create a consolidated task with the foreign keys + * @return type + */ + public function foreign_keys() + { + $state = function (array $attributes) { + $task = \ProcessMaker\Model\Task::factory()->create(); + $dynaform = \ProcessMaker\Model\Dynaform::factory()->create(); + return [ + 'TAS_UID' => $task->TAS_UID, + 'DYN_UID' => $dynaform->DYN_UID, + 'REP_TAB_UID' => G::generateUniqueID(), + 'CON_STATUS' => 'ACTIVE', + ]; + }; + return $this->state($state); + } + +} diff --git a/database/factories/DbSourceFactory.php b/database/factories/DbSourceFactory.php index de9db69ad..0f7100006 100644 --- a/database/factories/DbSourceFactory.php +++ b/database/factories/DbSourceFactory.php @@ -1,31 +1,43 @@ define(\ProcessMaker\Model\DbSource::class, function(Faker $faker) { +namespace Database\Factories; + +use App\Factories\Factory; +use G; +use Illuminate\Support\Str; + +class DbSourceFactory extends Factory +{ /** - * @todo Determine if we need more base columns populated + * Define the model's default state. + * + * @return array */ - $dbName = $faker->word; - return [ - 'DBS_UID' => G::generateUniqueID(), - 'PRO_UID' => function() { - return factory(\ProcessMaker\Model\Process::class)->create()->PRO_UID; - }, - 'DBS_TYPE' => 'mysql', - 'DBS_SERVER' => $faker->localIpv4, - 'DBS_DATABASE_NAME' => $faker->word, - 'DBS_USERNAME' => $faker->userName, + public function definition() + { /** - * @todo WHY figure out there's a magic value to the encryption here + * @todo Determine if we need more base columns populated */ - 'DBS_PASSWORD' => \G::encrypt( $faker->password, $dbName, false, false) . "_2NnV3ujj3w", - 'DBS_PORT' => $faker->numberBetween(1000, 9000), - 'DBS_ENCODE' => 'utf8', // @todo Perhaps grab this from our definitions in DbConnections - 'DBS_CONNECTION_TYPE' => 'NORMAL', // @todo Determine what this value means - 'DBS_TNS' => null // @todo Determine what this value means - ]; -}); \ No newline at end of file + $dbName = $this->faker->word; + return [ + 'DBS_UID' => G::generateUniqueID(), + 'PRO_UID' => function () { + return \ProcessMaker\Model\Process::factory()->create()->PRO_UID; + }, + 'DBS_TYPE' => 'mysql', + 'DBS_SERVER' => $this->faker->localIpv4, + 'DBS_DATABASE_NAME' => $this->faker->word, + 'DBS_USERNAME' => $this->faker->userName, + /** + * @todo WHY figure out there's a magic value to the encryption here + */ + 'DBS_PASSWORD' => \G::encrypt($this->faker->password, $dbName, false, false) . "_2NnV3ujj3w", + 'DBS_PORT' => $this->faker->numberBetween(1000, 9000), + 'DBS_ENCODE' => 'utf8', // @todo Perhaps grab this from our definitions in DbConnections + 'DBS_CONNECTION_TYPE' => 'NORMAL', // @todo Determine what this value means + 'DBS_TNS' => null // @todo Determine what this value means + ]; + } + +} diff --git a/database/factories/DepartmentFactory.php b/database/factories/DepartmentFactory.php index 1a4cc3ae5..6a99ea771 100644 --- a/database/factories/DepartmentFactory.php +++ b/database/factories/DepartmentFactory.php @@ -1,16 +1,31 @@ define(\ProcessMaker\Model\Department::class, function (Faker $faker) { - return [ - 'DEP_UID' => G::generateUniqueID(), - 'DEP_TITLE' => $faker->sentence(2), - 'DEP_PARENT' => '', - 'DEP_MANAGER' => '', - 'DEP_LOCATION' => 0, - 'DEP_STATUS' => 'ACTIVE', - 'DEP_REF_CODE' => '', - 'DEP_LDAP_DN' => '', - ]; -}); +use App\Factories\Factory; +use G; +use Illuminate\Support\Str; + +class DepartmentFactory extends Factory +{ + + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + return [ + 'DEP_UID' => G::generateUniqueID(), + 'DEP_TITLE' => $this->faker->sentence(2), + 'DEP_PARENT' => '', + 'DEP_MANAGER' => '', + 'DEP_LOCATION' => 0, + 'DEP_STATUS' => 'ACTIVE', + 'DEP_REF_CODE' => '', + 'DEP_LDAP_DN' => '', + ]; + } + +} diff --git a/database/factories/DocumentsFactory.php b/database/factories/DocumentsFactory.php index f4ef0429f..afbec1657 100644 --- a/database/factories/DocumentsFactory.php +++ b/database/factories/DocumentsFactory.php @@ -1,54 +1,76 @@ define(\ProcessMaker\Model\Documents::class, function (Faker $faker) { - $types = ['INPUT', 'OUTPUT', 'ATTACHED']; - $type = $faker->randomElement($types); - return [ - 'APP_DOC_UID' => G::generateUniqueID(), - 'APP_DOC_FILENAME' => 'image.png', - 'APP_DOC_TITLE' => '', - 'APP_DOC_COMMENT' => '', - 'DOC_VERSION' => 1, - 'APP_UID' => G::generateUniqueID(), - 'DEL_INDEX' => 1, - 'DOC_UID' => G::generateUniqueID(), - 'USR_UID' => G::generateUniqueID(), - 'APP_DOC_TYPE' => $type, - 'APP_DOC_CREATE_DATE' => $faker->date(), - 'APP_DOC_INDEX' => 1, - 'FOLDER_UID' => G::generateUniqueID(), - 'APP_DOC_PLUGIN' => '', - 'APP_DOC_TAGS' => '', - 'APP_DOC_STATUS' => 'ACTIVE', - 'APP_DOC_STATUS_DATE' => $faker->date(), - 'APP_DOC_FIELDNAME' => '', - 'APP_DOC_DRIVE_DOWNLOAD' => '', - ]; -}); +use App\Factories\Factory; +use G; +use Illuminate\Support\Str; -// Create a document related to the case notes -$factory->state(\ProcessMaker\Model\Documents::class, 'case_notes', function (Faker $faker) { - return [ - 'APP_DOC_UID' => G::generateUniqueID(), - 'APP_DOC_FILENAME' => 'image.png', - 'APP_DOC_TITLE' => '', - 'APP_DOC_COMMENT' => '', - 'DOC_VERSION' => 1, - 'APP_UID' => G::generateUniqueID(), - 'DEL_INDEX' => 1, - 'DOC_UID' => G::generateUniqueID(), - 'USR_UID' => G::generateUniqueID(), - 'APP_DOC_TYPE' => 'CASE_NOTE', - 'APP_DOC_CREATE_DATE' => $faker->date(), - 'APP_DOC_INDEX' => 1, - 'FOLDER_UID' => G::generateUniqueID(), - 'APP_DOC_PLUGIN' => '', - 'APP_DOC_TAGS' => '', - 'APP_DOC_STATUS' => 'ACTIVE', - 'APP_DOC_STATUS_DATE' => $faker->date(), - 'APP_DOC_FIELDNAME' => '', - 'APP_DOC_DRIVE_DOWNLOAD' => '', - ]; -}); +class DocumentsFactory extends Factory +{ + + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + $types = ['INPUT', 'OUTPUT', 'ATTACHED']; + $type = $this->faker->randomElement($types); + return [ + 'APP_DOC_UID' => G::generateUniqueID(), + 'APP_DOC_FILENAME' => 'image.png', + 'APP_DOC_TITLE' => '', + 'APP_DOC_COMMENT' => '', + 'DOC_VERSION' => 1, + 'APP_UID' => G::generateUniqueID(), + 'DEL_INDEX' => 1, + 'DOC_UID' => G::generateUniqueID(), + 'USR_UID' => G::generateUniqueID(), + 'APP_DOC_TYPE' => $type, + 'APP_DOC_CREATE_DATE' => $this->faker->date(), + 'APP_DOC_INDEX' => 1, + 'FOLDER_UID' => G::generateUniqueID(), + 'APP_DOC_PLUGIN' => '', + 'APP_DOC_TAGS' => '', + 'APP_DOC_STATUS' => 'ACTIVE', + 'APP_DOC_STATUS_DATE' => $this->faker->date(), + 'APP_DOC_FIELDNAME' => '', + 'APP_DOC_DRIVE_DOWNLOAD' => '', + ]; + } + + /** + * Create a document related to the case notes + * @return type + */ + public function case_notes() + { + $state = function (array $attributes) { + return [ + 'APP_DOC_UID' => G::generateUniqueID(), + 'APP_DOC_FILENAME' => 'image.png', + 'APP_DOC_TITLE' => '', + 'APP_DOC_COMMENT' => '', + 'DOC_VERSION' => 1, + 'APP_UID' => G::generateUniqueID(), + 'DEL_INDEX' => 1, + 'DOC_UID' => G::generateUniqueID(), + 'USR_UID' => G::generateUniqueID(), + 'APP_DOC_TYPE' => 'CASE_NOTE', + 'APP_DOC_CREATE_DATE' => $this->faker->date(), + 'APP_DOC_INDEX' => 1, + 'FOLDER_UID' => G::generateUniqueID(), + 'APP_DOC_PLUGIN' => '', + 'APP_DOC_TAGS' => '', + 'APP_DOC_STATUS' => 'ACTIVE', + 'APP_DOC_STATUS_DATE' => $this->faker->date(), + 'APP_DOC_FIELDNAME' => '', + 'APP_DOC_DRIVE_DOWNLOAD' => '', + ]; + }; + return $this->state($state); + } + +} diff --git a/database/factories/DynaformFactory.php b/database/factories/DynaformFactory.php index 793d743d7..7e94b980c 100644 --- a/database/factories/DynaformFactory.php +++ b/database/factories/DynaformFactory.php @@ -1,66 +1,92 @@ define(\ProcessMaker\Model\Dynaform::class, function(Faker $faker) { - $date = $faker->dateTime(); - return [ - 'DYN_UID' => G::generateUniqueID(), - 'DYN_TITLE' => $faker->sentence(2), - 'DYN_DESCRIPTION' => $faker->sentence(5), - 'PRO_UID' => function() { - $process = factory(Process::class)->create(); - return $process->PRO_UID; - }, - 'DYN_TYPE' => 'xmlform', - 'DYN_FILENAME' => '', - 'DYN_CONTENT' => '', - 'DYN_LABEL' => '', - 'DYN_VERSION' => 2, - 'DYN_UPDATE_DATE' => $date->format('Y-m-d H:i:s'), - ]; -}); -// Create a dynaform with the foreign keys -$factory->state(\ProcessMaker\Model\Dynaform::class, 'foreign_keys', function (Faker $faker) { - $date = $faker->dateTime(); - return [ - 'DYN_UID' => G::generateUniqueID(), - 'DYN_TITLE' => $faker->sentence(2), - 'DYN_DESCRIPTION' => $faker->sentence(5), - 'PRO_UID' => function() { - $process = factory(Process::class)->create(); - return $process->PRO_UID; - }, - 'DYN_TYPE' => 'xmlform', - 'DYN_FILENAME' => '', - 'DYN_CONTENT' => '', - 'DYN_LABEL' => '', - 'DYN_VERSION' => 2, - 'DYN_UPDATE_DATE' => $date->format('Y-m-d H:i:s'), - ]; -}); +class DynaformFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + $date = $this->faker->dateTime(); + return [ + 'DYN_UID' => G::generateUniqueID(), + 'DYN_TITLE' => $this->faker->sentence(2), + 'DYN_DESCRIPTION' => $this->faker->sentence(5), + 'PRO_UID' => function () { + $process = Process::factory()->create(); + return $process->PRO_UID; + }, + 'DYN_TYPE' => 'xmlform', + 'DYN_FILENAME' => '', + 'DYN_CONTENT' => '', + 'DYN_LABEL' => '', + 'DYN_VERSION' => 2, + 'DYN_UPDATE_DATE' => $date->format('Y-m-d H:i:s'), + ]; + } -// Create a dynaform with translations defined: ["es", "es-Es"] -$factory->state(\ProcessMaker\Model\Dynaform::class, 'translations', function (Faker $faker) { - $date = $faker->dateTime(); - return [ - 'DYN_UID' => G::generateUniqueID(), - 'DYN_TITLE' => $faker->sentence(2), - 'DYN_DESCRIPTION' => $faker->sentence(5), - 'PRO_UID' => function() { - $process = factory(Process::class)->create(); - return $process->PRO_UID; - }, - 'DYN_TYPE' => 'xmlform', - 'DYN_FILENAME' => '', - 'DYN_CONTENT' => '', - 'DYN_LABEL' => '{"es":{"Project-Id-Version":"PM 4.0.1","POT-Creation-Date":"","PO-Revision-Date":"2019-09-11 12:02-0400","Last-Translator":"Colosa ","Language-Team":"Colosa Developers Team ","MIME-Version":"1.0","Content-Type":"text\/plain; charset=utf-8","Content-Transfer_Encoding":"8bit","X-Poedit-SourceCharset":"utf-8","Content-Transfer-Encoding":"8bit","File-Name":"Test-v2.es.po","X-Generator":"Poedit 1.8.11","X-Poedit-Language":"en","X-Poedit-Country":".","Labels":[{"msgid":"Test without dependent fields","msgstr":"Ejemplo sin campos dependientes"},{"msgid":"Incident Type:","msgstr":"Tipo de incidente:"},{"msgid":"- Select -","msgstr":"- Seleccionar -"},{"msgid":"Incident Sub Type:","msgstr":"Sub tipo de incidente:"},{"msgid":"Test with dependent fields","msgstr":"Ejemplo con campos dependientes"},{"msgid":"Health\/Safety","msgstr":"Salud\/Seguridad"},{"msgid":"Environment","msgstr":"Ambiente"},{"msgid":"Fatality","msgstr":"Ambiente"},{"msgid":"Lost Time Injury","msgstr":"Ambiente"},{"msgid":"Environment","msgstr":"Ambiente"},{"msgid":"Medical Treatment Injury","msgstr":"Lesiones de tratamiento m\u00e9dico"},{"msgid":"Chemical\/Substance Spill","msgstr":"Derrame qu\u00edmico \/ de sustancias"},{"msgid":"Fire\/Explosion","msgstr":"Fuego\/Explosion"},{"msgid":"Offsite Release","msgstr":"Lanzamiento fuera del sitio"}]},"es-Es":{"Project-Id-Version":"PM 4.0.1","POT-Creation-Date":"","PO-Revision-Date":"2019-09-11 12:02-0400","Last-Translator":"Colosa ","Language-Team":"Colosa Developers Team ","MIME-Version":"1.0","Content-Type":"text\/plain; charset=utf-8","Content-Transfer_Encoding":"8bit","X-Poedit-SourceCharset":"utf-8","Content-Transfer-Encoding":"8bit","File-Name":"Test-v2.es-Es.po","X-Generator":"Poedit 1.8.11","X-Poedit-Language":"en","X-Poedit-Country":".","Labels":[{"msgid":"Test without dependent fields","msgstr":"Ejemplo sin campos dependientes"},{"msgid":"Incident Type:","msgstr":"Tipo de incidente:"},{"msgid":"- Select -","msgstr":"- Seleccionar -"},{"msgid":"Incident Sub Type:","msgstr":"Sub tipo de incidente:"},{"msgid":"Test with dependent fields","msgstr":"Ejemplo con campos dependientes"},{"msgid":"Health\/Safety","msgstr":"Salud\/Seguridad"},{"msgid":"Environment","msgstr":"Ambiente"},{"msgid":"Fatality","msgstr":"Ambiente"},{"msgid":"Lost Time Injury","msgstr":"Ambiente"},{"msgid":"Environment","msgstr":"Ambiente"},{"msgid":"Medical Treatment Injury","msgstr":"Lesiones de tratamiento m\u00e9dico"},{"msgid":"Chemical\/Substance Spill","msgstr":"Derrame qu\u00edmico \/ de sustancias"},{"msgid":"Fire\/Explosion","msgstr":"Fuego\/Explosion"},{"msgid":"Offsite Release","msgstr":"Lanzamiento fuera del sitio"}]}}', - 'DYN_VERSION' => 2, - 'DYN_UPDATE_DATE' => $date->format('Y-m-d H:i:s'), - ]; -}); \ No newline at end of file + /** + * Create a dynaform with the foreign keys + * @return type + */ + public function foreign_keys() + { + $state = function (array $attributes) { + $date = $this->faker->dateTime(); + return [ + 'DYN_UID' => G::generateUniqueID(), + 'DYN_TITLE' => $this->faker->sentence(2), + 'DYN_DESCRIPTION' => $this->faker->sentence(5), + 'PRO_UID' => function () { + $process = Process::factory()->create(); + return $process->PRO_UID; + }, + 'DYN_TYPE' => 'xmlform', + 'DYN_FILENAME' => '', + 'DYN_CONTENT' => '', + 'DYN_LABEL' => '', + 'DYN_VERSION' => 2, + 'DYN_UPDATE_DATE' => $date->format('Y-m-d H:i:s'), + ]; + }; + return $this->state($state); + } + + /** + * Create a dynaform with translations defined: ["es", "es-Es"] + * @return type + */ + public function translations() + { + $state = function (array $attributes) { + $date = $this->faker->dateTime(); + return [ + 'DYN_UID' => G::generateUniqueID(), + 'DYN_TITLE' => $this->faker->sentence(2), + 'DYN_DESCRIPTION' => $this->faker->sentence(5), + 'PRO_UID' => function () { + $process = Process::factory()->create(); + return $process->PRO_UID; + }, + 'DYN_TYPE' => 'xmlform', + 'DYN_FILENAME' => '', + 'DYN_CONTENT' => '', + 'DYN_LABEL' => '{"es":{"Project-Id-Version":"PM 4.0.1","POT-Creation-Date":"","PO-Revision-Date":"2019-09-11 12:02-0400","Last-Translator":"Colosa ","Language-Team":"Colosa Developers Team ","MIME-Version":"1.0","Content-Type":"text\/plain; charset=utf-8","Content-Transfer_Encoding":"8bit","X-Poedit-SourceCharset":"utf-8","Content-Transfer-Encoding":"8bit","File-Name":"Test-v2.es.po","X-Generator":"Poedit 1.8.11","X-Poedit-Language":"en","X-Poedit-Country":".","Labels":[{"msgid":"Test without dependent fields","msgstr":"Ejemplo sin campos dependientes"},{"msgid":"Incident Type:","msgstr":"Tipo de incidente:"},{"msgid":"- Select -","msgstr":"- Seleccionar -"},{"msgid":"Incident Sub Type:","msgstr":"Sub tipo de incidente:"},{"msgid":"Test with dependent fields","msgstr":"Ejemplo con campos dependientes"},{"msgid":"Health\/Safety","msgstr":"Salud\/Seguridad"},{"msgid":"Environment","msgstr":"Ambiente"},{"msgid":"Fatality","msgstr":"Ambiente"},{"msgid":"Lost Time Injury","msgstr":"Ambiente"},{"msgid":"Environment","msgstr":"Ambiente"},{"msgid":"Medical Treatment Injury","msgstr":"Lesiones de tratamiento m\u00e9dico"},{"msgid":"Chemical\/Substance Spill","msgstr":"Derrame qu\u00edmico \/ de sustancias"},{"msgid":"Fire\/Explosion","msgstr":"Fuego\/Explosion"},{"msgid":"Offsite Release","msgstr":"Lanzamiento fuera del sitio"}]},"es-Es":{"Project-Id-Version":"PM 4.0.1","POT-Creation-Date":"","PO-Revision-Date":"2019-09-11 12:02-0400","Last-Translator":"Colosa ","Language-Team":"Colosa Developers Team ","MIME-Version":"1.0","Content-Type":"text\/plain; charset=utf-8","Content-Transfer_Encoding":"8bit","X-Poedit-SourceCharset":"utf-8","Content-Transfer-Encoding":"8bit","File-Name":"Test-v2.es-Es.po","X-Generator":"Poedit 1.8.11","X-Poedit-Language":"en","X-Poedit-Country":".","Labels":[{"msgid":"Test without dependent fields","msgstr":"Ejemplo sin campos dependientes"},{"msgid":"Incident Type:","msgstr":"Tipo de incidente:"},{"msgid":"- Select -","msgstr":"- Seleccionar -"},{"msgid":"Incident Sub Type:","msgstr":"Sub tipo de incidente:"},{"msgid":"Test with dependent fields","msgstr":"Ejemplo con campos dependientes"},{"msgid":"Health\/Safety","msgstr":"Salud\/Seguridad"},{"msgid":"Environment","msgstr":"Ambiente"},{"msgid":"Fatality","msgstr":"Ambiente"},{"msgid":"Lost Time Injury","msgstr":"Ambiente"},{"msgid":"Environment","msgstr":"Ambiente"},{"msgid":"Medical Treatment Injury","msgstr":"Lesiones de tratamiento m\u00e9dico"},{"msgid":"Chemical\/Substance Spill","msgstr":"Derrame qu\u00edmico \/ de sustancias"},{"msgid":"Fire\/Explosion","msgstr":"Fuego\/Explosion"},{"msgid":"Offsite Release","msgstr":"Lanzamiento fuera del sitio"}]}}', + 'DYN_VERSION' => 2, + 'DYN_UPDATE_DATE' => $date->format('Y-m-d H:i:s'), + ]; + }; + return $this->state($state); + } + +} diff --git a/database/factories/ElementTaskRelationFactory.php b/database/factories/ElementTaskRelationFactory.php index 67a53f9b7..dbb904f56 100644 --- a/database/factories/ElementTaskRelationFactory.php +++ b/database/factories/ElementTaskRelationFactory.php @@ -1,13 +1,28 @@ define(\ProcessMaker\Model\ElementTaskRelation::class, function(Faker $faker) { - return [ - 'ETR_UID' => G::generateUniqueID(), - 'PRJ_UID' => G::generateUniqueID(), - 'ELEMENT_UID' => G::generateUniqueID(), - 'ELEMENT_TYPE' => 'bpmnEvent', - 'TAS_UID' => G::generateUniqueID(), - ]; -}); +use App\Factories\Factory; +use G; +use Illuminate\Support\Str; + +class ElementTaskRelationFactory extends Factory +{ + + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + return [ + 'ETR_UID' => G::generateUniqueID(), + 'PRJ_UID' => G::generateUniqueID(), + 'ELEMENT_UID' => G::generateUniqueID(), + 'ELEMENT_TYPE' => 'bpmnEvent', + 'TAS_UID' => G::generateUniqueID(), + ]; + } + +} diff --git a/database/factories/EmailEventFactory.php b/database/factories/EmailEventFactory.php index f4839f65b..ddd5369de 100644 --- a/database/factories/EmailEventFactory.php +++ b/database/factories/EmailEventFactory.php @@ -1,21 +1,35 @@ define(\ProcessMaker\Model\EmailEvent::class, function(Faker $faker) { - $bpmnEvent = factory(\ProcessMaker\Model\BpmnEvent::class)->create(); - return [ - 'EMAIL_EVENT_UID' => $faker->regexify("/[a-zA-Z]{32}/"), - 'PRJ_UID' => $bpmnEvent->PRJ_UID, - 'EVN_UID' => $bpmnEvent->EVN_UID, - 'EMAIL_EVENT_FROM' => $faker->email, - 'EMAIL_EVENT_TO' => $faker->email, - 'EMAIL_EVENT_SUBJECT' => $faker->title, - 'PRF_UID' => function() { - return factory(\ProcessMaker\Model\ProcessFiles::class)->create()->PRF_UID; - }, - 'EMAIL_SERVER_UID' => function() { - return factory(\ProcessMaker\Model\EmailServerModel::class)->create()->MESS_UID; - }, - ]; -}); +use App\Factories\Factory; +use Illuminate\Support\Str; + +class EmailEventFactory extends Factory +{ + + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + $bpmnEvent = \ProcessMaker\Model\BpmnEvent::factory()->create(); + return [ + 'EMAIL_EVENT_UID' => $this->faker->regexify("/[a-zA-Z]{32}/"), + 'PRJ_UID' => $bpmnEvent->PRJ_UID, + 'EVN_UID' => $bpmnEvent->EVN_UID, + 'EMAIL_EVENT_FROM' => $this->faker->email, + 'EMAIL_EVENT_TO' => $this->faker->email, + 'EMAIL_EVENT_SUBJECT' => $this->faker->title, + 'PRF_UID' => function () { + return \ProcessMaker\Model\ProcessFiles::factory()->create()->PRF_UID; + }, + 'EMAIL_SERVER_UID' => function () { + return \ProcessMaker\Model\EmailServerModel::factory()->create()->MESS_UID; + }, + ]; + } + +} diff --git a/database/factories/EmailServerFactory.php b/database/factories/EmailServerFactory.php deleted file mode 100755 index 713b0bca5..000000000 --- a/database/factories/EmailServerFactory.php +++ /dev/null @@ -1,92 +0,0 @@ -define(\ProcessMaker\Model\EmailServerModel::class, function(Faker $faker) { - return [ - 'MESS_UID' => G::generateUniqueID(), - 'MESS_ENGINE' => 'MAIL', - '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, - 'OAUTH_CLIENT_ID' => '', - 'OAUTH_CLIENT_SECRET' => '', - 'OAUTH_REFRESH_TOKEN' => '' - ]; -}); - -$factory->state(\ProcessMaker\Model\EmailServerModel::class, 'PHPMAILER', function ($faker) { - return [ - 'MESS_UID' => G::generateUniqueID(), - 'MESS_ENGINE' => 'PHPMAILER', - 'MESS_PORT' => $faker->numberBetween(400, 500), - 'MESS_INCOMING_SERVER' => '', - 'MESS_INCOMING_PORT' => 0, - 'MESS_RAUTH' => 1, - 'MESS_ACCOUNT' => $faker->email, - 'MESS_PASSWORD' => $faker->password, - 'MESS_FROM_MAIL' => $faker->email, - 'MESS_FROM_NAME' => $faker->name, - 'SMTPSECURE' => 'ssl', - 'MESS_TRY_SEND_INMEDIATLY' => 0, - 'MAIL_TO' => $faker->email, - 'MESS_DEFAULT' => 0, - 'OAUTH_CLIENT_ID' => '', - 'OAUTH_CLIENT_SECRET' => '', - 'OAUTH_REFRESH_TOKEN' => '' - ]; -}); - -$factory->state(\ProcessMaker\Model\EmailServerModel::class, 'IMAP', function ($faker) { - return [ - 'MESS_UID' => G::generateUniqueID(), - 'MESS_ENGINE' => 'IMAP', - 'MESS_PORT' => $faker->numberBetween(400, 500), - 'MESS_INCOMING_SERVER' => 'imap.' . $faker->domainName, - 'MESS_INCOMING_PORT' => $faker->numberBetween(400, 500), - 'MESS_RAUTH' => 1, - 'MESS_ACCOUNT' => $faker->email, - 'MESS_PASSWORD' => $faker->password, - 'MESS_FROM_MAIL' => $faker->email, - 'MESS_FROM_NAME' => $faker->name, - 'SMTPSECURE' => 'ssl', - 'MESS_TRY_SEND_INMEDIATLY' => 0, - 'MAIL_TO' => $faker->email, - 'MESS_DEFAULT' => 0, - 'OAUTH_CLIENT_ID' => '', - 'OAUTH_CLIENT_SECRET' => '', - 'OAUTH_REFRESH_TOKEN' => '' - ]; -}); - -$factory->state(\ProcessMaker\Model\EmailServerModel::class, 'GMAILAPI', function ($faker) { - return [ - 'MESS_UID' => G::generateUniqueID(), - 'MESS_ENGINE' => 'GMAILAPI', - 'MESS_PORT' => 0, - 'MESS_INCOMING_SERVER' => '', - 'MESS_INCOMING_PORT' => 0, - 'MESS_RAUTH' => 1, - 'MESS_ACCOUNT' => $faker->email, - 'MESS_PASSWORD' => '', - 'MESS_FROM_MAIL' => $faker->email, - 'MESS_FROM_NAME' => $faker->name, - 'SMTPSECURE' => 'No', - 'MESS_TRY_SEND_INMEDIATLY' => 0, - 'MAIL_TO' => $faker->email, - 'MESS_DEFAULT' => 0, - 'OAUTH_CLIENT_ID' => $faker->regexify("/[0-9]{12}-[a-z]{32}\.apps\.googleusercontent\.com/"), - 'OAUTH_CLIENT_SECRET' => $faker->regexify("/[a-z]{24}/"), - 'OAUTH_REFRESH_TOKEN' => $faker->regexify("/[a-z]{7}[a-zA-Z0-9]{355}==/") - ]; -}); diff --git a/database/factories/EmailServerModelFactory.php b/database/factories/EmailServerModelFactory.php new file mode 100755 index 000000000..37ed66a2e --- /dev/null +++ b/database/factories/EmailServerModelFactory.php @@ -0,0 +1,131 @@ + G::generateUniqueID(), + 'MESS_ENGINE' => 'MAIL', + '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, + 'OAUTH_CLIENT_ID' => '', + 'OAUTH_CLIENT_SECRET' => '', + 'OAUTH_REFRESH_TOKEN' => '' + ]; + } + + /** + * + * @return type + */ + public function PHPMAILER() + { + $state = function (array $attributes) { + return [ + 'MESS_UID' => G::generateUniqueID(), + 'MESS_ENGINE' => 'PHPMAILER', + 'MESS_PORT' => $this->faker->numberBetween(400, 500), + 'MESS_INCOMING_SERVER' => '', + 'MESS_INCOMING_PORT' => 0, + 'MESS_RAUTH' => 1, + 'MESS_ACCOUNT' => $this->faker->email, + 'MESS_PASSWORD' => $this->faker->password, + 'MESS_FROM_MAIL' => $this->faker->email, + 'MESS_FROM_NAME' => $this->faker->name, + 'SMTPSECURE' => 'ssl', + 'MESS_TRY_SEND_INMEDIATLY' => 0, + 'MAIL_TO' => $this->faker->email, + 'MESS_DEFAULT' => 0, + 'OAUTH_CLIENT_ID' => '', + 'OAUTH_CLIENT_SECRET' => '', + 'OAUTH_REFRESH_TOKEN' => '' + ]; + }; + return $this->state($state); + } + + /** + * + * @return type + */ + public function IMAP() + { + $state = function (array $attributes) { + return [ + 'MESS_UID' => G::generateUniqueID(), + 'MESS_ENGINE' => 'IMAP', + 'MESS_PORT' => $this->faker->numberBetween(400, 500), + 'MESS_INCOMING_SERVER' => 'imap.' . $this->faker->domainName, + 'MESS_INCOMING_PORT' => $this->faker->numberBetween(400, 500), + 'MESS_RAUTH' => 1, + 'MESS_ACCOUNT' => $this->faker->email, + 'MESS_PASSWORD' => $this->faker->password, + 'MESS_FROM_MAIL' => $this->faker->email, + 'MESS_FROM_NAME' => $this->faker->name, + 'SMTPSECURE' => 'ssl', + 'MESS_TRY_SEND_INMEDIATLY' => 0, + 'MAIL_TO' => $this->faker->email, + 'MESS_DEFAULT' => 0, + 'OAUTH_CLIENT_ID' => '', + 'OAUTH_CLIENT_SECRET' => '', + 'OAUTH_REFRESH_TOKEN' => '' + ]; + }; + return $this->state($state); + } + + /** + * + * @return type + */ + public function GMAILAPI() + { + $state = function (array $attributes) { + return [ + 'MESS_UID' => G::generateUniqueID(), + 'MESS_ENGINE' => 'GMAILAPI', + 'MESS_PORT' => 0, + 'MESS_INCOMING_SERVER' => '', + 'MESS_INCOMING_PORT' => 0, + 'MESS_RAUTH' => 1, + 'MESS_ACCOUNT' => $this->faker->email, + 'MESS_PASSWORD' => '', + 'MESS_FROM_MAIL' => $this->faker->email, + 'MESS_FROM_NAME' => $this->faker->name, + 'SMTPSECURE' => 'No', + 'MESS_TRY_SEND_INMEDIATLY' => 0, + 'MAIL_TO' => $this->faker->email, + 'MESS_DEFAULT' => 0, + 'OAUTH_CLIENT_ID' => $this->faker->regexify("/[0-9]{12}-[a-z]{32}\.apps\.googleusercontent\.com/"), + 'OAUTH_CLIENT_SECRET' => $this->faker->regexify("/[a-z]{24}/"), + 'OAUTH_REFRESH_TOKEN' => $this->faker->regexify("/[a-z]{7}[a-zA-Z0-9]{355}==/") + ]; + }; + return $this->state($state); + } + +} diff --git a/database/factories/FieldsFactory.php b/database/factories/FieldsFactory.php index 70615e769..3cb87fe81 100644 --- a/database/factories/FieldsFactory.php +++ b/database/factories/FieldsFactory.php @@ -1,50 +1,72 @@ define(\ProcessMaker\Model\Fields::class, function (Faker $faker) { - return [ - 'FLD_UID' => G::generateUniqueID(), - 'ADD_TAB_UID' => G::generateUniqueID(), - 'FLD_INDEX' => 0, - 'FLD_NAME' => 'VAR_' . $faker->sentence(1), - 'FLD_DESCRIPTION' => $faker->sentence(2), - 'FLD_TYPE' => 'VARCHAR', - 'FLD_SIZE' => 255, - 'FLD_NULL' => 1, - 'FLD_AUTO_INCREMENT' => 0, - 'FLD_KEY' => 1, - 'FLD_TABLE_INDEX' => 0, - 'FLD_FOREIGN_KEY' => 0, - 'FLD_FOREIGN_KEY_TABLE' => '', - 'FLD_DYN_NAME' => '', - 'FLD_DYN_UID' => '', - 'FLD_FILTER' => 0, - ]; -}); +class FieldsFactory extends Factory +{ -// Create columns from a table with the foreign keys -$factory->state(\ProcessMaker\Model\Fields::class, 'foreign_keys', function (Faker $faker) { - return [ - 'FLD_UID' => G::generateUniqueID(), - 'ADD_TAB_UID' => function() { - $table = factory(AdditionalTables::class)->create(['ADD_TAB_OFFLINE' => 1]); - return $table->ADD_TAB_UID; - }, - 'FLD_INDEX' => 0, - 'FLD_NAME' => 'VAR_' . $faker->sentence(1), - 'FLD_DESCRIPTION' => $faker->sentence(2), - 'FLD_TYPE' => 'VARCHAR', - 'FLD_SIZE' => 255, - 'FLD_NULL' => 1, - 'FLD_AUTO_INCREMENT' => 0, - 'FLD_KEY' => 1, - 'FLD_TABLE_INDEX' => 0, - 'FLD_FOREIGN_KEY' => 0, - 'FLD_FOREIGN_KEY_TABLE' => '', - 'FLD_DYN_NAME' => '', - 'FLD_DYN_UID' => '', - 'FLD_FILTER' => 0, - ]; -}); + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + return [ + 'FLD_UID' => G::generateUniqueID(), + 'ADD_TAB_UID' => G::generateUniqueID(), + 'FLD_INDEX' => 0, + 'FLD_NAME' => 'VAR_' . $this->faker->sentence(1), + 'FLD_DESCRIPTION' => $this->faker->sentence(2), + 'FLD_TYPE' => 'VARCHAR', + 'FLD_SIZE' => 255, + 'FLD_NULL' => 1, + 'FLD_AUTO_INCREMENT' => 0, + 'FLD_KEY' => 1, + 'FLD_TABLE_INDEX' => 0, + 'FLD_FOREIGN_KEY' => 0, + 'FLD_FOREIGN_KEY_TABLE' => '', + 'FLD_DYN_NAME' => '', + 'FLD_DYN_UID' => '', + 'FLD_FILTER' => 0, + ]; + } + + /** + * Create columns from a table with the foreign keys + * @return type + */ + public function foreign_keys() + { + $state = function (array $attributes) { + return [ + 'FLD_UID' => G::generateUniqueID(), + 'ADD_TAB_UID' => function () { + $table = AdditionalTables::factory()->create(['ADD_TAB_OFFLINE' => 1]); + return $table->ADD_TAB_UID; + }, + 'FLD_INDEX' => 0, + 'FLD_NAME' => 'VAR_' . $this->faker->sentence(1), + 'FLD_DESCRIPTION' => $this->faker->sentence(2), + 'FLD_TYPE' => 'VARCHAR', + 'FLD_SIZE' => 255, + 'FLD_NULL' => 1, + 'FLD_AUTO_INCREMENT' => 0, + 'FLD_KEY' => 1, + 'FLD_TABLE_INDEX' => 0, + 'FLD_FOREIGN_KEY' => 0, + 'FLD_FOREIGN_KEY_TABLE' => '', + 'FLD_DYN_NAME' => '', + 'FLD_DYN_UID' => '', + 'FLD_FILTER' => 0, + ]; + }; + return $this->state($state); + } + +} diff --git a/database/factories/GroupUserFactory.php b/database/factories/GroupUserFactory.php index 013f47a92..6d4d6fa10 100644 --- a/database/factories/GroupUserFactory.php +++ b/database/factories/GroupUserFactory.php @@ -1,25 +1,45 @@ define(\ProcessMaker\Model\GroupUser::class, function(Faker $faker) { - return [ - 'GRP_UID' => G::generateUniqueID(), - 'GRP_ID' => $faker->unique()->numberBetween(1, 2000), - 'USR_UID' => G::generateUniqueID() - ]; -}); +namespace Database\Factories; -// Create columns from a table with the foreign keys -$factory->state(\ProcessMaker\Model\GroupUser::class, 'foreign_keys', function (Faker $faker) { - // Create values in the foreign key relations - $user = factory(\ProcessMaker\Model\User::class)->create(); - $group = factory(\ProcessMaker\Model\Groupwf::class)->create(); - return [ - 'GRP_UID' => $group->GRP_UID, - 'GRP_ID' => $group->GRP_ID, - 'USR_UID' => $user->USR_UID, - ]; -}); \ No newline at end of file +use App\Factories\Factory; +use G; +use Illuminate\Support\Str; + +class GroupUserFactory extends Factory +{ + + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + return [ + 'GRP_UID' => G::generateUniqueID(), + 'GRP_ID' => $this->faker->unique()->numberBetween(1, 2000), + 'USR_UID' => G::generateUniqueID() + ]; + } + + /** + * Create columns from a table with the foreign keys + * @return type + */ + public function foreign_keys() + { + $state = function (array $attributes) { + // Create values in the foreign key relations + $user = \ProcessMaker\Model\User::factory()->create(); + $group = \ProcessMaker\Model\Groupwf::factory()->create(); + return [ + 'GRP_UID' => $group->GRP_UID, + 'GRP_ID' => $group->GRP_ID, + 'USR_UID' => $user->USR_UID, + ]; + }; + return $this->state($state); + } + +} diff --git a/database/factories/GroupwfFactory.php b/database/factories/GroupwfFactory.php index bfcdc09ea..fda46536c 100644 --- a/database/factories/GroupwfFactory.php +++ b/database/factories/GroupwfFactory.php @@ -1,17 +1,29 @@ define(\ProcessMaker\Model\Groupwf::class, function(Faker $faker) { - return [ - 'GRP_UID' => G::generateUniqueID(), - 'GRP_ID' => $faker->unique()->numberBetween(2000), - 'GRP_TITLE' => $faker->sentence(2), - 'GRP_STATUS' => 'ACTIVE', - 'GRP_LDAP_DN' => '', - 'GRP_UX' => 'NORMAL', - ]; -}); +namespace Database\Factories; +use App\Factories\Factory; +use G; +use Illuminate\Support\Str; + +class GroupwfFactory extends Factory +{ + + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + return [ + 'GRP_UID' => G::generateUniqueID(), + 'GRP_ID' => $this->faker->unique()->numberBetween(2000), + 'GRP_TITLE' => $this->faker->sentence(2), + 'GRP_STATUS' => 'ACTIVE', + 'GRP_LDAP_DN' => '', + 'GRP_UX' => 'NORMAL', + ]; + } + +} diff --git a/database/factories/InputDocumentFactory.php b/database/factories/InputDocumentFactory.php index 5d2200275..5625cc288 100644 --- a/database/factories/InputDocumentFactory.php +++ b/database/factories/InputDocumentFactory.php @@ -1,29 +1,41 @@ define(InputDocument::class, function(Faker $faker) { - return [ - 'INP_DOC_UID' => G::generateUniqueID(), - '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' - ]; -}); +class InputDocumentFactory extends Factory +{ + + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + return [ + 'INP_DOC_UID' => G::generateUniqueID(), + 'PRO_UID' => function () { + $process = Process::factory()->create(); + return $process->PRO_UID; + }, + 'INP_DOC_TITLE' => $this->faker->sentence(2), + 'INP_DOC_DESCRIPTION' => $this->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' + ]; + } + +} diff --git a/database/factories/LicenseManagerFactory.php b/database/factories/LicenseManagerFactory.php index 22d192f6d..009b2748d 100644 --- a/database/factories/LicenseManagerFactory.php +++ b/database/factories/LicenseManagerFactory.php @@ -1,18 +1,32 @@ define(\ProcessMaker\Model\LicenseManager::class, function(Faker $faker) { - return [ - "LICENSE_UID" => $faker->regexify("/[a-zA-Z]{32}/"), - "LICENSE_USER" => $faker->name, - "LICENSE_START" => 0, - "LICENSE_END" => 0, - "LICENSE_SPAN" => 0, - "LICENSE_STATUS" => 'ACTIVE', - "LICENSE_DATA" => '', - "LICENSE_PATH" => '', - "LICENSE_WORKSPACE" => '', - "LICENSE_TYPE" => 'ONPREMISE' - ]; -}); +use App\Factories\Factory; +use Illuminate\Support\Str; + +class LicenseManagerFactory extends Factory +{ + + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + return [ + "LICENSE_UID" => $this->faker->regexify("/[a-zA-Z]{32}/"), + "LICENSE_USER" => $this->faker->name, + "LICENSE_START" => 0, + "LICENSE_END" => 0, + "LICENSE_SPAN" => 0, + "LICENSE_STATUS" => 'ACTIVE', + "LICENSE_DATA" => '', + "LICENSE_PATH" => '', + "LICENSE_WORKSPACE" => '', + "LICENSE_TYPE" => 'ONPREMISE' + ]; + } + +} diff --git a/database/factories/ListUnassignedFactory.php b/database/factories/ListUnassignedFactory.php index 17a19b25c..67023b5c8 100644 --- a/database/factories/ListUnassignedFactory.php +++ b/database/factories/ListUnassignedFactory.php @@ -1,65 +1,85 @@ define(\ProcessMaker\Model\ListUnassigned::class, function(Faker $faker) { - return [ - 'APP_UID' => G::generateUniqueID(), - 'DEL_INDEX' => 2, - 'TAS_UID' => G::generateUniqueID(), - 'PRO_UID' => G::generateUniqueID(), - 'APP_NUMBER' => $faker->unique()->numberBetween(1000), - 'APP_TITLE' => $faker->sentence(3), - 'APP_PRO_TITLE' => $faker->sentence(3), - 'APP_TAS_TITLE' => $faker->sentence(3), - 'DEL_PREVIOUS_USR_USERNAME' => $faker->name, - 'DEL_PREVIOUS_USR_FIRSTNAME' => $faker->firstName, - 'DEL_PREVIOUS_USR_LASTNAME' => $faker->lastName, - 'APP_UPDATE_DATE' => $faker->dateTime(), - 'DEL_PREVIOUS_USR_UID' => G::generateUniqueID(), - 'DEL_DELEGATE_DATE' => $faker->dateTime(), - 'DEL_DUE_DATE' => $faker->dateTime(), - 'DEL_PRIORITY' => 3, - 'PRO_ID' => $faker->unique()->numberBetween(1000), - 'TAS_ID' => $faker->unique()->numberBetween(1000), - ]; -}); +class ListUnassignedFactory extends Factory +{ -$factory->state(\ProcessMaker\Model\ListUnassigned::class, 'foreign_keys', function (Faker $faker) { - $process = factory(Process::class)->create(); - $app = factory(Application::class)->create(['PRO_UID' => $process->PRO_UID]); - $user = factory(User::class)->create(); - $task = factory(Task::class)->create([ - 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', // Define a self-service type - 'TAS_GROUP_VARIABLE' => '', - 'PRO_UID' => $process->PRO_UID - ]); + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + return [ + 'APP_UID' => G::generateUniqueID(), + 'DEL_INDEX' => 2, + 'TAS_UID' => G::generateUniqueID(), + 'PRO_UID' => G::generateUniqueID(), + 'APP_NUMBER' => $this->faker->unique()->numberBetween(1000), + 'APP_TITLE' => $this->faker->sentence(3), + 'APP_PRO_TITLE' => $this->faker->sentence(3), + 'APP_TAS_TITLE' => $this->faker->sentence(3), + 'DEL_PREVIOUS_USR_USERNAME' => $this->faker->name, + 'DEL_PREVIOUS_USR_FIRSTNAME' => $this->faker->firstName, + 'DEL_PREVIOUS_USR_LASTNAME' => $this->faker->lastName, + 'APP_UPDATE_DATE' => $this->faker->dateTime(), + 'DEL_PREVIOUS_USR_UID' => G::generateUniqueID(), + 'DEL_DELEGATE_DATE' => $this->faker->dateTime(), + 'DEL_DUE_DATE' => $this->faker->dateTime(), + 'DEL_PRIORITY' => 3, + 'PRO_ID' => $this->faker->unique()->numberBetween(1000), + 'TAS_ID' => $this->faker->unique()->numberBetween(1000), + ]; + } - return [ - 'APP_UID' => $app->APP_UID, - 'DEL_INDEX' => 2, - 'TAS_UID' => $task->TAS_UID, - 'PRO_UID' => $process->PRO_UID, - 'APP_NUMBER' => $app->APP_NUMBER, - 'APP_TITLE' => $app->APP_TITLE, - 'APP_PRO_TITLE' => $process->PRO_TITLE, - 'APP_TAS_TITLE' => $task->TAS_TITLE, - 'DEL_PREVIOUS_USR_USERNAME' => $user->USR_USERNAME, - 'DEL_PREVIOUS_USR_FIRSTNAME' => $user->USR_FIRSTNAME, - 'DEL_PREVIOUS_USR_LASTNAME' => $user->USR_LASTNAME, - 'APP_UPDATE_DATE' => $faker->dateTime(), - 'DEL_PREVIOUS_USR_UID' => G::generateUniqueID(), - 'DEL_DELEGATE_DATE' => $faker->dateTime(), - 'DEL_DUE_DATE' => $faker->dateTime(), - 'DEL_PRIORITY' => 3, - 'PRO_ID' => $process->PRO_ID, - 'TAS_ID' => $task->TAS_ID, - ]; -}); + /** + * + * @return type + */ + public function foreign_keys() + { + $state = function (array $attributes) { + $process = Process::factory()->create(); + $app = Application::factory()->create(['PRO_UID' => $process->PRO_UID]); + $user = User::factory()->create(); + $task = Task::factory()->create([ + 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', // Define a self-service type + 'TAS_GROUP_VARIABLE' => '', + 'PRO_UID' => $process->PRO_UID + ]); + return [ + 'APP_UID' => $app->APP_UID, + 'DEL_INDEX' => 2, + 'TAS_UID' => $task->TAS_UID, + 'PRO_UID' => $process->PRO_UID, + 'APP_NUMBER' => $app->APP_NUMBER, + 'APP_TITLE' => $app->APP_TITLE, + 'APP_PRO_TITLE' => $process->PRO_TITLE, + 'APP_TAS_TITLE' => $task->TAS_TITLE, + 'DEL_PREVIOUS_USR_USERNAME' => $user->USR_USERNAME, + 'DEL_PREVIOUS_USR_FIRSTNAME' => $user->USR_FIRSTNAME, + 'DEL_PREVIOUS_USR_LASTNAME' => $user->USR_LASTNAME, + 'APP_UPDATE_DATE' => $this->faker->dateTime(), + 'DEL_PREVIOUS_USR_UID' => G::generateUniqueID(), + 'DEL_DELEGATE_DATE' => $this->faker->dateTime(), + 'DEL_DUE_DATE' => $this->faker->dateTime(), + 'DEL_PRIORITY' => 3, + 'PRO_ID' => $process->PRO_ID, + 'TAS_ID' => $task->TAS_ID, + ]; + }; + return $this->state($state); + } + +} diff --git a/database/factories/OauthClientsFactory.php b/database/factories/OauthClientsFactory.php index 21e70c0e2..df1c2b862 100644 --- a/database/factories/OauthClientsFactory.php +++ b/database/factories/OauthClientsFactory.php @@ -1,17 +1,31 @@ define(\ProcessMaker\Model\OauthClients::class, function(Faker $faker) { - return [ - "CLIENT_ID" => $faker->unique()->word(), - "CLIENT_SECRET" => $faker->regexify("/[a-zA-Z]{6}/"), - "CLIENT_NAME" => $faker->regexify("/[a-zA-Z]{6}/"), - "CLIENT_DESCRIPTION" => $faker->text, - "CLIENT_WEBSITE" => $faker->url, - "REDIRECT_URI" => $faker->url, - "USR_UID" => function() { - return factory(\ProcessMaker\Model\User::class)->create()->USR_UID; - } - ]; -}); +use App\Factories\Factory; +use Illuminate\Support\Str; + +class OauthClientsFactory extends Factory +{ + + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + return [ + "CLIENT_ID" => $this->faker->unique()->word(), + "CLIENT_SECRET" => $this->faker->regexify("/[a-zA-Z]{6}/"), + "CLIENT_NAME" => $this->faker->regexify("/[a-zA-Z]{6}/"), + "CLIENT_DESCRIPTION" => $this->faker->text, + "CLIENT_WEBSITE" => $this->faker->url, + "REDIRECT_URI" => $this->faker->url, + "USR_UID" => function () { + return \ProcessMaker\Model\User::factory()->create()->USR_UID; + } + ]; + } + +} diff --git a/database/factories/ObjectPermissionFactory.php b/database/factories/ObjectPermissionFactory.php index 8017f1cfc..31777d522 100644 --- a/database/factories/ObjectPermissionFactory.php +++ b/database/factories/ObjectPermissionFactory.php @@ -1,22 +1,34 @@ define(\ProcessMaker\Model\ObjectPermission::class, function(Faker $faker) { - return [ - 'OP_UID' => G::generateUniqueID(), - 'PRO_UID' => '', - 'TAS_UID' => '', - 'USR_UID' => '', - 'OP_USER_RELATION' => 1, - 'OP_TASK_SOURCE' => '', - 'OP_PARTICIPATE' => 0, - 'OP_OBJ_TYPE' => 'MSGS_HISTORY', - 'OP_OBJ_UID' => '', - 'OP_ACTION' => 'VIEW', - 'OP_CASE_STATUS' => 'ALL' - ]; -}); +use App\Factories\Factory; +use G; +use Illuminate\Support\Str; + +class ObjectPermissionFactory extends Factory +{ + + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + return [ + 'OP_UID' => G::generateUniqueID(), + 'PRO_UID' => '', + 'TAS_UID' => '', + 'USR_UID' => '', + 'OP_USER_RELATION' => 1, + 'OP_TASK_SOURCE' => '', + 'OP_PARTICIPATE' => 0, + 'OP_OBJ_TYPE' => 'MSGS_HISTORY', + 'OP_OBJ_UID' => '', + 'OP_ACTION' => 'VIEW', + 'OP_CASE_STATUS' => 'ALL' + ]; + } + +} diff --git a/database/factories/OutputDocumentFactory.php b/database/factories/OutputDocumentFactory.php index 68ef77090..2b8a70863 100644 --- a/database/factories/OutputDocumentFactory.php +++ b/database/factories/OutputDocumentFactory.php @@ -1,45 +1,57 @@ 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, - 'OUT_DOC_HEADER' => null, - 'OUT_DOC_FOOTER' => null - ]; -}); +class OutputDocumentFactory extends Factory +{ + + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + $date = $this->faker->dateTime(); + return [ + 'OUT_DOC_UID' => G::generateUniqueID(), + 'OUT_DOC_ID' => $this->faker->unique()->numberBetween(1, 10000), + 'OUT_DOC_TITLE' => $this->faker->sentence(2), + 'OUT_DOC_DESCRIPTION' => $this->faker->sentence(10), + 'OUT_DOC_FILENAME' => $this->faker->sentence(2), + 'OUT_DOC_TEMPLATE' => '', + 'PRO_UID' => function () { + $process = Process::factory()->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, + 'OUT_DOC_HEADER' => null, + 'OUT_DOC_FOOTER' => null + ]; + } + +} diff --git a/database/factories/ProcessCategoryFactory.php b/database/factories/ProcessCategoryFactory.php index aaaedfd75..f92dc207f 100644 --- a/database/factories/ProcessCategoryFactory.php +++ b/database/factories/ProcessCategoryFactory.php @@ -1,17 +1,28 @@ define(\ProcessMaker\Model\ProcessCategory::class, function (Faker $faker) { - return [ - 'CATEGORY_UID' => G::generateUniqueID(), - 'CATEGORY_ID' => $faker->unique()->numberBetween(1000), - 'CATEGORY_PARENT' => '', - 'CATEGORY_NAME' => $faker->sentence(5), - 'CATEGORY_ICON' => '', - ]; -}); +class ProcessCategoryFactory extends Factory +{ + + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + return [ + 'CATEGORY_UID' => G::generateUniqueID(), + 'CATEGORY_ID' => $this->faker->unique()->numberBetween(1000), + 'CATEGORY_PARENT' => '', + 'CATEGORY_NAME' => $this->faker->sentence(5), + 'CATEGORY_ICON' => '', + ]; + } + +} diff --git a/database/factories/ProcessFactory.php b/database/factories/ProcessFactory.php index 99c42f5a0..79bff8242 100644 --- a/database/factories/ProcessFactory.php +++ b/database/factories/ProcessFactory.php @@ -1,65 +1,77 @@ define(\ProcessMaker\Model\Process::class, function (Faker $faker) { +class ProcessFactory extends Factory +{ - return [ - 'PRO_UID' => G::generateUniqueID(), - 'PRO_ID' => $faker->unique()->numberBetween(2000), - 'PRO_TITLE' => $faker->sentence(3), - 'PRO_DESCRIPTION' => $faker->paragraph(3), - 'PRO_PARENT' => G::generateUniqueID(), - 'PRO_STATUS' => 'ACTIVE', - 'PRO_STATUS_ID' => 1, - 'PRO_TYPE' => 'NORMAL', - 'PRO_ASSIGNMENT' => 'FALSE', - 'PRO_TYPE_PROCESS' => 'PUBLIC', - 'PRO_UPDATE_DATE' => $faker->dateTime(), - 'PRO_CREATE_DATE' => $faker->dateTime(), - 'PRO_CREATE_USER' => '00000000000000000000000000000001', - 'PRO_DEBUG' => 0, - 'PRO_DYNAFORMS' => serialize([]), - 'PRO_ITEE' => 1, - 'PRO_ACTION_DONE' => serialize([]), - 'PRO_SUBPROCESS' => 0, - 'PRO_CATEGORY' => function () { - return factory(\ProcessMaker\Model\ProcessCategory::class)->create()->CATEGORY_UID; - }, - 'CATEGORY_ID' => 0 - ]; -}); + public function definition(): array + { + return [ + 'PRO_UID' => G::generateUniqueID(), + 'PRO_ID' => $this->faker->unique()->numberBetween(2000), + 'PRO_TITLE' => $this->faker->sentence(3), + 'PRO_DESCRIPTION' => $this->faker->paragraph(3), + 'PRO_PARENT' => G::generateUniqueID(), + 'PRO_STATUS' => 'ACTIVE', + 'PRO_STATUS_ID' => 1, + 'PRO_TYPE' => 'NORMAL', + 'PRO_ASSIGNMENT' => 'FALSE', + 'PRO_TYPE_PROCESS' => 'PUBLIC', + 'PRO_UPDATE_DATE' => $this->faker->dateTime(), + 'PRO_CREATE_DATE' => $this->faker->dateTime(), + 'PRO_CREATE_USER' => '00000000000000000000000000000001', + 'PRO_DEBUG' => 0, + 'PRO_DYNAFORMS' => serialize([]), + 'PRO_ITEE' => 1, + 'PRO_ACTION_DONE' => serialize([]), + 'PRO_SUBPROCESS' => 0, + 'PRO_CATEGORY' => function () { + return \ProcessMaker\Model\ProcessCategory::factory()->create()->CATEGORY_UID; + }, + 'CATEGORY_ID' => 0 + ]; + } -// Create a process with the foreign keys -$factory->state(\ProcessMaker\Model\Process::class, 'foreign_keys', function (Faker $faker) { - // Create user - $user = factory(\ProcessMaker\Model\User::class)->create(); + /** + * Create a process with the foreign keys + * @return type + */ + public function foreign_keys() + { + $state = function (array $attributes) { + // Create user + $user = \ProcessMaker\Model\User::factory()->create(); - return [ - 'PRO_UID' => G::generateUniqueID(), - 'PRO_ID' => $faker->unique()->numberBetween(1000), - 'PRO_TITLE' => $faker->sentence(3), - 'PRO_DESCRIPTION' => $faker->paragraph(3), - 'PRO_PARENT' => G::generateUniqueID(), - 'PRO_STATUS' => 'ACTIVE', - 'PRO_STATUS_ID' => 1, - 'PRO_TYPE' => 'NORMAL', - 'PRO_ASSIGNMENT' => 'FALSE', - 'PRO_TYPE_PROCESS' => 'PUBLIC', - 'PRO_UPDATE_DATE' => $faker->dateTime(), - 'PRO_CREATE_DATE' => $faker->dateTime(), - 'PRO_CREATE_USER' => $user->USR_UID, - 'PRO_DEBUG' => 0, - 'PRO_DYNAFORMS' => serialize([]), - 'PRO_ITEE' => 1, - 'PRO_ACTION_DONE' => serialize([]), - 'PRO_SUBPROCESS' => 0, - 'PRO_CATEGORY' => function () { - return factory(\ProcessMaker\Model\ProcessCategory::class)->create()->CATEGORY_UID; - }, - ]; -}); + return [ + 'PRO_UID' => G::generateUniqueID(), + 'PRO_ID' => $this->faker->unique()->numberBetween(1000), + 'PRO_TITLE' => $this->faker->sentence(3), + 'PRO_DESCRIPTION' => $this->faker->paragraph(3), + 'PRO_PARENT' => G::generateUniqueID(), + 'PRO_STATUS' => 'ACTIVE', + 'PRO_STATUS_ID' => 1, + 'PRO_TYPE' => 'NORMAL', + 'PRO_ASSIGNMENT' => 'FALSE', + 'PRO_TYPE_PROCESS' => 'PUBLIC', + 'PRO_UPDATE_DATE' => $this->faker->dateTime(), + 'PRO_CREATE_DATE' => $this->faker->dateTime(), + 'PRO_CREATE_USER' => $user->USR_UID, + 'PRO_DEBUG' => 0, + 'PRO_DYNAFORMS' => serialize([]), + 'PRO_ITEE' => 1, + 'PRO_ACTION_DONE' => serialize([]), + 'PRO_SUBPROCESS' => 0, + 'PRO_CATEGORY' => function () { + return \ProcessMaker\Model\ProcessCategory::factory()->create()->CATEGORY_UID; + }, + ]; + }; + return $this->state($state); + } +} diff --git a/database/factories/ProcessFilesFactory.php b/database/factories/ProcessFilesFactory.php index 2d9c84e59..237a6e875 100644 --- a/database/factories/ProcessFilesFactory.php +++ b/database/factories/ProcessFilesFactory.php @@ -1,17 +1,32 @@ define(\ProcessMaker\Model\ProcessFiles::class, function(Faker $faker) { - return [ - 'PRF_UID' => G::generateUniqueID(), - 'PRO_UID' => '', - 'USR_UID' => '', - 'PRF_UPDATE_USR_UID' => '', - 'PRF_PATH' => 'dummy_path', - 'PRF_TYPE' => '', - 'PRF_EDITABLE' => 1, - 'PRF_CREATE_DATE' => $faker->dateTime(), - 'PRF_UPDATE_DATE' => $faker->dateTime(), - ]; -}); +use App\Factories\Factory; +use G; +use Illuminate\Support\Str; + +class ProcessFilesFactory extends Factory +{ + + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + return [ + 'PRF_UID' => G::generateUniqueID(), + 'PRO_UID' => '', + 'USR_UID' => '', + 'PRF_UPDATE_USR_UID' => '', + 'PRF_PATH' => 'dummy_path', + 'PRF_TYPE' => '', + 'PRF_EDITABLE' => 1, + 'PRF_CREATE_DATE' => $this->faker->dateTime(), + 'PRF_UPDATE_DATE' => $this->faker->dateTime(), + ]; + } + +} diff --git a/database/factories/ProcessUserFactory.php b/database/factories/ProcessUserFactory.php index e84b6b42e..b64a59440 100644 --- a/database/factories/ProcessUserFactory.php +++ b/database/factories/ProcessUserFactory.php @@ -1,26 +1,48 @@ define(\ProcessMaker\Model\ProcessUser::class, function(Faker $faker) { - return [ - 'PU_UID' => G::generateUniqueID(), - 'PRO_UID' => G::generateUniqueID(), - 'USR_UID' => G::generateUniqueID(), - 'PU_TYPE' => 'SUPERVISOR' - ]; -}); +use App\Factories\Factory; +use G; +use Illuminate\Support\Str; -// Create a process with the foreign keys -$factory->state(\ProcessMaker\Model\ProcessUser::class, 'foreign_keys', function (Faker $faker) { - // Create user - $user = factory(\ProcessMaker\Model\User::class)->create(); - $process = factory(\ProcessMaker\Model\Process::class)->create(); +class ProcessUserFactory extends Factory +{ - return [ - 'PU_UID' => G::generateUniqueID(), - 'PRO_UID' => $process->PRO_UID, - 'USR_UID' => $user->USR_UID, - 'PU_TYPE' => 'SUPERVISOR' - ]; -}); \ No newline at end of file + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + return [ + 'PU_UID' => G::generateUniqueID(), + 'PRO_UID' => G::generateUniqueID(), + 'USR_UID' => G::generateUniqueID(), + 'PU_TYPE' => 'SUPERVISOR' + ]; + } + + /** + * Create a process with the foreign keys + * @return type + */ + public function foreign_keys() + { + $state = function (array $attributes) { + // Create user + $user = \ProcessMaker\Model\User::factory()->create(); + $process = \ProcessMaker\Model\Process::factory()->create(); + + return [ + 'PU_UID' => G::generateUniqueID(), + 'PRO_UID' => $process->PRO_UID, + 'USR_UID' => $user->USR_UID, + 'PU_TYPE' => 'SUPERVISOR' + ]; + }; + return $this->state($state); + } + +} diff --git a/database/factories/ProcessVariablesFactory.php b/database/factories/ProcessVariablesFactory.php index 77bc3ed8a..13bec32d8 100644 --- a/database/factories/ProcessVariablesFactory.php +++ b/database/factories/ProcessVariablesFactory.php @@ -1,49 +1,71 @@ define(ProcessVariables::class, function (Faker $faker) { - return [ - 'VAR_UID' => G::generateUniqueID(), - 'PRO_ID' => G::generateUniqueID(), - 'PRJ_UID' => G::generateUniqueID(), - 'VAR_NAME' => $faker->word, - 'VAR_FIELD_TYPE' => G::generateUniqueID(), - 'VAR_FIELD_TYPE_ID' => 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' => '' - ]; -}); +class ProcessVariablesFactory extends Factory +{ -// Create a processVariables with the foreign keys -$factory->state(ProcessVariables::class, 'foreign_keys', function (Faker $faker) { - $types = ['string', 'integer', 'float', 'boolean', 'datetime', 'grid', 'array', 'file', 'multiplefile', 'object']; - $varType = $faker->randomElement($types); - $varTypeId = array_search($varType, $types) + 1; - // Create values in the foreign key relations - $process = factory(\ProcessMaker\Model\Process::class)->create(); + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + return [ + 'VAR_UID' => G::generateUniqueID(), + 'PRO_ID' => G::generateUniqueID(), + 'PRJ_UID' => G::generateUniqueID(), + 'VAR_NAME' => $this->faker->word, + 'VAR_FIELD_TYPE' => G::generateUniqueID(), + 'VAR_FIELD_TYPE_ID' => 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' => '' + ]; + } - return [ - 'VAR_UID' => G::generateUniqueID(), - 'PRO_ID' => $process->PRO_ID, - 'PRJ_UID' => $process->PRO_UID, - 'VAR_NAME' => $faker->word, - 'VAR_FIELD_TYPE' => $varType, - 'VAR_FIELD_TYPE_ID' => $varTypeId, - 'VAR_FIELD_SIZE' => 10, - 'VAR_LABEL' => 'string', - 'VAR_DBCONNECTION' => 'workflow', - 'VAR_SQL' => '', - 'VAR_NULL' => 0, - 'VAR_DEFAULT' => '', - 'VAR_ACCEPTED_VALUES' => '[]', - 'INP_DOC_UID' => '' - ]; -}); \ No newline at end of file + /** + * Create a processVariables with the foreign keys + * @return type + */ + public function foreign_keys() + { + $state = function (array $attributes) { + $types = ['string', 'integer', 'float', 'boolean', 'datetime', 'grid', 'array', 'file', 'multiplefile', 'object']; + $varType = $this->faker->randomElement($types); + $varTypeId = array_search($varType, $types) + 1; + // Create values in the foreign key relations + $process = \ProcessMaker\Model\Process::factory()->create(); + + return [ + 'VAR_UID' => G::generateUniqueID(), + 'PRO_ID' => $process->PRO_ID, + 'PRJ_UID' => $process->PRO_UID, + 'VAR_NAME' => $this->faker->word, + 'VAR_FIELD_TYPE' => $varType, + 'VAR_FIELD_TYPE_ID' => $varTypeId, + 'VAR_FIELD_SIZE' => 10, + 'VAR_LABEL' => 'string', + 'VAR_DBCONNECTION' => 'workflow', + 'VAR_SQL' => '', + 'VAR_NULL' => 0, + 'VAR_DEFAULT' => '', + 'VAR_ACCEPTED_VALUES' => '[]', + 'INP_DOC_UID' => '' + ]; + }; + return $this->state($state); + } + +} diff --git a/database/factories/RbacAuthenticationSourceFactory.php b/database/factories/RbacAuthenticationSourceFactory.php index eb217ee54..6d0d86c39 100644 --- a/database/factories/RbacAuthenticationSourceFactory.php +++ b/database/factories/RbacAuthenticationSourceFactory.php @@ -1,22 +1,37 @@ define(\ProcessMaker\Model\RbacAuthenticationSource::class, function (Faker $faker) { - return [ - 'AUTH_SOURCE_UID' => G::generateUniqueID(), - 'AUTH_SOURCE_NAME' => $faker->title, - 'AUTH_SOURCE_PROVIDER' => 'ldapAdvanced', - 'AUTH_SOURCE_SERVER_NAME' => $faker->domainName, - 'AUTH_SOURCE_PORT' => $faker->numberBetween(100, 1000), - 'AUTH_SOURCE_ENABLED_TLS' => 0, - 'AUTH_SOURCE_VERSION' => 3, - 'AUTH_SOURCE_BASE_DN' => 'dc=processmaker,dc=test', - 'AUTH_ANONYMOUS' => 0, - 'AUTH_SOURCE_SEARCH_USER' => $faker->userName, - 'AUTH_SOURCE_PASSWORD' => $faker->password, - 'AUTH_SOURCE_ATTRIBUTES' => '', - 'AUTH_SOURCE_OBJECT_CLASSES' => '', - 'AUTH_SOURCE_DATA' => 'a:8:{s:9:"LDAP_TYPE";s:4:"ldap";s:25:"AUTH_SOURCE_AUTO_REGISTER";s:1:"0";s:31:"AUTH_SOURCE_IDENTIFIER_FOR_USER";s:3:"uid";s:24:"AUTH_SOURCE_USERS_FILTER";s:0:"";s:22:"AUTH_SOURCE_RETIRED_OU";s:0:"";s:20:"AUTH_SOURCE_SHOWGRID";s:2:"on";s:26:"AUTH_SOURCE_GRID_ATTRIBUTE";a:1:{i:1;a:2:{s:13:"attributeLdap";s:4:"test";s:13:"attributeUser";s:13:"USR_FIRSTNAME";}}s:20:"LDAP_PAGE_SIZE_LIMIT";i:1000;}' - ]; -}); +use App\Factories\Factory; +use G; +use Illuminate\Support\Str; + +class RbacAuthenticationSourceFactory extends Factory +{ + + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + return [ + 'AUTH_SOURCE_UID' => G::generateUniqueID(), + 'AUTH_SOURCE_NAME' => $this->faker->title, + 'AUTH_SOURCE_PROVIDER' => 'ldapAdvanced', + 'AUTH_SOURCE_SERVER_NAME' => $this->faker->domainName, + 'AUTH_SOURCE_PORT' => $this->faker->numberBetween(100, 1000), + 'AUTH_SOURCE_ENABLED_TLS' => 0, + 'AUTH_SOURCE_VERSION' => 3, + 'AUTH_SOURCE_BASE_DN' => 'dc=processmaker,dc=test', + 'AUTH_ANONYMOUS' => 0, + 'AUTH_SOURCE_SEARCH_USER' => $this->faker->userName, + 'AUTH_SOURCE_PASSWORD' => $this->faker->password, + 'AUTH_SOURCE_ATTRIBUTES' => '', + 'AUTH_SOURCE_OBJECT_CLASSES' => '', + 'AUTH_SOURCE_DATA' => 'a:8:{s:9:"LDAP_TYPE";s:4:"ldap";s:25:"AUTH_SOURCE_AUTO_REGISTER";s:1:"0";s:31:"AUTH_SOURCE_IDENTIFIER_FOR_USER";s:3:"uid";s:24:"AUTH_SOURCE_USERS_FILTER";s:0:"";s:22:"AUTH_SOURCE_RETIRED_OU";s:0:"";s:20:"AUTH_SOURCE_SHOWGRID";s:2:"on";s:26:"AUTH_SOURCE_GRID_ATTRIBUTE";a:1:{i:1;a:2:{s:13:"attributeLdap";s:4:"test";s:13:"attributeUser";s:13:"USR_FIRSTNAME";}}s:20:"LDAP_PAGE_SIZE_LIMIT";i:1000;}' + ]; + } + +} diff --git a/database/factories/RbacRolesFactory.php b/database/factories/RbacRolesFactory.php index f4ce2a7bc..081b2b7ba 100644 --- a/database/factories/RbacRolesFactory.php +++ b/database/factories/RbacRolesFactory.php @@ -1,17 +1,30 @@ define(\ProcessMaker\Model\RbacRoles::class, function(Faker $faker) { - return [ - 'ROL_UID' => G::generateUniqueID(), - 'ROL_PARENT' => '', // This value is empty because actually don't exists this type of relations between roles - 'ROL_SYSTEM' => '00000000000000000000000000000002', // Hardcoded value, this value refers to ProcessMaker - 'ROL_CODE' => strtoupper($faker->word), - 'ROL_CREATE_DATE' => $faker->date('Y-m-d H:i:s', 'now'), - 'ROL_UPDATE_DATE' => $faker->date('Y-m-d H:i:s', 'now'), - 'ROL_STATUS' => $faker->randomElement([0, 1]) - ]; -}); +namespace Database\Factories; + +use App\Factories\Factory; +use G; +use Illuminate\Support\Str; + +class RbacRolesFactory extends Factory +{ + + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + return [ + 'ROL_UID' => G::generateUniqueID(), + 'ROL_PARENT' => '', // This value is empty because actually don't exists this type of relations between roles + 'ROL_SYSTEM' => '00000000000000000000000000000002', // Hardcoded value, this value refers to ProcessMaker + 'ROL_CODE' => strtoupper($this->faker->word), + 'ROL_CREATE_DATE' => $this->faker->date('Y-m-d H:i:s', 'now'), + 'ROL_UPDATE_DATE' => $this->faker->date('Y-m-d H:i:s', 'now'), + 'ROL_STATUS' => $this->faker->randomElement([0, 1]) + ]; + } + +} diff --git a/database/factories/RbacUsersFactory.php b/database/factories/RbacUsersFactory.php index 00413b726..e20ea1435 100644 --- a/database/factories/RbacUsersFactory.php +++ b/database/factories/RbacUsersFactory.php @@ -1,46 +1,82 @@ define(\ProcessMaker\Model\RbacUsers::class, function (Faker $faker) { - return [ - 'USR_UID' => G::generateUniqueID(), - 'USR_USERNAME' => $faker->unique()->userName, - 'USR_PASSWORD' => $faker->password, - 'USR_FIRSTNAME' => $faker->firstName, - 'USR_LASTNAME' => $faker->lastName, - 'USR_EMAIL' => $faker->unique()->email, - 'USR_DUE_DATE' => $faker->dateTimeInInterval('now', '+1 year')->format('Y-m-d H:i:s'), - 'USR_CREATE_DATE' => $faker->date('Y-m-d H:i:s', 'now'), - 'USR_UPDATE_DATE' => $faker->date('Y-m-d H:i:s', 'now'), - 'USR_STATUS' => $faker->randomElement([0, 1]), - 'USR_AUTH_TYPE' => 'MYSQL', // Authentication type, by default is MySQL - 'UID_AUTH_SOURCE' => '00000000000000000000000000000000', // When the type is "MYSQL" the value for this field is this... - 'USR_AUTH_USER_DN' => '', // Don't required for now - 'USR_AUTH_SUPERVISOR_DN' => '' // Don't required for now - ]; -}); +use App\Factories\Factory; +use G; +use Illuminate\Support\Str; -// Create a deleted user -$factory->state(\ProcessMaker\Model\RbacUsers::class, 'deleted', function () { - return [ - 'USR_USERNAME' => '', - 'USR_STATUS' => 0, - 'USR_AUTH_TYPE' => '', - 'UID_AUTH_SOURCE' => '' - ]; -}); +class RbacUsersFactory extends Factory +{ -// Create an active user -$factory->state(\ProcessMaker\Model\RbacUsers::class, 'active', function () { - return [ - 'USR_STATUS' => 1 - ]; -}); + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + return [ + 'USR_UID' => G::generateUniqueID(), + 'USR_USERNAME' => $this->faker->unique()->userName, + 'USR_PASSWORD' => $this->faker->password, + 'USR_FIRSTNAME' => $this->faker->firstName, + 'USR_LASTNAME' => $this->faker->lastName, + 'USR_EMAIL' => $this->faker->unique()->email, + 'USR_DUE_DATE' => $this->faker->dateTimeInInterval('now', '+1 year')->format('Y-m-d H:i:s'), + 'USR_CREATE_DATE' => $this->faker->date('Y-m-d H:i:s', 'now'), + 'USR_UPDATE_DATE' => $this->faker->date('Y-m-d H:i:s', 'now'), + 'USR_STATUS' => $this->faker->randomElement([0, 1]), + 'USR_AUTH_TYPE' => 'MYSQL', // Authentication type, by default is MySQL + 'UID_AUTH_SOURCE' => '00000000000000000000000000000000', // When the type is "MYSQL" the value for this field is this... + 'USR_AUTH_USER_DN' => '', // Don't required for now + 'USR_AUTH_SUPERVISOR_DN' => '' // Don't required for now + ]; + } -// Create an inactive user -$factory->state(\ProcessMaker\Model\RbacUsers::class, 'inactive', function () { - return [ - 'USR_STATUS' => 0 - ]; -}); + /** + * Create a deleted user + * @return type + */ + public function deleted() + { + $state = function (array $attributes) { + return [ + 'USR_USERNAME' => '', + 'USR_STATUS' => 0, + 'USR_AUTH_TYPE' => '', + 'UID_AUTH_SOURCE' => '' + ]; + }; + return $this->state($state); + } + + /** + * Create an active user + * @return type + */ + public function active() + { + $state = function (array $attributes) { + return [ + 'USR_STATUS' => 1 + ]; + }; + return $this->state($state); + } + + /** + * Create an inactive user + * @return type + */ + public function inactive() + { + $state = function (array $attributes) { + return [ + 'USR_STATUS' => 0 + ]; + }; + return $this->state($state); + } + +} diff --git a/database/factories/RbacUsersRolesFactory.php b/database/factories/RbacUsersRolesFactory.php index 6d912a9c4..c109591ee 100644 --- a/database/factories/RbacUsersRolesFactory.php +++ b/database/factories/RbacUsersRolesFactory.php @@ -1,17 +1,30 @@ define(\ProcessMaker\Model\RbacUsersRoles::class, function() { - return [ - 'USR_UID' => function() { - $rbacUser = factory(\ProcessMaker\Model\RbacUsers::class)->create(); - return $rbacUser->USR_UID; - }, - 'ROL_UID' => function() { - $rbacRole = factory(\ProcessMaker\Model\RbacRoles::class)->create(); - return $rbacRole->ROL_UID; - } - ]; -}); +namespace Database\Factories; + +use App\Factories\Factory; +use Illuminate\Support\Str; + +class RbacUsersRolesFactory extends Factory +{ + + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + return [ + 'USR_UID' => function () { + $rbacUser = \ProcessMaker\Model\RbacUsers::factory()->create(); + return $rbacUser->USR_UID; + }, + 'ROL_UID' => function () { + $rbacRole = \ProcessMaker\Model\RbacRoles::factory()->create(); + return $rbacRole->ROL_UID; + } + ]; + } + +} diff --git a/database/factories/RouteFactory.php b/database/factories/RouteFactory.php index 18a3e2f57..30fc7d469 100644 --- a/database/factories/RouteFactory.php +++ b/database/factories/RouteFactory.php @@ -1,22 +1,35 @@ define(\ProcessMaker\Model\Route::class, function(Faker $faker) { - return [ - 'PRO_UID' => function() { - $process = factory(\ProcessMaker\Model\Process::class)->create(); - return $process->PRO_UID; - }, - 'TAS_UID' => function() { - $task = factory(\ProcessMaker\Model\Task::class)->create(); - return $task->TAS_UID; - }, - 'ROU_UID' => G::generateUniqueID(), - 'ROU_PARENT' => 0, - 'ROU_CASE' => 1, - 'ROU_TYPE' => 'SEQUENTIAL' - ]; -}); \ No newline at end of file +namespace Database\Factories; + +use App\Factories\Factory; +use G; +use Illuminate\Support\Str; + +class RouteFactory extends Factory +{ + + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + return [ + 'PRO_UID' => function () { + $process = \ProcessMaker\Model\Process::factory()->create(); + return $process->PRO_UID; + }, + 'TAS_UID' => function () { + $task = \ProcessMaker\Model\Task::factory()->create(); + return $task->TAS_UID; + }, + 'ROU_UID' => G::generateUniqueID(), + 'ROU_PARENT' => 0, + 'ROU_CASE' => 1, + 'ROU_TYPE' => 'SEQUENTIAL' + ]; + } + +} diff --git a/database/factories/StepFactory.php b/database/factories/StepFactory.php index c64c09395..61f5f2318 100644 --- a/database/factories/StepFactory.php +++ b/database/factories/StepFactory.php @@ -1,16 +1,31 @@ define(\ProcessMaker\Model\Step::class, function (Faker $faker) { - return [ - 'STEP_UID' => G::generateUniqueID(), - 'PRO_UID' => G::generateUniqueID(), - 'TAS_UID' => G::generateUniqueID(), - 'STEP_TYPE_OBJ' => 'DYNAFORM', - 'STEP_UID_OBJ' => '0', - 'STEP_CONDITION' => 'None', - 'STEP_POSITION' => 0, - 'STEP_MODE' => 'EDIT' - ]; -}); \ No newline at end of file +use App\Factories\Factory; +use G; +use Illuminate\Support\Str; + +class StepFactory extends Factory +{ + + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + return [ + 'STEP_UID' => G::generateUniqueID(), + 'PRO_UID' => G::generateUniqueID(), + 'TAS_UID' => G::generateUniqueID(), + 'STEP_TYPE_OBJ' => 'DYNAFORM', + 'STEP_UID_OBJ' => '0', + 'STEP_CONDITION' => 'None', + 'STEP_POSITION' => 0, + 'STEP_MODE' => 'EDIT' + ]; + } + +} diff --git a/database/factories/StepTriggerFactory.php b/database/factories/StepTriggerFactory.php index 6d63cdd80..d843591c1 100644 --- a/database/factories/StepTriggerFactory.php +++ b/database/factories/StepTriggerFactory.php @@ -1,18 +1,32 @@ define(\ProcessMaker\Model\StepTrigger::class, function (Faker $faker) { - return [ - 'STEP_UID' => $faker->regexify("/[a-zA-Z]{32}/"), - 'TAS_UID' => function() { - return factory(\ProcessMaker\Model\Task::class)->create()->TAS_UID; - }, - 'TRI_UID' => function() { - return factory(\ProcessMaker\Model\Triggers::class)->create()->TRI_UID; - }, - 'ST_TYPE' => 'BEFORE', - 'ST_CONDITION' => '', - 'ST_POSITION' => 1, - ]; -}); +use App\Factories\Factory; +use Illuminate\Support\Str; + +class StepTriggerFactory extends Factory +{ + + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + return [ + 'STEP_UID' => $this->faker->regexify("/[a-zA-Z]{32}/"), + 'TAS_UID' => function () { + return \ProcessMaker\Model\Task::factory()->create()->TAS_UID; + }, + 'TRI_UID' => function () { + return \ProcessMaker\Model\Triggers::factory()->create()->TRI_UID; + }, + 'ST_TYPE' => 'BEFORE', + 'ST_CONDITION' => '', + 'ST_POSITION' => 1, + ]; + } + +} diff --git a/database/factories/SubApplicationFactory.php b/database/factories/SubApplicationFactory.php index e21488705..d23b919a9 100644 --- a/database/factories/SubApplicationFactory.php +++ b/database/factories/SubApplicationFactory.php @@ -1,17 +1,32 @@ define(\ProcessMaker\Model\SubApplication::class, function (Faker $faker) { - return [ - 'APP_UID' => G::generateUniqueID(), - 'APP_PARENT' => G::generateUniqueID(), - 'DEL_INDEX_PARENT' => 2, - 'DEL_THREAD_PARENT' => 1, - 'SA_STATUS' => 'ACTIVE', - 'SA_VALUES_OUT' => 'a:0:{}', - 'SA_VALUES_IN' => 'a:0:{}', - 'SA_INIT_DATE' => $faker->dateTime(), - 'SA_FINISH_DATE' => $faker->dateTime(), - ]; -}); +use App\Factories\Factory; +use G; +use Illuminate\Support\Str; + +class SubApplicationFactory extends Factory +{ + + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + return [ + 'APP_UID' => G::generateUniqueID(), + 'APP_PARENT' => G::generateUniqueID(), + 'DEL_INDEX_PARENT' => 2, + 'DEL_THREAD_PARENT' => 1, + 'SA_STATUS' => 'ACTIVE', + 'SA_VALUES_OUT' => 'a:0:{}', + 'SA_VALUES_IN' => 'a:0:{}', + 'SA_INIT_DATE' => $this->faker->dateTime(), + 'SA_FINISH_DATE' => $this->faker->dateTime(), + ]; + } + +} diff --git a/database/factories/SubProcessFactory.php b/database/factories/SubProcessFactory.php index b98d4ee9b..061c487e3 100644 --- a/database/factories/SubProcessFactory.php +++ b/database/factories/SubProcessFactory.php @@ -1,18 +1,35 @@ define(\ProcessMaker\Model\SubProcess::class, function () { - return [ - 'SP_UID' => G::generateUniqueID(), - 'PRO_UID' => G::generateUniqueID(), - 'TAS_UID' => G::generateUniqueID(), - 'PRO_PARENT' => G::generateUniqueID(), - 'TAS_PARENT' => G::generateUniqueID(), - 'SP_TYPE' => '', - 'SP_SYNCHRONOUS' => 0, - 'SP_SYNCHRONOUS_TYPE' => '', - 'SP_SYNCHRONOUS_WAIT' => 0, - 'SP_VARIABLES_OUT' => '', - 'SP_VARIABLES_IN' => '', - 'SP_GRID_IN' => '' - ]; -}); +namespace Database\Factories; + +use App\Factories\Factory; +use G; +use Illuminate\Support\Str; + +class SubProcessFactory extends Factory +{ + + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + return [ + 'SP_UID' => G::generateUniqueID(), + 'PRO_UID' => G::generateUniqueID(), + 'TAS_UID' => G::generateUniqueID(), + 'PRO_PARENT' => G::generateUniqueID(), + 'TAS_PARENT' => G::generateUniqueID(), + 'SP_TYPE' => '', + 'SP_SYNCHRONOUS' => 0, + 'SP_SYNCHRONOUS_TYPE' => '', + 'SP_SYNCHRONOUS_WAIT' => 0, + 'SP_VARIABLES_OUT' => '', + 'SP_VARIABLES_IN' => '', + 'SP_GRID_IN' => '' + ]; + } + +} diff --git a/database/factories/TaskFactory.php b/database/factories/TaskFactory.php index caef8aba7..66b1eb700 100644 --- a/database/factories/TaskFactory.php +++ b/database/factories/TaskFactory.php @@ -1,90 +1,116 @@ define(\ProcessMaker\Model\Task::class, function(Faker $faker) { - $process = factory(\ProcessMaker\Model\Process::class)->create(); - return [ - 'PRO_UID' => $process->PRO_UID, - 'PRO_ID' => $process->PRO_ID, - 'TAS_UID' => G::generateUniqueID(), - 'TAS_TITLE' => $faker->sentence(2), - 'TAS_TYPE' => 'NORMAL', - 'TAS_TYPE_DAY' => 1, - 'TAS_DURATION' => 1, - 'TAS_ASSIGN_TYPE' => 'BALANCED', - 'TAS_DEF_TITLE' => $faker->sentence(2), - 'TAS_DEF_DESCRIPTION' => $faker->sentence(2), - 'TAS_ASSIGN_VARIABLE' => '@@SYS_NEXT_USER_TO_BE_ASSIGNED', - 'TAS_MI_INSTANCE_VARIABLE' => '@@SYS_VAR_TOTAL_INSTANCE', - 'TAS_MI_COMPLETE_VARIABLE' => '@@SYS_VAR_TOTAL_INSTANCES_COMPLETE', - 'TAS_ASSIGN_LOCATION' => 'FALSE', - 'TAS_ASSIGN_LOCATION_ADHOC' => 'FALSE', - 'TAS_TRANSFER_FLY' => 'FALSE', - 'TAS_LAST_ASSIGNED' => 0, - 'TAS_USER' => 0, - 'TAS_CAN_UPLOAD' => 'FALSE', - 'TAS_CAN_CANCEL' => 'FALSE', - 'TAS_OWNER_APP' => 'FALSE', - 'TAS_CAN_SEND_MESSAGE' => 'FALSE', - 'TAS_SEND_LAST_EMAIL' => 'FALSE', - 'TAS_SELFSERVICE_TIMEOUT' => 0, - ]; -}); +use App\Factories\Factory; +use G; +use Illuminate\Support\Str; -// Create a task with the foreign keys -$factory->state(\ProcessMaker\Model\Task::class, 'foreign_keys', function (Faker $faker) { - $process = factory(\ProcessMaker\Model\Process::class)->create(); - return [ - 'PRO_UID' => $process->PRO_UID, - 'PRO_ID' => $process->PRO_ID, - 'TAS_UID' => G::generateUniqueID(), - 'TAS_TITLE' => $faker->sentence(2), - 'TAS_TYPE' => 'NORMAL', - 'TAS_TYPE_DAY' => 1, - 'TAS_DURATION' => 1, - 'TAS_ASSIGN_TYPE' => 'BALANCED', - 'TAS_DEF_TITLE' => $faker->sentence(2), - 'TAS_DEF_DESCRIPTION' => $faker->sentence(2), - 'TAS_ASSIGN_VARIABLE' => '@@SYS_NEXT_USER_TO_BE_ASSIGNED', - 'TAS_MI_INSTANCE_VARIABLE' => '@@SYS_VAR_TOTAL_INSTANCE', - 'TAS_MI_COMPLETE_VARIABLE' => '@@SYS_VAR_TOTAL_INSTANCES_COMPLETE', - 'TAS_ASSIGN_LOCATION' => 'FALSE', - 'TAS_ASSIGN_LOCATION_ADHOC' => 'FALSE', - 'TAS_TRANSFER_FLY' => 'FALSE', - 'TAS_LAST_ASSIGNED' => 0, - 'TAS_USER' => 0, - 'TAS_CAN_UPLOAD' => 'FALSE', - 'TAS_CAN_CANCEL' => 'FALSE', - 'TAS_OWNER_APP' => 'FALSE', - 'TAS_CAN_SEND_MESSAGE' => 'FALSE', - 'TAS_SEND_LAST_EMAIL' => 'FALSE', - 'TAS_SELFSERVICE_TIMEOUT' => 0, - ]; -}); +class TaskFactory extends Factory +{ -// Create a task related with the self-service timeout execution -$factory->state(\ProcessMaker\Model\Task::class, 'sef_service_timeout', function (Faker $faker) { - $timeUnit = $faker->randomElement(['MINUTES', 'HOURS', 'DAYS']); - $execution = $faker->randomElement(['EVERY_TIME', 'ONCE']); - return [ - 'TAS_UID' => G::generateUniqueID(), - 'TAS_ID' => $faker->unique()->numberBetween(1, 200000), - 'TAS_TITLE' => $faker->sentence(2), - 'TAS_TYPE' => 'NORMAL', - 'TAS_TYPE_DAY' => 1, - 'TAS_DURATION' => 1, - 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', - 'TAS_ASSIGN_VARIABLE' => '@@SYS_NEXT_USER_TO_BE_ASSIGNED', - 'TAS_SELFSERVICE_TIMEOUT' => 1, - 'TAS_SELFSERVICE_TIME' => $faker->unique()->numberBetween(1, 24), - 'TAS_SELFSERVICE_TIME_UNIT' => $timeUnit, - 'TAS_SELFSERVICE_TRIGGER_UID' => function() { - return $trigger = factory(\ProcessMaker\Model\Triggers::class)->create()->TRI_UID; - }, - 'TAS_SELFSERVICE_EXECUTION' => $execution, - ]; -}); + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + $process = \ProcessMaker\Model\Process::factory()->create(); + return [ + 'PRO_UID' => $process->PRO_UID, + 'PRO_ID' => $process->PRO_ID, + 'TAS_UID' => G::generateUniqueID(), + 'TAS_TITLE' => $this->faker->sentence(2), + 'TAS_TYPE' => 'NORMAL', + 'TAS_TYPE_DAY' => 1, + 'TAS_DURATION' => 1, + 'TAS_ASSIGN_TYPE' => 'BALANCED', + 'TAS_DEF_TITLE' => $this->faker->sentence(2), + 'TAS_DEF_DESCRIPTION' => $this->faker->sentence(2), + 'TAS_ASSIGN_VARIABLE' => '@@SYS_NEXT_USER_TO_BE_ASSIGNED', + 'TAS_MI_INSTANCE_VARIABLE' => '@@SYS_VAR_TOTAL_INSTANCE', + 'TAS_MI_COMPLETE_VARIABLE' => '@@SYS_VAR_TOTAL_INSTANCES_COMPLETE', + 'TAS_ASSIGN_LOCATION' => 'FALSE', + 'TAS_ASSIGN_LOCATION_ADHOC' => 'FALSE', + 'TAS_TRANSFER_FLY' => 'FALSE', + 'TAS_LAST_ASSIGNED' => 0, + 'TAS_USER' => 0, + 'TAS_CAN_UPLOAD' => 'FALSE', + 'TAS_CAN_CANCEL' => 'FALSE', + 'TAS_OWNER_APP' => 'FALSE', + 'TAS_CAN_SEND_MESSAGE' => 'FALSE', + 'TAS_SEND_LAST_EMAIL' => 'FALSE', + 'TAS_SELFSERVICE_TIMEOUT' => 0, + ]; + } + + /** + * Create a task with the foreign keys + * @return type + */ + public function foreign_keys() + { + $state = function (array $attributes) { + $process = \ProcessMaker\Model\Process::factory()->create(); + return [ + 'PRO_UID' => $process->PRO_UID, + 'PRO_ID' => $process->PRO_ID, + 'TAS_UID' => G::generateUniqueID(), + 'TAS_TITLE' => $this->faker->sentence(2), + 'TAS_TYPE' => 'NORMAL', + 'TAS_TYPE_DAY' => 1, + 'TAS_DURATION' => 1, + 'TAS_ASSIGN_TYPE' => 'BALANCED', + 'TAS_DEF_TITLE' => $this->faker->sentence(2), + 'TAS_DEF_DESCRIPTION' => $this->faker->sentence(2), + 'TAS_ASSIGN_VARIABLE' => '@@SYS_NEXT_USER_TO_BE_ASSIGNED', + 'TAS_MI_INSTANCE_VARIABLE' => '@@SYS_VAR_TOTAL_INSTANCE', + 'TAS_MI_COMPLETE_VARIABLE' => '@@SYS_VAR_TOTAL_INSTANCES_COMPLETE', + 'TAS_ASSIGN_LOCATION' => 'FALSE', + 'TAS_ASSIGN_LOCATION_ADHOC' => 'FALSE', + 'TAS_TRANSFER_FLY' => 'FALSE', + 'TAS_LAST_ASSIGNED' => 0, + 'TAS_USER' => 0, + 'TAS_CAN_UPLOAD' => 'FALSE', + 'TAS_CAN_CANCEL' => 'FALSE', + 'TAS_OWNER_APP' => 'FALSE', + 'TAS_CAN_SEND_MESSAGE' => 'FALSE', + 'TAS_SEND_LAST_EMAIL' => 'FALSE', + 'TAS_SELFSERVICE_TIMEOUT' => 0, + ]; + }; + return $this->state($state); + } + + /** + * Create a task related with the self-service timeout execution + * @return type + */ + public function sef_service_timeout() + { + $state = function (array $attributes) { + $timeUnit = $this->faker->randomElement(['MINUTES', 'HOURS', 'DAYS']); + $execution = $this->faker->randomElement(['EVERY_TIME', 'ONCE']); + return [ + 'TAS_UID' => G::generateUniqueID(), + 'TAS_ID' => $this->faker->unique()->numberBetween(1, 200000), + 'TAS_TITLE' => $this->faker->sentence(2), + 'TAS_TYPE' => 'NORMAL', + 'TAS_TYPE_DAY' => 1, + 'TAS_DURATION' => 1, + 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', + 'TAS_ASSIGN_VARIABLE' => '@@SYS_NEXT_USER_TO_BE_ASSIGNED', + 'TAS_SELFSERVICE_TIMEOUT' => 1, + 'TAS_SELFSERVICE_TIME' => $this->faker->unique()->numberBetween(1, 24), + 'TAS_SELFSERVICE_TIME_UNIT' => $timeUnit, + 'TAS_SELFSERVICE_TRIGGER_UID' => function () { + return $trigger = \ProcessMaker\Model\Triggers::factory()->create()->TRI_UID; + }, + 'TAS_SELFSERVICE_EXECUTION' => $execution, + ]; + }; + return $this->state($state); + } + +} diff --git a/database/factories/TaskSchedulerFactory.php b/database/factories/TaskSchedulerFactory.php index 1dd54c754..8fc58744e 100644 --- a/database/factories/TaskSchedulerFactory.php +++ b/database/factories/TaskSchedulerFactory.php @@ -1,27 +1,38 @@ define(\ProcessMaker\Model\TaskScheduler::class, function (Faker $faker) { - return [ - 'id' => $faker->unique()->numberBetween(5000), - 'title' => $faker->title, - 'startingTime' => $faker->dateTime(), - 'endingTime' => $faker->dateTime(), - 'everyOn' => "", - 'interval' => "", - 'description' => "", - 'expression' => "", - 'body' => "", - 'type' => "", - 'category' => "emails_notifications", //emails_notifications, case_actions, plugins, processmaker_sync - 'system' => "", - 'timezone' => "", - 'enable' => "", - 'creation_date' => $faker->dateTime(), - 'last_update' => $faker->dateTime() - ]; -}); +use App\Factories\Factory; +use Illuminate\Support\Str; + +class TaskSchedulerFactory extends Factory +{ + + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + return [ + 'id' => $this->faker->unique()->numberBetween(5000), + 'title' => $this->faker->title, + 'startingTime' => $this->faker->dateTime(), + 'endingTime' => $this->faker->dateTime(), + 'everyOn' => "", + 'interval' => "", + 'description' => "", + 'expression' => "", + 'body' => "", + 'type' => "", + 'category' => "emails_notifications", //emails_notifications, case_actions, plugins, processmaker_sync + 'system' => "", + 'timezone' => "", + 'enable' => "", + 'creation_date' => $this->faker->dateTime(), + 'last_update' => $this->faker->dateTime() + ]; + } + +} diff --git a/database/factories/TaskUserFactory.php b/database/factories/TaskUserFactory.php index 2b7c65049..2da94713a 100644 --- a/database/factories/TaskUserFactory.php +++ b/database/factories/TaskUserFactory.php @@ -1,70 +1,106 @@ define(\ProcessMaker\Model\TaskUser::class, function(Faker $faker) { - return [ - 'TAS_UID' => function() { - $task = factory(\ProcessMaker\Model\Task::class)->create(); - return $task->TAS_UID; - }, - 'TU_TYPE' => 1, - 'TU_RELATION' => 1 - ]; -}); +use App\Factories\Factory; +use Illuminate\Support\Str; -// Create a delegation with the foreign keys -$factory->state(\ProcessMaker\Model\TaskUser::class, 'foreign_keys', function (Faker $faker) { - $user = factory(\ProcessMaker\Model\User::class)->create(); - $task = factory(\ProcessMaker\Model\Task::class)->create(); - return [ - 'TAS_UID' => $task->TAS_UID, - 'USR_UID' => $user->USR_UID, - 'TU_TYPE' => 1, - 'TU_RELATION' => 1 - ]; -}); +class TaskUserFactory extends Factory +{ -$factory->state(\ProcessMaker\Model\TaskUser::class, 'normal_assigment_user', function (Faker $faker) { - $user = factory(\ProcessMaker\Model\User::class)->create(); - $task = factory(\ProcessMaker\Model\Task::class)->create(); - return [ - 'TAS_UID' => $task->TAS_UID, - 'USR_UID' => $user->USR_UID, - 'TU_RELATION' => 1, - 'TU_TYPE' => 1, - ]; -}); + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + return [ + 'TAS_UID' => function () { + $task = \ProcessMaker\Model\Task::factory()->create(); + return $task->TAS_UID; + }, + 'TU_TYPE' => 1, + 'TU_RELATION' => 1 + ]; + } -$factory->state(\ProcessMaker\Model\TaskUser::class, 'normal_assigment_group', function (Faker $faker) { - $group = factory(\ProcessMaker\Model\Groupwf::class)->create(); - $task = factory(\ProcessMaker\Model\Task::class)->create(); - return [ - 'TAS_UID' => $task->TAS_UID, - 'USR_UID' => $group->GRP_UID, - 'TU_RELATION' => 2, - 'TU_TYPE' => 1, - ]; -}); + /** + * Create a delegation with the foreign keys. + */ + public function foreign_keys() + { + $state = function (array $attributes) { + $user = \ProcessMaker\Model\User::factory()->create(); + $task = \ProcessMaker\Model\Task::factory()->create(); + return [ + 'TAS_UID' => $task->TAS_UID, + 'USR_UID' => $user->USR_UID, + 'TU_TYPE' => 1, + 'TU_RELATION' => 1 + ]; + }; + return $this->state($state); + } -$factory->state(\ProcessMaker\Model\TaskUser::class, 'adhoc_assigment_user', function (Faker $faker) { - $user = factory(\ProcessMaker\Model\User::class)->create(); - $task = factory(\ProcessMaker\Model\Task::class)->create(); - return [ - 'TAS_UID' => $task->TAS_UID, - 'USR_UID' => $user->USR_UID, - 'TU_RELATION' => 1, - 'TU_TYPE' => 2, - ]; -}); + public function normal_assigment_user() + { + $state = function (array $attributes) { + $user = \ProcessMaker\Model\User::factory()->create(); + $task = \ProcessMaker\Model\Task::factory()->create(); + return [ + 'TAS_UID' => $task->TAS_UID, + 'USR_UID' => $user->USR_UID, + 'TU_RELATION' => 1, + 'TU_TYPE' => 1, + ]; + }; + return $this->state($state); + } -$factory->state(\ProcessMaker\Model\TaskUser::class, 'adhoc_assigment_group', function (Faker $faker) { - $group = factory(\ProcessMaker\Model\Groupwf::class)->create(); - $task = factory(\ProcessMaker\Model\Task::class)->create(); - return [ - 'TAS_UID' => $task->TAS_UID, - 'USR_UID' => $group->GRP_UID, - 'TU_RELATION' => 2, - 'TU_TYPE' => 2, - ]; -}); \ No newline at end of file + public function normal_assigment_group() + { + $state = function (array $attributes) { + $group = \ProcessMaker\Model\Groupwf::factory()->create(); + $task = \ProcessMaker\Model\Task::factory()->create(); + return [ + 'TAS_UID' => $task->TAS_UID, + 'USR_UID' => $group->GRP_UID, + 'TU_RELATION' => 2, + 'TU_TYPE' => 1, + ]; + }; + return $this->state($state); + } + + public function adhoc_assigment_user() + { + $state = function (array $attributes) { + $user = \ProcessMaker\Model\User::factory()->create(); + $task = \ProcessMaker\Model\Task::factory()->create(); + return [ + 'TAS_UID' => $task->TAS_UID, + 'USR_UID' => $user->USR_UID, + 'TU_RELATION' => 1, + 'TU_TYPE' => 2, + ]; + }; + return $this->state($state); + } + + public function adhoc_assigment_group() + { + $state = function (array $attributes) { + $group = \ProcessMaker\Model\Groupwf::factory()->create(); + $task = \ProcessMaker\Model\Task::factory()->create(); + return [ + 'TAS_UID' => $task->TAS_UID, + 'USR_UID' => $group->GRP_UID, + 'TU_RELATION' => 2, + 'TU_TYPE' => 2, + ]; + }; + return $this->state($state); + } + +} diff --git a/database/factories/TriggersFactory.php b/database/factories/TriggersFactory.php index 11117f083..7850769eb 100644 --- a/database/factories/TriggersFactory.php +++ b/database/factories/TriggersFactory.php @@ -1,18 +1,32 @@ define(Triggers::class, function (Faker $faker) { - return [ - 'TRI_UID' => $faker->regexify("/[a-zA-Z]{32}/"), - 'TRI_TITLE' => $faker->sentence(5), - 'TRI_DESCRIPTION' => $faker->text, - 'PRO_UID' => function() { - return factory(\ProcessMaker\Model\Process::class)->create()->PRO_UID; - }, - 'TRI_TYPE' => 'SCRIPT', - 'TRI_WEBBOT' => '$var = 1;', - 'TRI_PARAM' => '', - ]; -}); +class TriggersFactory extends Factory +{ + + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + return [ + 'TRI_UID' => $this->faker->regexify("/[a-zA-Z]{32}/"), + 'TRI_TITLE' => $this->faker->sentence(5), + 'TRI_DESCRIPTION' => $this->faker->text, + 'PRO_UID' => function () { + return \ProcessMaker\Model\Process::factory()->create()->PRO_UID; + }, + 'TRI_TYPE' => 'SCRIPT', + 'TRI_WEBBOT' => '$var = 1;', + 'TRI_PARAM' => '', + ]; + } + +} diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index a5dc9278f..1974fd78a 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -1,21 +1,36 @@ define(\ProcessMaker\Model\User::class, function (Faker $faker) { - return [ - 'USR_UID' => G::generateUniqueID(), - 'USR_USERNAME' => $faker->unique()->userName, - 'USR_PASSWORD' => $faker->password, - 'USR_FIRSTNAME' => $faker->firstName, - 'USR_LASTNAME' => $faker->lastName, - 'USR_EMAIL' => $faker->unique()->email, - '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) - ]; -}); \ No newline at end of file +use App\Factories\Factory; +use G; +use Illuminate\Support\Str; + +class UserFactory extends Factory +{ + + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + return [ + 'USR_UID' => G::generateUniqueID(), + 'USR_USERNAME' => $this->faker->unique()->userName, + 'USR_PASSWORD' => $this->faker->password, + 'USR_FIRSTNAME' => $this->faker->firstName, + 'USR_LASTNAME' => $this->faker->lastName, + 'USR_EMAIL' => $this->faker->unique()->email, + 'USR_DUE_DATE' => new \Carbon\Carbon(2030, 1, 1), + 'USR_STATUS' => 'ACTIVE', + 'USR_ROLE' => $this->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) + ]; + } + +} diff --git a/database/factories/UserReportingFactory.php b/database/factories/UserReportingFactory.php index 46da8d3fd..3927d7690 100644 --- a/database/factories/UserReportingFactory.php +++ b/database/factories/UserReportingFactory.php @@ -1,13 +1,28 @@ define(\ProcessMaker\Model\UserReporting::class, function (Faker $faker) { - return [ - 'USR_UID' => G::generateUniqueID(), - 'TAS_UID' => G::generateUniqueID(), - 'PRO_UID' => G::generateUniqueID(), - 'MONTH' => 12, - 'YEAR' => 2020, - ]; -}); +use App\Factories\Factory; +use G; +use Illuminate\Support\Str; + +class UserReportingFactory extends Factory +{ + + /** + * Define the model's default state. + * + * @return array + */ + public function definition() + { + return [ + 'USR_UID' => G::generateUniqueID(), + 'TAS_UID' => G::generateUniqueID(), + 'PRO_UID' => G::generateUniqueID(), + 'MONTH' => 12, + 'YEAR' => 2020, + ]; + } + +} diff --git a/gulliver/bin/tasks/pakeTest.php b/gulliver/bin/tasks/pakeTest.php deleted file mode 100644 index d901ec833..000000000 --- a/gulliver/bin/tasks/pakeTest.php +++ /dev/null @@ -1,131 +0,0 @@ -. - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ - - - -pake_desc('launch unit tests'); -pake_task('test-unit', 'project_exists'); - -pake_desc('launch functional tests for an application'); -pake_task('test-functional', 'project_exists'); - -pake_desc('launch all tests'); -pake_task('test-all', 'project_exists'); - - /** - * Function run_test_all - * access public - */ - -function run_test_all($task, $args) -{ - require_once(sfConfig::get('sf_symfony_lib_dir').'/lime/lime.php'); - - $h = new lime_harness(new lime_output_color()); - $h->base_dir = sfConfig::get('sf_test_dir'); - - // register all tests - $finder = pakeFinder::type('file')->ignore_version_control()->follow_link()->name('*Test.php'); - $h->register($finder->in($h->base_dir)); - - $h->run(); -} - -function run_test_functional($task, $args) -{ - if (!count($args)) - { - throw new Exception('You must provide the app to test.'); - } - - $app = $args[0]; - - if (!is_dir(sfConfig::get('sf_app_dir').DIRECTORY_SEPARATOR.$app)) - { - throw new Exception(sprintf('The app "%s" does not exist.', $app)); - } - - if (isset($args[1])) - { - foreach (array_splice($args, 1) as $path) - { - $files = pakeFinder::type('file')->ignore_version_control()->follow_link()->name(basename($path).'Test.php')->in(sfConfig::get('sf_test_dir').DIRECTORY_SEPARATOR.'functional'.DIRECTORY_SEPARATOR.$app.DIRECTORY_SEPARATOR.dirname($path)); - foreach ($files as $file) - { - include($file); - } - } - } - else - { - require_once(sfConfig::get('sf_symfony_lib_dir').'/lime/lime.php'); - - $h = new lime_harness(new lime_output_color()); - $h->base_dir = sfConfig::get('sf_test_dir').'/functional/'.$app; - - // register functional tests - $finder = pakeFinder::type('file')->ignore_version_control()->follow_link()->name('*Test.php'); - $h->register($finder->in($h->base_dir)); - - $h->run(); - } -} - -function run_test_unit($task, $args) -{ - $environment = isset ( $arg[1] ) ? $arg[1] : G_TEST_ENV; - printf("start test in %s environment\n", pakeColor::colorize( $environment, 'INFO')); - define ( 'G_ENVIRONMENT', $environment ); - - if (isset($args[0])) - { - foreach ($args as $path) - { - $pathUnit = PATH_CORE . 'test' . PATH_SEP . 'unit' . PATH_SEP . dirname($path); - $files = pakeFinder::type('file')->ignore_version_control()->follow_link()->name(basename($path).'Test.php')->in( $pathUnit ); - foreach ($files as $file) - { - $fName = str_replace ( PATH_CORE . 'test' . PATH_SEP . 'unit' . PATH_SEP , '', $file ); - printf("\ntesting %s \n", pakeColor::colorize( $fName, 'INFO')); - include($file); - } - } - } - else - { - - require_once( PATH_THIRDPARTY . '/lime/lime.php'); - $h = new lime_harness(new lime_output_color()); - $h->base_dir = $pathUnit = PATH_CORE . 'test' . PATH_SEP . 'unit'; -// $h->base_dir = $pathUnit = PATH_CORE . 'test' . PATH_SEP . 'unit' . PATH_SEP . "processmaker"; - - // register unit tests - $finder = pakeFinder::type('file')->ignore_version_control()->follow_link()->name('*Test.php'); - $h->register($finder->in($h->base_dir)); - - $h->run(); - } -} diff --git a/gulliver/bin/tasks/templates/sysGeneric.php.tpl b/gulliver/bin/tasks/templates/sysGeneric.php.tpl index f89aba6fe..36da20d20 100644 --- a/gulliver/bin/tasks/templates/sysGeneric.php.tpl +++ b/gulliver/bin/tasks/templates/sysGeneric.php.tpl @@ -65,7 +65,6 @@ $docuroot = explode ( PATH_SEP , $_SERVER['DOCUMENT_ROOT'] ); $virtualURITable['/(sys*)'] = FALSE; $virtualURITable['/errors/(*)'] = PATH_GULLIVER_HOME . 'methods/errors/'; $virtualURITable['/controls/(*)'] = PATH_GULLIVER_HOME . 'methods/controls/'; - $virtualURITable['/html2ps_pdf/(*)'] = PATH_THIRDPARTY . 'html2ps_pdf/'; $virtualURITable['/Krumo/(*)'] = PATH_THIRDPARTY . 'krumo/'; $virtualURITable['/codepress/(*)'] = PATH_THIRDPARTY . 'codepress/'; diff --git a/gulliver/system/class.bootstrap.php b/gulliver/system/class.bootstrap.php index d0a6dc85a..b1af1edaa 100644 --- a/gulliver/system/class.bootstrap.php +++ b/gulliver/system/class.bootstrap.php @@ -510,7 +510,7 @@ class Bootstrap * @param array list plugins active * @return void */ - public static function LoadTranslationPlugins($lang = SYS_LANG, $listPluginsActive) + public static function LoadTranslationPlugins($lang = SYS_LANG, $listPluginsActive = []) { if (! (is_array($listPluginsActive))) { return null; diff --git a/gulliver/system/class.g.php b/gulliver/system/class.g.php index 05653aee3..77c8c493d 100644 --- a/gulliver/system/class.g.php +++ b/gulliver/system/class.g.php @@ -5616,23 +5616,28 @@ class G } } + $pathSep = getConstant('PATH_SEP'); + $pathSkinEngine = getConstant('PATH_SKIN_ENGINE'); + $pathSkins = getConstant('PATH_SKINS'); + $pathCustomSkins = getConstant('PATH_CUSTOM_SKINS'); + $arrayAux = explode("?", $strAux); $fileTemplate = $arrayAux[0]; - if (file_exists(PATH_SKIN_ENGINE . "base" . PATH_SEP . $fileTemplate)) { - $path = PATH_SKIN_ENGINE . "base" . PATH_SEP; + if (file_exists($pathSkinEngine . "base" . $pathSep . $fileTemplate)) { + $path = $pathSkinEngine . "base" . $pathSep; } - if (file_exists(PATH_SKIN_ENGINE . $skin . PATH_SEP . $fileTemplate)) { - $path = PATH_SKIN_ENGINE . $skin . PATH_SEP; + if (file_exists($pathSkinEngine . $skin . $pathSep . $fileTemplate)) { + $path = $pathSkinEngine . $skin . $pathSep; } - if (file_exists(PATH_SKINS . $skin . PATH_SEP . $fileTemplate)) { - $path = PATH_SKINS . $skin . PATH_SEP; + if (file_exists($pathSkins . $skin . $pathSep . $fileTemplate)) { + $path = $pathSkins . $skin . $pathSep; } - if (file_exists(PATH_CUSTOM_SKINS . $skin . PATH_SEP . $fileTemplate)) { - $path = PATH_CUSTOM_SKINS . $skin . PATH_SEP; + if (file_exists($pathCustomSkins . $skin . $pathSep . $fileTemplate)) { + $path = $pathCustomSkins . $skin . $pathSep; } } } @@ -5786,7 +5791,7 @@ class G return $from; } - public function getRealExtension($extensionInpDoc) + public static function getRealExtension($extensionInpDoc) { $aux = explode('.', strtolower($extensionInpDoc)); return isset($aux[1]) ? $aux[1] : ''; @@ -5976,7 +5981,7 @@ class G if ($browser == null || $version == null) { $info = G::getBrowser(); $browser = $info['name']; - $version = $info['version']; + $version = intval($info['version']); } if ( diff --git a/gulliver/system/class.headPublisher.php b/gulliver/system/class.headPublisher.php index 152b278c4..03520af98 100644 --- a/gulliver/system/class.headPublisher.php +++ b/gulliver/system/class.headPublisher.php @@ -1,29 +1,4 @@ . - * - * For more information, contact Colosa Inc, 2566 Le Jeune Rd., - * Coral Gables, FL, 33134, USA, or email info@colosa.com. - * - */ use ProcessMaker\Plugins\PluginRegistry; use ProcessMaker\Core\System; @@ -31,8 +6,6 @@ use ProcessMaker\Core\System; /** * Class headPublisher * - * @author David S. Callizaya S. - * @package gulliver.system * @access public */ class headPublisher @@ -417,7 +390,13 @@ class headPublisher return $script; } - public function getExtJsVariablesScript() + /** + * Build javascript section with declaration of variables + * + * @param string $declarationKeyword + * @return string + */ + public function getExtJsVariablesScript($declarationKeyword = 'var') { $script = ''; if (count($this->extVariable) > 0) { @@ -427,15 +406,7 @@ class headPublisher $value = $val['value']; $variablesValues = G::json_encode($value); $variablesValues = $this->stripCodeQuotes($variablesValues); - // var_dump($variablesValues); - // echo "
"; - $script .= " var $name = " . $variablesValues . ";\n"; - /* - if ($val ['type'] == 'number') - $script .= " var $name = $value;\n"; - else - $script .= " var $name = '$value';\n"; - */ + $script .= " $declarationKeyword $name = " . $variablesValues . ";\n"; } $script .= "\n"; } diff --git a/gulliver/system/class.pagedTable.php b/gulliver/system/class.pagedTable.php index 4df9fd8a7..b07d9db80 100644 --- a/gulliver/system/class.pagedTable.php +++ b/gulliver/system/class.pagedTable.php @@ -339,7 +339,7 @@ class pagedTable // Config attributes from XMLFORM file $myAttributes = get_class_vars(get_class($this)); foreach ($this->xmlForm->xmlform->tree->attribute as $atrib => $value) { - if (array_key_exists($atrib, $myAttributes)) { + if (is_array($myAttributes) && array_key_exists($atrib, $myAttributes)) { eval('settype($value,gettype($this->' . $atrib . '));'); if ($value !== '') { eval('$this->' . $atrib . '=$value;'); diff --git a/gulliver/system/class.xmlform.php b/gulliver/system/class.xmlform.php index ea2519b19..1ba801356 100644 --- a/gulliver/system/class.xmlform.php +++ b/gulliver/system/class.xmlform.php @@ -425,14 +425,7 @@ class XmlFormField $fields = []; if (isset($this->formula)) { preg_match_all("/\b[a-zA-Z][a-zA-Z_0-9]*\b/", $this->formula, $matches, PREG_PATTERN_ORDER); - /* if ($this->formula!=''){ - var_dump($this->formula); - var_dump($matches); - var_dump(array_keys($this->owner->fields)); - die; - }*/ foreach ($matches[0] as $field) { - //if (array_key_exists( $this->owner->fields, $field )) $fields[] = $field; } } diff --git a/phpunit.xml b/phpunit.xml index 433c8e8ae..771dbfc25 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -7,7 +7,6 @@ convertWarningsToExceptions="false" processIsolation="false" stopOnFailure="false" - syntaxCheck="true" bootstrap="tests/bootstrap.php" stderr="true" > diff --git a/rbac/engine/classes/model/Roles.php b/rbac/engine/classes/model/Roles.php index 4ec3e6a34..e1912fb4b 100644 --- a/rbac/engine/classes/model/Roles.php +++ b/rbac/engine/classes/model/Roles.php @@ -796,7 +796,7 @@ class Roles extends BaseRoles $criteria->add(PermissionsPeer::PER_CODE, '%' . $filter . '%', Criteria::LIKE); } - if (!is_null($status) && ($status == 1 || $status == 0)) { + if (!is_null($status) && ($status === 1 || $status === 0)) { $criteria->add(PermissionsPeer::PER_STATUS, $status); } diff --git a/resources/views/admin/settings/customCasesList.blade.php b/resources/views/admin/settings/customCasesList.blade.php index 8865ba9d3..457097066 100644 --- a/resources/views/admin/settings/customCasesList.blade.php +++ b/resources/views/admin/settings/customCasesList.blade.php @@ -10,7 +10,7 @@ - {{ ScriptVariables::render() }} + {!! $oHeadPublisher->getExtJsVariablesScript('') !!}
diff --git a/tests/Feature/DBQueryTest.php b/tests/Feature/DBQueryTest.php index a1bcc7d6e..af614e54b 100644 --- a/tests/Feature/DBQueryTest.php +++ b/tests/Feature/DBQueryTest.php @@ -2,10 +2,10 @@ namespace Tests\Feature; -use Illuminate\Foundation\Testing\DatabaseTransactions; -use Illuminate\Support\Facades\DB; use ProcessMaker\Model\DbSource; use ProcessMaker\Model\Process; +use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Support\Facades\DB; use Tests\TestCase; class DBQueryTest extends TestCase @@ -16,7 +16,7 @@ class DBQueryTest extends TestCase /** * Sets up the unit tests. */ - protected function setUp() + protected function setUp(): void { parent::setUp(); } @@ -35,7 +35,9 @@ class DBQueryTest extends TestCase 'USR_UID' => '00000000000000000000000000000001', 'USR_USERNAME' => 'admin' ]; - $this->assertArraySubset($expected, $results[1]); + foreach ($expected as $key => $value) { + $this->assertEquals($value, $results[1][$key]); + } } /** @@ -56,9 +58,9 @@ class DBQueryTest extends TestCase { // Our test external database is created in our tests/bootstrap.php file // We'll use our factories to create our process and database - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); // Let's create an external DB to ourselves - $externalDB = factory(DbSource::class)->create([ + $externalDB = DbSource::factory()->create([ 'DBS_SERVER' => config('database.connections.testexternal.host'), 'DBS_PORT' => '3306', 'DBS_USERNAME' => config('database.connections.testexternal.username'), @@ -90,9 +92,9 @@ class DBQueryTest extends TestCase } // Our test external database is created in our tests/bootstrap.php file // We'll use our factories to create our process and database - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); // Let's create an external DB to ourselves - $externalDB = factory(DbSource::class)->create([ + $externalDB = DbSource::factory()->create([ 'DBS_SERVER' => env('MSSQL_HOST'), 'DBS_PORT' => env('MSSQL_PORT'), 'DBS_TYPE' => 'mssql', diff --git a/tests/Performance/workflow/engine/src/ProcessMaker/Model/DelegationTest.php b/tests/Performance/workflow/engine/src/ProcessMaker/Model/DelegationTest.php index a0b5e7e65..637529a12 100644 --- a/tests/Performance/workflow/engine/src/ProcessMaker/Model/DelegationTest.php +++ b/tests/Performance/workflow/engine/src/ProcessMaker/Model/DelegationTest.php @@ -1,4 +1,5 @@ markTestSkipped('Test related to the performance are disabled for this server configuration'); @@ -48,24 +49,24 @@ class DelegationTest extends TestCase //Define the maximum time of execution $maximumTime = $this->maximumExecutionTime; //Create process - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); //Create user - $user = factory(User::class)->create(); + $user = User::factory()->create(); //Create a task self service - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID ]); //Assign a user in the task - factory(TaskUser::class)->create([ + TaskUser::factory()->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([ + Delegation::factory($total)->create([ 'TAS_ID' => $task->TAS_ID, 'DEL_THREAD_STATUS' => 'OPEN', 'USR_ID' => 0, @@ -93,31 +94,31 @@ class DelegationTest extends TestCase //Define the maximum time of execution $maximumTime = $this->maximumExecutionTime; //Create process - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); //Create a case - $application = factory(Application::class)->create(); + $application = Application::factory()->create(); //Create user - $user = factory(User::class)->create(); + $user = User::factory()->create(); //Create a task self service value based - $task = factory(Task::class)->create([ + $task = Task::factory()->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([ + $appSelfValue = AppAssignSelfServiceValue::factory()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'DEL_INDEX' => 2, 'TAS_ID' => $task->TAS_ID ]); - factory(AppAssignSelfServiceValueGroup::class)->create([ + AppAssignSelfServiceValueGroup::factory()->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([ + Delegation::factory($total)->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'DEL_INDEX' => $appSelfValue->DEL_INDEX, 'TAS_ID' => $task->TAS_ID, @@ -146,50 +147,50 @@ class DelegationTest extends TestCase //Define the maximum time of execution $maximumTime = $this->maximumExecutionTime; //Create process - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); //Create a case - $application = factory(Application::class)->create(); + $application = Application::factory()->create(); //Create user - $user = factory(User::class)->create(); + $user = User::factory()->create(); //Create a task self service - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID ]); //Assign a user in the task - factory(TaskUser::class)->create([ + TaskUser::factory()->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([ + Delegation::factory($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([ + $task1 = Task::factory()->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([ + $appSelfValue = AppAssignSelfServiceValue::factory()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'DEL_INDEX' => 2, 'TAS_ID' => $task1->TAS_ID ]); - factory(AppAssignSelfServiceValueGroup::class)->create([ + AppAssignSelfServiceValueGroup::factory()->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([ + Delegation::factory($total / 2)->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'DEL_INDEX' => $appSelfValue->DEL_INDEX, 'TAS_ID' => $task->TAS_ID, @@ -218,32 +219,32 @@ class DelegationTest extends TestCase //Define the maximum time of execution $maximumTime = $this->maximumExecutionTime; //Create process - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); //Create group - $group = factory(Groupwf::class)->create(); + $group = Groupwf::factory()->create(); //Create user - $user = factory(User::class)->create(); + $user = User::factory()->create(); //Assign a user in the group - factory(GroupUser::class)->create([ + GroupUser::factory()->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([ + $task = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID ]); //Assign a user in the task - factory(TaskUser::class)->create([ + TaskUser::factory()->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([ + Delegation::factory($total)->create([ 'TAS_ID' => $task->TAS_ID, 'DEL_THREAD_STATUS' => 'OPEN', 'USR_ID' => 0, @@ -271,44 +272,44 @@ class DelegationTest extends TestCase //Define the maximum time of execution $maximumTime = $this->maximumExecutionTime; //Create process - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); //Create a task self service value based - $task = factory(Task::class)->create([ + $task = Task::factory()->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(); + $application = Application::factory()->create(); //Create group - $group = factory(Groupwf::class)->create(); + $group = Groupwf::factory()->create(); //Create user - $user = factory(User::class)->create([ + $user = User::factory()->create([ 'USR_USERNAME' => 'gary', 'USR_LASTNAME' => 'Gary', 'USR_FIRSTNAME' => 'Bailey', ]); //Assign a user in the group - factory(GroupUser::class)->create([ + GroupUser::factory()->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([ + $appSelfValue = AppAssignSelfServiceValue::factory()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'APP_UID' => $application->APP_UID, 'DEL_INDEX' => 2, 'TAS_ID' => $task->TAS_ID ]); - factory(AppAssignSelfServiceValueGroup::class)->create([ + AppAssignSelfServiceValueGroup::factory()->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([ + Delegation::factory($total)->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'DEL_INDEX' => 2, 'TAS_ID' => $task->TAS_ID, @@ -337,89 +338,89 @@ class DelegationTest extends TestCase //Define the maximum time of execution $maximumTime = $this->maximumExecutionTime; //Create process - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); //Create group - $group = factory(Groupwf::class)->create(); + $group = Groupwf::factory()->create(); //Create user - $user = factory(User::class)->create(); + $user = User::factory()->create(); //Assign a user in the group - factory(GroupUser::class)->create([ + GroupUser::factory()->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([ + $task1 = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID ]); //Assign a user in the task1 - factory(TaskUser::class)->create([ + TaskUser::factory()->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([ + $task2 = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID ]); //Assign a user in the task2 - factory(TaskUser::class)->create([ + TaskUser::factory()->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([ + $task3 = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID ]); //Assign a user in the task - factory(TaskUser::class)->create([ + TaskUser::factory()->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([ + $task4 = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID ]); //Assign a user in the task - factory(TaskUser::class)->create([ + TaskUser::factory()->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([ + Delegation::factory($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([ + Delegation::factory($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([ + Delegation::factory($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([ + Delegation::factory($total / 4)->create([ 'TAS_ID' => $task4->TAS_ID, 'DEL_THREAD_STATUS' => 'OPEN', 'USR_ID' => 0, @@ -447,30 +448,30 @@ class DelegationTest extends TestCase //Define the maximum time of execution $maximumTime = $this->maximumExecutionTime; //Create process - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); //Create a case - $application = factory(Application::class)->create(); + $application = Application::factory()->create(); //Create user - $user = factory(User::class)->create(); + $user = User::factory()->create(); //Create a task1 self service value based - $task1 = factory(Task::class)->create([ + $task1 = Task::factory()->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([ + $appSelfValue = AppAssignSelfServiceValue::factory()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'TAS_ID' => $task1->TAS_ID ]); - factory(AppAssignSelfServiceValueGroup::class)->create([ + AppAssignSelfServiceValueGroup::factory()->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([ + Delegation::factory($total / 2)->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'DEL_INDEX' => $appSelfValue->DEL_INDEX, 'TAS_ID' => $task1->TAS_ID, @@ -478,24 +479,24 @@ class DelegationTest extends TestCase 'USR_ID' => 0, ]); //Create a task2 self service value based - $task2 = factory(Task::class)->create([ + $task2 = Task::factory()->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([ + $appSelfValue = AppAssignSelfServiceValue::factory()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'TAS_ID' => $task2->TAS_ID ]); - factory(AppAssignSelfServiceValueGroup::class)->create([ + AppAssignSelfServiceValueGroup::factory()->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([ + Delegation::factory($total / 2)->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'DEL_INDEX' => $appSelfValue->DEL_INDEX, 'TAS_ID' => $task2->TAS_ID, diff --git a/tests/TestCase.php b/tests/TestCase.php index 75b4def94..2bf761a42 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -2,6 +2,7 @@ namespace Tests; +use App\Factories\Factory; use Illuminate\Foundation\Testing\TestCase as BaseTestCase; use Illuminate\Support\Facades\DB; use Propel; @@ -20,6 +21,12 @@ abstract class TestCase extends BaseTestCase */ protected $currentArgv; + /** + * The array of the initial tables to be dropped. + * @var array + */ + public static $truncateInitialTables = ''; + /** * Create application */ @@ -48,7 +55,7 @@ abstract class TestCase extends BaseTestCase * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ - protected function setUp() + protected function setUp(): void { /** * Lost argv are restored. @@ -61,14 +68,79 @@ abstract class TestCase extends BaseTestCase * Lost config are restored. */ app()->instance('config', $this->currentConfig); + error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT); } /** * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. */ - protected function tearDown() + protected function tearDown(): void { parent::tearDown(); } + + /** + * truncate non-initial Models. + * @return void + */ + public function truncateNonInitialModels(): void + { + DB::statement("set global max_connections = 500;"); + if (empty(static::$truncateInitialTables)) { + $initialTables = [ + 'RBAC_PERMISSIONS', + 'RBAC_ROLES', + 'RBAC_ROLES_PERMISSIONS', + 'RBAC_SYSTEMS', + 'RBAC_USERS', + 'RBAC_USERS_ROLES', + 'USERS', + 'CONTENT', + 'LANGUAGE', + 'ISO_COUNTRY', + 'ISO_SUBDIVISION', + 'ISO_LOCATION', + 'TRANSLATION', + 'DASHLET', + 'DASHLET_INSTANCE', + 'CONFIGURATION', + 'CATALOG', + 'ADDONS_MANAGER', + 'APP_SEQUENCE', + 'OAUTH_CLIENTS', + 'OAUTH_ACCESS_TOKENS' + ]; + $directory = Factory::$customDirectoryForModels; + if (file_exists($directory)) { + $files = scandir($directory); + $files = array_diff($files, ['.', '..']); + $tables = []; + foreach ($files as $filename) { + $filepath = $directory . $filename; + $ext = pathinfo($filepath, PATHINFO_EXTENSION); + if (strtolower($ext) !== 'php') { + continue; + } + $modelName = pathinfo($filepath, PATHINFO_FILENAME); + $model = Factory::$customNameSpaceForModels . $modelName; + $tableName = (new $model())->getTable(); + $tables[] = $tableName; + } + $result = array_diff($tables, $initialTables); + $result = array_values($result); + $truncates = []; + foreach ($result as $value) { + $truncates[] = 'TRUNCATE TABLE ' . $value; + } + static::$truncateInitialTables = implode(';', $truncates); + } + } else { + DB::unprepared( + "SET FOREIGN_KEY_CHECKS = 0;" . + static::$truncateInitialTables . + ";SET FOREIGN_KEY_CHECKS = 1;" + ); + } + } } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 7508f3b4d..dc85e3948 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -136,6 +136,15 @@ if (env('RUN_MSSQL_TESTS')) { * This is for standard ProcessMaker tables */ if (!env('POPULATE_DATABASE')) { + refreshDatabases(); +} + +/** + * Refresh databases. + * @return void + */ +function refreshDatabases(): void +{ // Create a table for define the connection Schema::connection('testexternal')->dropIfExists('test'); Schema::connection('testexternal')->create('test', function ($table) { diff --git a/tests/unit/app/CustomizeFormatterTest.php b/tests/unit/app/CustomizeFormatterTest.php index bec190b3b..f3901348c 100644 --- a/tests/unit/app/CustomizeFormatterTest.php +++ b/tests/unit/app/CustomizeFormatterTest.php @@ -14,7 +14,7 @@ class CustomizeFormatterTest extends TestCase /** * This is executed for each test. */ - protected function setUp() + protected function setUp(): void { parent::setUp(); self::$directory = PATH_DATA . 'logs/'; @@ -23,7 +23,7 @@ class CustomizeFormatterTest extends TestCase /** * This is done before the first test. */ - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { $file = new Filesystem(); $file->cleanDirectory(self::$directory); @@ -32,7 +32,7 @@ class CustomizeFormatterTest extends TestCase /** * This is done after the last test. */ - public static function tearDownAfterClass() + public static function tearDownAfterClass(): void { $file = new Filesystem(); $file->cleanDirectory(self::$directory); @@ -68,6 +68,6 @@ class CustomizeFormatterTest extends TestCase $this->assertCount(1, $files); $string = File::get($files[0]); - $this->assertRegExp("/{$message}/", $string); + $this->assertMatchesRegularExpression("/{$message}/", $string); } } diff --git a/tests/unit/gulliver/methods/DefaultAjaxTest.php b/tests/unit/gulliver/methods/DefaultAjaxTest.php index ca928a86a..de3a7ee8a 100644 --- a/tests/unit/gulliver/methods/DefaultAjaxTest.php +++ b/tests/unit/gulliver/methods/DefaultAjaxTest.php @@ -6,6 +6,15 @@ use Tests\TestCase; class DefaultAjaxTest extends TestCase { + /** + * Set up method. + * @return void + */ + public function setUp(): void + { + parent::setUp(); + $this->markTestSkipped('Issues with php 8'); + } /** * This gets data from a json file. diff --git a/tests/unit/gulliver/system/BootstrapTest.php b/tests/unit/gulliver/system/BootstrapTest.php index d717d29de..19a7ee5cb 100644 --- a/tests/unit/gulliver/system/BootstrapTest.php +++ b/tests/unit/gulliver/system/BootstrapTest.php @@ -15,7 +15,7 @@ class BootstrapTest extends TestCase /** * Set up method. */ - public function setUp() + public function setUp(): void { parent::setUp(); $this->faker = Factory::create(); @@ -34,35 +34,35 @@ class BootstrapTest extends TestCase $result = Bootstrap::streamCSSBigFile($filename); //add more assertions - $this->assertRegexp("/{$filename}/", $result); - $this->assertRegexp("/font-face/", $result); - $this->assertRegexp("/font-family/", $result); + $this->assertMatchesRegularExpression("/{$filename}/", $result); + $this->assertMatchesRegularExpression("/font-face/", $result); + $this->assertMatchesRegularExpression("/font-family/", $result); $filename = "jscolors"; $result = Bootstrap::streamCSSBigFile($filename); //add more assertions - $this->assertRegexp("/{$filename}/", $result); + $this->assertMatchesRegularExpression("/{$filename}/", $result); $filename = "xmlcolors"; $result = Bootstrap::streamCSSBigFile($filename); //add more assertions - $this->assertRegexp("/{$filename}/", $result); + $this->assertMatchesRegularExpression("/{$filename}/", $result); $filename = "classic"; $result = Bootstrap::streamCSSBigFile($filename); //add more assertions - $this->assertRegexp("/{$filename}/", $result); - $this->assertRegexp("/font-family/", $result); - $this->assertRegexp("/ss_group_suit/", $result); + $this->assertMatchesRegularExpression("/{$filename}/", $result); + $this->assertMatchesRegularExpression("/font-family/", $result); + $this->assertMatchesRegularExpression("/ss_group_suit/", $result); $filename = "classic-extjs"; $result = Bootstrap::streamCSSBigFile($filename); //add more assertions - $this->assertRegexp("/{$filename}/", $result); + $this->assertMatchesRegularExpression("/{$filename}/", $result); } /** @@ -101,7 +101,7 @@ class BootstrapTest extends TestCase foreach ($files as $value) { $result = $result . File::get($value->getPathname()); } - $this->assertRegExp("/{$channel}/", $result); + $this->assertMatchesRegularExpression("/{$channel}/", $result); } /** @@ -136,6 +136,6 @@ class BootstrapTest extends TestCase foreach ($files as $value) { $result = $result . File::get($value->getPathname()); } - $this->assertRegExp("/{$channel}/", $result); + $this->assertMatchesRegularExpression("/{$channel}/", $result); } } diff --git a/tests/unit/gulliver/system/CodeScannerTest.php b/tests/unit/gulliver/system/CodeScannerTest.php index ba560859b..fd4785d73 100644 --- a/tests/unit/gulliver/system/CodeScannerTest.php +++ b/tests/unit/gulliver/system/CodeScannerTest.php @@ -24,7 +24,7 @@ class CodeScannerTest extends TestCase /** * Call the setUp parent method and create some *.ini files */ - public function setUp() + public function setUp(): void { parent::setUp(); // TODO: Change the autogenerated stub @@ -105,7 +105,7 @@ class CodeScannerTest extends TestCase /** * Call the tearDown parent method and remove some files created */ - public function tearDown() + public function tearDown(): void { parent::tearDown(); @@ -203,7 +203,7 @@ class CodeScannerTest extends TestCase $result = $codeScanner->checkDisabledCode('PATH', $this->pathPlugin); $this->assertNotEmpty($result); } else { - $this->markTestIncomplete( + $this->markTestSkipped( 'Please check the configurations to the Code Security Scanner' ); } diff --git a/tests/unit/gulliver/system/ReplaceDataFieldTest.php b/tests/unit/gulliver/system/ReplaceDataFieldTest.php index f0653c86c..662683bad 100644 --- a/tests/unit/gulliver/system/ReplaceDataFieldTest.php +++ b/tests/unit/gulliver/system/ReplaceDataFieldTest.php @@ -33,7 +33,7 @@ class ReplaceDataFieldTest extends TestCase $stringToCheck = G::replaceDataField($string, $result, $dbEngine, $recursive); // Assert the @qq is not being set as an empty value - $this->assertRegExp("/asa@qq.fds/", $stringToCheck); + $this->assertMatchesRegularExpression("/asa@qq.fds/", $stringToCheck); // Testing with a "@qstring" value $result = [ @@ -48,7 +48,7 @@ class ReplaceDataFieldTest extends TestCase $stringToCheck = G::replaceDataField($string, $result, $dbEngine, $recursive); // Assert the @qstring is not being set as an empty value - $this->assertRegExp("/@qstring/", $stringToCheck); + $this->assertMatchesRegularExpression("/@qstring/", $stringToCheck); } /** @@ -80,7 +80,7 @@ class ReplaceDataFieldTest extends TestCase $stringToCheck = G::replaceDataField($string, $result, $dbEngine, $recursive); // Assert the @qq is not being set as an empty value - $this->assertRegExp("/asa@qq.fds/", $stringToCheck); + $this->assertMatchesRegularExpression("/asa@qq.fds/", $stringToCheck); // Testing with a "@qstring" value $result = [ @@ -95,7 +95,7 @@ class ReplaceDataFieldTest extends TestCase $stringToCheck = G::replaceDataField($string, $result, $dbEngine, $recursive); // Assert the @qstring is not being set as an empty value - $this->assertRegExp("/@qstring/", $stringToCheck); + $this->assertMatchesRegularExpression("/@qstring/", $stringToCheck); } /** @@ -119,7 +119,7 @@ class ReplaceDataFieldTest extends TestCase $stringToCheck = G::replaceDataField($string, $variables, $dbEngine, $recursive); // The variable @#DOC_UID inside in the variable "@#upload_New" shouldn't be replaced - $this->assertRegExp("/@#DOC_UID/", $stringToCheck); + $this->assertMatchesRegularExpression("/@#DOC_UID/", $stringToCheck); // Set parameters to test the method $dbEngine = 'mysql'; @@ -129,7 +129,7 @@ class ReplaceDataFieldTest extends TestCase $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->assertMatchesRegularExpression("/1988828025cc89aba0cd2b8079038028/", $stringToCheck); } /** @@ -153,7 +153,7 @@ class ReplaceDataFieldTest extends TestCase $stringToCheck = G::replaceDataField($string, $variables, $dbEngine, $recursive); // The variable @=DOC_UID inside in the variable "@=upload_New" shouldn't be replaced - $this->assertRegExp("/@=DOC_UID/", $stringToCheck); + $this->assertMatchesRegularExpression("/@=DOC_UID/", $stringToCheck); // Set parameters to test the method $dbEngine = 'mysql'; @@ -163,6 +163,6 @@ class ReplaceDataFieldTest extends TestCase $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->assertMatchesRegularExpression("/1988828025cc89aba0cd2b8079038028/", $stringToCheck); } } diff --git a/tests/unit/gulliver/system/gTest.php b/tests/unit/gulliver/system/gTest.php index df011d4e9..68598f3d3 100644 --- a/tests/unit/gulliver/system/gTest.php +++ b/tests/unit/gulliver/system/gTest.php @@ -15,7 +15,7 @@ class gTest extends TestCase /** * Set up method. */ - public function setUp() + public function setUp(): void { parent::setUp(); $this->faker = Factory::create(); diff --git a/tests/unit/rbac/engine/classes/model/RolesTest.php b/tests/unit/rbac/engine/classes/model/RolesTest.php index c032095c8..4e44ae409 100644 --- a/tests/unit/rbac/engine/classes/model/RolesTest.php +++ b/tests/unit/rbac/engine/classes/model/RolesTest.php @@ -23,13 +23,13 @@ class RolesTest extends TestCase $rolesInstance = new Roles(); // Create elements - $role = factory(RbacRoles::class)->create(); - $deletedUser = factory(RbacUsers::class)->states('deleted')->create(); - $activeUser = factory(RbacUsers::class)->states('active')->create(); - $inactiveUser = factory(RbacUsers::class)->states('inactive')->create(); + $role = RbacRoles::factory()->create(); + $deletedUser = RbacUsers::factory()->deleted()->create(); + $activeUser = RbacUsers::factory()->active()->create(); + $inactiveUser = RbacUsers::factory()->inactive()->create(); // Assign the role to a deleted user - factory(RbacUsersRoles::class)->create([ + RbacUsersRoles::factory()->create([ 'ROL_UID' => $role->ROL_UID, 'USR_UID' => $deletedUser->USR_UID ]); @@ -37,7 +37,7 @@ class RolesTest extends TestCase $this->assertEquals(0, $rolesInstance->numUsersWithRole($role->ROL_UID)); // Assign the role to an active user - factory(RbacUsersRoles::class)->create([ + RbacUsersRoles::factory()->create([ 'ROL_UID' => $role->ROL_UID, 'USR_UID' => $activeUser->USR_UID ]); @@ -45,7 +45,7 @@ class RolesTest extends TestCase $this->assertEquals(1, $rolesInstance->numUsersWithRole($role->ROL_UID)); // Assign the role to an inactive user - factory(RbacUsersRoles::class)->create([ + RbacUsersRoles::factory()->create([ 'ROL_UID' => $role->ROL_UID, 'USR_UID' => $inactiveUser->USR_UID ]); diff --git a/tests/unit/thirdparty/propel-generator/classes/propel/engine/database/model/PhpNameGeneratorTest.php b/tests/unit/thirdparty/propel-generator/classes/propel/engine/database/model/PhpNameGeneratorTest.php index caf8634ff..0f014ae50 100644 --- a/tests/unit/thirdparty/propel-generator/classes/propel/engine/database/model/PhpNameGeneratorTest.php +++ b/tests/unit/thirdparty/propel-generator/classes/propel/engine/database/model/PhpNameGeneratorTest.php @@ -12,7 +12,7 @@ class PhpNameGeneratorTest extends TestCase /** * Set up the test class */ - public function setUp() + public function setUp(): void { // Call the setUp parent method parent::setUp(); diff --git a/tests/unit/workflow/engine/bin/tasks/CliWorkspacesTest.php b/tests/unit/workflow/engine/bin/tasks/CliWorkspacesTest.php index 10b4f0aa2..93bc80184 100644 --- a/tests/unit/workflow/engine/bin/tasks/CliWorkspacesTest.php +++ b/tests/unit/workflow/engine/bin/tasks/CliWorkspacesTest.php @@ -7,15 +7,13 @@ use ProcessMaker\Model\Dynaform; use ProcessMaker\Model\Process; use ProcessMaker\Model\ProcessVariables; use ProcessMaker\Model\Triggers; +use Tests\CreateTestSite; use Tests\TestCase; class CliWorkspacesTest extends TestCase { use DatabaseTransactions; - - protected function setUp() - { - } + use CreateTestSite; /** * Test that the deprecated files are removed successfully @@ -25,6 +23,7 @@ class CliWorkspacesTest extends TestCase */ public function it_should_delete_the_deprecated_files() { + ob_start(); include(PATH_TRUNK . 'workflow/engine/bin/tasks/cliWorkspaces.php'); if (!file_exists(PATH_TRUNK . 'workflow/engine/methods/users/data_usersList.php')) { $filename = PATH_TRUNK . 'workflow/engine/methods/users/data_usersList.php'; @@ -83,6 +82,7 @@ class CliWorkspacesTest extends TestCase } } + ob_get_clean(); // This assert the data_usersList.php does not exist anymore $this->assertFalse(file_exists(PATH_TRUNK . 'workflow/engine/methods/users/data_usersList.php')); } @@ -154,33 +154,34 @@ class CliWorkspacesTest extends TestCase */ public function it_should_test_the_incompatibilities_in_the_dynaforms_queries() { - $this->markTestIncomplete();//This can't be tested due to the db.php invocation config(["system.workspace" => 'workflow']); + $workspace = config("system.workspace"); + $this->createDBFile($workspace); - $process = factory(Process::class, 2)->create(); + $process = Process::factory(2)->create(); - factory(Dynaform::class)->create( + Dynaform::factory()->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( + $dynaform = Dynaform::factory()->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":""}]}]}' ] ); - $variables = factory(ProcessVariables::class)->create( + $variables = ProcessVariables::factory()->create( [ 'PRJ_UID' => $process[0]['PRO_UID'], 'VAR_SQL' => 'SELECT * FROM USERS WHERE USR_UID="213" UNION SELECT * from PROCESS' ] ); - $trigger = factory(Triggers::class)->create( + $trigger = Triggers::factory()->create( [ 'PRO_UID' => $process[0]['PRO_UID'], 'TRI_WEBBOT' => '$text=222; @@ -207,26 +208,28 @@ class CliWorkspacesTest extends TestCase ] ); + ob_start(); check_queries_incompatibilities('workflow'); $result = ob_get_contents(); + ob_get_clean(); // This assert that the message contains the second process name - $this->assertRegExp('/'.$process[1]['PRO_TITLE'].'/',$result); + $this->assertMatchesRegularExpression('/'.$process[1]['PRO_TITLE'].'/',$result); // This assert that the message contains the second dynaform with the UNION query - $this->assertRegExp('/'.$dynaform['DYN_TITLE'].'/',$result); + $this->assertMatchesRegularExpression('/'.$dynaform['DYN_TITLE'].'/',$result); // This assert that the message contains the first process name - $this->assertRegExp('/'.$process[0]['PRO_TITLE'].'/',$result); + $this->assertMatchesRegularExpression('/'.$process[0]['PRO_TITLE'].'/',$result); // This assert that the message contains the first dynaform with the UNION query - $this->assertRegExp('/'.$variables['VAR_TITLE'].'/',$result); + $this->assertMatchesRegularExpression('/'.$variables['VAR_TITLE'].'/',$result); // This assert that the message contains the first process name - $this->assertRegExp('/'.$process[0]['PRO_TITLE'].'/',$result); + $this->assertMatchesRegularExpression('/'.$process[0]['PRO_TITLE'].'/',$result); // This assert that the message contains the first trigger with the UNION query - $this->assertRegExp('/'.$trigger['TRI_TITLE'].'/',$result); + $this->assertMatchesRegularExpression('/'.$trigger['TRI_TITLE'].'/',$result); } } \ No newline at end of file diff --git a/tests/unit/workflow/engine/classes/ActionsByEmailCoreClassTest.php b/tests/unit/workflow/engine/classes/ActionsByEmailCoreClassTest.php index 2a66c92e3..aaa4b7cc5 100644 --- a/tests/unit/workflow/engine/classes/ActionsByEmailCoreClassTest.php +++ b/tests/unit/workflow/engine/classes/ActionsByEmailCoreClassTest.php @@ -16,7 +16,7 @@ class ActionsByEmailCoreClassTest extends TestCase /** * Method set up. */ - public function setUp() + public function setUp(): void { parent::setUp(); if (!defined('PATH_IMAGES_ENVIRONMENT_USERS')) { @@ -52,14 +52,14 @@ class ActionsByEmailCoreClassTest extends TestCase $user = User::where('USR_UID', '=', '00000000000000000000000000000001') ->get() ->first(); - $process = factory(Process::class)->create(); - $task = factory(Task::class)->create([ + $process = Process::factory()->create(); + $task = Task::factory()->create([ 'PRO_UID' => $process->PRO_UID ]); - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'PRO_UID' => $process->PRO_UID ]); - $delegation = factory(Delegation::class)->create([ + $delegation = Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'PRO_UID' => $process->PRO_UID, 'TAS_UID' => $task->TAS_UID, @@ -91,17 +91,17 @@ class ActionsByEmailCoreClassTest extends TestCase $user = User::where('USR_UID', '=', '00000000000000000000000000000001') ->get() ->first(); - $process = factory(Process::class)->create(); - $task = factory(Task::class)->create([ + $process = Process::factory()->create(); + $task = Task::factory()->create([ 'PRO_UID' => $process->PRO_UID ]); $abeConfiguration = [ 'ABE_EMAIL_SERVER_UID' => '' ]; - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'PRO_UID' => $process->PRO_UID ]); - $delegation = factory(Delegation::class)->create([ + $delegation = Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'PRO_UID' => $process->PRO_UID, 'TAS_UID' => $task->TAS_UID, @@ -133,15 +133,15 @@ class ActionsByEmailCoreClassTest extends TestCase $user = User::where('USR_UID', '=', '00000000000000000000000000000001') ->get() ->first(); - $process = factory(Process::class)->create(); - $task = factory(Task::class)->create([ + $process = Process::factory()->create(); + $task = Task::factory()->create([ 'PRO_UID' => $process->PRO_UID ]); - $dynaform = factory(Dynaform::class)->create([ + $dynaform = Dynaform::factory()->create([ 'PRO_UID' => $process->PRO_UID ]); - $emailServer = factory(ProcessMaker\Model\EmailServerModel::class)->create(); - $abeConfiguration = factory(AbeConfiguration::class)->create([ + $emailServer = ProcessMaker\Model\EmailServerModel::factory()->create(); + $abeConfiguration = AbeConfiguration::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'TAS_UID' => '', 'DYN_UID' => $dynaform->DYN_UID, @@ -151,10 +151,10 @@ class ActionsByEmailCoreClassTest extends TestCase ]); $abeConfiguration = $abeConfiguration->toArray(); - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'PRO_UID' => $process->PRO_UID ]); - $delegation = factory(Delegation::class)->create([ + $delegation = Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'PRO_UID' => $process->PRO_UID, 'TAS_UID' => $task->TAS_UID, @@ -186,19 +186,19 @@ class ActionsByEmailCoreClassTest extends TestCase */ public function it_should_test_sendActionsByEmail_method_with_exception_if_email_to_is_empty() { - $user = factory(User::class)->create([ + $user = User::factory()->create([ 'USR_EMAIL' => '' ]); - $process = factory(Process::class)->create(); - $task = factory(Task::class)->create([ + $process = Process::factory()->create(); + $task = Task::factory()->create([ 'PRO_UID' => $process->PRO_UID ]); - $dynaform = factory(Dynaform::class)->create([ + $dynaform = Dynaform::factory()->create([ 'PRO_UID' => $process->PRO_UID ]); - $emailServer = factory(ProcessMaker\Model\EmailServerModel::class)->create(); - $abeConfiguration = factory(AbeConfiguration::class)->create([ + $emailServer = ProcessMaker\Model\EmailServerModel::factory()->create(); + $abeConfiguration = AbeConfiguration::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'TAS_UID' => $task->TAS_UID, 'DYN_UID' => $dynaform->DYN_UID, @@ -209,10 +209,10 @@ class ActionsByEmailCoreClassTest extends TestCase ]); $abeConfiguration = $abeConfiguration->toArray(); - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'PRO_UID' => $process->PRO_UID ]); - $delegation = factory(Delegation::class)->create([ + $delegation = Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'PRO_UID' => $process->PRO_UID, 'TAS_UID' => $task->TAS_UID, @@ -245,17 +245,17 @@ class ActionsByEmailCoreClassTest extends TestCase */ public function it_should_test_sendActionsByEmail_method_with_exception_if_email_type_is_empty() { - $user = factory(User::class)->create(); + $user = User::factory()->create(); - $process = factory(Process::class)->create(); - $task = factory(Task::class)->create([ + $process = Process::factory()->create(); + $task = Task::factory()->create([ 'PRO_UID' => $process->PRO_UID ]); - $dynaform = factory(Dynaform::class)->create([ + $dynaform = Dynaform::factory()->create([ 'PRO_UID' => $process->PRO_UID ]); - $emailServer = factory(ProcessMaker\Model\EmailServerModel::class)->create(); - $abeConfiguration = factory(AbeConfiguration::class)->create([ + $emailServer = ProcessMaker\Model\EmailServerModel::factory()->create(); + $abeConfiguration = AbeConfiguration::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'TAS_UID' => $task->TAS_UID, 'DYN_UID' => $dynaform->DYN_UID, @@ -266,10 +266,10 @@ class ActionsByEmailCoreClassTest extends TestCase ]); $abeConfiguration = $abeConfiguration->toArray(); - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'PRO_UID' => $process->PRO_UID ]); - $delegation = factory(Delegation::class)->create([ + $delegation = Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'PRO_UID' => $process->PRO_UID, 'TAS_UID' => $task->TAS_UID, @@ -304,15 +304,15 @@ class ActionsByEmailCoreClassTest extends TestCase $user = User::where('USR_UID', '=', '00000000000000000000000000000001') ->get() ->first(); - $process = factory(Process::class)->create(); - $task = factory(Task::class)->create([ + $process = Process::factory()->create(); + $task = Task::factory()->create([ 'PRO_UID' => $process->PRO_UID ]); - $dynaform = factory(Dynaform::class)->create([ + $dynaform = Dynaform::factory()->create([ 'PRO_UID' => $process->PRO_UID ]); - $emailServer = factory(ProcessMaker\Model\EmailServerModel::class)->create(); - $abeConfiguration = factory(AbeConfiguration::class)->create([ + $emailServer = ProcessMaker\Model\EmailServerModel::factory()->create(); + $abeConfiguration = AbeConfiguration::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'TAS_UID' => $task->TAS_UID, 'DYN_UID' => $dynaform->DYN_UID, @@ -322,11 +322,11 @@ class ActionsByEmailCoreClassTest extends TestCase ]); $abeConfiguration = $abeConfiguration->toArray(); - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'PRO_UID' => $process->PRO_UID ]); - $delegation = factory(Delegation::class)->create([ + $delegation = Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'PRO_UID' => $process->PRO_UID, 'TAS_UID' => $task->TAS_UID, @@ -363,15 +363,15 @@ class ActionsByEmailCoreClassTest extends TestCase $user = User::where('USR_UID', '=', '00000000000000000000000000000001') ->get() ->first(); - $process = factory(Process::class)->create(); - $task = factory(Task::class)->create([ + $process = Process::factory()->create(); + $task = Task::factory()->create([ 'PRO_UID' => $process->PRO_UID ]); - $dynaform = factory(Dynaform::class)->create([ + $dynaform = Dynaform::factory()->create([ 'PRO_UID' => $process->PRO_UID ]); - $emailServer = factory(ProcessMaker\Model\EmailServerModel::class)->create(); - $abeConfiguration = factory(AbeConfiguration::class)->create([ + $emailServer = ProcessMaker\Model\EmailServerModel::factory()->create(); + $abeConfiguration = AbeConfiguration::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'TAS_UID' => $task->TAS_UID, 'DYN_UID' => $dynaform->DYN_UID, @@ -382,11 +382,11 @@ class ActionsByEmailCoreClassTest extends TestCase ]); $abeConfiguration = $abeConfiguration->toArray(); - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'PRO_UID' => $process->PRO_UID ]); - $delegation = factory(Delegation::class)->create([ + $delegation = Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'PRO_UID' => $process->PRO_UID, 'TAS_UID' => $task->TAS_UID, @@ -423,15 +423,15 @@ class ActionsByEmailCoreClassTest extends TestCase $user = User::where('USR_UID', '=', '00000000000000000000000000000001') ->get() ->first(); - $process = factory(Process::class)->create(); - $task = factory(Task::class)->create([ + $process = Process::factory()->create(); + $task = Task::factory()->create([ 'PRO_UID' => $process->PRO_UID ]); - $dynaform = factory(Dynaform::class)->create([ + $dynaform = Dynaform::factory()->create([ 'PRO_UID' => $process->PRO_UID ]); - $emailServer = factory(ProcessMaker\Model\EmailServerModel::class)->create(); - $abeConfiguration = factory(AbeConfiguration::class)->create([ + $emailServer = ProcessMaker\Model\EmailServerModel::factory()->create(); + $abeConfiguration = AbeConfiguration::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'TAS_UID' => $task->TAS_UID, 'DYN_UID' => $dynaform->DYN_UID, @@ -442,11 +442,11 @@ class ActionsByEmailCoreClassTest extends TestCase ]); $abeConfiguration = $abeConfiguration->toArray(); - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'PRO_UID' => $process->PRO_UID ]); - $delegation = factory(Delegation::class)->create([ + $delegation = Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'PRO_UID' => $process->PRO_UID, 'TAS_UID' => $task->TAS_UID, @@ -483,16 +483,16 @@ class ActionsByEmailCoreClassTest extends TestCase $user = User::where('USR_UID', '=', '00000000000000000000000000000001') ->get() ->first(); - $process = factory(Process::class)->create(); - $task = factory(Task::class)->create([ + $process = Process::factory()->create(); + $task = Task::factory()->create([ 'PRO_UID' => $process->PRO_UID ]); - $dynaform = factory(Dynaform::class)->create([ + $dynaform = Dynaform::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'DYN_CONTENT' => file_get_contents(PATH_TRUNK . "/tests/resources/dynaform2.json") ]); - $emailServer = factory(ProcessMaker\Model\EmailServerModel::class)->create(); - $abeConfiguration = factory(AbeConfiguration::class)->create([ + $emailServer = ProcessMaker\Model\EmailServerModel::factory()->create(); + $abeConfiguration = AbeConfiguration::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'TAS_UID' => $task->TAS_UID, 'DYN_UID' => $dynaform->DYN_UID, @@ -503,11 +503,11 @@ class ActionsByEmailCoreClassTest extends TestCase ]); $abeConfiguration = $abeConfiguration->toArray(); - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'PRO_UID' => $process->PRO_UID ]); - $delegation = factory(Delegation::class)->create([ + $delegation = Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'PRO_UID' => $process->PRO_UID, 'TAS_UID' => $task->TAS_UID, @@ -544,16 +544,16 @@ class ActionsByEmailCoreClassTest extends TestCase $user = User::where('USR_UID', '=', '00000000000000000000000000000001') ->get() ->first(); - $process = factory(Process::class)->create(); - $task = factory(Task::class)->create([ + $process = Process::factory()->create(); + $task = Task::factory()->create([ 'PRO_UID' => $process->PRO_UID ]); - $dynaform = factory(Dynaform::class)->create([ + $dynaform = Dynaform::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'DYN_CONTENT' => file_get_contents(PATH_TRUNK . "/tests/resources/dynaform3.json") ]); - $emailServer = factory(ProcessMaker\Model\EmailServerModel::class)->create(); - $abeConfiguration = factory(AbeConfiguration::class)->create([ + $emailServer = ProcessMaker\Model\EmailServerModel::factory()->create(); + $abeConfiguration = AbeConfiguration::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'TAS_UID' => $task->TAS_UID, 'DYN_UID' => $dynaform->DYN_UID, @@ -565,11 +565,11 @@ class ActionsByEmailCoreClassTest extends TestCase ]); $abeConfiguration = $abeConfiguration->toArray(); - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'PRO_UID' => $process->PRO_UID ]); - $delegation = factory(Delegation::class)->create([ + $delegation = Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'PRO_UID' => $process->PRO_UID, 'TAS_UID' => $task->TAS_UID, @@ -598,11 +598,11 @@ class ActionsByEmailCoreClassTest extends TestCase $result = $reflectionMethod->invokeArgs($this->actionsByEmailCoreClass, []); - $this->assertContains('jsondata', $result); - $this->assertContains('httpServerHostname', $result); - $this->assertContains('pm_run_outside_main_app', $result); - $this->assertContains('pathRTLCss', $result); - $this->assertContains('fieldsRequired', $result); + $this->assertStringContainsString('jsondata', $result); + $this->assertStringContainsString('httpServerHostname', $result); + $this->assertStringContainsString('pm_run_outside_main_app', $result); + $this->assertStringContainsString('pathRTLCss', $result); + $this->assertStringContainsString('fieldsRequired', $result); } /** @@ -615,16 +615,16 @@ class ActionsByEmailCoreClassTest extends TestCase $user = User::where('USR_UID', '=', '00000000000000000000000000000001') ->get() ->first(); - $process = factory(Process::class)->create(); - $task = factory(Task::class)->create([ + $process = Process::factory()->create(); + $task = Task::factory()->create([ 'PRO_UID' => $process->PRO_UID ]); - $dynaform = factory(Dynaform::class)->create([ + $dynaform = Dynaform::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'DYN_CONTENT' => file_get_contents(PATH_TRUNK . "/tests/resources/dynaform3.json") ]); - $emailServer = factory(ProcessMaker\Model\EmailServerModel::class)->create(); - $abeConfiguration = factory(AbeConfiguration::class)->create([ + $emailServer = ProcessMaker\Model\EmailServerModel::factory()->create(); + $abeConfiguration = AbeConfiguration::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'TAS_UID' => $task->TAS_UID, 'DYN_UID' => $dynaform->DYN_UID, @@ -636,11 +636,11 @@ class ActionsByEmailCoreClassTest extends TestCase ]); $abeConfiguration = $abeConfiguration->toArray(); - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'PRO_UID' => $process->PRO_UID ]); - $delegation = factory(Delegation::class)->create([ + $delegation = Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'PRO_UID' => $process->PRO_UID, 'TAS_UID' => $task->TAS_UID, @@ -669,11 +669,11 @@ class ActionsByEmailCoreClassTest extends TestCase $result = $reflectionMethod->invokeArgs($this->actionsByEmailCoreClass, []); - $this->assertContains('jsondata', $result); - $this->assertContains('httpServerHostname', $result); - $this->assertContains('pm_run_outside_main_app', $result); - $this->assertContains('pathRTLCss', $result); - $this->assertContains('fieldsRequired', $result); + $this->assertStringContainsString('jsondata', $result); + $this->assertStringContainsString('httpServerHostname', $result); + $this->assertStringContainsString('pm_run_outside_main_app', $result); + $this->assertStringContainsString('pathRTLCss', $result); + $this->assertStringContainsString('fieldsRequired', $result); } /** @@ -687,16 +687,16 @@ class ActionsByEmailCoreClassTest extends TestCase $user = User::where('USR_UID', '=', '00000000000000000000000000000001') ->get() ->first(); - $process = factory(Process::class)->create(); - $task = factory(Task::class)->create([ + $process = Process::factory()->create(); + $task = Task::factory()->create([ 'PRO_UID' => $process->PRO_UID ]); - $dynaform = factory(Dynaform::class)->create([ + $dynaform = Dynaform::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'DYN_CONTENT' => file_get_contents(PATH_TRUNK . "/tests/resources/dynaform3.json") ]); - $emailServer = factory(ProcessMaker\Model\EmailServerModel::class)->create(); - $abeConfiguration = factory(AbeConfiguration::class)->create([ + $emailServer = ProcessMaker\Model\EmailServerModel::factory()->create(); + $abeConfiguration = AbeConfiguration::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'TAS_UID' => $task->TAS_UID, 'DYN_UID' => $dynaform->DYN_UID, @@ -708,11 +708,11 @@ class ActionsByEmailCoreClassTest extends TestCase ]); $abeConfiguration = $abeConfiguration->toArray(); - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'PRO_UID' => $process->PRO_UID ]); - $delegation = factory(Delegation::class)->create([ + $delegation = Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'PRO_UID' => $process->PRO_UID, 'TAS_UID' => $task->TAS_UID, @@ -741,10 +741,10 @@ class ActionsByEmailCoreClassTest extends TestCase $result = $reflectionMethod->invokeArgs($this->actionsByEmailCoreClass, []); - $this->assertContains('jsondata', $result); - $this->assertContains('httpServerHostname', $result); - $this->assertContains('pm_run_outside_main_app', $result); - $this->assertContains('pathRTLCss', $result); - $this->assertContains('fieldsRequired', $result); + $this->assertStringContainsString('jsondata', $result); + $this->assertStringContainsString('httpServerHostname', $result); + $this->assertStringContainsString('pm_run_outside_main_app', $result); + $this->assertStringContainsString('pathRTLCss', $result); + $this->assertStringContainsString('fieldsRequired', $result); } } diff --git a/tests/unit/workflow/engine/classes/CasesTest.php b/tests/unit/workflow/engine/classes/CasesTest.php index 94807dd7d..9aa26ba15 100644 --- a/tests/unit/workflow/engine/classes/CasesTest.php +++ b/tests/unit/workflow/engine/classes/CasesTest.php @@ -21,11 +21,19 @@ class CasesTest extends TestCase /** * Call setUp method */ - public function setUp() + public function setUp(): void { parent::setUp(); // TODO: Change the autogenerated stub } + /** + * Call the tearDown method + */ + public function tearDown(): void + { + // The parent method needs to be override due to errors appearing + } + /** * Test getNextStep method with no steps * @@ -34,13 +42,13 @@ class CasesTest extends TestCase */ public function it_should_test_get_next_step_method() { - $process = factory(Process::class)->create(); - $application = factory(Application::class)->create(['PRO_UID' => $process->PRO_UID]); - $appDelegation = factory(Delegation::class)->create([ + $process = Process::factory()->create(); + $application = Application::factory()->create(['PRO_UID' => $process->PRO_UID]); + $appDelegation = Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'PRO_UID' => $process->PRO_UID ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'PRO_UID' => $process->PRO_UID, 'DEL_INDEX' => 2, @@ -60,19 +68,19 @@ class CasesTest extends TestCase */ public function it_should_test_get_next_step_method_position() { - $process = factory(Process::class)->create(); - $application = factory(Application::class)->create(['PRO_UID' => $process->PRO_UID]); - $appDelegation = factory(Delegation::class)->create([ + $process = Process::factory()->create(); + $application = Application::factory()->create(['PRO_UID' => $process->PRO_UID]); + $appDelegation = Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'PRO_UID' => $process->PRO_UID ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'PRO_UID' => $process->PRO_UID, 'DEL_INDEX' => 2, 'DEL_PREVIOUS' => $appDelegation->DEL_INDEX ]); - factory(Step::class)->create([ + Step::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'TAS_UID' => $appDelegation->TAS_UID, 'STEP_POSITION' => 2, @@ -91,19 +99,19 @@ class CasesTest extends TestCase */ public function it_should_test_get_next_step_method_output_document() { - $process = factory(Process::class)->create(); - $application = factory(Application::class)->create(['PRO_UID' => $process->PRO_UID]); - $appDelegation = factory(Delegation::class)->create([ + $process = Process::factory()->create(); + $application = Application::factory()->create(['PRO_UID' => $process->PRO_UID]); + $appDelegation = Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'PRO_UID' => $process->PRO_UID ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'PRO_UID' => $process->PRO_UID, 'DEL_INDEX' => 2, 'DEL_PREVIOUS' => $appDelegation->DEL_INDEX ]); - factory(Step::class)->create([ + Step::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'TAS_UID' => $appDelegation->TAS_UID, 'STEP_POSITION' => 2, @@ -123,19 +131,19 @@ class CasesTest extends TestCase */ public function it_should_test_get_next_step_method_input_document() { - $process = factory(Process::class)->create(); - $application = factory(Application::class)->create(['PRO_UID' => $process->PRO_UID]); - $appDelegation = factory(Delegation::class)->create([ + $process = Process::factory()->create(); + $application = Application::factory()->create(['PRO_UID' => $process->PRO_UID]); + $appDelegation = Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'PRO_UID' => $process->PRO_UID ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'PRO_UID' => $process->PRO_UID, 'DEL_INDEX' => 2, 'DEL_PREVIOUS' => $appDelegation->DEL_INDEX ]); - factory(Step::class)->create([ + Step::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'TAS_UID' => $appDelegation->TAS_UID, 'STEP_POSITION' => 2, @@ -155,19 +163,19 @@ class CasesTest extends TestCase */ public function it_should_test_get_next_step_method_external() { - $process = factory(Process::class)->create(); - $application = factory(Application::class)->create(['PRO_UID' => $process->PRO_UID]); - $appDelegation = factory(Delegation::class)->create([ + $process = Process::factory()->create(); + $application = Application::factory()->create(['PRO_UID' => $process->PRO_UID]); + $appDelegation = Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'PRO_UID' => $process->PRO_UID ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'PRO_UID' => $process->PRO_UID, 'DEL_INDEX' => 2, 'DEL_PREVIOUS' => $appDelegation->DEL_INDEX ]); - factory(Step::class)->create([ + Step::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'TAS_UID' => $appDelegation->TAS_UID, 'STEP_POSITION' => 2, @@ -187,19 +195,19 @@ class CasesTest extends TestCase */ public function it_should_test_get_next_step_method_message() { - $process = factory(Process::class)->create(); - $application = factory(Application::class)->create(['PRO_UID' => $process->PRO_UID]); - $appDelegation = factory(Delegation::class)->create([ + $process = Process::factory()->create(); + $application = Application::factory()->create(['PRO_UID' => $process->PRO_UID]); + $appDelegation = Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'PRO_UID' => $process->PRO_UID ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'PRO_UID' => $process->PRO_UID, 'DEL_INDEX' => 2, 'DEL_PREVIOUS' => $appDelegation->DEL_INDEX ]); - factory(Step::class)->create([ + Step::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'TAS_UID' => $appDelegation->TAS_UID, 'STEP_POSITION' => 2, @@ -219,13 +227,13 @@ class CasesTest extends TestCase */ public function it_should_test_get_next_step_method_step_does_not_exists() { - $process = factory(Process::class)->create(); - $application = factory(Application::class)->create(['PRO_UID' => $process->PRO_UID]); - $appDelegation = factory(Delegation::class)->create([ + $process = Process::factory()->create(); + $application = Application::factory()->create(['PRO_UID' => $process->PRO_UID]); + $appDelegation = Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'PRO_UID' => $process->PRO_UID ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'PRO_UID' => $process->PRO_UID, 'DEL_INDEX' => 2, @@ -257,9 +265,9 @@ class CasesTest extends TestCase */ public function it_should_test_get_next_step_method_step_false() { - $process = factory(Process::class)->create(); - $application = factory(Application::class)->create(); - $appDelegation = factory(Delegation::class)->create(); + $process = Process::factory()->create(); + $application = Application::factory()->create(); + $appDelegation = Delegation::factory()->create(); $cases = new Cases(); $res = $cases->getNextStep($process->PRO_UID, $application->APP_UID, $appDelegation->DEL_INDEX); $this->assertFalse($res); @@ -274,19 +282,19 @@ class CasesTest extends TestCase public function it_should_test_get_next_step_method_gmail() { $_SESSION['gmail'] = ''; - $process = factory(Process::class)->create(); - $application = factory(Application::class)->create(['PRO_UID' => $process->PRO_UID]); - $appDelegation = factory(Delegation::class)->create([ + $process = Process::factory()->create(); + $application = Application::factory()->create(['PRO_UID' => $process->PRO_UID]); + $appDelegation = Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'PRO_UID' => $process->PRO_UID ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'PRO_UID' => $process->PRO_UID, 'DEL_INDEX' => 2, 'DEL_PREVIOUS' => $appDelegation->DEL_INDEX ]); - factory(Step::class)->create([ + Step::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'TAS_UID' => $appDelegation->TAS_UID, 'STEP_POSITION' => 2, @@ -307,19 +315,19 @@ class CasesTest extends TestCase public function it_should_test_get_next_step_method_gmail_nextstep() { $_SESSION['gmail'] = ''; - $process = factory(Process::class)->create(); - $application = factory(Application::class)->create(['PRO_UID' => $process->PRO_UID]); - $appDelegation = factory(Delegation::class)->create([ + $process = Process::factory()->create(); + $application = Application::factory()->create(['PRO_UID' => $process->PRO_UID]); + $appDelegation = Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'PRO_UID' => $process->PRO_UID ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'PRO_UID' => $process->PRO_UID, 'DEL_INDEX' => 2, 'DEL_PREVIOUS' => $appDelegation->DEL_INDEX ]); - factory(Step::class)->create([ + Step::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'TAS_UID' => $appDelegation->TAS_UID, 'STEP_POSITION' => 1, @@ -340,19 +348,19 @@ class CasesTest extends TestCase public function it_should_test_get_next_step_method_condition_empty() { $_SESSION['gmail'] = ''; - $process = factory(Process::class)->create(); - $application = factory(Application::class)->create(['PRO_UID' => $process->PRO_UID]); - $appDelegation = factory(Delegation::class)->create([ + $process = Process::factory()->create(); + $application = Application::factory()->create(['PRO_UID' => $process->PRO_UID]); + $appDelegation = Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'PRO_UID' => $process->PRO_UID ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'PRO_UID' => $process->PRO_UID, 'DEL_INDEX' => 2, 'DEL_PREVIOUS' => $appDelegation->DEL_INDEX ]); - factory(Step::class)->create([ + Step::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'TAS_UID' => $appDelegation->TAS_UID, 'STEP_POSITION' => 2, @@ -373,24 +381,24 @@ class CasesTest extends TestCase public function it_should_test_get_start_cases() { // Creating a process with initial tasks - $process = factory(Process::class)->create(); - $user = factory(User::class)->create(); - $normalTask = factory(Task::class)->create([ + $process = Process::factory()->create(); + $user = User::factory()->create(); + $normalTask = Task::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'PRO_ID' => $process->PRO_ID, 'TAS_START' => 'TRUE' ]); - $webEntryTask = factory(Task::class)->create([ + $webEntryTask = Task::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'PRO_ID' => $process->PRO_ID, 'TAS_START' => 'TRUE', 'TAS_TYPE' => 'WEBENTRYEVENT' ]); - factory(TaskUser::class)->create([ + TaskUser::factory()->create([ 'TAS_UID' => $normalTask->TAS_UID, 'USR_UID' => $user->USR_UID ]); - factory(TaskUser::class)->create([ + TaskUser::factory()->create([ 'TAS_UID' => $webEntryTask->TAS_UID, 'USR_UID' => $user->USR_UID ]); @@ -415,8 +423,8 @@ class CasesTest extends TestCase */ public function it_shoult_test_the_get_to_method_with_default_tas_assign_type() { - $task = factory(Task::class)->create(); - $user = factory(User::class)->create([ + $task = Task::factory()->create(); + $user = User::factory()->create([ 'USR_EMAIL' => 'test@test.com' ]); @@ -424,7 +432,7 @@ class CasesTest extends TestCase $cases = new Cases(); $result = $cases->getTo($task->TAS_UID, $user->USR_UID, ''); $this->assertNotEmpty($result); - $this->assertRegExp("/{$user->USR_EMAIL}/", $result["to"]); + $this->assertMatchesRegularExpression("/{$user->USR_EMAIL}/", $result["to"]); } /** @@ -435,41 +443,41 @@ class CasesTest extends TestCase */ public function it_shoult_test_the_get_to_method_with_self_service_tas_assign_type() { - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'TAS_ASSIGN_TYPE' => 'BALANCED' ]); - $task2 = factory(Task::class)->create([ + $task2 = Task::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE' ]); - $user = factory(User::class)->create([ + $user = User::factory()->create([ 'USR_EMAIL' => 'test@test.com' ]); - $user2 = factory(User::class)->create([ + $user2 = User::factory()->create([ 'USR_EMAIL' => 'test2@test2.com' ]); - factory(TaskUser::class)->create([ + TaskUser::factory()->create([ 'TAS_UID' => $task2->TAS_UID, 'USR_UID' => $user->USR_UID ]); - factory(TaskUser::class)->create([ + TaskUser::factory()->create([ 'TAS_UID' => $task2->TAS_UID, 'USR_UID' => $user2->USR_UID ]); - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'APP_STATUS_ID' => 2, 'PRO_UID' => $process->PRO_UID, 'APP_INIT_USER' => "00000000000000000000000000000001", 'APP_CUR_USER' => $user2->USR_UID ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'DEL_INDEX' => 1, 'APP_NUMBER' => $application->APP_NUMBER, @@ -480,7 +488,7 @@ class CasesTest extends TestCase 'DEL_THREAD' => 1, 'DEL_THREAD_STATUS' => 'CLOSED' ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'DEL_INDEX' => 2, 'APP_NUMBER' => $application->APP_NUMBER, @@ -491,7 +499,7 @@ class CasesTest extends TestCase 'DEL_THREAD' => 2, 'DEL_THREAD_STATUS' => 'OPEN' ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'DEL_INDEX' => 3, 'APP_NUMBER' => $application->APP_NUMBER, @@ -526,8 +534,8 @@ class CasesTest extends TestCase $this->assertNotEmpty($result); // Asserts the emails of both users are contained in the result - $this->assertRegExp("/{$user->USR_EMAIL}/", $result["to"]); - $this->assertRegExp("/{$user2->USR_EMAIL}/", $result["to"]); + $this->assertMatchesRegularExpression("/{$user->USR_EMAIL}/", $result["to"]); + $this->assertMatchesRegularExpression("/{$user2->USR_EMAIL}/", $result["to"]); } /** @@ -538,41 +546,41 @@ class CasesTest extends TestCase */ public function it_shoult_test_the_get_to_method_with_multiple_instance_tas_assign_type() { - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'TAS_ASSIGN_TYPE' => 'BALANCED' ]); - $task2 = factory(Task::class)->create([ + $task2 = Task::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'TAS_ASSIGN_TYPE' => 'MULTIPLE_INSTANCE' ]); - $user = factory(User::class)->create([ + $user = User::factory()->create([ 'USR_EMAIL' => 'test@test.com' ]); - $user2 = factory(User::class)->create([ + $user2 = User::factory()->create([ 'USR_EMAIL' => 'test2@test2.com' ]); - factory(TaskUser::class)->create([ + TaskUser::factory()->create([ 'TAS_UID' => $task2->TAS_UID, 'USR_UID' => $user->USR_UID ]); - factory(TaskUser::class)->create([ + TaskUser::factory()->create([ 'TAS_UID' => $task2->TAS_UID, 'USR_UID' => $user2->USR_UID ]); - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'APP_STATUS_ID' => 2, 'PRO_UID' => $process->PRO_UID, 'APP_INIT_USER' => "00000000000000000000000000000001", 'APP_CUR_USER' => $user2->USR_UID ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'DEL_INDEX' => 1, 'APP_NUMBER' => $application->APP_NUMBER, @@ -583,7 +591,7 @@ class CasesTest extends TestCase 'DEL_THREAD' => 1, 'DEL_THREAD_STATUS' => 'CLOSED' ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'DEL_INDEX' => 2, 'APP_NUMBER' => $application->APP_NUMBER, @@ -594,7 +602,7 @@ class CasesTest extends TestCase 'DEL_THREAD' => 2, 'DEL_THREAD_STATUS' => 'OPEN' ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'DEL_INDEX' => 3, 'APP_NUMBER' => $application->APP_NUMBER, @@ -629,7 +637,7 @@ class CasesTest extends TestCase $this->assertNotEmpty($result); // Asserts the emails of both users are contained in the result - $this->assertRegExp("/{$user->USR_EMAIL}/", $result["to"]); + $this->assertMatchesRegularExpression("/{$user->USR_EMAIL}/", $result["to"]); } /** @@ -640,42 +648,42 @@ class CasesTest extends TestCase */ public function it_shoult_test_the_get_to_method_with_multiple_instance_value_based_tas_assign_type() { - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'TAS_ASSIGN_TYPE' => 'BALANCED' ]); - $task2 = factory(Task::class)->create([ + $task2 = Task::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'TAS_ASSIGN_TYPE' => 'MULTIPLE_INSTANCE_VALUE_BASED', 'TAS_ASSIGN_VARIABLE' => '@@users' ]); - $user = factory(User::class)->create([ + $user = User::factory()->create([ 'USR_EMAIL' => 'test@test.com' ]); - $user2 = factory(User::class)->create([ + $user2 = User::factory()->create([ 'USR_EMAIL' => 'test2@test2.com' ]); - factory(TaskUser::class)->create([ + TaskUser::factory()->create([ 'TAS_UID' => $task2->TAS_UID, 'USR_UID' => $user->USR_UID ]); - factory(TaskUser::class)->create([ + TaskUser::factory()->create([ 'TAS_UID' => $task2->TAS_UID, 'USR_UID' => $user2->USR_UID ]); - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'APP_STATUS_ID' => 2, 'PRO_UID' => $process->PRO_UID, 'APP_INIT_USER' => "00000000000000000000000000000001", 'APP_CUR_USER' => $user2->USR_UID ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'DEL_INDEX' => 1, 'APP_NUMBER' => $application->APP_NUMBER, @@ -686,7 +694,7 @@ class CasesTest extends TestCase 'DEL_THREAD' => 1, 'DEL_THREAD_STATUS' => 'CLOSED' ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'DEL_INDEX' => 2, 'APP_NUMBER' => $application->APP_NUMBER, @@ -697,7 +705,7 @@ class CasesTest extends TestCase 'DEL_THREAD' => 2, 'DEL_THREAD_STATUS' => 'OPEN' ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'DEL_INDEX' => 3, 'APP_NUMBER' => $application->APP_NUMBER, @@ -733,14 +741,6 @@ class CasesTest extends TestCase $this->assertNotEmpty($result); // Asserts the emails of both users are contained in the result - $this->assertRegExp("/{$user->USR_EMAIL}/", $result["to"]); - } - - /** - * Call the tearDown method - */ - public function tearDown() - { - // The parent method needs to be override due to errors appearing + $this->assertMatchesRegularExpression("/{$user->USR_EMAIL}/", $result["to"]); } } diff --git a/tests/unit/workflow/engine/classes/ConfigurationsTest.php b/tests/unit/workflow/engine/classes/ConfigurationsTest.php index 4530a67aa..de33e48c0 100644 --- a/tests/unit/workflow/engine/classes/ConfigurationsTest.php +++ b/tests/unit/workflow/engine/classes/ConfigurationsTest.php @@ -19,7 +19,7 @@ class ConfigurationsTest extends TestCase public function it_should_return_empty_preferences() { //Define a user preferences empty - $configuration = factory(Configuration::class)->states('userPreferencesEmpty')->create(); + $configuration = Configuration::factory()->userPreferencesEmpty()->create(); //Get the user preferences $conf = new Configurations(); diff --git a/tests/unit/workflow/engine/classes/DbConnectionsTest.php b/tests/unit/workflow/engine/classes/DbConnectionsTest.php index eb8509038..ec97d5c56 100644 --- a/tests/unit/workflow/engine/classes/DbConnectionsTest.php +++ b/tests/unit/workflow/engine/classes/DbConnectionsTest.php @@ -16,7 +16,7 @@ class DbConnectionsTest extends TestCase /** * Setup method. */ - public function setUp() + public function setUp(): void { parent::setUp(); $this->dbConnections = new DbConnections(); @@ -29,10 +29,10 @@ class DbConnectionsTest extends TestCase */ public function it_should_test_loadAdditionalConnections_method() { - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); $dbName = env('DB_DATABASE'); - $dbSource = factory(DbSource::class)->create([ + $dbSource = DbSource::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'DBS_TYPE' => 'mysql', 'DBS_SERVER' => env('DB_HOST'), @@ -60,10 +60,10 @@ class DbConnectionsTest extends TestCase */ public function it_should_test_loadAdditionalConnections_method_with_force_option_true() { - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); $dbName = env('DB_DATABASE'); - $dbSource = factory(DbSource::class)->create([ + $dbSource = DbSource::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'DBS_TYPE' => 'mysql', 'DBS_SERVER' => env('DB_HOST'), @@ -88,10 +88,10 @@ class DbConnectionsTest extends TestCase */ public function it_should_test_loadAdditionalConnections_method_with_force_option_false() { - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); $dbName = env('DB_DATABASE'); - $dbSource = factory(DbSource::class)->create([ + $dbSource = DbSource::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'DBS_TYPE' => 'mysql', 'DBS_SERVER' => env('DB_HOST'), diff --git a/tests/unit/workflow/engine/classes/DerivationTest.php b/tests/unit/workflow/engine/classes/DerivationTest.php index a8a07b06c..a3235d8d2 100644 --- a/tests/unit/workflow/engine/classes/DerivationTest.php +++ b/tests/unit/workflow/engine/classes/DerivationTest.php @@ -24,7 +24,7 @@ class DerivationTest extends TestCase /** * Call the setUp parent method */ - public function setUp() + public function setUp(): void { parent::setUp(); // TODO: Change the autogenerated stub @@ -39,7 +39,7 @@ class DerivationTest extends TestCase /** * Call the tearDown method */ - public function tearDown() + public function tearDown(): void { parent::tearDown(); // TODO: Change the autogenerated stub } @@ -119,23 +119,23 @@ class DerivationTest extends TestCase public function it_should_test_the_do_derivation_method_sending_variables_synchronously() { // Create the models - $user = factory(User::class)->create(); - $process = factory(Process::class)->create([ + $user = User::factory()->create(); + $process = Process::factory()->create([ 'PRO_CREATE_USER' => $user->USR_UID ]); - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'PRO_UID' => $process->PRO_UID, ]); - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'APP_INIT_USER' => $user->USR_UID, 'APP_CUR_USER' => $user->USR_UID ]); - $appDelegation = factory(Delegation::class)->create([ + $appDelegation = Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'APP_NUMBER' => $application->APP_NUMBER ]); - factory(SubApplication::class)->create([ + SubApplication::factory()->create([ 'APP_UID' => $application->APP_UID, 'APP_PARENT' => $application->APP_UID, 'DEL_INDEX_PARENT' => $appDelegation->DEL_INDEX @@ -203,35 +203,35 @@ class DerivationTest extends TestCase public function it_should_test_the_do_derivation_method_sending_variables_asynchronously() { // Create the models - $user = factory(User::class)->create(); - $process = factory(Process::class)->create([ + $user = User::factory()->create(); + $process = Process::factory()->create([ 'PRO_CREATE_USER' => $user->USR_UID ]); - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'TAS_USER' => $user->USR_UID ]); - factory(TaskUser::class)->create([ + TaskUser::factory()->create([ 'TAS_UID' => $task->TAS_UID, 'USR_UID' => $user->USR_UID ]); - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'APP_INIT_USER' => $user->USR_UID, 'APP_CUR_USER' => $user->USR_UID ]); - $appDelegation = factory(Delegation::class)->create([ + $appDelegation = Delegation::factory()->create([ 'TAS_UID' => $task->TAS_UID, 'APP_UID' => $application->APP_UID, 'APP_NUMBER' => $application->APP_NUMBER ]); - factory(SubApplication::class)->create([ + SubApplication::factory()->create([ 'APP_UID' => $application->APP_UID, 'APP_PARENT' => $application->APP_UID, 'DEL_INDEX_PARENT' => $appDelegation->DEL_INDEX, 'SA_STATUS' => 'FINISHED' ]); - factory(Route::class)->create([ + Route::factory()->create([ 'TAS_UID' => $task->TAS_UID, 'ROU_NEXT_TASK' => $task->TAS_UID, 'PRO_UID' => $process->PRO_UID diff --git a/tests/unit/workflow/engine/classes/LdapAdvancedTest.php b/tests/unit/workflow/engine/classes/LdapAdvancedTest.php index 7919570de..799739ca0 100644 --- a/tests/unit/workflow/engine/classes/LdapAdvancedTest.php +++ b/tests/unit/workflow/engine/classes/LdapAdvancedTest.php @@ -13,7 +13,7 @@ class LdapAdvancedTest extends TestCase /** * Method setUp. */ - public function setUp() + public function setUp(): void { parent::setUp(); $this->ldapAdvanced = new LdapAdvanced(); diff --git a/tests/unit/workflow/engine/classes/PmDynaformTest.php b/tests/unit/workflow/engine/classes/PmDynaformTest.php index eedd7ff95..08d00caca 100644 --- a/tests/unit/workflow/engine/classes/PmDynaformTest.php +++ b/tests/unit/workflow/engine/classes/PmDynaformTest.php @@ -1,7 +1,6 @@ truncateNonInitialModels(); } /** @@ -48,10 +47,9 @@ class PmDynaformTest extends TestCase { $arrayForm = $this->createArrayDynaform(); - $process = factory(Process::class, 1)->create(); + $process = Process::factory(1)->create(); - $dynaform = factory(Dynaform::class, 1)->create([ - 'DYN_ID' => 6, + $dynaform = Dynaform::factory(1)->create([ 'DYN_UID' => $arrayForm['items'][0]['id'], 'PRO_UID' => $process[0]->PRO_UID, 'DYN_CONTENT' => G::json_encode($arrayForm) @@ -72,10 +70,9 @@ class PmDynaformTest extends TestCase { $arrayForm = $this->createArrayDynaform(); - $process = factory(Process::class, 1)->create(); + $process = Process::factory(1)->create(); - $dynaform = factory(Dynaform::class, 1)->create([ - 'DYN_ID' => 5, + $dynaform = Dynaform::factory(1)->create([ 'DYN_UID' => $arrayForm['items'][0]['id'], 'PRO_UID' => $process[0]->PRO_UID, 'DYN_CONTENT' => G::json_encode($arrayForm) @@ -96,10 +93,9 @@ class PmDynaformTest extends TestCase { $arrayForm = $this->createArrayDynaform(); - $process = factory(Process::class, 1)->create(); + $process = Process::factory(1)->create(); - $dynaform = factory(Dynaform::class, 1)->create([ - 'DYN_ID' => 5, + $dynaform = Dynaform::factory(1)->create([ 'DYN_UID' => $arrayForm['items'][0]['id'], 'PRO_UID' => $process[0]->PRO_UID, 'DYN_CONTENT' => G::json_encode($arrayForm) @@ -120,10 +116,9 @@ class PmDynaformTest extends TestCase { $arrayForm = $this->createArrayDynaform(); - $process = factory(Process::class, 1)->create(); + $process = Process::factory(1)->create(); - $dynaform = factory(Dynaform::class, 1)->create([ - 'DYN_ID' => 5, + $dynaform = Dynaform::factory(1)->create([ 'DYN_UID' => $arrayForm['items'][0]['id'], 'PRO_UID' => $process[0]->PRO_UID, 'DYN_CONTENT' => G::json_encode($arrayForm) @@ -144,10 +139,9 @@ class PmDynaformTest extends TestCase { $arrayForm = $this->createArrayDynaform(); - $process = factory(Process::class, 1)->create(); + $process = Process::factory(1)->create(); - $dynaform = factory(Dynaform::class, 1)->create([ - 'DYN_ID' => 5, + $dynaform = Dynaform::factory(1)->create([ 'DYN_UID' => $arrayForm['items'][0]['id'], 'PRO_UID' => $process[0]->PRO_UID, 'DYN_CONTENT' => G::json_encode($arrayForm) @@ -169,10 +163,9 @@ class PmDynaformTest extends TestCase { $arrayForm = $this->createArrayDynaform(); - $process = factory(Process::class, 1)->create(); + $process = Process::factory(1)->create(); - $dynaform = factory(Dynaform::class, 1)->create([ - 'DYN_ID' => 5, + $dynaform = Dynaform::factory(1)->create([ 'DYN_UID' => $arrayForm['items'][0]['id'], 'PRO_UID' => $process[0]->PRO_UID, 'DYN_CONTENT' => G::json_encode($arrayForm) @@ -194,10 +187,9 @@ class PmDynaformTest extends TestCase { $arrayForm = $this->createArrayDynaform(); - $process = factory(Process::class, 1)->create(); + $process = Process::factory(1)->create(); - $dynaform = factory(Dynaform::class, 1)->create([ - 'DYN_ID' => 4, + $dynaform = Dynaform::factory(1)->create([ 'DYN_UID' => $arrayForm['items'][0]['id'], 'PRO_UID' => $process[0]->PRO_UID, 'DYN_CONTENT' => G::json_encode($arrayForm) @@ -223,10 +215,9 @@ class PmDynaformTest extends TestCase { $arrayForm = $this->createArrayDynaform(); - $process = factory(Process::class, 1)->create(); + $process = Process::factory(1)->create(); - $dynaform = factory(Dynaform::class, 1)->create([ - 'DYN_ID' => 6, + $dynaform = Dynaform::factory(1)->create([ 'DYN_UID' => $arrayForm['items'][0]['id'], 'PRO_UID' => $process[0]->PRO_UID, 'DYN_CONTENT' => G::json_encode($arrayForm) @@ -247,10 +238,9 @@ class PmDynaformTest extends TestCase { $arrayForm = $this->createArrayDynaform(); - $process = factory(Process::class, 1)->create(); + $process = Process::factory(1)->create(); - $dynaform = factory(Dynaform::class, 1)->create([ - 'DYN_ID' => 5, + $dynaform = Dynaform::factory(1)->create([ 'DYN_UID' => $arrayForm['items'][0]['id'], 'PRO_UID' => $process[0]->PRO_UID, 'DYN_CONTENT' => G::json_encode($arrayForm) @@ -271,10 +261,9 @@ class PmDynaformTest extends TestCase { $arrayForm = $this->createArrayDynaform(); - $process = factory(Process::class, 1)->create(); + $process = Process::factory(1)->create(); - $dynaform = factory(Dynaform::class, 1)->create([ - 'DYN_ID' => 3, + $dynaform = Dynaform::factory(1)->create([ 'DYN_UID' => $arrayForm['items'][0]['id'], 'PRO_UID' => $process[0]->PRO_UID, 'DYN_CONTENT' => G::json_encode($arrayForm) @@ -294,11 +283,10 @@ class PmDynaformTest extends TestCase */ public function it_should_return_null_when_not_exist_dynaform() { - $process = factory(Process::class, 1)->create(); + $process = Process::factory(1)->create(); $arrayForm = $this->createArrayDynaform(); - $dynaform = factory(Dynaform::class, 1)->create([ - 'DYN_ID' => 7, + $dynaform = Dynaform::factory(1)->create([ 'DYN_UID' => $arrayForm['items'][0]['id'], 'PRO_UID' => $process[0]->PRO_UID, 'DYN_CONTENT' => G::json_encode($arrayForm) @@ -330,19 +318,17 @@ class PmDynaformTest extends TestCase */ public function it_should_return_array_dynaforms_except_current_dynaform_in_second_execution() { - $process = factory(Process::class, 1)->create(); + $process = Process::factory(1)->create(); $arrayForm = $this->createArrayDynaform(); - $dynaform = factory(Dynaform::class, 1)->create([ - 'DYN_ID' => 7, + $dynaform = Dynaform::factory(1)->create([ 'DYN_UID' => $arrayForm['items'][0]['id'], 'PRO_UID' => $process[0]->PRO_UID, 'DYN_CONTENT' => G::json_encode($arrayForm) ]); $arrayForm2 = $this->createArrayDynaform(); - $dynaform2 = factory(Dynaform::class, 1)->create([ - 'DYN_ID' => 9, + $dynaform2 = Dynaform::factory(1)->create([ 'DYN_UID' => $arrayForm2['items'][0]['id'], 'PRO_UID' => $process[0]->PRO_UID, 'DYN_CONTENT' => G::json_encode($arrayForm2) @@ -364,19 +350,17 @@ class PmDynaformTest extends TestCase */ public function it_should_return_array_dynaforms_except_current_dynaform() { - $process = factory(Process::class, 1)->create(); + $process = Process::factory(1)->create(); $arrayForm = $this->createArrayDynaform(); - $dynaform = factory(Dynaform::class, 1)->create([ - 'DYN_ID' => 7, + $dynaform = Dynaform::factory(1)->create([ 'DYN_UID' => $arrayForm['items'][0]['id'], 'PRO_UID' => $process[0]->PRO_UID, 'DYN_CONTENT' => G::json_encode($arrayForm) ]); $arrayForm2 = $this->createArrayDynaform(); - $dynaform2 = factory(Dynaform::class, 1)->create([ - 'DYN_ID' => 9, + $dynaform2 = Dynaform::factory(1)->create([ 'DYN_UID' => $arrayForm2['items'][0]['id'], 'PRO_UID' => $process[0]->PRO_UID, 'DYN_CONTENT' => G::json_encode($arrayForm2) @@ -416,10 +400,9 @@ class PmDynaformTest extends TestCase { $arrayForm = $this->createArrayDynaform(); - $process = factory(Process::class, 1)->create(); + $process = Process::factory(1)->create(); - $dynaform = factory(Dynaform::class, 1)->create([ - 'DYN_ID' => 1, + $dynaform = Dynaform::factory(1)->create([ 'DYN_UID' => $arrayForm['items'][0]['id'], 'PRO_UID' => $process[0]->PRO_UID, 'DYN_CONTENT' => G::json_encode($arrayForm) @@ -443,10 +426,9 @@ class PmDynaformTest extends TestCase $arrayForm = $this->createArrayDynaform(); - $process = factory(Process::class, 1)->create(); + $process = Process::factory(1)->create(); - $dynaform = factory(Dynaform::class, 1)->create([ - 'DYN_ID' => 2, + $dynaform = Dynaform::factory(1)->create([ 'PRO_UID' => $process[0]->PRO_UID, 'DYN_CONTENT' => G::json_encode($arrayForm) ]); @@ -831,7 +813,7 @@ class PmDynaformTest extends TestCase { // Create a form without translations defined $arrayForm = $this->createArrayDynaform(); - $form = factory(Dynaform::class)->create([ + $form = Dynaform::factory()->create([ 'DYN_UID' => $arrayForm['items'][0]['id'], 'DYN_CONTENT' => G::json_encode($arrayForm) ]); @@ -841,7 +823,7 @@ class PmDynaformTest extends TestCase // Create a form with translations defined $arrayForm = $this->createArrayDynaform(); - $form = factory(Dynaform::class)->states('translations')->create([ + $form = Dynaform::factory()->translations()->create([ 'DYN_UID' => $arrayForm['items'][0]['id'], 'DYN_CONTENT' => G::json_encode($arrayForm) ]); @@ -861,7 +843,7 @@ class PmDynaformTest extends TestCase { $arrayForm = $this->createArrayDynaform(); // Create a translations related to ["es", "es-Es"] - $form = factory(Dynaform::class)->states('translations')->create([ + $form = Dynaform::factory()->translations()->create([ 'DYN_UID' => $arrayForm['items'][0]['id'], 'DYN_CONTENT' => G::json_encode($arrayForm) ]); @@ -963,7 +945,7 @@ class PmDynaformTest extends TestCase public function it_should_get_dynaform_title() { // Create a Dynaform - $dynaform = factory(Dynaform::class)->create([]); + $dynaform = Dynaform::factory()->create([]); // Instance the class to test $pmDynaform = new PmDynaform(); @@ -1082,10 +1064,10 @@ class PmDynaformTest extends TestCase $data2 = file_get_contents($pathData2); $json2 = json_decode($data2); - $dynaform = factory(Dynaform::class)->create([ + $dynaform = Dynaform::factory()->create([ 'DYN_CONTENT' => $data ]); - factory(Dynaform::class)->create([ + Dynaform::factory()->create([ 'DYN_CONTENT' => $data, 'PRO_UID' => $dynaform->PRO_UID ]); @@ -1160,10 +1142,10 @@ class PmDynaformTest extends TestCase $data2 = file_get_contents($pathData2); $json2 = json_decode($data2); - $dynaform = factory(Dynaform::class)->create([ + $dynaform = Dynaform::factory()->create([ 'DYN_CONTENT' => $data ]); - factory(Dynaform::class)->create([ + Dynaform::factory()->create([ 'DYN_CONTENT' => $data, 'PRO_UID' => $dynaform->PRO_UID ]); diff --git a/tests/unit/workflow/engine/classes/PmFunctions/ExecuteQueryTest.php b/tests/unit/workflow/engine/classes/PmFunctions/ExecuteQueryTest.php index 2a068fd73..166600175 100644 --- a/tests/unit/workflow/engine/classes/PmFunctions/ExecuteQueryTest.php +++ b/tests/unit/workflow/engine/classes/PmFunctions/ExecuteQueryTest.php @@ -4,7 +4,6 @@ namespace Tests\unit\workflow\engine\classes\PmFunctions; use Faker\Factory; use G; -use Illuminate\Foundation\Testing\DatabaseTransactions; use ProcessMaker\Model\DbSource; use ProcessMaker\Model\ProcessCategory; use ProcessMaker\Model\User; @@ -22,10 +21,10 @@ class ExecuteQueryTest extends TestCase protected $contentSystemTables = "tables = 'APPLICATION|APP_SEQUENCE|APP_DELEGATION|APP_DOCUMENT|APP_MESSAGE|APP_OWNER|CONFIGURATION|CONTENT|DEPARTMENT|DYNAFORM|GROUPWF|GROUP_USER|HOLIDAY|INPUT_DOCUMENT|ISO_COUNTRY|ISO_LOCATION|ISO_SUBDIVISION|LANGUAGE|LEXICO|OUTPUT_DOCUMENT|PROCESS|PROCESS_OWNER|REPORT_TABLE|REPORT_VAR|ROUTE|STEP|STEP_TRIGGER|SWIMLANES_ELEMENTS|TASK|TASK_USER|TRANSLATION|TRIGGERS|USERS|APP_THREAD|APP_DELAY|PROCESS_USER|SESSION|DB_SOURCE|STEP_SUPERVISOR|OBJECT_PERMISSION|CASE_TRACKER|CASE_TRACKER_OBJECT|CASE_CONSOLIDATED|STAGE|SUB_PROCESS|SUB_APPLICATION|LOGIN_LOG|USERS_PROPERTIES|ADDITIONAL_TABLES|FIELDS|SHADOW_TABLE|EVENT|GATEWAY|APP_EVENT|APP_CACHE_VIEW|DIM_TIME_DELEGATE|DIM_TIME_COMPLETE|APP_HISTORY|APP_FOLDER|FIELD_CONDITION|LOG_CASES_SCHEDULER|CASE_SCHEDULER|CALENDAR_DEFINITION|CALENDAR_BUSINESS_HOURS|CALENDAR_HOLIDAYS|CALENDAR_ASSIGNMENTS|PROCESS_CATEGORY|APP_NOTES|DASHLET|DASHLET_INSTANCE|APP_SOLR_QUEUE|SEQUENCES|SESSION_STORAGE|PROCESS_FILES|WEB_ENTRY|OAUTH_ACCESS_TOKENS|OAUTH_AUTHORIZATION_CODES|OAUTH_CLIENTS|OAUTH_REFRESH_TOKENS|OAUTH_SCOPES|PMOAUTH_USER_ACCESS_TOKENS|BPMN_PROJECT|BPMN_PROCESS|BPMN_ACTIVITY|BPMN_ARTIFACT|BPMN_DIAGRAM|BPMN_BOUND|BPMN_DATA|BPMN_EVENT|BPMN_FLOW|BPMN_GATEWAY|BPMN_LANESET|BPMN_LANE|BPMN_PARTICIPANT|BPMN_EXTENSION|BPMN_DOCUMENTATION|PROCESS_VARIABLES|APP_TIMEOUT_ACTION_EXECUTED|ADDONS_STORE|ADDONS_MANAGER|LICENSE_MANAGER|APP_ASSIGN_SELF_SERVICE_VALUE|APP_ASSIGN_SELF_SERVICE_VALUE_GROUP|LIST_INBOX|LIST_PARTICIPATED_HISTORY|LIST_PARTICIPATED_LAST|LIST_COMPLETED|LIST_PAUSED|LIST_CANCELED|LIST_MY_INBOX|LIST_UNASSIGNED|LIST_UNASSIGNED_GROUP|MESSAGE_TYPE|MESSAGE_TYPE_VARIABLE|EMAIL_SERVER|WEB_ENTRY_EVENT|MESSAGE_EVENT_DEFINITION|MESSAGE_EVENT_RELATION|MESSAGE_APPLICATION|ELEMENT_TASK_RELATION|ABE_CONFIGURATION|ABE_REQUESTS|ABE_RESPONSES|USR_REPORTING|PRO_REPORTING|DASHBOARD|DASHBOARD_INDICATOR|DASHBOARD_DAS_IND|CATALOG|SCRIPT_TASK|TIMER_EVENT|EMAIL_EVENT|NOTIFICATION_DEVICE|GMAIL_RELABELING|NOTIFICATION_QUEUE|PLUGINS_REGISTRY|APP_DATA_CHANGE_LOG|JOBS_PENDING|JOBS_FAILED|RBAC_PERMISSIONS|RBAC_ROLES|RBAC_ROLES_PERMISSIONS|RBAC_SYSTEMS|RBAC_USERS|RBAC_USERS_ROLES|RBAC_AUTHENTICATION_SOURCE|'"; protected $oldContentSystemTables = ""; - public function setUp() + public function setUp(): void { parent::setUp(); - ProcessCategory::truncate(); + $this->truncateNonInitialModels(); $this->oldContentSystemTables = ""; $path = PATH_CONFIG . $this->nameSystemTables; if (file_exists($path)) { @@ -34,7 +33,7 @@ class ExecuteQueryTest extends TestCase file_put_contents($path, $this->contentSystemTables); } - public function tearDown() + public function tearDown(): void { parent::tearDown(); $path = PATH_CONFIG . $this->nameSystemTables; @@ -47,7 +46,7 @@ class ExecuteQueryTest extends TestCase */ public function it_must_return_the_result_of_execute_query_method() { - $user = factory(User::class, 5)->create(); + $user = User::factory(5)->create(); $user = $user->sortByDesc('USR_UID')->values()->map(function($item) { $result = [ @@ -139,7 +138,7 @@ class ExecuteQueryTest extends TestCase $id = $faker->unique()->numberBetween(1, 10000000); $newName = str_replace("'", " ", $faker->name); - $category = factory(ProcessCategory::class)->create([ + $category = ProcessCategory::factory()->create([ 'CATEGORY_ID' => $id ]); $expected = $category->toArray(); @@ -176,7 +175,7 @@ class ExecuteQueryTest extends TestCase $id = $faker->unique()->numberBetween(1, 10000000); $newName = str_replace("'", " ", $faker->name); - $category = factory(ProcessCategory::class)->create([ + $category = ProcessCategory::factory()->create([ 'CATEGORY_ID' => $id ]); $expected = $category->toArray(); @@ -205,7 +204,7 @@ class ExecuteQueryTest extends TestCase { $this->expectException(SQLException::class); $database = env('DB_DATABASE'); - $category = factory(ProcessCategory::class)->create(); + $category = ProcessCategory::factory()->create(); $sql = "" . "DELETE FROM {$database}.PROCESS_CATEGORY " @@ -228,7 +227,7 @@ class ExecuteQueryTest extends TestCase public function this_connects_to_an_external_database_using_the_execute_query_method() { $dbName = env('DB_DATABASE'); - $dbSource = factory(DbSource::class)->create([ + $dbSource = DbSource::factory()->create([ 'DBS_TYPE' => 'mysql', 'DBS_SERVER' => env('DB_HOST'), 'DBS_DATABASE_NAME' => $dbName, @@ -253,10 +252,10 @@ class ExecuteQueryTest extends TestCase */ public function this_connects_to_an_external_oracle_database_using_the_execute_query_method() { - $this->markTestIncomplete('This test has not been implemented yet.'); + $this->markTestSkipped('This test has not been implemented yet.'); $dbName = "XE"; - $dbSource = factory(DbSource::class)->create([ + $dbSource = DbSource::factory()->create([ 'DBS_TYPE' => 'oracle', 'DBS_CONNECTION_TYPE' => 'NORMAL', 'DBS_SERVER' => 'localhost', @@ -322,7 +321,7 @@ class ExecuteQueryTest extends TestCase $id = $faker->unique()->numberBetween(1, 10000000); $newName = str_replace("'", " ", $faker->name); - $category = factory(ProcessCategory::class)->create([ + $category = ProcessCategory::factory()->create([ 'CATEGORY_ID' => $id ]); $expected = $category->toArray(); diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFAddCaseNoteTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFAddCaseNoteTest.php index 7a030d362..8be936730 100644 --- a/tests/unit/workflow/engine/classes/PmFunctions/PMFAddCaseNoteTest.php +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFAddCaseNoteTest.php @@ -23,7 +23,7 @@ class PMFAddCaseNoteTest extends TestCase public function it_add_case_notes() { // Create notes - $table = factory(Delegation::class)->states('foreign_keys')->create(); + $table = Delegation::factory()->foreign_keys()->create(); // Force commit for propel DB::commit(); $result = PMFAddCaseNote($table->APP_UID, $table->PRO_UID, $table->TAS_UID, $table->USR_UID, 'note'); diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFAssignUserToGroupTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFAssignUserToGroupTest.php index 4a50e0ec5..124ad70bc 100644 --- a/tests/unit/workflow/engine/classes/PmFunctions/PMFAssignUserToGroupTest.php +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFAssignUserToGroupTest.php @@ -26,15 +26,15 @@ class PMFAssignUserToGroupTest extends TestCase { // Create user global $RBAC; - $user = factory(User::class)->create(); - factory(RbacUsers::class)->create([ + $user = User::factory()->create(); + RbacUsers::factory()->create([ 'USR_UID' => $user->USR_UID, 'USR_USERNAME' => $user->USR_USERNAME, 'USR_FIRSTNAME' => $user->USR_FIRSTNAME, 'USR_LASTNAME' => $user->USR_LASTNAME ]); // Create group - $group = factory(Groupwf::class)->create(); + $group = Groupwf::factory()->create(); DB::commit(); $result = PMFAssignUserToGroup($user->USR_UID, $group->GRP_UID); $this->assertNotEmpty($result); diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFCaseInformationTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFCaseInformationTest.php index 07b8f56e1..15fec1072 100644 --- a/tests/unit/workflow/engine/classes/PmFunctions/PMFCaseInformationTest.php +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFCaseInformationTest.php @@ -1,6 +1,6 @@ states('foreign_keys')->create(); + $table = Application::factory()->foreign_keys()->create(); // Force commit for propel DB::commit(); // Call the funtion @@ -74,8 +74,8 @@ class PMFCaseInformation extends TestCase */ public function it_should_test_this_pmfunction_index_parameter() { - $application = factory(Application::class)->states('todo')->create(); - $table = factory(Delegation::class)->states('foreign_keys')->create([ + $application = Application::factory()->todo()->create(); + $table = Delegation::factory()->foreign_keys()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'APP_UID' => $application->APP_UID, ]); @@ -104,8 +104,8 @@ class PMFCaseInformation extends TestCase */ public function it_should_test_this_pmfunction_app_data_parameter() { - $application = factory(Application::class)->states('todo')->create(); - $table = factory(Delegation::class)->states('foreign_keys')->create([ + $application = Application::factory()->todo()->create(); + $table = Delegation::factory()->foreign_keys()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'APP_UID' => $application->APP_UID, ]); diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFCaseListTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFCaseListTest.php index 623592931..195e4603c 100644 --- a/tests/unit/workflow/engine/classes/PmFunctions/PMFCaseListTest.php +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFCaseListTest.php @@ -24,8 +24,8 @@ class PMFCaseListTest extends TestCase public function it_return_list_of_cases() { // Create delegation - $table = factory(Delegation::class)->states('foreign_keys')->create(); - factory(AppThread::class)->create([ + $table = Delegation::factory()->foreign_keys()->create(); + AppThread::factory()->create([ 'APP_THREAD_STATUS' => 'OPEN', 'APP_UID' => $table->APP_UID ]); diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFCreateUserTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFCreateUserTest.php index 543a5f5ca..9a24f41e0 100644 --- a/tests/unit/workflow/engine/classes/PmFunctions/PMFCreateUserTest.php +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFCreateUserTest.php @@ -25,8 +25,8 @@ class PMFCreateUserTest extends TestCase public function it_create_user() { // Create User - $user = factory(User::class)->create(); - factory(RbacUsers::class)->create([ + $user = User::factory()->create(); + RbacUsers::factory()->create([ 'USR_UID' => $user->USR_UID, 'USR_USERNAME' => $user->USR_USERNAME, 'USR_FIRSTNAME' => $user->USR_FIRSTNAME, diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFDeleteCaseTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFDeleteCaseTest.php index ac923c6d8..726898118 100644 --- a/tests/unit/workflow/engine/classes/PmFunctions/PMFDeleteCaseTest.php +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFDeleteCaseTest.php @@ -25,8 +25,8 @@ class PMFDeleteCaseTest extends TestCase public function it_should_test_this_pmfunction_default_parameters() { $this->expectException(Exception::class); - $table = factory(Delegation::class)->states('foreign_keys')->create(); - factory(Triggers::class)->create([ + $table = Delegation::factory()->foreign_keys()->create(); + Triggers::factory()->create([ 'PRO_UID' => $table->PRO_UID ]); // Force commit for propel diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFGetCaseNotesTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFGetCaseNotesTest.php index 8356e14ca..59a925a84 100644 --- a/tests/unit/workflow/engine/classes/PmFunctions/PMFGetCaseNotesTest.php +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFGetCaseNotesTest.php @@ -24,8 +24,8 @@ class PMFGetCaseNotesTest extends TestCase public function it_get_case_notes() { // Create notes - $user = factory(User::class)->create(); - $table = factory(AppNotes::class)->create([ + $user = User::factory()->create(); + $table = AppNotes::factory()->create([ 'USR_UID' => $user->USR_UID ]); // Force commit for propel diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFGetGroupNameTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFGetGroupNameTest.php index 02b8edf89..8c291e009 100644 --- a/tests/unit/workflow/engine/classes/PmFunctions/PMFGetGroupNameTest.php +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFGetGroupNameTest.php @@ -23,7 +23,7 @@ class PMFGetGroupNameTest extends TestCase public function it_get_group_name() { // Create group - $group = factory(Groupwf::class)->create(); + $group = Groupwf::factory()->create(); DB::commit(); $result = PMFGetGroupName($group->GRP_TITLE, 'en'); $this->assertFalse($result); diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFGetGroupUIDTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFGetGroupUIDTest.php index b734415fd..89ceae571 100644 --- a/tests/unit/workflow/engine/classes/PmFunctions/PMFGetGroupUIDTest.php +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFGetGroupUIDTest.php @@ -22,7 +22,7 @@ class PMFGetGroupUIDTest extends TestCase public function it_group_uid() { // Create group - $group = factory(Groupwf::class)->create(); + $group = Groupwf::factory()->create(); $result = PMFGetGroupUID($group->GRP_UID); $this->assertFalse($result); } diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFGetGroupUsersTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFGetGroupUsersTest.php index 7158be644..410d5bc88 100644 --- a/tests/unit/workflow/engine/classes/PmFunctions/PMFGetGroupUsersTest.php +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFGetGroupUsersTest.php @@ -23,7 +23,7 @@ class PMFGetGroupUsersTest extends TestCase public function it_return_list_of_groups() { // Create group - $group = factory(Groupwf::class)->create(); + $group = Groupwf::factory()->create(); DB::commit(); $result = PMFGetGroupUsers($group->GRP_UID); $this->assertEmpty($result); diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFGetProcessUidByNameTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFGetProcessUidByNameTest.php index 3bf26bcdd..e32d67d3b 100644 --- a/tests/unit/workflow/engine/classes/PmFunctions/PMFGetProcessUidByNameTest.php +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFGetProcessUidByNameTest.php @@ -23,7 +23,7 @@ class PMFGetProcessUidByNameTest extends TestCase public function it_return_process() { // Create process - $table = factory(Process::class)->create(); + $table = Process::factory()->create(); DB::commit(); $result = PMFGetProcessUidByName($table->PRO_TITLE); $this->assertNotEmpty($result); diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFGetTaskNameTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFGetTaskNameTest.php index 298b91d4d..fb942b7e9 100644 --- a/tests/unit/workflow/engine/classes/PmFunctions/PMFGetTaskNameTest.php +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFGetTaskNameTest.php @@ -23,7 +23,7 @@ class PMFGetTaskNameTest extends TestCase public function it_return_task_name() { // Create task - $task = factory(Task::class)->create(); + $task = Task::factory()->create(); DB::commit(); $result = PMFGetTaskName($task->TAS_UID); $this->assertNotEmpty($result); diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFGetTaskUIDTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFGetTaskUIDTest.php index e1db6e911..2519d10e8 100644 --- a/tests/unit/workflow/engine/classes/PmFunctions/PMFGetTaskUIDTest.php +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFGetTaskUIDTest.php @@ -23,7 +23,7 @@ class PMFGetTaskUIDTest extends TestCase public function it_return_task_uid() { // Create task - $table = factory(Task::class)->states('foreign_keys')->create(); + $table = Task::factory()->foreign_keys()->create(); DB::commit(); $result = PMFGetTaskUID($table->TAS_TITLE); $this->assertFalse($result); diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFGetUserEmailAddressTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFGetUserEmailAddressTest.php index 4750e1108..490a9e44c 100644 --- a/tests/unit/workflow/engine/classes/PmFunctions/PMFGetUserEmailAddressTest.php +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFGetUserEmailAddressTest.php @@ -22,7 +22,7 @@ class PMFGetUserEmailAddressTest extends TestCase { // Create User global $RBAC; - $user = factory(User::class)->create(); + $user = User::factory()->create(); DB::commit(); $result = PMFGetUserEmailAddress([$user->USR_UID], null); $this->assertNotEmpty($result); diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFGroupListTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFGroupListTest.php index 29ee9143c..566e4fdac 100644 --- a/tests/unit/workflow/engine/classes/PmFunctions/PMFGroupListTest.php +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFGroupListTest.php @@ -23,7 +23,7 @@ class PMFGroupListTest extends TestCase public function it_return_list_of_groups() { // Create group - factory(Groupwf::class)->create(); + Groupwf::factory()->create(); DB::commit(); $result = PMFGroupList(); $this->assertNotEmpty($result); diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFInformationUserTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFInformationUserTest.php index 51606e76a..55e0442ee 100644 --- a/tests/unit/workflow/engine/classes/PmFunctions/PMFInformationUserTest.php +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFInformationUserTest.php @@ -24,7 +24,7 @@ class PMFInformationUserTest extends TestCase { // Create User global $RBAC; - $user = factory(User::class)->create(); + $user = User::factory()->create(); DB::commit(); $result = PMFInformationUser($user->USR_UID); $this->assertNotEmpty($result); diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFNewCaseImpersonateTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFNewCaseImpersonateTest.php index 8766b32a8..dcd2c8485 100644 --- a/tests/unit/workflow/engine/classes/PmFunctions/PMFNewCaseImpersonateTest.php +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFNewCaseImpersonateTest.php @@ -1,6 +1,6 @@ states('foreign_keys')->create(); + $table = Delegation::factory()->foreign_keys()->create(); // Force commit for propel DB::commit(); $result = PMFNewCaseImpersonate($table->PRO_UID, $table->USR_UID, [], ''); diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFNewCaseTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFNewCaseTest.php index 76aafbfbf..b562950d6 100644 --- a/tests/unit/workflow/engine/classes/PmFunctions/PMFNewCaseTest.php +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFNewCaseTest.php @@ -1,6 +1,6 @@ states('foreign_keys')->create(); + $table = Delegation::factory()->foreign_keys()->create(); // Force commit for propel DB::commit(); $result = PMFNewCase($table->PRO_UID, $table->USR_UID, $table->TAS_UID, [], null); diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFNewUserTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFNewUserTest.php index 23ff5da49..4dd61e67d 100644 --- a/tests/unit/workflow/engine/classes/PmFunctions/PMFNewUserTest.php +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFNewUserTest.php @@ -2,8 +2,6 @@ namespace Tests\unit\workflow\engine\classes\PmFunctions; -use Illuminate\Foundation\Testing\DatabaseTransactions; -use Illuminate\Support\Facades\DB; use ProcessMaker\Model\GroupUser; use ProcessMaker\Model\Groupwf; use ProcessMaker\Model\RbacUsers; @@ -19,7 +17,7 @@ class PMFNewUserTest extends TestCase /** * Creates the setUp method */ - public function setUp() + public function setUp(): void { parent::setup(); @@ -37,7 +35,7 @@ class PMFNewUserTest extends TestCase /** * Creates the tearDown method */ - public function tearDown() + public function tearDown(): void { parent::tearDown(); } @@ -56,7 +54,7 @@ class PMFNewUserTest extends TestCase $RBAC->initRBAC(); $RBAC->loadUserRolePermission('PROCESSMAKER', $_SESSION['USER_LOGGED']); - $group = factory(Groupwf::class)->create(); + $group = Groupwf::factory()->create(); // Active $result = PMFNewUser("test", "Test123*", "test", "test", "test@test.com", "PROCESSMAKER_ADMIN", null, null, $group['GRP_UID']); diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFProcessListTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFProcessListTest.php index b15b437f8..0b2ab5e01 100644 --- a/tests/unit/workflow/engine/classes/PmFunctions/PMFProcessListTest.php +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFProcessListTest.php @@ -22,7 +22,7 @@ class PMFProcessListTest extends TestCase public function it_return_list_of_process() { // Create delegation - factory(Process::class)->create(); + Process::factory()->create(); $result = PMFProcessList(); $this->assertNotEmpty($result); } diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFRemoveUsersFromGroupTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFRemoveUsersFromGroupTest.php index 5f84140a9..1a25dd16b 100644 --- a/tests/unit/workflow/engine/classes/PmFunctions/PMFRemoveUsersFromGroupTest.php +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFRemoveUsersFromGroupTest.php @@ -25,9 +25,9 @@ class PMFRemoveUsersFromGroupTest extends TestCase public function it_remove_user_group() { // Create group - $user = factory(User::class)->create(); - $group = factory(Groupwf::class)->create(); - $groupUser = factory(GroupUser::class)->create([ + $user = User::factory()->create(); + $group = Groupwf::factory()->create(); + $groupUser = GroupUser::factory()->create([ 'GRP_UID' => $group->GRP_UID, 'GRP_ID' => $group->GRP_ID, 'USR_UID' =>$user->USR_UID diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFRemoveUsersToGroupTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFRemoveUsersToGroupTest.php index 3c35b59f7..4c34ce18d 100644 --- a/tests/unit/workflow/engine/classes/PmFunctions/PMFRemoveUsersToGroupTest.php +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFRemoveUsersToGroupTest.php @@ -25,9 +25,9 @@ class PMFRemoveUsersToGroupTest extends TestCase public function it_remove_user_group() { // Create group - $user = factory(User::class)->create(); - $group = factory(Groupwf::class)->create(); - $groupUser = factory(GroupUser::class)->create([ + $user = User::factory()->create(); + $group = Groupwf::factory()->create(); + $groupUser = GroupUser::factory()->create([ 'GRP_UID' => $group->GRP_UID, 'GRP_ID' => $group->GRP_ID, 'USR_UID' =>$user->USR_UID diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFRoleListTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFRoleListTest.php index 89d18e9ef..1dd44a461 100644 --- a/tests/unit/workflow/engine/classes/PmFunctions/PMFRoleListTest.php +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFRoleListTest.php @@ -24,7 +24,7 @@ class PMFRoleListTest extends TestCase { // Create roles global $RBAC; - factory(RbacRoles::class)->create(); + RbacRoles::factory()->create(); DB::commit(); $result = PMFRoleList(); $this->assertNotEmpty($result); diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFSendMessageTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFSendMessageTest.php index 276366f6d..37bfc6b14 100644 --- a/tests/unit/workflow/engine/classes/PmFunctions/PMFSendMessageTest.php +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFSendMessageTest.php @@ -39,7 +39,7 @@ class PMFSendMessageTest extends TestCase mkdir(PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . $proUid); } file_put_contents(PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . $proUid . PATH_SEP . 'template.html', $data); - $template = factory(\ProcessMaker\Model\ProcessFiles::class)->create([ + $template = \ProcessMaker\Model\ProcessFiles::factory()->create([ 'PRO_UID' => $proUid, 'USR_UID' => $usrUid, 'PRF_PATH' => 'template.html' @@ -56,7 +56,7 @@ class PMFSendMessageTest extends TestCase { $passwordEnv = env('emailAccountPassword'); $password = G::encrypt("hash:" . $passwordEnv, 'EMAILENCRYPT'); - $emailServer = factory(EmailServerModel::class)->create([ + $emailServer = EmailServerModel::factory()->create([ 'MESS_ENGINE' => env('emailEngine'), 'MESS_SERVER' => env('emailServer'), 'MESS_PORT' => env('emailPort'), @@ -82,11 +82,11 @@ class PMFSendMessageTest extends TestCase */ public function it_send_message_related_to_same_case() { - $user = factory(User::class)->create(); - $process = factory(Process::class)->create([ + $user = User::factory()->create(); + $process = Process::factory()->create([ 'PRO_CREATE_USER' => $user->USR_UID ]); - $app = factory(Application::class)->create([ + $app = Application::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'APP_INIT_USER' => $user->USR_UID, 'APP_CUR_USER' => $user->USR_UID @@ -111,10 +111,10 @@ class PMFSendMessageTest extends TestCase */ public function it_send_message_related_to_different_case() { - $user = factory(User::class)->create(); - $process = factory(Process::class)->create(); - $app = factory(Application::class)->create(['PRO_UID' => $process->PRO_UID]); - $app2 = factory(Application::class)->create(['PRO_UID' => $process->PRO_UID]); + $user = User::factory()->create(); + $process = Process::factory()->create(); + $app = Application::factory()->create(['PRO_UID' => $process->PRO_UID]); + $app2 = Application::factory()->create(['PRO_UID' => $process->PRO_UID]); $template = $this->createTemplate($process->PRO_UID, $user->USR_UID); $emailServer = $this->createEmailServer(); // Set different case in session diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFTaskCaseTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFTaskCaseTest.php index dd0f4e639..e1e026d8a 100644 --- a/tests/unit/workflow/engine/classes/PmFunctions/PMFTaskCaseTest.php +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFTaskCaseTest.php @@ -23,8 +23,8 @@ class PMFTaskCaseTest extends TestCase */ public function it_return_pending_tasks() { - $task = factory(Task::class)->create(); - $table = factory(Delegation::class)->states('foreign_keys')->create([ + $task = Task::factory()->create(); + $table = Delegation::factory()->foreign_keys()->create([ 'TAS_ID' => $task->TAS_ID, 'TAS_UID' => $task->TAS_UID ]); diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFTaskListTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFTaskListTest.php index a06d5728f..4a73dfbc9 100644 --- a/tests/unit/workflow/engine/classes/PmFunctions/PMFTaskListTest.php +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFTaskListTest.php @@ -25,11 +25,11 @@ class PMFTaskListTest extends TestCase public function it_return_pending_tasks() { // Create task - $task = factory(Task::class)->create(); + $task = Task::factory()->create(); // Create user - $user = factory(User::class)->create(); + $user = User::factory()->create(); // Assign a user in the task - factory(TaskUser::class)->create([ + TaskUser::factory()->create([ 'TAS_UID' => $task->TAS_UID, 'USR_UID' => $user->USR_UID, 'TU_RELATION' => 1, //Related to the user diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFTasksListByProcessIdTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFTasksListByProcessIdTest.php index 81867df76..590011bb7 100644 --- a/tests/unit/workflow/engine/classes/PmFunctions/PMFTasksListByProcessIdTest.php +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFTasksListByProcessIdTest.php @@ -23,7 +23,7 @@ class PMFTasksListByProcessIdTest extends TestCase public function it_return_process_tasks() { // Create task - $task = factory(Task::class)->create(); + $task = Task::factory()->create(); DB::commit(); $result = PMFTasksListByProcessId($task->PRO_UID); $this->assertNotEmpty($result); diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFUnpauseCaseTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFUnpauseCaseTest.php index 5decfe3de..01f496de6 100644 --- a/tests/unit/workflow/engine/classes/PmFunctions/PMFUnpauseCaseTest.php +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFUnpauseCaseTest.php @@ -25,7 +25,7 @@ class PMFUnpauseCaseTest extends TestCase public function it_should_test_this_pmfunction_default_parameters() { $this->expectException(Exception::class); - $table = factory(Delegation::class)->states('foreign_keys')->create(); + $table = Delegation::factory()->foreign_keys()->create(); // Force commit for propel DB::commit(); $result = PMFUnpauseCase($table->APP_UID, $table->DEL_INDEX, $table->USR_UID); diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFUpdateUserTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFUpdateUserTest.php index 284621bfc..a26177ecf 100644 --- a/tests/unit/workflow/engine/classes/PmFunctions/PMFUpdateUserTest.php +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFUpdateUserTest.php @@ -24,7 +24,7 @@ class PMFUpdateUserTest extends TestCase { // Create User global $RBAC; - $user = factory(User::class)->create(); + $user = User::factory()->create(); DB::commit(); $result = PMFUpdateUser($user->USR_UID, $user->USR_USERNAME, 'John A.'); $this->assertEquals(0, $result); diff --git a/tests/unit/workflow/engine/classes/PmFunctions/PMFUserListTest.php b/tests/unit/workflow/engine/classes/PmFunctions/PMFUserListTest.php index 6f91b52e4..bf2921fef 100644 --- a/tests/unit/workflow/engine/classes/PmFunctions/PMFUserListTest.php +++ b/tests/unit/workflow/engine/classes/PmFunctions/PMFUserListTest.php @@ -22,7 +22,7 @@ class PMFUserListTest extends TestCase public function it_return_list_of_users() { // Create user - $user = factory(User::class)->create(); + $user = User::factory()->create(); $result = PMFUserList(); $this->assertNotEmpty($result); } diff --git a/tests/unit/workflow/engine/classes/PmFunctions/UserInfoTest.php b/tests/unit/workflow/engine/classes/PmFunctions/UserInfoTest.php index d95f74e1d..61f96f827 100644 --- a/tests/unit/workflow/engine/classes/PmFunctions/UserInfoTest.php +++ b/tests/unit/workflow/engine/classes/PmFunctions/UserInfoTest.php @@ -22,7 +22,7 @@ class UserInfoTest extends TestCase { // Create User global $RBAC; - $user = factory(User::class)->create(); + $user = User::factory()->create(); DB::commit(); $result = userInfo($user->USR_UID); $this->assertNotEmpty($result); diff --git a/tests/unit/workflow/engine/classes/PmTableTest.php b/tests/unit/workflow/engine/classes/PmTableTest.php index 7de49c917..82c8812c5 100644 --- a/tests/unit/workflow/engine/classes/PmTableTest.php +++ b/tests/unit/workflow/engine/classes/PmTableTest.php @@ -2,7 +2,7 @@ use Tests\TestCase; -class PmTablesTest extends TestCase +class PmTableTest extends TestCase { /** * Check if the "removePmtPropelFolder" is working correctly diff --git a/tests/unit/workflow/engine/classes/ProcessesTest.php b/tests/unit/workflow/engine/classes/ProcessesTest.php index 513efa943..373f2475a 100644 --- a/tests/unit/workflow/engine/classes/ProcessesTest.php +++ b/tests/unit/workflow/engine/classes/ProcessesTest.php @@ -26,15 +26,6 @@ class ProcessesTest extends TestCase 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->processes = new Processes(); } @@ -57,10 +48,10 @@ class ProcessesTest extends TestCase */ public function it_should_return_dynaforms() { - $process = factory(Process::class)->create()->first(); + $process = Process::factory()->create()->first(); $proUid = $process->PRO_UID; - $dynaforms = factory(Dynaform::class, 6) + $dynaforms = Dynaform::factory(6) ->create([ 'PRO_UID' => $proUid ]) @@ -109,10 +100,10 @@ class ProcessesTest extends TestCase */ public function it_should_return_input_documents() { - $process = factory(Process::class)->create()->first(); + $process = Process::factory()->create()->first(); $proUid = $process->PRO_UID; - $inputDocument = factory(InputDocument::class, 6) + $inputDocument = InputDocument::factory(6) ->create([ 'PRO_UID' => $proUid ]) @@ -161,10 +152,10 @@ class ProcessesTest extends TestCase */ public function it_should_return_output_documents() { - $process = factory(Process::class)->create()->first(); + $process = Process::factory()->create()->first(); $proUid = $process->PRO_UID; - $outputDocument = factory(OutputDocument::class, 6) + $outputDocument = OutputDocument::factory(6) ->create([ 'PRO_UID' => $proUid ]) @@ -443,7 +434,7 @@ class ProcessesTest extends TestCase */ public function it_should_get_workflow_data() { - $process = factory(\ProcessMaker\Model\Process::class)->create(); + $process = \ProcessMaker\Model\Process::factory()->create(); $processes = new Processes(); $result = $processes->getWorkflowData($process->PRO_UID); $this->assertNotNull($result); @@ -493,7 +484,7 @@ class ProcessesTest extends TestCase */ public function it_create_variables_from_import_old() { - $process = factory(\ProcessMaker\Model\Process::class)->create(); + $process = \ProcessMaker\Model\Process::factory()->create(); $attributes[] = [ 'VAR_UID' => G::generateUniqueID(), 'PRJ_UID' => $process->PRO_UID, @@ -526,7 +517,7 @@ class ProcessesTest extends TestCase */ public function it_create_variables_from_import_new() { - $process = factory(\ProcessMaker\Model\Process::class)->create(); + $process = \ProcessMaker\Model\Process::factory()->create(); $attributes[] = [ 'VAR_UID' => G::generateUniqueID(), 'PRJ_UID' => $process->PRO_UID, diff --git a/tests/unit/workflow/engine/classes/ReportTablesTest.php b/tests/unit/workflow/engine/classes/ReportTablesTest.php index fa1081bf8..7fd63152f 100644 --- a/tests/unit/workflow/engine/classes/ReportTablesTest.php +++ b/tests/unit/workflow/engine/classes/ReportTablesTest.php @@ -1,6 +1,5 @@ create([ + $user = User::factory()->create([ 'USR_UID' => $userUid ]); - $process = factory(Process::class)->create([ + $process = Process::factory()->create([ 'PRO_UID' => $processUid ]); - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'PRO_UID' => $process->PRO_UID ]); - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'APP_UID' => $applicationUid, 'APP_NUMBER' => $applicationNumber, @@ -825,7 +822,7 @@ class ReportTablesTest extends TestCase $grid = 'var_Grid1'; //assert exception - $this->expectException(Exception::class); + $this->expectException(TypeError::class); $reportTables = new ReportTables(); $reportTables->populateTable($tableName, $connectionShortName, $type, null, $proUid, $grid); diff --git a/tests/unit/workflow/engine/classes/SpoolRunTest.php b/tests/unit/workflow/engine/classes/SpoolRunTest.php index 942a7054c..4d472f970 100644 --- a/tests/unit/workflow/engine/classes/SpoolRunTest.php +++ b/tests/unit/workflow/engine/classes/SpoolRunTest.php @@ -83,11 +83,11 @@ class SpoolRunTest extends TestCase public function it_should_handle_gmail_oauth_option() { $appMsgUid = G::generateUniqueID(); - factory(AppMessage::class)->create([ + AppMessage::factory()->create([ 'APP_MSG_UID' => $appMsgUid ]); - $emailServer = factory(EmailServerModel::class)->states('GMAILAPI')->make(); + $emailServer = EmailServerModel::factory()->GMAILAPI()->make(); $config = $emailServer->toArray(); $config['SMTPSecure'] = 'ssl'; @@ -124,14 +124,14 @@ class SpoolRunTest extends TestCase { $string = ini_get("sendmail_path"); if (!is_executable($string)) { - $this->markTestIncomplete($string . " not found"); + $this->markTestSkipped($string . " not found"); } $appMsgUid = G::generateUniqueID(); - factory(AppMessage::class)->create([ + AppMessage::factory()->create([ 'APP_MSG_UID' => $appMsgUid ]); - $emailServer = factory(EmailServerModel::class)->create(); + $emailServer = EmailServerModel::factory()->create(); $config = $emailServer->toArray(); @@ -166,11 +166,11 @@ class SpoolRunTest extends TestCase public function it_should_handle_php_mailer_option() { $appMsgUid = G::generateUniqueID(); - factory(AppMessage::class)->create([ + AppMessage::factory()->create([ 'APP_MSG_UID' => $appMsgUid ]); - $emailServer = factory(EmailServerModel::class)->states('PHPMAILER')->make(); + $emailServer = EmailServerModel::factory()->PHPMAILER()->make(); $config = $emailServer->toArray(); $config['SMTPSecure'] = 'ssl'; @@ -207,11 +207,11 @@ class SpoolRunTest extends TestCase public function it_should_handle_utf8_characters() { $appMsgUid = G::generateUniqueID(); - factory(AppMessage::class)->create([ + AppMessage::factory()->create([ 'APP_MSG_UID' => $appMsgUid ]); - $emailServer = factory(EmailServerModel::class)->states('PHPMAILER')->make(); + $emailServer = EmailServerModel::factory()->PHPMAILER()->make(); $config = $emailServer->toArray(); $config['SMTPSecure'] = 'ssl'; @@ -250,11 +250,11 @@ class SpoolRunTest extends TestCase public function it_should_handle_attachment_files() { $appMsgUid = G::generateUniqueID(); - factory(AppMessage::class)->create([ + AppMessage::factory()->create([ 'APP_MSG_UID' => $appMsgUid ]); - $emailServer = factory(EmailServerModel::class)->states('PHPMAILER')->make(); + $emailServer = EmailServerModel::factory()->PHPMAILER()->make(); $config = $emailServer->toArray(); $config['SMTPSecure'] = 'ssl'; @@ -303,11 +303,11 @@ class SpoolRunTest extends TestCase public function it_should_handle_envelope_to() { $appMsgUid = G::generateUniqueID(); - factory(AppMessage::class)->create([ + AppMessage::factory()->create([ 'APP_MSG_UID' => $appMsgUid ]); - $emailServer = factory(EmailServerModel::class)->states('PHPMAILER')->make(); + $emailServer = EmailServerModel::factory()->PHPMAILER()->make(); $config = $emailServer->toArray(); $config['SMTPSecure'] = 'ssl'; @@ -345,11 +345,11 @@ class SpoolRunTest extends TestCase public function it_should_test_updateSpoolStatus_method() { $appMsgUid = G::generateUniqueID(); - factory(AppMessage::class)->create([ + AppMessage::factory()->create([ 'APP_MSG_UID' => $appMsgUid ]); - $emailServer = factory(EmailServerModel::class)->states('PHPMAILER')->make(); + $emailServer = EmailServerModel::factory()->PHPMAILER()->make(); $config = $emailServer->toArray(); $config['SMTPSecure'] = 'ssl'; diff --git a/tests/unit/workflow/engine/classes/WorkflowToolsTest.php b/tests/unit/workflow/engine/classes/WorkflowToolsTest.php index e863b2cbe..617fb9015 100644 --- a/tests/unit/workflow/engine/classes/WorkflowToolsTest.php +++ b/tests/unit/workflow/engine/classes/WorkflowToolsTest.php @@ -12,7 +12,7 @@ class WorkflowToolsTest extends TestCase /** * Method set up. */ - public function setUp() + public function setUp(): void { parent::setUp(); $this->workspaceTools = new WorkspaceTools('workflow'); @@ -21,7 +21,7 @@ class WorkflowToolsTest extends TestCase /** * Method tear down. */ - public function tearDown() + public function tearDown(): void { parent::tearDown(); } @@ -34,8 +34,7 @@ class WorkflowToolsTest extends TestCase public function it_should_test_addAsyncOptionToSchedulerCommands_method() { //method "WorkspaceTools::initPropel(true)" crashes all connections - $message = "WorkspaceTools::initPropel(true) crashes all connections"; - $this->markTestIncomplete($message); + $this->markTestSkipped("WorkspaceTools::initPropel(true) crashes all connections"); ob_start(); $this->workspaceTools->addAsyncOptionToSchedulerCommands(false); diff --git a/tests/unit/workflow/engine/classes/WorkspaceToolsTest.php b/tests/unit/workflow/engine/classes/WorkspaceToolsTest.php index bfb39c22b..025366ab9 100755 --- a/tests/unit/workflow/engine/classes/WorkspaceToolsTest.php +++ b/tests/unit/workflow/engine/classes/WorkspaceToolsTest.php @@ -41,6 +41,16 @@ class WorkspaceToolsTest extends TestCase $this->assertEquals('Côte d\'Ivoire', $res['IC_NAME']); } + /** + * Set up method. + * @return void + */ + public function setUp(): void + { + parent::setUp(); + $this->truncateNonInitialModels(); + } + /** * Tests the migrateCaseTitleToThreads method * @@ -49,63 +59,96 @@ class WorkspaceToolsTest extends TestCase */ public function it_should_test_migrate_case_title_to_threads_method() { - $application1 = factory(Application::class)->create([ + $application1 = Application::factory()->create([ 'APP_STATUS' => 'TO_DO', 'APP_STATUS_ID' => 2, ]); - $application2 = factory(Application::class)->create([ + $application2 = Application::factory()->create([ 'APP_STATUS' => 'COMPLETED', 'APP_STATUS_ID' => 3, ]); - $application3 = factory(Application::class)->create([ + $application3 = Application::factory()->create([ 'APP_STATUS' => 'CANCELED', 'APP_STATUS_ID' => 4, ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_UID' => $application1->APP_UID, 'APP_NUMBER' => $application1->APP_NUMBER, + 'DEL_TITLE' => $application1->APP_TITLE, 'DEL_INDEX' => 1 ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_UID' => $application1->APP_UID, 'APP_NUMBER' => $application1->APP_NUMBER, + 'DEL_TITLE' => $application1->APP_TITLE, 'DEL_INDEX' => 2 ]); - $delegation1 = factory(Delegation::class)->create([ + $delegation1 = Delegation::factory()->create([ 'APP_UID' => $application1->APP_UID, 'APP_NUMBER' => $application1->APP_NUMBER, + 'DEL_TITLE' => $application1->APP_TITLE, 'DEL_INDEX' => 3, ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_UID' => $application2->APP_UID, 'APP_NUMBER' => $application2->APP_NUMBER, + 'DEL_TITLE' => $application2->APP_TITLE, 'DEL_INDEX' => 1 ]); - $delegation2 = factory(Delegation::class)->create([ + $delegation2 = Delegation::factory()->create([ 'APP_UID' => $application2->APP_UID, 'APP_NUMBER' => $application2->APP_NUMBER, + 'DEL_TITLE' => $application2->APP_TITLE, 'DEL_INDEX' => 2, 'DEL_LAST_INDEX' => 1 ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_UID' => $application3->APP_UID, 'APP_NUMBER' => $application3->APP_NUMBER, + 'DEL_TITLE' => $application3->APP_TITLE, 'DEL_INDEX' => 1 ]); - $delegation3 = factory(Delegation::class)->create([ + $delegation3 = Delegation::factory()->create([ 'APP_UID' => $application3->APP_UID, 'APP_NUMBER' => $application3->APP_NUMBER, + 'DEL_TITLE' => $application3->APP_TITLE, 'DEL_INDEX' => 2, 'DEL_LAST_INDEX' => 1 ]); + if (!defined('DB_RBAC_USER')) { + define('DB_RBAC_USER', DB_USER); + } + if (!defined('DB_RBAC_PASS')) { + define('DB_RBAC_PASS', DB_PASS); + } + if (!defined('DB_RBAC_HOST')) { + define('DB_RBAC_HOST', DB_HOST); + } + if (!defined('DB_RBAC_NAME')) { + define('DB_RBAC_NAME', DB_NAME); + } + if (!defined('DB_REPORT_USER')) { + define('DB_REPORT_USER', DB_USER); + } + if (!defined('DB_REPORT_PASS')) { + define('DB_REPORT_PASS', DB_PASS); + } + if (!defined('DB_REPORT_HOST')) { + define('DB_REPORT_HOST', DB_HOST); + } + if (!defined('DB_REPORT_NAME')) { + define('DB_REPORT_NAME', DB_NAME); + } + ob_start(); $workspaceTools = new WorkspaceTools(''); $workspaceTools->migrateCaseTitleToThreads(['testexternal']); $result = ob_get_contents(); - $this->assertRegExp("/The Case Title has been updated successfully in APP_DELEGATION table./", $result); + ob_end_clean(); + $this->assertMatchesRegularExpression("/The Case Title has been updated successfully in APP_DELEGATION table./", $result); $r = Delegation::select('DEL_TITLE')->where('DELEGATION_ID', $delegation1->DELEGATION_ID)->get()->values()->toArray(); $this->assertEquals($r[0]['DEL_TITLE'], $application1->APP_TITLE); diff --git a/tests/unit/workflow/engine/classes/WsBaseTest.php b/tests/unit/workflow/engine/classes/WsBaseTest.php index 3d56cd091..bf4953cb2 100755 --- a/tests/unit/workflow/engine/classes/WsBaseTest.php +++ b/tests/unit/workflow/engine/classes/WsBaseTest.php @@ -2,7 +2,6 @@ use App\Jobs\EmailEvent; use Faker\Factory; -use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Facades\Queue; use ProcessMaker\Model\Application; use ProcessMaker\Model\AppDelay; @@ -23,9 +22,6 @@ use Tests\TestCase; */ class WsBaseTest extends TestCase { - - use DatabaseTransactions; - /** * Constructor of the class. * @@ -36,15 +32,6 @@ class WsBaseTest extends TestCase 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(); Application::query()->truncate(); AppThread::query()->truncate(); Delegation::query()->truncate(); @@ -54,7 +41,7 @@ class WsBaseTest extends TestCase * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. */ - protected function tearDown() + public function tearDown(): void { parent::tearDown(); } @@ -89,19 +76,19 @@ class WsBaseTest extends TestCase 'PIN' => '97ZN' ]; - $user = factory(User::class)->create([ + $user = User::factory()->create([ 'USR_UID' => $userUid ]); - $process = factory(Process::class)->create([ + $process = Process::factory()->create([ 'PRO_UID' => $processUid ]); - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'PRO_UID' => $process->PRO_UID ]); - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'APP_UID' => $applicationUid, 'APP_NUMBER' => $applicationNumber, @@ -124,7 +111,7 @@ class WsBaseTest extends TestCase { $passwordEnv = env('emailAccountPassword'); $password = G::encrypt("hash:" . $passwordEnv, 'EMAILENCRYPT'); - $emailServer = factory(EmailServerModel::class)->create([ + $emailServer = EmailServerModel::factory()->create([ 'MESS_ENGINE' => env('emailEngine'), 'MESS_SERVER' => env('emailServer'), 'MESS_PORT' => env('emailPort'), @@ -167,7 +154,7 @@ class WsBaseTest extends TestCase mkdir(PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . $proUid); } file_put_contents(PATH_DATA_SITE . 'mailTemplates' . PATH_SEP . $proUid . PATH_SEP . 'template.html', $data); - $template = factory(\ProcessMaker\Model\ProcessFiles::class)->create([ + $template = \ProcessMaker\Model\ProcessFiles::factory()->create([ 'PRO_UID' => $proUid, 'USR_UID' => $usrUid, 'PRF_PATH' => 'template.html' @@ -506,16 +493,16 @@ class WsBaseTest extends TestCase public function it_should_test_that_the_cases_list_method_returns_the_case_title() { //Create the user factory - $user = factory(User::class)->create(); + $user = User::factory()->create(); //Create the application factory - $application1 = factory(Application::class)->create( + $application1 = Application::factory()->create( [ 'APP_STATUS' => 'TO_DO', 'APP_TITLE' => 'Title1' ] ); - $application2 = factory(Application::class)->create( + $application2 = Application::factory()->create( [ 'APP_STATUS' => 'DRAFT', 'APP_TITLE' => 'Title2' @@ -523,7 +510,7 @@ class WsBaseTest extends TestCase ); //Create the delegation factory - $delegation1 = factory(Delegation::class)->create( + $delegation1 = Delegation::factory()->create( [ 'USR_UID' => $user->USR_UID, 'DEL_THREAD_STATUS' => 'OPEN', @@ -531,7 +518,7 @@ class WsBaseTest extends TestCase 'APP_NUMBER' => $application1->APP_NUMBER ] ); - $delegation2 = factory(Delegation::class)->create( + $delegation2 = Delegation::factory()->create( [ 'USR_UID' => $user->USR_UID, 'DEL_THREAD_STATUS' => 'OPEN', @@ -541,13 +528,13 @@ class WsBaseTest extends TestCase ); //Create app thread factory - factory(AppThread::class)->create( + AppThread::factory()->create( [ 'APP_THREAD_STATUS' => 'OPEN', 'APP_UID' => $delegation1->APP_UID ] ); - factory(AppThread::class)->create( + AppThread::factory()->create( [ 'APP_THREAD_STATUS' => 'OPEN', 'APP_UID' => $delegation2->APP_UID @@ -580,17 +567,17 @@ class WsBaseTest extends TestCase public function it_should_test_the_cases_list_method_when_there_are_no_results() { //Create the user factory - $user1 = factory(User::class)->create(); - $user2 = factory(User::class)->create(); + $user1 = User::factory()->create(); + $user2 = User::factory()->create(); //Create the application factory - $application1 = factory(Application::class)->create( + $application1 = Application::factory()->create( [ 'APP_STATUS' => 'TO_DO', 'APP_TITLE' => 'Title1' ] ); - $application2 = factory(Application::class)->create( + $application2 = Application::factory()->create( [ 'APP_STATUS' => 'DRAFT', 'APP_TITLE' => 'Title2' @@ -598,7 +585,7 @@ class WsBaseTest extends TestCase ); //Create the delegation factory - $delegation1 = factory(Delegation::class)->create( + $delegation1 = Delegation::factory()->create( [ 'USR_UID' => $user1->USR_UID, 'DEL_THREAD_STATUS' => 'OPEN', @@ -606,7 +593,7 @@ class WsBaseTest extends TestCase 'APP_NUMBER' => $application1->APP_NUMBER ] ); - $delegation2 = factory(Delegation::class)->create( + $delegation2 = Delegation::factory()->create( [ 'USR_UID' => $user1->USR_UID, 'DEL_THREAD_STATUS' => 'OPEN', @@ -616,13 +603,13 @@ class WsBaseTest extends TestCase ); //Create app thread factory - factory(AppThread::class)->create( + AppThread::factory()->create( [ 'APP_THREAD_STATUS' => 'OPEN', 'APP_UID' => $delegation1->APP_UID ] ); - factory(AppThread::class)->create( + AppThread::factory()->create( [ 'APP_THREAD_STATUS' => 'OPEN', 'APP_UID' => $delegation2->APP_UID @@ -803,11 +790,11 @@ class WsBaseTest extends TestCase */ public function it_should_set_flag_when_is_same_case() { - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'APP_STATUS_ID' => 2, 'APP_STATUS' => 'TO_DO' ]); - $delegation = factory(Delegation::class)->states('foreign_keys')->create([ + $delegation = Delegation::factory()->foreign_keys()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'APP_UID' => $application->APP_UID, ]); @@ -826,7 +813,7 @@ class WsBaseTest extends TestCase */ public function it_should_validate_required_app_uid() { - $delegation = factory(Delegation::class)->states('foreign_keys')->create(); + $delegation = Delegation::factory()->foreign_keys()->create(); $ws = new WsBase(); $response = (object) $ws->cancelCase('', $delegation->DE_INDEX, $delegation->URS_UID); $this->assertEquals($response->status_code, 100); @@ -842,11 +829,11 @@ class WsBaseTest extends TestCase public function it_should_validate_required_status_todo() { // Create a case in DRAFT status - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'APP_STATUS_ID' => 1, 'APP_STATUS' => 'DRAFT' ]); - $delegation = factory(Delegation::class)->states('foreign_keys')->create([ + $delegation = Delegation::factory()->foreign_keys()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'APP_UID' => $application->APP_UID, ]); @@ -856,11 +843,11 @@ class WsBaseTest extends TestCase $this->assertEquals($response->message, G::LoadTranslation("ID_CASE_IN_STATUS") . ' DRAFT'); // Create a case in COMPLETED status - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'APP_STATUS_ID' => 3, 'APP_STATUS' => 'COMPLETED' ]); - $delegation = factory(Delegation::class)->states('foreign_keys')->create([ + $delegation = Delegation::factory()->foreign_keys()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'APP_UID' => $application->APP_UID, ]); @@ -870,11 +857,11 @@ class WsBaseTest extends TestCase $this->assertEquals($response->message, G::LoadTranslation("ID_CASE_IN_STATUS") . ' COMPLETED'); // Create a case in CANCELLED status - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'APP_STATUS_ID' => 4, 'APP_STATUS' => 'CANCELLED' ]); - $delegation = factory(Delegation::class)->states('foreign_keys')->create([ + $delegation = Delegation::factory()->foreign_keys()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'APP_UID' => $application->APP_UID, ]); @@ -892,11 +879,11 @@ class WsBaseTest extends TestCase */ public function it_should_validate_required_del_index() { - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'APP_STATUS_ID' => 2, 'APP_STATUS' => 'TO_DO' ]); - $delegation = factory(Delegation::class)->states('foreign_keys')->create([ + $delegation = Delegation::factory()->foreign_keys()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'APP_UID' => $application->APP_UID, ]); @@ -914,11 +901,11 @@ class WsBaseTest extends TestCase */ public function it_should_validate_required_open_thread() { - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'APP_STATUS_ID' => 2, 'APP_STATUS' => 'TO_DO' ]); - $delegation = factory(Delegation::class)->states('foreign_keys')->create([ + $delegation = Delegation::factory()->foreign_keys()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'APP_UID' => $application->APP_UID, 'DEL_THREAD_STATUS' => 'CLOSED' @@ -937,11 +924,11 @@ class WsBaseTest extends TestCase */ public function it_should_validate_required_usr_uid() { - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'APP_STATUS_ID' => 2, 'APP_STATUS' => 'TO_DO' ]); - $delegation = factory(Delegation::class)->states('foreign_keys')->create([ + $delegation = Delegation::factory()->foreign_keys()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'APP_UID' => $application->APP_UID, ]); @@ -959,30 +946,30 @@ class WsBaseTest extends TestCase */ public function it_should_validate_only_one_thread_opened() { - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'APP_STATUS_ID' => 2, 'APP_STATUS' => 'TO_DO' ]); - factory(AppThread::class)->create([ + AppThread::factory()->create([ 'APP_UID' => $application->APP_UID, 'APP_THREAD_INDEX' => 1, 'APP_THREAD_PARENT' => 1, 'APP_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 1 ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'APP_UID' => $application->APP_UID, 'DEL_THREAD_STATUS' => 'OPEN' ]); - factory(AppThread::class)->create([ + AppThread::factory()->create([ 'APP_UID' => $application->APP_UID, 'APP_THREAD_INDEX' => 2, 'APP_THREAD_PARENT' => 1, 'APP_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 2 ]); - $delegation = factory(Delegation::class)->states('foreign_keys')->create([ + $delegation = Delegation::factory()->foreign_keys()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'APP_UID' => $application->APP_UID, 'DEL_THREAD_STATUS' => 'OPEN', @@ -1012,35 +999,35 @@ class WsBaseTest extends TestCase $RBAC->loadUserRolePermission('PROCESSMAKER', $_SESSION['USER_LOGGED']); // Create the data related to the cancel a case - $process = factory(Process::class)->create([ + $process = Process::factory()->create([ 'PRO_CREATE_USER' => $user->USR_UID ]); - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'TAS_USER' => $user->USR_UID ]); - factory(TaskUser::class)->create([ + TaskUser::factory()->create([ 'TAS_UID' => $task->TAS_UID, 'USR_UID' => $user->USR_UID ]); - factory(UserReporting::class)->create([ + UserReporting::factory()->create([ 'TAS_UID' => $task->TAS_UID ]); - $application = factory(Application::class)->states('foreign_keys')->create([ + $application = Application::factory()->foreign_keys()->create([ 'PRO_UID' => $process->PRO_UID, 'APP_INIT_USER' => $user->USR_UID, 'APP_CUR_USER' => $user->USR_UID, 'APP_STATUS_ID' => 2, 'APP_STATUS' => 'TO_DO' ]); - factory(AppThread::class)->create([ + AppThread::factory()->create([ 'APP_UID' => $application->APP_UID, 'APP_THREAD_INDEX' => 1, 'APP_THREAD_PARENT' => 1, 'APP_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 2 ]); - $delegation = factory(Delegation::class)->states('foreign_keys')->create([ + $delegation = Delegation::factory()->foreign_keys()->create([ 'TAS_UID' => $task->TAS_UID, 'PRO_UID' => $application->PRO_UID, 'APP_NUMBER' => $application->APP_NUMBER, @@ -1074,25 +1061,25 @@ class WsBaseTest extends TestCase $RBAC->loadUserRolePermission('PROCESSMAKER', $_SESSION['USER_LOGGED']); // Create the data related to the cancel a case - $task = factory(Task::class)->create(); - factory(UserReporting::class)->create([ + $task = Task::factory()->create(); + UserReporting::factory()->create([ 'TAS_UID' => $task->TAS_UID ]); - $application = factory(Application::class)->states('foreign_keys')->create([ + $application = Application::factory()->foreign_keys()->create([ 'APP_STATUS_ID' => 2, 'APP_INIT_USER' => $user->USR_UID, 'APP_CUR_USER' => $user->USR_UID, 'APP_STATUS' => 'TO_DO' ]); // Create the first thread - factory(AppThread::class)->create([ + AppThread::factory()->create([ 'APP_UID' => $application->APP_UID, 'APP_THREAD_INDEX' => 2, 'APP_THREAD_PARENT' => 1, 'APP_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 2 ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'TAS_UID' => $task->TAS_UID, 'PRO_UID' => $application->PRO_UID, 'APP_NUMBER' => $application->APP_NUMBER, @@ -1102,14 +1089,14 @@ class WsBaseTest extends TestCase 'DEL_PREVIOUS' => 2, ]); // Create the second thread - factory(AppThread::class)->create([ + AppThread::factory()->create([ 'APP_UID' => $application->APP_UID, 'APP_THREAD_INDEX' => 3, 'APP_THREAD_PARENT' => 1, 'APP_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 3 ]); - $delegation = factory(Delegation::class)->states('foreign_keys')->create([ + $delegation = Delegation::factory()->foreign_keys()->create([ 'TAS_UID' => $task->TAS_UID, 'PRO_UID' => $application->PRO_UID, 'USR_UID' => $user->USR_UID, @@ -1136,18 +1123,18 @@ class WsBaseTest extends TestCase public function it_tried_cancel_an_undefined_case() { $fakeApp = G::generateUniqueID(); - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'APP_STATUS_ID' => 2, 'APP_STATUS' => 'TO_DO' ]); - factory(AppThread::class)->create([ + AppThread::factory()->create([ 'APP_UID' => $application->APP_UID, 'APP_THREAD_INDEX' => 1, 'APP_THREAD_PARENT' => 1, 'APP_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 2 ]); - $delegation = factory(Delegation::class)->states('foreign_keys')->create([ + $delegation = Delegation::factory()->foreign_keys()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'APP_UID' => $application->APP_UID, 'DEL_THREAD_STATUS' => 'OPEN', @@ -1156,7 +1143,7 @@ class WsBaseTest extends TestCase $ws = new WsBase(); $response = (object) $ws->cancelCase($fakeApp, $delegation->DEL_INDEX, $delegation->USR_UID); $this->assertEquals($response->status_code, 100); - $this->assertContains($fakeApp, $response->message); + $this->assertStringContainsString($fakeApp, $response->message); } /** @@ -1168,51 +1155,51 @@ class WsBaseTest extends TestCase public function it_should_test_the_unassigned_case_list_method_with_unassigned_cases() { //Create process - $process1 = factory(Process::class)->create([ + $process1 = Process::factory()->create([ 'PRO_TITLE' => 'China Supplier Payment Proposal' ]); - $process2 = factory(Process::class)->create([ + $process2 = Process::factory()->create([ 'PRO_TITLE' => 'Egypt Supplier Payment Proposal' ]); //Create application - $application1 = factory(Application::class)->create([ + $application1 = Application::factory()->create([ 'APP_STATUS_ID' => 2 ]); //Create user - $user = factory(User::class)->create(); + $user = User::factory()->create(); //Create a task self service - $task1 = factory(Task::class)->create([ + $task1 = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process1->PRO_UID ]); - $task2 = factory(Task::class)->create([ + $task2 = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process1->PRO_UID ]); //Assign a user in the task - factory(TaskUser::class)->create([ + TaskUser::factory()->create([ 'TAS_UID' => $task1->TAS_UID, 'USR_UID' => $user->USR_UID, 'TU_RELATION' => 1, //Related to the user 'TU_TYPE' => 1 ]); - factory(TaskUser::class)->create([ + TaskUser::factory()->create([ 'TAS_UID' => $task2->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, 2)->create([ + Delegation::factory(2)->create([ 'APP_NUMBER' => $application1->APP_NUMBER, 'TAS_ID' => $task1->TAS_ID, 'PRO_ID' => $process1->id, 'DEL_THREAD_STATUS' => 'OPEN', 'USR_ID' => 0, ]); - factory(Delegation::class, 2)->create([ + Delegation::factory(2)->create([ 'APP_NUMBER' => $application1->APP_NUMBER, 'TAS_ID' => $task2->TAS_ID, 'PRO_ID' => $process2->id, @@ -1235,52 +1222,52 @@ class WsBaseTest extends TestCase public function it_should_test_the_unassigned_case_list_method_without_unassigned_cases() { //Create process - $process1 = factory(Process::class)->create([ + $process1 = Process::factory()->create([ 'PRO_TITLE' => 'China Supplier Payment Proposal' ]); - $process2 = factory(Process::class)->create([ + $process2 = Process::factory()->create([ 'PRO_TITLE' => 'Egypt Supplier Payment Proposal' ]); //Create application - $application1 = factory(Application::class)->create([ + $application1 = Application::factory()->create([ 'APP_STATUS_ID' => 2 ]); //Create user - $user = factory(User::class)->create(); + $user = User::factory()->create(); //Create a task self service - $task1 = factory(Task::class)->create([ + $task1 = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process1->PRO_UID ]); - $task2 = factory(Task::class)->create([ + $task2 = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process1->PRO_UID ]); //Assign a user in the task - factory(TaskUser::class)->create([ + TaskUser::factory()->create([ 'TAS_UID' => $task1->TAS_UID, 'USR_UID' => $user->USR_UID, 'TU_RELATION' => 1, //Related to the user 'TU_TYPE' => 1 ]); //Assign a user in the task - factory(TaskUser::class)->create([ + TaskUser::factory()->create([ 'TAS_UID' => $task2->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, 2)->create([ + Delegation::factory(2)->create([ 'APP_NUMBER' => $application1->APP_NUMBER, 'TAS_ID' => $task1->TAS_ID, 'PRO_ID' => $process1->id, 'DEL_THREAD_STATUS' => 'OPEN', 'USR_ID' => 5, ]); - factory(Delegation::class, 2)->create([ + Delegation::factory(2)->create([ 'APP_NUMBER' => $application1->APP_NUMBER, 'TAS_ID' => $task2->TAS_ID, 'PRO_ID' => $process2->id, @@ -1308,18 +1295,18 @@ class WsBaseTest extends TestCase $response = (object) $ws->pauseCase('', 0, ''); $this->assertEquals($response->status_code, 100); // Validate the status - $application = factory(Application::class)->states('draft')->create(); + $application = Application::factory()->draft()->create(); $ws = new WsBase(); $response = (object) $ws->pauseCase($application->APP_UID, 0, ''); $this->assertEquals($response->status_code, 100); // Validate the index - $application = factory(Application::class)->states('todo')->create(); + $application = Application::factory()->todo()->create(); $ws = new WsBase(); $response = (object) $ws->pauseCase($application->APP_UID, '', ''); $this->assertEquals($response->status_code, 100); // Validate the user - $application = factory(Application::class)->states('todo')->create(); - $delegation = factory(Delegation::class)->states('foreign_keys')->create([ + $application = Application::factory()->todo()->create(); + $delegation = Delegation::factory()->foreign_keys()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'APP_UID' => $application->APP_UID, ]); @@ -1327,12 +1314,12 @@ class WsBaseTest extends TestCase $response = (object) $ws->pauseCase($application->APP_UID, $delegation->DEL_INDEX, ''); $this->assertEquals($response->status_code, 100); // If needs to validate the current user - $user = factory(User::class)->create(); + $user = User::factory()->create(); $response = (object) $ws->pauseCase($application->APP_UID, $delegation->DEL_INDEX, $user->USR_UID, null, true); $this->assertEquals($response->status_code, 100); // Validate if status is closed - $application = factory(Application::class)->states('todo')->create(); - $delegation = factory(Delegation::class)->states('foreign_keys')->create([ + $application = Application::factory()->todo()->create(); + $delegation = Delegation::factory()->foreign_keys()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'APP_UID' => $application->APP_UID, 'DEL_THREAD_STATUS' => 'CLOSED', @@ -1342,12 +1329,12 @@ class WsBaseTest extends TestCase $response = (object) $ws->pauseCase($application->APP_UID, $delegation->DEL_INDEX, $delegation->USR_UID, null); $this->assertEquals($response->status_code, 100); // Validate if the case is paused - $application = factory(Application::class)->states('todo')->create(); - $delegation = factory(Delegation::class)->states('foreign_keys')->create([ + $application = Application::factory()->todo()->create(); + $delegation = Delegation::factory()->foreign_keys()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'APP_UID' => $application->APP_UID, ]); - factory(AppDelay::class)->create([ + AppDelay::factory()->create([ 'APP_DELEGATION_USER' => $delegation->USR_UID, 'PRO_UID' => $delegation->PRO_UID, 'APP_NUMBER' => $delegation->APP_NUMBER, @@ -1355,7 +1342,7 @@ class WsBaseTest extends TestCase 'APP_DISABLE_ACTION_USER' => 0, 'APP_TYPE' => 'PAUSE' ]); - factory(AppThread::class)->create([ + AppThread::factory()->create([ 'APP_UID' => $delegation->APP_UID, 'APP_THREAD_INDEX' => 1, 'APP_THREAD_PARENT' => 0, @@ -1365,8 +1352,8 @@ class WsBaseTest extends TestCase $ws = new WsBase(); $response = (object) $ws->pauseCase($application->APP_UID, $delegation->DEL_INDEX, $delegation->USR_UID, null); // Review the unpaused date - $application = factory(Application::class)->states('todo')->create(); - $delegation = factory(Delegation::class)->states('foreign_keys')->create([ + $application = Application::factory()->todo()->create(); + $delegation = Delegation::factory()->foreign_keys()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'APP_UID' => $application->APP_UID, ]); @@ -1383,14 +1370,14 @@ class WsBaseTest extends TestCase */ public function it_pause_case() { - $application = factory(Application::class)->states('todo')->create(); - $delegation = factory(Delegation::class)->states('foreign_keys')->create([ + $application = Application::factory()->todo()->create(); + $delegation = Delegation::factory()->foreign_keys()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'APP_UID' => $application->APP_UID, 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 2, ]); - factory(AppDelay::class)->create([ + AppDelay::factory()->create([ 'APP_DELEGATION_USER' => $delegation->USR_UID, 'PRO_UID' => $delegation->PRO_UID, 'APP_NUMBER' => $delegation->APP_NUMBER, @@ -1398,7 +1385,7 @@ class WsBaseTest extends TestCase 'APP_DISABLE_ACTION_USER' => 0, 'APP_TYPE' => 'PAUSE' ]); - factory(AppThread::class)->create([ + AppThread::factory()->create([ 'APP_UID' => $delegation->APP_UID, 'APP_THREAD_INDEX' => 1, 'APP_THREAD_PARENT' => 0, @@ -1407,6 +1394,6 @@ class WsBaseTest extends TestCase ]); $ws = new WsBase(); $response = (object) $ws->pauseCase($delegation->APP_UID, $delegation->DEL_INDEX, $delegation->USR_UID); - $this->assertNotEmpty($response->status_code); + $this->assertEquals(0, $response->status_code); } } diff --git a/tests/unit/workflow/engine/classes/WsResponseTest.php b/tests/unit/workflow/engine/classes/WsResponseTest.php index 33f5fa2d6..12083f623 100644 --- a/tests/unit/workflow/engine/classes/WsResponseTest.php +++ b/tests/unit/workflow/engine/classes/WsResponseTest.php @@ -9,7 +9,7 @@ class WsResponseTest extends TestCase /** * Set up method. */ - public function setUp() + public function setUp(): void { parent::setUp(); } @@ -66,7 +66,7 @@ class WsResponseTest extends TestCase //assert $actual = $this->wsResponse->getPayloadString('test'); - $this->assertContains('test', $actual); + $this->assertStringContainsString('test', $actual); } /** diff --git a/tests/unit/workflow/engine/classes/model/AdditionalTablesTest.php b/tests/unit/workflow/engine/classes/model/AdditionalTablesTest.php index 92af01607..4e2a6042a 100644 --- a/tests/unit/workflow/engine/classes/model/AdditionalTablesTest.php +++ b/tests/unit/workflow/engine/classes/model/AdditionalTablesTest.php @@ -24,11 +24,8 @@ class AdditionalTablesTest extends TestCase /** * Set up method. */ - public function setUp() + public function setUp(): void { - if (version_compare(phpversion(), 7.3, '>') ) { - $this->markTestSkipped('The changes in third party are not available'); - } parent::setUp(); } @@ -62,7 +59,9 @@ class AdditionalTablesTest extends TestCase $actual = $additionalTablesModel->toArray(); unset($data["ADD_TAB_UID"]); - $this->assertArraySubset($data, $actual); + foreach ($data as $key => $value) { + $this->assertEquals($value, $actual[$key]); + } } /** @@ -86,7 +85,7 @@ class AdditionalTablesTest extends TestCase */ public function it_should_update() { - $additionalTables = factory(AdditionalTablesModel::class)->create(); + $additionalTables = AdditionalTablesModel::factory()->create(); $expected = [ "ADD_TAB_UID" => $additionalTables->ADD_TAB_UID, @@ -135,11 +134,11 @@ class AdditionalTablesTest extends TestCase */ public function it_should_get_all_registries() { - $proUid = factory(\ProcessMaker\Model\Process::class)->create()->PRO_UID; + $proUid = \ProcessMaker\Model\Process::factory()->create()->PRO_UID; //local connections - $additionalTables = factory(AdditionalTablesModel::class, 3); - $dbSource = factory(\ProcessMaker\Model\DbSource::class)->create([ + $additionalTables = AdditionalTablesModel::factory(3); + $dbSource = \ProcessMaker\Model\DbSource::factory()->create([ 'PRO_UID' => $proUid, 'DBS_SERVER' => env('DB_HOST'), 'DBS_DATABASE_NAME' => env('DB_DATABASE'), @@ -148,7 +147,7 @@ class AdditionalTablesTest extends TestCase 'DBS_PORT' => '3306', 'DBS_CONNECTION_TYPE' => 'NORMAL' ]); - $additionalTable = factory(AdditionalTablesModel::class)->create([ + $additionalTable = AdditionalTablesModel::factory()->create([ 'PRO_UID' => $proUid, 'DBS_UID' => $dbSource->DBS_UID, ]); @@ -157,7 +156,7 @@ class AdditionalTablesTest extends TestCase $this->createSchema($dbSource->DBS_DATABASE_NAME, $tableName, $name, $dbSource->DBS_UID); //external connection - $dbSource = factory(\ProcessMaker\Model\DbSource::class)->create([ + $dbSource = \ProcessMaker\Model\DbSource::factory()->create([ 'PRO_UID' => $proUid, 'DBS_SERVER' => config('database.connections.testexternal.host'), 'DBS_DATABASE_NAME' => config('database.connections.testexternal.database'), @@ -166,7 +165,7 @@ class AdditionalTablesTest extends TestCase 'DBS_PORT' => '3306', 'DBS_CONNECTION_TYPE' => 'NORMAL' ]); - $additionalTable = factory(AdditionalTablesModel::class)->create([ + $additionalTable = AdditionalTablesModel::factory()->create([ 'PRO_UID' => $proUid, 'DBS_UID' => $dbSource->DBS_UID, ]); @@ -223,14 +222,14 @@ class AdditionalTablesTest extends TestCase */ public function it_should_test_populate_report_table() { - $proUid = factory(Process::class)->create()->PRO_UID; + $proUid = Process::factory()->create()->PRO_UID; - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'PRO_UID' => $proUid ]); //local connections - $dbSource = factory(DbSource::class)->create([ + $dbSource = DbSource::factory()->create([ 'PRO_UID' => $proUid, 'DBS_SERVER' => env('DB_HOST'), 'DBS_DATABASE_NAME' => env('DB_DATABASE'), @@ -239,7 +238,7 @@ class AdditionalTablesTest extends TestCase 'DBS_PORT' => '3306', 'DBS_CONNECTION_TYPE' => 'NORMAL' ]); - $additionalTable = factory(AdditionalTablesModel::class)->create([ + $additionalTable = AdditionalTablesModel::factory()->create([ 'PRO_UID' => $proUid, 'DBS_UID' => $dbSource->DBS_UID, ]); @@ -248,7 +247,7 @@ class AdditionalTablesTest extends TestCase $this->createSchema($dbSource->DBS_DATABASE_NAME, $tableName, $name, $dbSource->DBS_UID); //external connection - $dbSource = factory(DbSource::class)->create([ + $dbSource = DbSource::factory()->create([ 'PRO_UID' => $proUid, 'DBS_SERVER' => config('database.connections.testexternal.host'), 'DBS_DATABASE_NAME' => config('database.connections.testexternal.database'), @@ -257,7 +256,7 @@ class AdditionalTablesTest extends TestCase 'DBS_PORT' => '3306', 'DBS_CONNECTION_TYPE' => 'NORMAL' ]); - $additionalTable = factory(AdditionalTablesModel::class)->create([ + $additionalTable = AdditionalTablesModel::factory()->create([ 'PRO_UID' => $proUid, 'DBS_UID' => $dbSource->DBS_UID, ]); @@ -265,10 +264,10 @@ class AdditionalTablesTest extends TestCase $nameExternal = $additionalTable->ADD_TAB_CLASS_NAME; $this->createSchema($dbSource->DBS_DATABASE_NAME, $tableNameExternal, $nameExternal, $dbSource->DBS_UID); - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'PRO_UID' => $proUid ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'DEL_THREAD_STATUS' => 'CLOSED', 'APP_NUMBER' => $application->APP_NUMBER, 'TAS_UID' => $task->TAS_UID, @@ -356,7 +355,6 @@ class AdditionalTablesTest extends TestCase */ private function createSchema(string $connection, string $tableName, string $className, string $dbsUid = 'workflow') { - $this->markTestIncomplete('Illegal mix of collations'); $query = "" . "CREATE TABLE IF NOT EXISTS `{$tableName}` (" . "`APP_UID` varchar(32) NOT NULL," @@ -366,7 +364,8 @@ class AdditionalTablesTest extends TestCase . "`VAR2` varchar(255) DEFAULT NULL," . "`VAR3` varchar(255) DEFAULT NULL," . "PRIMARY KEY (`APP_UID`)," - . "KEY `indexTable` (`APP_UID`))"; + . "KEY `indexTable` (`APP_UID`)" + . ")ENGINE=InnoDB DEFAULT CHARSET='utf8'"; if (!empty(config("database.connections.{$connection}"))) { DB::connection($connection)->statement($query); } else { diff --git a/tests/unit/workflow/engine/classes/model/AppNotesTest.php b/tests/unit/workflow/engine/classes/model/AppNotesTest.php index 293379c88..d97615690 100644 --- a/tests/unit/workflow/engine/classes/model/AppNotesTest.php +++ b/tests/unit/workflow/engine/classes/model/AppNotesTest.php @@ -26,7 +26,7 @@ class AppNotesTest extends TestCase /** * Set up method */ - public function setUp() + public function setUp(): void { parent::setUp(); $this->faker = Factory::create(); @@ -39,8 +39,8 @@ class AppNotesTest extends TestCase */ public function it_test_case_notes_creation() { - $application = factory(Application::class)->create(); - $user = factory(User::class)->create(); + $application = Application::factory()->create(); + $user = User::factory()->create(); $reason = "The case was canceled due to:"; $appNotes = new ModelAppNotes(); $noteContent = addslashes($reason); @@ -62,8 +62,8 @@ class AppNotesTest extends TestCase */ public function it_test_case_notes_creation_and_send_email_to_user() { - $application = factory(Application::class)->create(); - $user = factory(User::class)->create(); + $application = Application::factory()->create(); + $user = User::factory()->create(); $reason = "The case was canceled due to:"; $appNotes = new ModelAppNotes(); $noteContent = addslashes($reason); @@ -91,9 +91,9 @@ class AppNotesTest extends TestCase */ public function it_test_case_notes_creation_and_send_email() { - $application = factory(Application::class)->create(); - $user = factory(User::class)->create(); - factory(Delegation::class)->create([ + $application = Application::factory()->create(); + $user = User::factory()->create(); + Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'USR_UID' => $user->USR_UID ]); @@ -140,8 +140,8 @@ class AppNotesTest extends TestCase { $user = User::where('USR_UID', '=', '00000000000000000000000000000001') ->first(); - $application = factory(Application::class)->create(); - $delegation = factory(Delegation::class)->create([ + $application = Application::factory()->create(); + $delegation = Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'USR_UID' => $user->USR_UID ]); @@ -172,17 +172,17 @@ class AppNotesTest extends TestCase { $user = User::where('USR_UID', '=', '00000000000000000000000000000001') ->first(); - $application = factory(Application::class)->create(); - $delegation = factory(Delegation::class)->create([ + $application = Application::factory()->create(); + $delegation = Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'USR_UID' => $user->USR_UID ]); - $appNote = factory(AppNotes::class)->create(); - $appDocument = factory(Documents::class)->create([ + $appNote = AppNotes::factory()->create(); + $appDocument = Documents::factory()->create([ 'APP_UID' => $application->APP_UID, 'DOC_ID' => $appNote->NOTE_ID ]); - factory(EmailServerModel::class)->create([ + EmailServerModel::factory()->create([ 'MESS_DEFAULT' => 1 ]); @@ -210,8 +210,8 @@ class AppNotesTest extends TestCase */ public function it_should_test_get_attached_files_from_the_casenote() { - $appNote = factory(AppNotes::class)->create(); - $appDocument = factory(Documents::class)->create([ + $appNote = AppNotes::factory()->create(); + $appDocument = Documents::factory()->create([ 'DOC_ID' => $appNote->NOTE_ID ]); diff --git a/tests/unit/workflow/engine/classes/model/ListCanceledTest.php b/tests/unit/workflow/engine/classes/model/ListCanceledTest.php index cfe13a22b..e4ecd0bc3 100644 --- a/tests/unit/workflow/engine/classes/model/ListCanceledTest.php +++ b/tests/unit/workflow/engine/classes/model/ListCanceledTest.php @@ -15,7 +15,7 @@ class ListCanceledTest extends TestCase /** * Set up method. */ - public function setUp() + public function setUp(): void { parent::setUp(); $this->faker = Factory::create(); @@ -25,7 +25,7 @@ class ListCanceledTest extends TestCase /** * Tear down method, */ - public function tearDown() + public function tearDown(): void { parent::tearDown(); } @@ -36,7 +36,7 @@ class ListCanceledTest extends TestCase */ public function it_should_test_loadFilters_method() { - $delegation = factory(Delegation::class)->create([ + $delegation = Delegation::factory()->create([ 'DEL_THREAD_STATUS' => 'CLOSED', ]); @@ -45,7 +45,7 @@ class ListCanceledTest extends TestCase 'filter' => '', 'search' => $delegation->application->APP_UID, 'process' => $delegation->process->PRO_UID, - 'category' => $delegation->process->PRO_CATEGORY, + 'category' => $this->faker->word, 'dateFrom' => '', 'dateTo' => '' ]; diff --git a/tests/unit/workflow/engine/classes/model/ListCompletedTest.php b/tests/unit/workflow/engine/classes/model/ListCompletedTest.php index c6369bd5d..a3d128927 100644 --- a/tests/unit/workflow/engine/classes/model/ListCompletedTest.php +++ b/tests/unit/workflow/engine/classes/model/ListCompletedTest.php @@ -15,7 +15,7 @@ class ListCompletedTest extends TestCase /** * Set up method. */ - public function setUp() + public function setUp(): void { parent::setUp(); $this->faker = Factory::create(); @@ -25,7 +25,7 @@ class ListCompletedTest extends TestCase /** * Tear down method, */ - public function tearDown() + public function tearDown(): void { parent::tearDown(); } @@ -36,7 +36,7 @@ class ListCompletedTest extends TestCase */ public function it_should_test_loadFilters_method() { - $delegation = factory(Delegation::class)->create([ + $delegation = Delegation::factory()->create([ 'DEL_THREAD_STATUS' => 'CLOSED', ]); @@ -48,7 +48,7 @@ class ListCompletedTest extends TestCase 'filter' => '', //read,unread 'search' => $delegation->application->APP_UID, 'process' => $delegation->process->PRO_UID, - 'category' => $delegation->process->PRO_CATEGORY, + 'category' => $this->faker->word, 'dateFrom' => '', 'dateTo' => '' ]; diff --git a/tests/unit/workflow/engine/classes/model/ListInboxTest.php b/tests/unit/workflow/engine/classes/model/ListInboxTest.php index c35f325b6..ef98858fa 100644 --- a/tests/unit/workflow/engine/classes/model/ListInboxTest.php +++ b/tests/unit/workflow/engine/classes/model/ListInboxTest.php @@ -15,7 +15,7 @@ class ListInboxTest extends TestCase /** * Set up method. */ - public function setUp() + public function setUp(): void { parent::setUp(); $this->faker = Factory::create(); @@ -25,7 +25,7 @@ class ListInboxTest extends TestCase /** * Tear down method, */ - public function tearDown() + public function tearDown(): void { parent::tearDown(); } @@ -36,7 +36,7 @@ class ListInboxTest extends TestCase */ public function it_should_test_loadFilters_method() { - $delegation = factory(Delegation::class)->create([ + $delegation = Delegation::factory()->create([ 'DEL_THREAD_STATUS' => 'CLOSED', ]); @@ -48,7 +48,7 @@ class ListInboxTest extends TestCase 'search' => $delegation->application->APP_UID, 'caseLink' => $delegation->application->APP_UID, 'process' => $delegation->process->PRO_UID, - 'category' => $delegation->process->PRO_CATEGORY, + 'category' => $this->faker->word, 'dateFrom' => '', 'dateTo' => '', 'filterStatus' => 'ON_TIME', //ON_TIME,AT_RISK,OVERDUE diff --git a/tests/unit/workflow/engine/classes/model/ListMyInboxTest.php b/tests/unit/workflow/engine/classes/model/ListMyInboxTest.php index b177be742..8d2c6aab9 100644 --- a/tests/unit/workflow/engine/classes/model/ListMyInboxTest.php +++ b/tests/unit/workflow/engine/classes/model/ListMyInboxTest.php @@ -15,7 +15,7 @@ class ListMyInboxTest extends TestCase /** * Set up method. */ - public function setUp() + public function setUp(): void { parent::setUp(); $this->faker = Factory::create(); @@ -25,7 +25,7 @@ class ListMyInboxTest extends TestCase /** * Tear down method, */ - public function tearDown() + public function tearDown(): void { parent::tearDown(); } @@ -36,7 +36,7 @@ class ListMyInboxTest extends TestCase */ public function it_should_test_loadFilters_method() { - $delegation = factory(Delegation::class)->create([ + $delegation = Delegation::factory()->create([ 'DEL_THREAD_STATUS' => 'CLOSED', ]); @@ -45,7 +45,7 @@ class ListMyInboxTest extends TestCase 'filter' => '', 'search' => $delegation->application->APP_UID, 'process' => $delegation->process->PRO_UID, - 'category' => $delegation->process->PRO_CATEGORY, + 'category' => $this->faker->word, 'dateFrom' => '', 'dateTo' => '' ]; diff --git a/tests/unit/workflow/engine/classes/model/ListParticipatedHistoryTest.php b/tests/unit/workflow/engine/classes/model/ListParticipatedHistoryTest.php index d0ea09708..83ac79455 100644 --- a/tests/unit/workflow/engine/classes/model/ListParticipatedHistoryTest.php +++ b/tests/unit/workflow/engine/classes/model/ListParticipatedHistoryTest.php @@ -15,7 +15,7 @@ class ListParticipatedHistoryTest extends TestCase /** * Set up method. */ - public function setUp() + public function setUp(): void { parent::setUp(); $this->faker = Factory::create(); @@ -25,7 +25,7 @@ class ListParticipatedHistoryTest extends TestCase /** * Tear down method, */ - public function tearDown() + public function tearDown(): void { parent::tearDown(); } @@ -36,7 +36,7 @@ class ListParticipatedHistoryTest extends TestCase */ public function it_should_test_loadFilters_method() { - $delegation = factory(Delegation::class)->create([ + $delegation = Delegation::factory()->create([ 'DEL_THREAD_STATUS' => 'CLOSED', ]); @@ -45,7 +45,7 @@ class ListParticipatedHistoryTest extends TestCase 'filter' => '', 'search' => $delegation->application->APP_UID, 'process' => $delegation->process->PRO_UID, - 'category' => $delegation->process->PRO_CATEGORY, + 'category' => $this->faker->word, 'dateFrom' => '', 'dateTo' => '' ]; diff --git a/tests/unit/workflow/engine/classes/model/ListParticipatedLastTest.php b/tests/unit/workflow/engine/classes/model/ListParticipatedLastTest.php index 2a9440e8b..7632cbb76 100644 --- a/tests/unit/workflow/engine/classes/model/ListParticipatedLastTest.php +++ b/tests/unit/workflow/engine/classes/model/ListParticipatedLastTest.php @@ -15,7 +15,7 @@ class ListParticipatedLastTest extends TestCase /** * Set up method. */ - public function setUp() + public function setUp(): void { parent::setUp(); $this->faker = Factory::create(); @@ -25,7 +25,7 @@ class ListParticipatedLastTest extends TestCase /** * Tear down method, */ - public function tearDown() + public function tearDown(): void { parent::tearDown(); } @@ -36,7 +36,7 @@ class ListParticipatedLastTest extends TestCase */ public function it_should_test_loadFilters_method() { - $delegation = factory(Delegation::class)->create([ + $delegation = Delegation::factory()->create([ 'DEL_THREAD_STATUS' => 'CLOSED', ]); @@ -46,7 +46,7 @@ class ListParticipatedLastTest extends TestCase 'search' => $delegation->application->APP_UID, 'caseLink' => $delegation->application->APP_UID, 'process' => $delegation->process->PRO_UID, - 'category' => $delegation->process->PRO_CATEGORY, + 'category' => $this->faker->word, 'dateFrom' => '', 'dateTo' => '', 'filterStatus' => 'ON_TIME', //ON_TIME,AT_RISK,OVERDUE diff --git a/tests/unit/workflow/engine/classes/model/ListPausedTest.php b/tests/unit/workflow/engine/classes/model/ListPausedTest.php index 3e4070331..fd66d312a 100644 --- a/tests/unit/workflow/engine/classes/model/ListPausedTest.php +++ b/tests/unit/workflow/engine/classes/model/ListPausedTest.php @@ -15,7 +15,7 @@ class ListPausedTest extends TestCase /** * Set up method. */ - public function setUp() + public function setUp(): void { parent::setUp(); $this->faker = Factory::create(); @@ -25,7 +25,7 @@ class ListPausedTest extends TestCase /** * Tear down method, */ - public function tearDown() + public function tearDown(): void { parent::tearDown(); } @@ -36,7 +36,7 @@ class ListPausedTest extends TestCase */ public function it_should_test_loadFilters_method() { - $delegation = factory(Delegation::class)->create([ + $delegation = Delegation::factory()->create([ 'DEL_THREAD_STATUS' => 'CLOSED', ]); @@ -46,7 +46,7 @@ class ListPausedTest extends TestCase 'search' => $delegation->application->APP_UID, 'caseLink' => $delegation->application->APP_UID, 'process' => $delegation->process->PRO_UID, - 'category' => $delegation->process->PRO_CATEGORY, + 'category' => $this->faker->word, 'filterStatus' => 'ON_TIME' //ON_TIME,AT_RISK,OVERDUE ]; $this->listPaused->loadFilters($criteria, $filters); diff --git a/tests/unit/workflow/engine/classes/model/ListUnassignedTest.php b/tests/unit/workflow/engine/classes/model/ListUnassignedTest.php index fb3f1b3cc..76f2795e8 100644 --- a/tests/unit/workflow/engine/classes/model/ListUnassignedTest.php +++ b/tests/unit/workflow/engine/classes/model/ListUnassignedTest.php @@ -15,7 +15,7 @@ class ListUnassignedTest extends TestCase /** * Set up method. */ - public function setUp() + public function setUp(): void { parent::setUp(); $this->faker = Factory::create(); @@ -25,7 +25,7 @@ class ListUnassignedTest extends TestCase /** * Tear down method, */ - public function tearDown() + public function tearDown(): void { parent::tearDown(); } @@ -36,7 +36,7 @@ class ListUnassignedTest extends TestCase */ public function it_should_test_loadFilters_method() { - $delegation = factory(Delegation::class)->create([ + $delegation = Delegation::factory()->create([ 'DEL_THREAD_STATUS' => 'CLOSED', ]); @@ -46,7 +46,7 @@ class ListUnassignedTest extends TestCase 'search' => $delegation->application->APP_UID, 'caseLink' => $delegation->application->APP_UID, 'process' => $delegation->process->PRO_UID, - 'category' => $delegation->process->PRO_CATEGORY, + 'category' => $this->faker->word, 'newestthan' => $delegation->DEL_DELEGATE_DATE->format('Y-m-d H:i:s'), 'oldestthan' => $delegation->DEL_DELEGATE_DATE->format('Y-m-d H:i:s'), 'appUidCheck' => $delegation->application->APP_UID diff --git a/tests/unit/workflow/engine/classes/model/OutputDocumentTest.php b/tests/unit/workflow/engine/classes/model/OutputDocumentTest.php index f454c8692..d44a11dc3 100644 --- a/tests/unit/workflow/engine/classes/model/OutputDocumentTest.php +++ b/tests/unit/workflow/engine/classes/model/OutputDocumentTest.php @@ -48,7 +48,7 @@ class OutputDocumentTest extends TestCase public function it_should_generate_tcpdf() { // Create a register in the output document - $output = factory(OutputDocumentModel::class)->create([ + $output = OutputDocumentModel::factory()->create([ 'OUT_DOC_TEMPLATE' => ' diff --git a/tests/unit/workflow/engine/controllers/DesignerTest.php b/tests/unit/workflow/engine/controllers/DesignerTest.php index 3f3d24ba4..fef03826c 100644 --- a/tests/unit/workflow/engine/controllers/DesignerTest.php +++ b/tests/unit/workflow/engine/controllers/DesignerTest.php @@ -18,9 +18,9 @@ class DesignerTest extends TestCase public function it_should_test_that_the_index_method_is_not_throwing_an_exception() { //Create the process factory - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); //Create the application factory - $application = factory(Application::class)->create( + $application = Application::factory()->create( [ 'APP_PIN' => G::encryptOld('LJ5W'), ] @@ -69,8 +69,8 @@ class DesignerTest extends TestCase $res = ob_get_clean(); //Assert the result does not have errors - $this->assertNotContains('Call to a member function getUsrUid() on null', $res); - $this->assertNotContains('Uncaught TypeError: Argument 2 passed to Illumincate\Routing\UrlGenerator::_construct() must be an instance of Illuminate\Http\Request, null given', + $this->assertStringNotContainsString('Call to a member function getUsrUid() on null', $res); + $this->assertStringNotContainsString('Uncaught TypeError: Argument 2 passed to Illumincate\Routing\UrlGenerator::_construct() must be an instance of Illuminate\Http\Request, null given', $res); } @@ -82,9 +82,9 @@ class DesignerTest extends TestCase public function it_should_test_the_index_method_when_the_user_logged_is_empty() { //Create the process factory - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); //Create the application factory - $application = factory(Application::class)->create( + $application = Application::factory()->create( [ 'APP_PIN' => G::encryptOld('LJ5W'), ] diff --git a/tests/unit/workflow/engine/controllers/PmTablesProxyTest.php b/tests/unit/workflow/engine/controllers/PmTablesProxyTest.php index 663f5dd28..8ccc8a922 100644 --- a/tests/unit/workflow/engine/controllers/PmTablesProxyTest.php +++ b/tests/unit/workflow/engine/controllers/PmTablesProxyTest.php @@ -3,6 +3,8 @@ namespace Tests\unit\workflow\engine\controllers; use AdditionalTables; +use Exception; +use Faker\Factory; use G; use Illuminate\Foundation\Testing\DatabaseTransactions; use pmTablesProxy; @@ -18,15 +20,6 @@ class PmTablesProxyTest extends TestCase use CreateTestSite; use DatabaseTransactions; - protected $preserveGlobalState = false; - protected $runTestInSeparateProcess = true; - - private $repTableBigInt; - private $repTableChar; - private $repTableInteger; - private $repTableSmallInt; - private $repTableTinyInt; - private $repTableVarChar; private $repTableBigIntUid; private $repTableCharUid; private $repTableIntegerUid; @@ -37,7 +30,7 @@ class PmTablesProxyTest extends TestCase /** * It setup the variables for the unit tests */ - protected function setUp() + public function setUp(): void { parent::setUp(); @@ -48,8 +41,28 @@ class PmTablesProxyTest extends TestCase //Set the user logged as the admin $_SESSION['USER_LOGGED'] = "00000000000000000000000000000001"; - // The InputFilter class use deprecated code - error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT); + $this->markTestSkipped("propel classes are not generated correctly"); + } + + /** + * Delete all the PM Tables created for the test + */ + public function tearDown(): void + { + parent::tearDown(); + $obj = new pmTablesProxy(); + $httpDataBigInt = (object)['rows' => '[{"id":"' . $this->repTableBigIntUid . '","type":""}]']; + $httpDataChar = (object)['rows' => '[{"id":"' . $this->repTableCharUid . '","type":""}]']; + $httpDataSmallInt = (object)['rows' => '[{"id":"' . $this->repTableSmallIntUid . '","type":""}]']; + $httpDataInteger = (object)['rows' => '[{"id":"' . $this->repTableIntegerUid . '","type":""}]']; + $httpDataVarChar = (object)['rows' => '[{"id":"' . $this->repTableVarCharUid . '","type":""}]']; + $httpDataTinyInt = (object)['rows' => '[{"id":"' . $this->repTableTinyIntUid . '","type":""}]']; + $obj->delete($httpDataBigInt); + $obj->delete($httpDataChar); + $obj->delete($httpDataSmallInt); + $obj->delete($httpDataInteger); + $obj->delete($httpDataVarChar); + $obj->delete($httpDataTinyInt); } /** @@ -62,7 +75,6 @@ class PmTablesProxyTest extends TestCase */ public function it_should_test_big_int_id() { - $this->markTestIncomplete(); $reportTable = new ReportTable(); //PM table with a bigint id @@ -106,7 +118,7 @@ class PmTablesProxyTest extends TestCase ]; //This create the report tables - $this->repTableBigInt = $reportTable->saveStructureOfTable($httpDatavarBigInt, true); + $reportTable->saveStructureOfTable($httpDatavarBigInt, true); $pmTablesList = new AdditionalTables(); $resuPmTableList = $pmTablesList->getAll(); $this->repTableBigIntUid = $resuPmTableList['rows'][0]['ADD_TAB_UID']; @@ -129,7 +141,7 @@ class PmTablesProxyTest extends TestCase ]; //This method update the PM tables rows - $resultDataUpdateBigInt = $obj->dataUpdate($httpDataUpdateBigInt); + $obj->dataUpdate($httpDataUpdateBigInt); //Assert the values were updated $resUpdateBigInt = $obj->dataView((object)["id" => $this->repTableBigIntUid]); @@ -173,7 +185,6 @@ class PmTablesProxyTest extends TestCase */ public function it_should_test_var_char_id() { - $this->markTestIncomplete(); $reportTable = new ReportTable(); //PM table with a char id @@ -217,7 +228,7 @@ class PmTablesProxyTest extends TestCase ]; //This create the report tables - $this->repTableChar = $reportTable->saveStructureOfTable($httpDatavarChar, true); + $reportTable->saveStructureOfTable($httpDatavarChar, true); $pmTablesList = new AdditionalTables(); $resuPmTableList = $pmTablesList->getAll(); $this->repTableCharUid = $resuPmTableList['rows'][0]['ADD_TAB_UID']; @@ -240,7 +251,7 @@ class PmTablesProxyTest extends TestCase ]; //This method update the PM tables rows - $resultDataUpdateChar = $obj->dataUpdate($httpDataUpdateChar); + $obj->dataUpdate($httpDataUpdateChar); //Assert the values were updated $resUpdateChar = $obj->dataView((object)["id" => $this->repTableCharUid]); @@ -284,7 +295,6 @@ class PmTablesProxyTest extends TestCase */ public function it_should_test_integer_id() { - $this->markTestIncomplete(); $reportTable = new ReportTable(); //PM table with an integer id @@ -328,7 +338,7 @@ class PmTablesProxyTest extends TestCase ]; //This create the report tables - $this->repTableInteger = $reportTable->saveStructureOfTable($httpDatavarInteger, true); + $reportTable->saveStructureOfTable($httpDatavarInteger, true); $pmTablesList = new AdditionalTables(); $resuPmTableList = $pmTablesList->getAll(); $this->repTableIntegerUid = $resuPmTableList['rows'][0]['ADD_TAB_UID']; @@ -342,7 +352,7 @@ class PmTablesProxyTest extends TestCase ]; //This will add rows to the PM tables - $res = $obj->dataCreate($httpDataInteger); + $obj->dataCreate($httpDataInteger); //The variables that will be used to update the rows in the PM tables $httpDataUpdateInteger = (object)[ @@ -351,7 +361,7 @@ class PmTablesProxyTest extends TestCase ]; //This method update the PM tables rows - $resultDataUpdateInteger = $obj->dataUpdate($httpDataUpdateInteger); + $obj->dataUpdate($httpDataUpdateInteger); //Assert the values were updated $resUpdateInteger = $obj->dataView((object)["id" => $this->repTableIntegerUid]); @@ -395,7 +405,6 @@ class PmTablesProxyTest extends TestCase */ public function it_should_test_smallint_id() { - $this->markTestIncomplete(); $reportTable = new ReportTable(); //PM table with a smallint id @@ -439,7 +448,7 @@ class PmTablesProxyTest extends TestCase ]; //This create the report tables - $this->repTableSmallInt = $reportTable->saveStructureOfTable($httpDatavarSmallInt, true); + $reportTable->saveStructureOfTable($httpDatavarSmallInt, true); $pmTablesList = new AdditionalTables(); $resuPmTableList = $pmTablesList->getAll(); $this->repTableSmallIntUid = $resuPmTableList['rows'][0]['ADD_TAB_UID']; @@ -462,7 +471,7 @@ class PmTablesProxyTest extends TestCase ]; //This method update the PM tables rows - $resultDataUpdateSmallInt = $obj->dataUpdate($httpDataUpdateSmallInt); + $obj->dataUpdate($httpDataUpdateSmallInt); //Assert the values were updated $resUpdateSmallInt = $obj->dataView((object)["id" => $this->repTableSmallIntUid]); @@ -505,7 +514,6 @@ class PmTablesProxyTest extends TestCase */ public function it_should_test_tinyint_id() { - $this->markTestIncomplete(); $reportTable = new ReportTable(); //PM table with a tinyint id @@ -549,7 +557,7 @@ class PmTablesProxyTest extends TestCase ]; //This create the report tables - $this->repTableTinyInt = $reportTable->saveStructureOfTable($httpDatavarTinyInt, true); + $reportTable->saveStructureOfTable($httpDatavarTinyInt, true); $pmTablesList = new AdditionalTables(); $resuPmTableList = $pmTablesList->getAll(); $this->repTableTinyIntUid = $resuPmTableList['rows'][0]['ADD_TAB_UID']; @@ -572,7 +580,7 @@ class PmTablesProxyTest extends TestCase ]; //This method update the PM tables rows - $resultDataUpdateTinyInt = $obj->dataUpdate($httpDataUpdateTinyInt); + $obj->dataUpdate($httpDataUpdateTinyInt); //Assert the values were updated $resUpdateTinyInt = $obj->dataView((object)["id" => $this->repTableTinyIntUid]); @@ -615,7 +623,6 @@ class PmTablesProxyTest extends TestCase */ public function it_should_test_varchar_id() { - $this->markTestIncomplete(); $reportTable = new ReportTable(); //PM table with a varchar id @@ -659,7 +666,7 @@ class PmTablesProxyTest extends TestCase ]; //This create the report tables - $this->repTableVarChar = $reportTable->saveStructureOfTable($httpDatavarVarChar, true); + $reportTable->saveStructureOfTable($httpDatavarVarChar, true); $pmTablesList = new AdditionalTables(); $resuPmTableList = $pmTablesList->getAll(); $this->repTableVarCharUid = $resuPmTableList['rows'][0]['ADD_TAB_UID']; @@ -682,7 +689,7 @@ class PmTablesProxyTest extends TestCase ]; //This method update the PM tables rows - $resultDataUpdateVarChar = $obj->dataUpdate($httpDataUpdateVarChar); + $obj->dataUpdate($httpDataUpdateVarChar); //Assert the values were updated $resUpdateVarChar = $obj->dataView((object)["id" => $this->repTableVarCharUid]); @@ -724,7 +731,6 @@ class PmTablesProxyTest extends TestCase */ public function it_should_test_varchar_id_filter() { - $this->markTestIncomplete(); $reportTable = new ReportTable(); //PM table with a varchar id @@ -768,7 +774,7 @@ class PmTablesProxyTest extends TestCase ]; //This create the report tables - $this->repTableVarChar = $reportTable->saveStructureOfTable($httpDatavarVarChar, true); + $reportTable->saveStructureOfTable($httpDatavarVarChar, true); $pmTablesList = new AdditionalTables(); $resuPmTableList = $pmTablesList->getAll(); $this->repTableVarCharUid = $resuPmTableList['rows'][0]['ADD_TAB_UID']; @@ -799,7 +805,6 @@ class PmTablesProxyTest extends TestCase */ public function it_should_test_varchar_id_exception() { - $this->markTestSkipped("Is not compatible with php74."); $reportTable = new ReportTable(); //PM table with a varchar id @@ -843,7 +848,7 @@ class PmTablesProxyTest extends TestCase ]; //This create the report tables - $this->repTableVarChar = $reportTable->saveStructureOfTable($httpDatavarVarChar, true); + $reportTable->saveStructureOfTable($httpDatavarVarChar, true); $pmTablesList = new AdditionalTables(); $resuPmTableList = $pmTablesList->getAll(); $this->repTableVarCharUid = $resuPmTableList['rows'][0]['ADD_TAB_UID']; @@ -879,7 +884,6 @@ class PmTablesProxyTest extends TestCase */ public function it_should_test_varchar_id_rows() { - $this->markTestIncomplete(); $reportTable = new ReportTable(); //PM table with a varchar id @@ -923,7 +927,7 @@ class PmTablesProxyTest extends TestCase ]; //This create the report tables - $this->repTableVarChar = $reportTable->saveStructureOfTable($httpDatavarVarChar, true); + $reportTable->saveStructureOfTable($httpDatavarVarChar, true); $pmTablesList = new AdditionalTables(); $resuPmTableList = $pmTablesList->getAll(); $this->repTableVarCharUid = $resuPmTableList['rows'][0]['ADD_TAB_UID']; @@ -937,7 +941,7 @@ class PmTablesProxyTest extends TestCase ]; //This will add rows to the PM tables - $r = $obj->dataCreate($httpDataVarChar); + $obj->dataCreate($httpDataVarChar); //The variables that will be used to update the rows in the PM tables $httpDataUpdateVarChar = (object)[ @@ -964,7 +968,7 @@ class PmTablesProxyTest extends TestCase ]), ]; - $this->expectExceptionMessage("**ID_PMTABLE_CLASS_DOESNT_EXIST**"); + $this->expectException(Exception::class); //This method update the PM tables rows $obj->dataUpdate($httpDataUpdateVarChar); } @@ -977,17 +981,18 @@ class PmTablesProxyTest extends TestCase */ public function it_should_test_destroy_method() { - $this->markTestSkipped("Is not compatible with php74."); + $faker = Factory::create(); $obj = new pmTablesProxy(); //Variable that is sent to the destroy method $httpDataDestroyTest = (object)[ - 'id' => "fakeUID", - 'rows' => G::encrypt("076", PMTABLE_KEY), + 'id' => $faker->unique()->numberBetween(1, 100), + 'rows' => G::encrypt("076", PMTABLE_KEY) ]; //Assert the exception message when the PM table does not exists - $this->expectExceptionMessage('ID_PMTABLE_CLASS_DOESNT_EXIST'); + $this->expectException(Exception::class); + //This method deletes a specific row of a PM table $obj->dataDestroy($httpDataDestroyTest); } @@ -1000,7 +1005,6 @@ class PmTablesProxyTest extends TestCase */ public function it_should_test_destroy_method_success() { - $this->markTestSkipped("Is not compatible with php74."); $reportTable = new ReportTable(); //PM table with a varchar id @@ -1044,7 +1048,7 @@ class PmTablesProxyTest extends TestCase ]; //This create the report tables - $this->repTableVarChar = $reportTable->saveStructureOfTable($httpDatavarVarChar, true); + $reportTable->saveStructureOfTable($httpDatavarVarChar, true); $pmTablesList = new AdditionalTables(); $resuPmTableList = $pmTablesList->getAll(); $this->repTableVarCharUid = $resuPmTableList['rows'][0]['ADD_TAB_UID']; @@ -1066,27 +1070,7 @@ class PmTablesProxyTest extends TestCase //This method deletes a specific row of a PM table $obj->dataDestroy($httpDataDestroyTest); - } - - /** - * Delete all the PM Tables created for the test - */ - public function tearDown() - { - parent::tearDown(); - $obj = new pmTablesProxy(); - $httpDataBigInt = (object)['rows' => '[{"id":"' . $this->repTableBigIntUid . '","type":""}]']; - $httpDataChar = (object)['rows' => '[{"id":"' . $this->repTableCharUid . '","type":""}]']; - $httpDataSmallInt = (object)['rows' => '[{"id":"' . $this->repTableSmallIntUid . '","type":""}]']; - $httpDataInteger = (object)['rows' => '[{"id":"' . $this->repTableIntegerUid . '","type":""}]']; - $httpDataVarChar = (object)['rows' => '[{"id":"' . $this->repTableVarCharUid . '","type":""}]']; - $httpDataTinyInt = (object)['rows' => '[{"id":"' . $this->repTableTinyIntUid . '","type":""}]']; - $obj->delete($httpDataBigInt); - $obj->delete($httpDataChar); - $obj->delete($httpDataSmallInt); - $obj->delete($httpDataInteger); - $obj->delete($httpDataVarChar); - $obj->delete($httpDataTinyInt); + $this->assertTrue(property_exists($obj, 'jsonResponse')); } /** @@ -1119,6 +1103,7 @@ class PmTablesProxyTest extends TestCase $pmTablesProxy = new pmTablesProxy(); $result = $pmTablesProxy->import($httpData); + ob_end_clean(); //asserts $this->assertObjectHasAttribute('fromAdmin', $result); diff --git a/tests/unit/workflow/engine/methods/authSources/AuthSourcesEditTest.php b/tests/unit/workflow/engine/methods/authSources/AuthSourcesEditTest.php index 474a6c84c..c8db87f7b 100644 --- a/tests/unit/workflow/engine/methods/authSources/AuthSourcesEditTest.php +++ b/tests/unit/workflow/engine/methods/authSources/AuthSourcesEditTest.php @@ -14,10 +14,13 @@ class AuthSourcesEditTest extends TestCase /** * This set initial parameters for each test. */ - public function setUp() + public function setUp(): void { parent::setUp(); $this->settingUserLogged(); + if (!defined('SYS_COLLECTION')) { + define('SYS_COLLECTION', 'case'); + } } /** @@ -59,7 +62,7 @@ class AuthSourcesEditTest extends TestCase $fileName = PATH_METHODS . 'authSources/authSources_Edit.php'; $_REQUEST['AUTH_SOURCE_PROVIDER'] = 'ldapAdvanced'; - $authenticationSource = factory(RbacAuthenticationSource::class) + $authenticationSource = RbacAuthenticationSource::factory() ->create(); $_GET['sUID'] = $authenticationSource->AUTH_SOURCE_UID; diff --git a/tests/unit/workflow/engine/methods/authSources/AuthSourcesNewTest.php b/tests/unit/workflow/engine/methods/authSources/AuthSourcesNewTest.php index c1714441e..116092780 100644 --- a/tests/unit/workflow/engine/methods/authSources/AuthSourcesNewTest.php +++ b/tests/unit/workflow/engine/methods/authSources/AuthSourcesNewTest.php @@ -13,7 +13,7 @@ class AuthSourcesNewTest extends TestCase /** * This set initial parameters for each test. */ - public function setUp() + public function setUp(): void { parent::setUp(); $this->settingUserLogged(); diff --git a/tests/unit/workflow/engine/methods/cases/CaseMessageHistory_AjaxTest.php b/tests/unit/workflow/engine/methods/cases/CaseMessageHistory_AjaxTest.php index 981398d30..37f761aa0 100644 --- a/tests/unit/workflow/engine/methods/cases/CaseMessageHistory_AjaxTest.php +++ b/tests/unit/workflow/engine/methods/cases/CaseMessageHistory_AjaxTest.php @@ -18,14 +18,19 @@ class CaseMessageHistory_AjaxTest extends TestCase /** * This method calls the parent setUp */ - public function setUp() + public function setUp(): void { - if (version_compare(phpversion(), 7.3, '>') ) { - $this->markTestSkipped('The changes in third party are not available'); - } parent::setUp(); } + /** + * This method calls the parent tearDown + */ + public function tearDown(): void + { + parent::tearDown(); + } + /** * It tests the message history grid messageHistoryGridList_JXP action with no permissions configured * @@ -33,27 +38,27 @@ class CaseMessageHistory_AjaxTest extends TestCase */ public function it_shoud_test_the_message_history_grid_list_jxp_action_with_no_permissions() { - $user = factory(USER::class)->create(); - $process = factory(PROCESS::class)->create(); + $user = USER::factory()->create(); + $process = PROCESS::factory()->create(); - $application = factory(APPLICATION::class)->create([ + $application = APPLICATION::factory()->create([ 'PRO_UID' => $process['PRO_UID'], 'APP_INIT_USER' => $user['USR_UID'], 'APP_CUR_USER' => $user['USR_UID'] ]); - $task = factory(TASK::class)->create([ + $task = TASK::factory()->create([ 'PRO_UID' => $process['PRO_UID'], 'TAS_USER' => $user['USR_UID'] ]); - $appmessage1 = factory(APPMESSAGE::class)->create([ + $appmessage1 = APPMESSAGE::factory()->create([ 'PRO_ID' => $process['PRO_ID'], 'TAS_ID' => $task['TAS_ID'], 'APP_NUMBER' => $application['APP_NUMBER'] ]); - $appmessage2 = factory(APPMESSAGE::class)->create([ + $appmessage2 = APPMESSAGE::factory()->create([ 'APP_MSG_TYPE' => 'PM_FUNCTION', 'PRO_ID' => $process['PRO_ID'], 'TAS_ID' => $task['TAS_ID'], @@ -86,24 +91,24 @@ class CaseMessageHistory_AjaxTest extends TestCase */ public function it_shoud_test_the_message_history_grid_list_jxp_action_with_view_permission() { - $user = factory(USER::class)->create(); + $user = USER::factory()->create(); - $processView = factory(PROCESS::class)->create([ + $processView = PROCESS::factory()->create([ 'PRO_CREATE_USER' => $user['USR_UID'] ]); - $application = factory(APPLICATION::class)->create([ + $application = APPLICATION::factory()->create([ 'PRO_UID' => $processView['PRO_UID'], 'APP_INIT_USER' => $user['USR_UID'], 'APP_CUR_USER' => $user['USR_UID'] ]); - $task = factory(TASK::class)->create([ + $task = TASK::factory()->create([ 'PRO_UID' => $processView['PRO_UID'], 'TAS_USER' => $user['USR_UID'] ]); - $delegation = factory(DELEGATION::class)->create([ + $delegation = DELEGATION::factory()->create([ 'APP_UID' => $application['APP_UID'], 'DEL_INDEX' => 0, 'DEL_PREVIOUS' => 0, @@ -116,14 +121,14 @@ class CaseMessageHistory_AjaxTest extends TestCase 'DEL_PRIORITY' => 3, ]); - $appmessage1 = factory(APPMESSAGE::class)->create([ + $appmessage1 = APPMESSAGE::factory()->create([ 'PRO_ID' => $processView['PRO_ID'], 'TAS_ID' => $task['TAS_ID'], 'APP_NUMBER' => $application['APP_NUMBER'], 'DEL_INDEX' => 0 ]); - $appmessage2 = factory(APPMESSAGE::class)->create([ + $appmessage2 = APPMESSAGE::factory()->create([ 'APP_MSG_TYPE' => 'PM_FUNCTION', 'PRO_ID' => $processView['PRO_ID'], 'TAS_ID' => $task['TAS_ID'], @@ -131,7 +136,7 @@ class CaseMessageHistory_AjaxTest extends TestCase 'DEL_INDEX' => 0 ]); - $objectPermission = factory(OBJECTPERMISSION::class)->create([ + $objectPermission = OBJECTPERMISSION::factory()->create([ 'PRO_UID' => $processView['PRO_UID'], 'TAS_UID' => $task['TAS_UID'], 'USR_UID' => $user['USR_UID'], @@ -162,24 +167,24 @@ class CaseMessageHistory_AjaxTest extends TestCase */ public function it_shoud_test_the_message_history_grid_list_jxp_action_with_resend_permission() { - $user = factory(USER::class)->create(); + $user = USER::factory()->create(); - $processView = factory(PROCESS::class)->create([ + $processView = PROCESS::factory()->create([ 'PRO_CREATE_USER' => $user['USR_UID'] ]); - $application = factory(APPLICATION::class)->create([ + $application = APPLICATION::factory()->create([ 'PRO_UID' => $processView['PRO_UID'], 'APP_INIT_USER' => $user['USR_UID'], 'APP_CUR_USER' => $user['USR_UID'] ]); - $task = factory(TASK::class)->create([ + $task = TASK::factory()->create([ 'PRO_UID' => $processView['PRO_UID'], 'TAS_USER' => $user['USR_UID'] ]); - $delegation = factory(DELEGATION::class)->create([ + $delegation = DELEGATION::factory()->create([ 'APP_UID' => $application['APP_UID'], 'DEL_INDEX' => 0, 'DEL_PREVIOUS' => 0, @@ -192,14 +197,14 @@ class CaseMessageHistory_AjaxTest extends TestCase 'DEL_PRIORITY' => 3, ]); - $appmessage1 = factory(APPMESSAGE::class)->create([ + $appmessage1 = APPMESSAGE::factory()->create([ 'PRO_ID' => $processView['PRO_ID'], 'TAS_ID' => $task['TAS_ID'], 'APP_NUMBER' => $application['APP_NUMBER'], 'DEL_INDEX' => 0 ]); - $appmessage2 = factory(APPMESSAGE::class)->create([ + $appmessage2 = APPMESSAGE::factory()->create([ 'APP_MSG_TYPE' => 'PM_FUNCTION', 'PRO_ID' => $processView['PRO_ID'], 'TAS_ID' => $task['TAS_ID'], @@ -207,7 +212,7 @@ class CaseMessageHistory_AjaxTest extends TestCase 'DEL_INDEX' => 0 ]); - $objectPermission = factory(OBJECTPERMISSION::class)->create([ + $objectPermission = OBJECTPERMISSION::factory()->create([ 'PRO_UID' => $processView['PRO_UID'], 'TAS_UID' => $task['TAS_UID'], 'USR_UID' => $user['USR_UID'], @@ -238,35 +243,35 @@ class CaseMessageHistory_AjaxTest extends TestCase */ public function it_shoud_test_the_message_history_grid_list_jxp_action_with_block_permission() { - $user = factory(USER::class)->create(); + $user = USER::factory()->create(); - $process = factory(PROCESS::class)->create(); + $process = PROCESS::factory()->create(); - $application = factory(APPLICATION::class)->create([ + $application = APPLICATION::factory()->create([ 'PRO_UID' => $process['PRO_UID'], 'APP_INIT_USER' => $user['USR_UID'], 'APP_CUR_USER' => $user['USR_UID'] ]); - $task = factory(TASK::class)->create([ + $task = TASK::factory()->create([ 'PRO_UID' => $process['PRO_UID'], 'TAS_USER' => $user['USR_UID'] ]); - $appmessage1 = factory(APPMESSAGE::class)->create([ + $appmessage1 = APPMESSAGE::factory()->create([ 'PRO_ID' => $process['PRO_ID'], 'TAS_ID' => $task['TAS_ID'], 'APP_NUMBER' => $application['APP_NUMBER'] ]); - $appmessage2 = factory(APPMESSAGE::class)->create([ + $appmessage2 = APPMESSAGE::factory()->create([ 'APP_MSG_TYPE' => 'PM_FUNCTION', 'PRO_ID' => $process['PRO_ID'], 'TAS_ID' => $task['TAS_ID'], 'APP_NUMBER' => $application['APP_NUMBER'] ]); - $objectPermission = factory(OBJECTPERMISSION::class)->create([ + $objectPermission = OBJECTPERMISSION::factory()->create([ 'PRO_UID' => $process['PRO_UID'], 'TAS_UID' => $task['TAS_UID'], 'USR_UID' => $user['USR_UID'], @@ -290,12 +295,4 @@ class CaseMessageHistory_AjaxTest extends TestCase ob_end_clean(); $this->assertEmpty(json_decode($result)->data); } - - /** - * This method calls the parent tearDown - */ - public function tearDown() - { - parent::tearDown(); - } -} \ No newline at end of file +} diff --git a/tests/unit/workflow/engine/methods/cases/CasesMenuHighlightTest.php b/tests/unit/workflow/engine/methods/cases/CasesMenuHighlightTest.php index 739553346..93e055433 100644 --- a/tests/unit/workflow/engine/methods/cases/CasesMenuHighlightTest.php +++ b/tests/unit/workflow/engine/methods/cases/CasesMenuHighlightTest.php @@ -20,7 +20,7 @@ class CasesMenuHighlightTest extends TestCase /** * This sets the initial parameters for each test. */ - public function setUp() + public function setUp(): void { parent::setUp(); $this->settingUserLogged(); @@ -52,17 +52,17 @@ class CasesMenuHighlightTest extends TestCase public function it_should_test_the_response_of_the_cases_menu_highlight_file() { // Create process - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); // Create a task self service - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID ]); // Assign the current user in the task - factory(TaskUser::class)->create([ + TaskUser::factory()->create([ 'TAS_UID' => $task->TAS_UID, 'USR_UID' => $this->user->USR_UID, 'TU_RELATION' => 1, //Related to the user @@ -70,7 +70,7 @@ class CasesMenuHighlightTest extends TestCase ]); // Create records in delegation relate to self-service - factory(Delegation::class, 10)->create([ + Delegation::factory(10)->create([ 'TAS_ID' => $task->TAS_ID, 'DEL_THREAD_STATUS' => 'OPEN', 'USR_ID' => 0 diff --git a/tests/unit/workflow/engine/methods/cases/CasesOpenTest.php b/tests/unit/workflow/engine/methods/cases/CasesOpenTest.php index 0d5a262a8..2601624d4 100644 --- a/tests/unit/workflow/engine/methods/cases/CasesOpenTest.php +++ b/tests/unit/workflow/engine/methods/cases/CasesOpenTest.php @@ -40,23 +40,23 @@ class CasesOpenTest extends TestCase $RBAC->initRBAC(); $RBAC->loadUserRolePermission('PROCESSMAKER', $_SESSION['USER_LOGGED']); - $task = factory(Task::class)->create(); - $dynaform = factory(Dynaform::class)->create(); - $process = factory(Process::class)->create([ + $task = Task::factory()->create(); + $dynaform = Dynaform::factory()->create(); + $process = Process::factory()->create([ 'PRO_DYNAFORMS' => $dynaform['DYN_UID'] ]); - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'PRO_UID' => $process['PRO_UID'], 'APP_STATUS' => 'COMPLETED' ]); - $delegation = factory(Delegation::class)->create([ + $delegation = Delegation::factory()->create([ 'APP_UID' => $application['APP_UID'], 'TAS_UID' => $task['TAS_UID'], 'DEL_INDEX' => 1, 'DEL_THREAD_STATUS' => 'CLOSED' ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_UID' => $application['APP_UID'], 'TAS_UID' => $task['TAS_UID'], 'DEL_INDEX' => 2, @@ -85,6 +85,6 @@ class CasesOpenTest extends TestCase ob_end_clean(); $res = ''; - $this->assertContains($res, $outputBuffer); + $this->assertStringContainsString($res, $outputBuffer); } } diff --git a/tests/unit/workflow/engine/methods/cases/CasesShowDocumentTest.php b/tests/unit/workflow/engine/methods/cases/CasesShowDocumentTest.php index 1aca4ce42..099c29468 100644 --- a/tests/unit/workflow/engine/methods/cases/CasesShowDocumentTest.php +++ b/tests/unit/workflow/engine/methods/cases/CasesShowDocumentTest.php @@ -13,12 +13,8 @@ class CasesShowDocumentTest extends TestCase /** * Setup method. */ - public function setUp() + public function setUp(): void { - if (version_compare(phpversion(), 7.3, '>') ) { - $this->markTestSkipped('The changes in third party are not available'); - } - parent::setUp(); if (!defined('PATH_DOCUMENT')) { define('PATH_DOCUMENT', PATH_DB . config('system.workspace') . PATH_SEP . 'files' . PATH_SEP); @@ -35,7 +31,7 @@ class CasesShowDocumentTest extends TestCase $RBAC = RBAC::getSingleton(); $RBAC->initRBAC(); - $appDocument = factory(Documents::class)->create([ + $appDocument = Documents::factory()->create([ 'APP_DOC_FILENAME' => 'text.txt' ]); diff --git a/tests/unit/workflow/engine/methods/emailServer/EmailServerAjaxTest.php b/tests/unit/workflow/engine/methods/emailServer/EmailServerAjaxTest.php index 1613fc400..fc455b367 100644 --- a/tests/unit/workflow/engine/methods/emailServer/EmailServerAjaxTest.php +++ b/tests/unit/workflow/engine/methods/emailServer/EmailServerAjaxTest.php @@ -13,7 +13,7 @@ class EmailServerAjaxTest extends TestCase /** * This set initial parameters for each test. */ - public function setUp() + public function setUp(): void { parent::setUp(); $this->settingUserLogged(); @@ -133,7 +133,7 @@ class EmailServerAjaxTest extends TestCase { $faker = Factory::create(); - $emailServer = factory(EmailServerModel::class)->create([ + $emailServer = EmailServerModel::factory()->create([ 'MESS_ENGINE' => 'PHPMAILER', ]); @@ -169,7 +169,7 @@ class EmailServerAjaxTest extends TestCase */ public function it_should_verify_the_option_del() { - $emailServer = factory(EmailServerModel::class)->create([ + $emailServer = EmailServerModel::factory()->create([ 'MESS_ENGINE' => 'PHPMAILER', ]); diff --git a/tests/unit/workflow/engine/methods/emailServer/EmailServerGmailOAuthTest.php b/tests/unit/workflow/engine/methods/emailServer/EmailServerGmailOAuthTest.php index d3762c28b..4a1bd1003 100644 --- a/tests/unit/workflow/engine/methods/emailServer/EmailServerGmailOAuthTest.php +++ b/tests/unit/workflow/engine/methods/emailServer/EmailServerGmailOAuthTest.php @@ -15,7 +15,7 @@ class EmailServerGmailOAuthTest extends TestCase /** * This method calls the parent setUp */ - public function setUp() + public function setUp(): void { if (version_compare(phpversion(), 7.3, '>') ) { $this->markTestSkipped('The changes in third party are not available'); diff --git a/tests/unit/workflow/engine/methods/emailServer/EmailServerTest.php b/tests/unit/workflow/engine/methods/emailServer/EmailServerTest.php index 5ea67190d..38f9a85de 100644 --- a/tests/unit/workflow/engine/methods/emailServer/EmailServerTest.php +++ b/tests/unit/workflow/engine/methods/emailServer/EmailServerTest.php @@ -32,6 +32,6 @@ class EmailServerTest extends TestCase require_once PATH_METHODS . 'emailServer/emailServer.php'; $content = ob_get_clean(); - $this->assertContains("EMAILSERVER_LICENSED", $content); + $this->assertStringContainsString("EMAILSERVER_LICENSED", $content); } } diff --git a/tests/unit/workflow/engine/methods/groups/GroupsAjaxTest.php b/tests/unit/workflow/engine/methods/groups/GroupsAjaxTest.php index b3195479e..17e5ac389 100644 --- a/tests/unit/workflow/engine/methods/groups/GroupsAjaxTest.php +++ b/tests/unit/workflow/engine/methods/groups/GroupsAjaxTest.php @@ -15,11 +15,11 @@ class GroupsAjaxTest extends TestCase /** * Set up function */ - public function setUp() + public function setUp(): void { parent::setUp(); + $this->truncateNonInitialModels(); $this->settingUserLogged(); - Groupwf::truncate(); $this->createGroups(); } @@ -28,7 +28,7 @@ class GroupsAjaxTest extends TestCase */ private function createGroups() { - $this->groups = factory(Groupwf::class, 10)->create(); + $this->groups = Groupwf::factory(10)->create(); } /** @@ -58,6 +58,7 @@ class GroupsAjaxTest extends TestCase { global $RBAC; $_POST['action'] = 'groupsList'; + $_GET['action'] = 'groupsList'; $_REQUEST["dir"] = "DESC"; $_REQUEST["sort"] = "GRP_TITLE"; @@ -68,10 +69,9 @@ class GroupsAjaxTest extends TestCase $content = ob_get_clean(); $content = json_decode($content, JSON_OBJECT_AS_ARRAY); - // @todo, review the issue in the circle CI - //$this->assertArrayHasKey("success", $content); - //$this->assertArrayHasKey("groups", $content); - //$this->assertTrue($content["success"]); - //$this->assertTrue(is_array($content["groups"])); + $this->assertArrayHasKey("success", $content); + $this->assertArrayHasKey("groups", $content); + $this->assertTrue($content["success"]); + $this->assertTrue(is_array($content["groups"])); } } diff --git a/tests/unit/workflow/engine/methods/services/ActionsByEmailDataFormTest.php b/tests/unit/workflow/engine/methods/services/ActionsByEmailDataFormTest.php index 308008eb9..f4d348de8 100644 --- a/tests/unit/workflow/engine/methods/services/ActionsByEmailDataFormTest.php +++ b/tests/unit/workflow/engine/methods/services/ActionsByEmailDataFormTest.php @@ -14,7 +14,7 @@ class ActionsByEmailDataFormTest extends TestCase /** * Setup method. */ - public function setUp() + public function setUp(): void { parent::setUp(); if (!defined('URL_KEY')) { @@ -46,16 +46,16 @@ class ActionsByEmailDataFormTest extends TestCase */ public function it_should_test_view_action_by_email_with_time_zone() { - $process = factory(\ProcessMaker\Model\Process::class)->create(); + $process = \ProcessMaker\Model\Process::factory()->create(); $pathData = PATH_TRUNK . "tests/resources/dynaform1.json"; $content = file_get_contents($pathData); - $dynaform = factory(\ProcessMaker\Model\Dynaform::class)->create([ + $dynaform = \ProcessMaker\Model\Dynaform::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'DYN_CONTENT' => $content ]); - $delegation = factory(\ProcessMaker\Model\Delegation::class)->state('closed')->create([ + $delegation = \ProcessMaker\Model\Delegation::factory()->closed()->create([ 'PRO_UID' => $process->PRO_UID ]); @@ -78,6 +78,6 @@ class ActionsByEmailDataFormTest extends TestCase ob_end_clean(); $this->assertNotEmpty($content); - $this->assertContains('ID_ABE_FORM_ALREADY_FILLED', $content); + $this->assertStringContainsString('ID_ABE_FORM_ALREADY_FILLED', $content); } } diff --git a/tests/unit/workflow/engine/methods/users/UsersAjaxTest.php b/tests/unit/workflow/engine/methods/users/UsersAjaxTest.php index 21cce0555..7262b44e3 100644 --- a/tests/unit/workflow/engine/methods/users/UsersAjaxTest.php +++ b/tests/unit/workflow/engine/methods/users/UsersAjaxTest.php @@ -13,7 +13,7 @@ class UsersAjaxTest extends TestCase /** * Set up the deprecated errors */ - public function setUp() + public function setUp(): void { parent::setUp(); error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT); @@ -28,10 +28,10 @@ class UsersAjaxTest extends TestCase //Declare the global variable global $RBAC; //Creates the user factory - $user = factory(User::class)->create(); + $user = User::factory()->create(); $usrUid = $user['USR_UID']; //Creates the configuration factory - factory(Configuration::class)->create([ + Configuration::factory()->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:"";}', @@ -88,7 +88,7 @@ class UsersAjaxTest extends TestCase //Declare the global variable global $RBAC; //Creates the user factory - $user2 = factory(User::class)->create( + $user2 = User::factory()->create( [ 'USR_ROLE' => 'PROCESSMAKER_ADMIN', 'USR_EMAIL' => 'test@processmaker.com' @@ -96,7 +96,7 @@ class UsersAjaxTest extends TestCase ); $usrUid = $user2['USR_UID']; //Creates the configuration factory - factory(Configuration::class)->create([ + Configuration::factory()->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:"";}', @@ -106,7 +106,7 @@ class UsersAjaxTest extends TestCase ]); //Creates the UsersRoles factory - factory(RbacUsersRoles::class)->create( + RbacUsersRoles::factory()->create( [ 'USR_UID' => $usrUid, 'ROL_UID' => '00000000000000000000000000000002' diff --git a/tests/unit/workflow/engine/methods/users/Users_AjaxTest.php b/tests/unit/workflow/engine/methods/users/Users_AjaxTest.php index d5796adab..441cb7b2a 100644 --- a/tests/unit/workflow/engine/methods/users/Users_AjaxTest.php +++ b/tests/unit/workflow/engine/methods/users/Users_AjaxTest.php @@ -14,7 +14,7 @@ class Users_AjaxTest extends TestCase /** * Set up the deprecated errors */ - public function setUp() + public function setUp(): void { parent::setUp(); error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT); @@ -31,16 +31,16 @@ class Users_AjaxTest extends TestCase global $RBAC; //Creates the user factory - $user = factory(User::class)->create(); + $user = User::factory()->create(); $usrUid = $user['USR_UID']; - factory(Process::class)->create([ + Process::factory()->create([ 'PRO_CREATE_USER' => $usrUid, 'PRO_STATUS' => 'ACTIVE', 'PRO_TYPE_PROCESS' => 'PRIVATE', ]); //Creates the configuration factory - factory(Configuration::class)->create([ + Configuration::factory()->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:"";}', @@ -94,8 +94,8 @@ class Users_AjaxTest extends TestCase global $RBAC; //Creates the user factory - $user = factory(User::class)->create(); - factory(RbacUsers::class)->create([ + $user = User::factory()->create(); + RbacUsers::factory()->create([ 'USR_UID' => $user['USR_UID'], 'USR_USERNAME' => $user->USR_USERNAME, 'USR_FIRSTNAME' => $user->USR_FIRSTNAME, @@ -103,7 +103,7 @@ class Users_AjaxTest extends TestCase ]); $usrUid = $user['USR_UID']; - $process = factory(Process::class)->create([ + $process = Process::factory()->create([ 'PRO_CREATE_USER' => $usrUid, 'PRO_STATUS' => 'ACTIVE', 'PRO_TYPE_PROCESS' => 'PRIVATE', diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/ActionsByEmailTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/ActionsByEmailTest.php index ab20ed1ee..fec4be8ee 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/ActionsByEmailTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/ActionsByEmailTest.php @@ -16,6 +16,16 @@ use Tests\TestCase; class ActionsByEmailTest extends TestCase { + /** + * + * @return void + */ + public function setUp(): void + { + parent::setUp(); + $this->truncateNonInitialModels(); + } + /** * Test the forwardMail method * @@ -25,21 +35,21 @@ class ActionsByEmailTest extends TestCase public function it_should_test_the_forward_mail_method() { //Create the Task factory - factory(Task::class)->create(); + Task::factory()->create(); //Create the Process factory - factory(Process::class)->create(); + Process::factory()->create(); //Create the Dynaform factory - factory(Dynaform::class)->create(); + Dynaform::factory()->create(); //Create the EmailServerModel factory - factory(EmailServerModel::class)->create(); + EmailServerModel::factory()->create(); //Create the Application factory - factory(Application::class)->create(); + Application::factory()->create(); //Create the Delegation factory - $delegation = factory(Delegation::class)->create(); + $delegation = Delegation::factory()->create(); //Create the AbeConfiguration factory - $abeConfiguration = factory(AbeConfiguration::class)->create(); + $abeConfiguration = AbeConfiguration::factory()->create(); //Create the AbeConfiguration factory - $abeRequest = factory(AbeRequest::class)->create([ + $abeRequest = AbeRequest::factory()->create([ 'ABE_UID' => $abeConfiguration->ABE_UID, 'APP_UID' => $delegation->APP_UID, 'DEL_INDEX' => $delegation->DEL_INDEX, @@ -60,7 +70,7 @@ class ActionsByEmailTest extends TestCase $res = $abe->forwardMail($arrayData); //Assert the email was sent successfully - $this->assertContains('**ID_EMAIL_RESENT_TO**: ' . $abeRequest->ABE_REQ_SENT_TO, $res); + $this->assertStringContainsString('**ID_EMAIL_RESENT_TO**: ' . $abeRequest->ABE_REQ_SENT_TO, $res); } /** @@ -72,21 +82,21 @@ class ActionsByEmailTest extends TestCase public function it_should_test_the_forward_mail_method_when_an_error_occurs() { //Create the Task factory - factory(Task::class)->create(); + Task::factory()->create(); //Create the Process factory - factory(Process::class)->create(); + Process::factory()->create(); //Create the Dynaform factory - factory(Dynaform::class)->create(); + Dynaform::factory()->create(); //Create the EmailServerModel factory - factory(EmailServerModel::class)->create(); + EmailServerModel::factory()->create(); //Create the Application factory - factory(Application::class)->create(); + Application::factory()->create(); //Create the Delegation factory - $delegation = factory(Delegation::class)->create(); + $delegation = Delegation::factory()->create(); //Create the AbeConfiguration factory - $abeConfiguration = factory(AbeConfiguration::class)->create(); + $abeConfiguration = AbeConfiguration::factory()->create(); //Create the AbeConfiguration factory - $abeRequest = factory(AbeRequest::class)->create([ + $abeRequest = AbeRequest::factory()->create([ 'ABE_UID' => $abeConfiguration->ABE_UID, 'APP_UID' => $delegation->APP_UID, 'DEL_INDEX' => $delegation->DEL_INDEX, @@ -107,7 +117,7 @@ class ActionsByEmailTest extends TestCase $res = $abe->forwardMail($arrayData); //Assert that an unexpected error occur - $this->assertContains('**ID_UNEXPECTED_ERROR_OCCURRED_PLEASE**', $res); + $this->assertStringContainsString('**ID_UNEXPECTED_ERROR_OCCURRED_PLEASE**', $res); } /** @@ -119,23 +129,23 @@ class ActionsByEmailTest extends TestCase public function it_should_test_the_forward_mail_method_when_the_email_cannot_be_sent() { //Create the Task factory - factory(Task::class)->create(); + Task::factory()->create(); //Create the Process factory - factory(Process::class)->create(); + Process::factory()->create(); //Create the Dynaform factory - factory(Dynaform::class)->create(); + Dynaform::factory()->create(); //Create the EmailServerModel factory - factory(EmailServerModel::class)->create(); + EmailServerModel::factory()->create(); //Create the Application factory - factory(Application::class)->create(); + Application::factory()->create(); //Create the Delegation factory - $delegation = factory(Delegation::class)->create([ + $delegation = Delegation::factory()->create([ 'DEL_FINISH_DATE' => '2019-09-27 14:53:06' ]); //Create the AbeConfiguration factory - $abeConfiguration = factory(AbeConfiguration::class)->create(); + $abeConfiguration = AbeConfiguration::factory()->create(); //Create the AbeConfiguration factory - $abeRequest = factory(AbeRequest::class)->create([ + $abeRequest = AbeRequest::factory()->create([ 'ABE_UID' => $abeConfiguration->ABE_UID, 'APP_UID' => $delegation->APP_UID, 'DEL_INDEX' => $delegation->DEL_INDEX, @@ -156,7 +166,7 @@ class ActionsByEmailTest extends TestCase $res = $abe->forwardMail($arrayData); //Assert the email was not sent - $this->assertContains('**ID_UNABLE_TO_SEND_EMAIL**', $res); + $this->assertStringContainsString('**ID_UNABLE_TO_SEND_EMAIL**', $res); } /** @@ -168,23 +178,23 @@ class ActionsByEmailTest extends TestCase public function it_should_test_the_forward_mail_method_when_the_req_uid_is_not_set() { //Create the Task factory - factory(Task::class)->create(); + Task::factory()->create(); //Create the Process factory - factory(Process::class)->create(); + Process::factory()->create(); //Create the Dynaform factory - factory(Dynaform::class)->create(); + Dynaform::factory()->create(); //Create the EmailServerModel factory - factory(EmailServerModel::class)->create(); + EmailServerModel::factory()->create(); //Create the Application factory - factory(Application::class)->create(); + Application::factory()->create(); //Create the Delegation factory - $delegation = factory(Delegation::class)->create([ + $delegation = Delegation::factory()->create([ 'DEL_FINISH_DATE' => '2019-09-27 14:53:06' ]); //Create the AbeConfiguration factory - $abeConfiguration = factory(AbeConfiguration::class)->create(); + $abeConfiguration = AbeConfiguration::factory()->create(); //Create the AbeConfiguration factory - $abeRequest = factory(AbeRequest::class)->create([ + $abeRequest = AbeRequest::factory()->create([ 'ABE_UID' => $abeConfiguration->ABE_UID, 'APP_UID' => $delegation->APP_UID, 'DEL_INDEX' => $delegation->DEL_INDEX, @@ -204,7 +214,7 @@ class ActionsByEmailTest extends TestCase $res = $abe->forwardMail($arrayData); //Assert the email was not sent - $this->assertContains('**ID_UNEXPECTED_ERROR_OCCURRED_PLEASE**', $res); + $this->assertStringContainsString('**ID_UNEXPECTED_ERROR_OCCURRED_PLEASE**', $res); } /** @@ -216,23 +226,23 @@ class ActionsByEmailTest extends TestCase public function it_should_test_the_forward_mail_method_with_ssl() { //Create the Task factory - factory(Task::class)->create(); + Task::factory()->create(); //Create the Process factory - factory(Process::class)->create(); + Process::factory()->create(); //Create the Dynaform factory - factory(Dynaform::class)->create(); + Dynaform::factory()->create(); //Create the EmailServerModel factory with smtp secure - factory(EmailServerModel::class)->create( + EmailServerModel::factory()->create( ['SMTPSECURE' => 'ssl'] ); //Create the Application factory - factory(Application::class)->create(); + Application::factory()->create(); //Create the Delegation factory - $delegation = factory(Delegation::class)->create(); + $delegation = Delegation::factory()->create(); //Create the AbeConfiguration factory - $abeConfiguration = factory(AbeConfiguration::class)->create(); + $abeConfiguration = AbeConfiguration::factory()->create(); //Create the AbeConfiguration factory - $abeRequest = factory(AbeRequest::class)->create([ + $abeRequest = AbeRequest::factory()->create([ 'ABE_UID' => $abeConfiguration->ABE_UID, 'APP_UID' => $delegation->APP_UID, 'DEL_INDEX' => $delegation->DEL_INDEX, @@ -253,7 +263,7 @@ class ActionsByEmailTest extends TestCase $res = $abe->forwardMail($arrayData); //Assert the email was sent successfully - $this->assertContains('**ID_EMAIL_RESENT_TO**: ' . $abeRequest->ABE_REQ_SENT_TO, $res); + $this->assertStringContainsString('**ID_EMAIL_RESENT_TO**: ' . $abeRequest->ABE_REQ_SENT_TO, $res); } /** @@ -264,13 +274,11 @@ class ActionsByEmailTest extends TestCase */ public function it_should_test_the_load_action_by_email_method() { - AbeConfiguration::truncate(); - AbeRequest::truncate(); - $user = factory(User::class)->create(); - $application = factory(Application::class)->create([ + $user = User::factory()->create(); + $application = Application::factory()->create([ 'APP_UID' => '123456asse' ]); - $delegation = factory(Delegation::class)->create([ + $delegation = Delegation::factory()->create([ 'USR_UID' => $user->USR_UID, 'USR_ID' => $user->USR_ID, 'APP_UID' => $application->APP_UID, @@ -278,7 +286,7 @@ class ActionsByEmailTest extends TestCase 'DEL_PREVIOUS' => 0, 'DEL_INDEX' => 1 ]); - $delegation2 = factory(Delegation::class)->create([ + $delegation2 = Delegation::factory()->create([ 'USR_UID' => $user->USR_UID, 'USR_ID' => $user->USR_ID, 'APP_UID' => $application->APP_UID, @@ -286,12 +294,12 @@ class ActionsByEmailTest extends TestCase 'DEL_PREVIOUS' => 1, 'DEL_INDEX' => 2 ]); - $abeConfiguration = factory(AbeConfiguration::class)->create([ + $abeConfiguration = AbeConfiguration::factory()->create([ 'PRO_UID' => $delegation->PRO_UID, 'TAS_UID' => $delegation->TAS_UID, 'ABE_TYPE' => 'LINK', ]); - $abeRequest = factory(AbeRequest::class)->create([ + $abeRequest = AbeRequest::factory()->create([ 'ABE_UID' => $abeConfiguration->ABE_UID, 'APP_UID' => $delegation2->APP_UID, 'DEL_INDEX' => $delegation2->DEL_INDEX, diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/AbstractCasesTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/AbstractCasesTest.php index eb971523d..73be239eb 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/AbstractCasesTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/AbstractCasesTest.php @@ -4,7 +4,6 @@ namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases; use Exception; use G; -use Illuminate\Foundation\Testing\DatabaseTransactions; use ProcessMaker\BusinessModel\Cases\AbstractCases; use ProcessMaker\BusinessModel\Cases\Draft; use ProcessMaker\BusinessModel\Cases\Paused; @@ -24,7 +23,14 @@ use Tests\TestCase; */ class AbstractCasesTest extends TestCase { - use DatabaseTransactions; + /** + * Method set up. + */ + public function setUp(): void + { + parent::setUp(); + $this->truncateNonInitialModels(); + } /** * This check the getter and setter related to the category @@ -35,7 +41,7 @@ class AbstractCasesTest extends TestCase */ public function it_return_set_get_category() { - $category = factory(ProcessCategory::class)->create(); + $category = ProcessCategory::factory()->create(); $absCases = new AbstractCases(); $absCases->setCategoryId($category->CATEGORY_ID); $actual = $absCases->getCategoryId(); @@ -51,7 +57,7 @@ class AbstractCasesTest extends TestCase */ public function it_return_set_get_category_uid() { - $category = factory(ProcessCategory::class)->create(); + $category = ProcessCategory::factory()->create(); $absCases = new AbstractCases(); $absCases->setCategoryUid($category->CATEGORY_UID); $actual = $absCases->getCategoryUid(); @@ -69,7 +75,7 @@ class AbstractCasesTest extends TestCase */ public function it_return_set_get_process() { - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); $absCases = new AbstractCases(); $absCases->setProcessUid($process->PRO_UID); $actual = $absCases->getProcessUid(); @@ -88,7 +94,7 @@ class AbstractCasesTest extends TestCase */ public function it_return_set_get_task() { - $task = factory(Task::class)->create(); + $task = Task::factory()->create(); $absCases = new AbstractCases(); $absCases->setTaskId($task->TAS_ID); $actual = $absCases->getTaskId(); @@ -106,7 +112,7 @@ class AbstractCasesTest extends TestCase */ public function it_return_set_get_user() { - $users = factory(User::class)->create(); + $users = User::factory()->create(); $absCases = new AbstractCases(); $absCases->setUserUid($users->USR_UID); $actual = $absCases->getUserUid(); @@ -125,7 +131,7 @@ class AbstractCasesTest extends TestCase */ public function it_return_set_get_user_completed() { - $users = factory(User::class)->create(); + $users = User::factory()->create(); $absCases = new AbstractCases(); $absCases->setUserCompletedId($users->USR_ID); $actual = $absCases->getUserCompletedId(); @@ -141,7 +147,7 @@ class AbstractCasesTest extends TestCase */ public function it_return_set_get_user_started() { - $users = factory(User::class)->create(); + $users = User::factory()->create(); $absCases = new AbstractCases(); $absCases->setUserStartedId($users->USR_ID); $actual = $absCases->getUserStartedId(); @@ -157,7 +163,7 @@ class AbstractCasesTest extends TestCase */ public function it_return_set_get_user_send() { - $users = factory(User::class)->create(); + $users = User::factory()->create(); $absCases = new AbstractCases(); $absCases->setSendBy($users->USR_UID); $actual = $absCases->getSendBy(); @@ -224,7 +230,7 @@ class AbstractCasesTest extends TestCase */ public function it_return_set_get_case_number() { - $case = factory(Application::class)->create(); + $case = Application::factory()->create(); $absCases = new AbstractCases(); $absCases->setCaseNumber($case->APP_NUMBER); $actual = $absCases->getCaseNumber(); @@ -242,8 +248,8 @@ class AbstractCasesTest extends TestCase */ public function it_return_set_get_range_case_number() { - $case1 = factory(Application::class)->create(); - $case2 = factory(Application::class)->create([ + $case1 = Application::factory()->create(); + $case2 = Application::factory()->create([ 'APP_NUMBER' => $case1->APP_NUMBER + 1 ]); $absCases = new AbstractCases(); @@ -448,7 +454,7 @@ class AbstractCasesTest extends TestCase */ public function it_return_set_get_case() { - $application = factory(Application::class)->create(); + $application = Application::factory()->create(); $absCases = new AbstractCases(); $absCases->setCaseUid($application->APP_UID); $actual = $absCases->getCaseUid(); @@ -934,7 +940,7 @@ class AbstractCasesTest extends TestCase */ public function it_return_task_pending_result() { - $task = factory(Task::class, 2)->create(); + $task = Task::factory(2)->create(); $absCases = new AbstractCases(); $pending = '[ {"tas_id":'.$task[0]->TAS_ID.', "user_id":1, "due_date":"2020-12-04 19:11:14"}, @@ -956,7 +962,7 @@ class AbstractCasesTest extends TestCase */ public function it_return_thread_information() { - $delegation = factory(Delegation::class)->states('foreign_keys')->create(); + $delegation = Delegation::factory()->foreign_keys()->create(); $taskPending = Delegation::getLastThread($delegation->APP_NUMBER); $absCases = new AbstractCases(); foreach ($taskPending as $thread) { diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/BatchRoutingTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/BatchRoutingTest.php index 8d7e55ab1..c9fa23842 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/BatchRoutingTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/BatchRoutingTest.php @@ -2,7 +2,6 @@ namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases; -use Illuminate\Foundation\Testing\DatabaseTransactions; use ProcessMaker\BusinessModel\Cases\BatchRouting; use ProcessMaker\Model\Consolidated; use ProcessMaker\Model\Delegation; @@ -15,14 +14,13 @@ use Tests\TestCase; */ class BatchRoutingTest extends TestCase { - use DatabaseTransactions; - /** * Method set up. */ - public function setUp() + public function setUp(): void { parent::setUp(); + $this->truncateNonInitialModels(); } /** @@ -32,8 +30,8 @@ class BatchRoutingTest extends TestCase */ public function createConsolidated() { - $consolidated = factory(Consolidated::class)->states('foreign_keys')->create(); - $delegation = factory(Delegation::class)->states('foreign_keys')->create([ + $consolidated = Consolidated::factory()->foreign_keys()->create(); + $delegation = Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'TAS_UID' => $consolidated->TAS_UID, ]); diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/CanceledTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/CanceledTest.php index 143721296..f5aae7829 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/CanceledTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/CanceledTest.php @@ -2,7 +2,6 @@ namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases; -use Illuminate\Foundation\Testing\DatabaseTransactions; use ProcessMaker\BusinessModel\Cases\Canceled; use ProcessMaker\Model\Application; use ProcessMaker\Model\Delegation; @@ -15,14 +14,13 @@ use Tests\TestCase; */ class CanceledTest extends TestCase { - use DatabaseTransactions; - /** * Method set up. */ - public function setUp() + public function setUp(): void { parent::setUp(); + $this->truncateNonInitialModels(); } /** @@ -32,8 +30,8 @@ class CanceledTest extends TestCase */ public function createCanceled() { - $application = factory(Application::class)->states('canceled')->create(); - $delegation = factory(Delegation::class)->states('foreign_keys')->create([ + $application = Application::factory()->canceled()->create(); + $delegation = Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'CLOSED', 'DEL_INDEX' => 1, 'USR_UID' => $application->APP_INIT_USER, diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/CasesListTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/CasesListTest.php index 1e8ccc7c9..113f17de6 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/CasesListTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/CasesListTest.php @@ -2,7 +2,6 @@ namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases; -use Illuminate\Foundation\Testing\DatabaseTransactions; use ProcessMaker\BusinessModel\Cases\CasesList; use ProcessMaker\Model\Application; use ProcessMaker\Model\Delegation; @@ -15,14 +14,13 @@ use Tests\TestCase; */ class CasesListTest extends TestCase { - use DatabaseTransactions; - /** * Method set up. */ - public function setUp() + public function setUp(): void { parent::setUp(); + $this->truncateNonInitialModels(); } /** @@ -32,8 +30,8 @@ class CasesListTest extends TestCase */ public function createCases() { - $application = factory(Application::class)->states('completed')->create(); - $delegation = factory(Delegation::class)->states('foreign_keys')->create([ + $application = Application::factory()->completed()->create(); + $delegation = Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'CLOSED', 'DEL_INDEX' => 1, 'USR_UID' => $application->APP_INIT_USER, @@ -64,7 +62,7 @@ class CasesListTest extends TestCase */ public function it_return_all_counters() { - $delegation = factory(Delegation::class)->states('foreign_keys')->create(); + $delegation = Delegation::factory()->foreign_keys()->create(); $count = new CasesList(); $result = $count->getAllCounters($delegation->USR_UID); $this->assertNotEmpty($result); @@ -88,7 +86,7 @@ class CasesListTest extends TestCase */ public function it_return_at_least_one() { - $delegation = factory(Delegation::class)->states('foreign_keys')->create(); + $delegation = Delegation::factory()->foreign_keys()->create(); $count = new CasesList(); $result = $count->atLeastOne($delegation->USR_UID); $this->assertNotEmpty($result); diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/CompletedTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/CompletedTest.php index e2f502dea..abc4c7fe5 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/CompletedTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/CompletedTest.php @@ -2,7 +2,6 @@ namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases; -use Illuminate\Foundation\Testing\DatabaseTransactions; use ProcessMaker\BusinessModel\Cases\Completed; use ProcessMaker\Model\Application; use ProcessMaker\Model\Delegation; @@ -15,14 +14,13 @@ use Tests\TestCase; */ class CompletedTest extends TestCase { - use DatabaseTransactions; - /** * Method set up. */ - public function setUp() + public function setUp(): void { parent::setUp(); + $this->truncateNonInitialModels(); } /** @@ -32,8 +30,8 @@ class CompletedTest extends TestCase */ public function createCompleted() { - $application = factory(Application::class)->states('completed')->create(); - $delegation = factory(Delegation::class)->states('foreign_keys')->create([ + $application = Application::factory()->completed()->create(); + $delegation = Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'CLOSED', 'DEL_INDEX' => 1, 'USR_UID' => $application->APP_INIT_USER, diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/DraftTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/DraftTest.php index b16fa7323..a000b7841 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/DraftTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/DraftTest.php @@ -4,7 +4,6 @@ namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases; use DateInterval; use Datetime; -use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Facades\DB; use ProcessMaker\BusinessModel\Cases\Draft; use ProcessMaker\Model\AdditionalTables; @@ -22,16 +21,13 @@ use Tests\TestCase; */ class DraftTest extends TestCase { - use DatabaseTransactions; - /** * Method set up. */ - public function setUp() + public function setUp(): void { parent::setUp(); - Delegation::truncate(); - Application::truncate(); + $this->truncateNonInitialModels(); } /** @@ -43,8 +39,8 @@ class DraftTest extends TestCase */ public function createDraft() { - $application = factory(Application::class)->states('draft')->create(); - $delegation = factory(Delegation::class)->states('foreign_keys')->create([ + $application = Application::factory()->draft()->create(); + $delegation = Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 1, 'USR_UID' => $application->APP_INIT_USER, @@ -64,15 +60,15 @@ class DraftTest extends TestCase */ public function createManyDraft($cases) { - $user = factory(\ProcessMaker\Model\User::class)->create(); + $user = \ProcessMaker\Model\User::factory()->create(); for ($i = 0; $i < $cases; $i = $i + 1) { - $application = factory(Application::class)->states('draft')->create([ + $application = Application::factory()->draft()->create([ 'APP_INIT_USER' => $user->USR_UID, 'APP_INIT_USER_ID' => $user->USR_ID, 'APP_CUR_USER' => $user->USR_UID, ]); - $delegation = factory(Delegation::class)->states('foreign_keys')->create([ + $delegation = Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 1, 'APP_UID' => $application->APP_UID, @@ -341,18 +337,18 @@ class DraftTest extends TestCase */ public function it_should_test_get_counters_by_processes_method_no_filter() { - $process = factory(Process::class)->create(); - $process2 = factory(Process::class)->create(); - $user = factory(User::class)->create(); - $application1 = factory(Application::class)->states('draft')->create([ + $process = Process::factory()->create(); + $process2 = Process::factory()->create(); + $user = User::factory()->create(); + $application1 = Application::factory()->draft()->create([ 'APP_INIT_USER' => $user->USR_UID, 'APP_CUR_USER' => $user->USR_UID, ]); - $application2 = factory(Application::class)->states('draft')->create([ + $application2 = Application::factory()->draft()->create([ 'APP_INIT_USER' => $user->USR_UID, 'APP_CUR_USER' => $user->USR_UID, ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 1, 'USR_UID' => $application1->APP_INIT_USER, @@ -362,7 +358,7 @@ class DraftTest extends TestCase 'PRO_ID' => $process->PRO_ID, 'PRO_UID' => $process->PRO_UID ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 1, 'USR_UID' => $application2->APP_INIT_USER, @@ -388,18 +384,18 @@ class DraftTest extends TestCase */ public function it_should_test_get_counters_by_processes_method_category() { - $process = factory(Process::class)->create([ + $process = Process::factory()->create([ 'CATEGORY_ID' => 1 ]); - $process2 = factory(Process::class)->create([ + $process2 = Process::factory()->create([ 'CATEGORY_ID' => 2 ]); - $user = factory(User::class)->create(); - $application = factory(Application::class, 5)->states('draft')->create([ + $user = User::factory()->create(); + $application = Application::factory(5)->draft()->create([ 'APP_INIT_USER' => $user->USR_UID, 'APP_CUR_USER' => $user->USR_UID, ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 1, 'USR_UID' => $application[0]->APP_INIT_USER, @@ -409,7 +405,7 @@ class DraftTest extends TestCase 'PRO_ID' => $process->PRO_ID, 'PRO_UID' => $process->PRO_UID ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 1, 'USR_UID' => $application[1]->APP_INIT_USER, @@ -419,7 +415,7 @@ class DraftTest extends TestCase 'PRO_ID' => $process->PRO_ID, 'PRO_UID' => $process->PRO_UID ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 1, 'USR_UID' => $application[2]->APP_INIT_USER, @@ -429,7 +425,7 @@ class DraftTest extends TestCase 'PRO_ID' => $process->PRO_ID, 'PRO_UID' => $process->PRO_UID ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 1, 'USR_UID' => $application[3]->APP_INIT_USER, @@ -439,7 +435,7 @@ class DraftTest extends TestCase 'PRO_ID' => $process2->PRO_ID, 'PRO_UID' => $process2->PRO_UID ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 1, 'USR_UID' => $application[4]->APP_INIT_USER, @@ -465,23 +461,23 @@ class DraftTest extends TestCase */ public function it_should_test_get_counters_by_processes_method_top_ten() { - $process1 = factory(Process::class)->create(); - $process2 = factory(Process::class)->create(); - $process3 = factory(Process::class)->create(); - $process4 = factory(Process::class)->create(); - $process5 = factory(Process::class)->create(); - $process6 = factory(Process::class)->create(); - $process7 = factory(Process::class)->create(); - $process8 = factory(Process::class)->create(); - $process9 = factory(Process::class)->create(); - $process10 = factory(Process::class)->create(); - $process11 = factory(Process::class)->create(); - $user = factory(User::class)->create(); - $application = factory(Application::class, 14)->states('draft')->create([ + $process1 = Process::factory()->create(); + $process2 = Process::factory()->create(); + $process3 = Process::factory()->create(); + $process4 = Process::factory()->create(); + $process5 = Process::factory()->create(); + $process6 = Process::factory()->create(); + $process7 = Process::factory()->create(); + $process8 = Process::factory()->create(); + $process9 = Process::factory()->create(); + $process10 = Process::factory()->create(); + $process11 = Process::factory()->create(); + $user = User::factory()->create(); + $application = Application::factory(14)->draft()->create([ 'APP_INIT_USER' => $user->USR_UID, 'APP_CUR_USER' => $user->USR_UID, ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 1, 'USR_UID' => $application[0]->APP_INIT_USER, @@ -491,7 +487,7 @@ class DraftTest extends TestCase 'PRO_ID' => $process1->PRO_ID, 'PRO_UID' => $process1->PRO_UID ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 1, 'USR_UID' => $application[1]->APP_INIT_USER, @@ -501,7 +497,7 @@ class DraftTest extends TestCase 'PRO_ID' => $process1->PRO_ID, 'PRO_UID' => $process1->PRO_UID ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 1, 'USR_UID' => $application[2]->APP_INIT_USER, @@ -511,7 +507,7 @@ class DraftTest extends TestCase 'PRO_ID' => $process1->PRO_ID, 'PRO_UID' => $process1->PRO_UID ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 1, 'USR_UID' => $application[3]->APP_INIT_USER, @@ -521,7 +517,7 @@ class DraftTest extends TestCase 'PRO_ID' => $process2->PRO_ID, 'PRO_UID' => $process2->PRO_UID ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 1, 'USR_UID' => $application[4]->APP_INIT_USER, @@ -531,7 +527,7 @@ class DraftTest extends TestCase 'PRO_ID' => $process2->PRO_ID, 'PRO_UID' => $process2->PRO_UID ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 1, 'USR_UID' => $application[5]->APP_INIT_USER, @@ -541,7 +537,7 @@ class DraftTest extends TestCase 'PRO_ID' => $process3->PRO_ID, 'PRO_UID' => $process3->PRO_UID ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 1, 'USR_UID' => $application[6]->APP_INIT_USER, @@ -551,7 +547,7 @@ class DraftTest extends TestCase 'PRO_ID' => $process4->PRO_ID, 'PRO_UID' => $process4->PRO_UID ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 1, 'USR_UID' => $application[7]->APP_INIT_USER, @@ -561,7 +557,7 @@ class DraftTest extends TestCase 'PRO_ID' => $process5->PRO_ID, 'PRO_UID' => $process5->PRO_UID ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 1, 'USR_UID' => $application[8]->APP_INIT_USER, @@ -571,7 +567,7 @@ class DraftTest extends TestCase 'PRO_ID' => $process6->PRO_ID, 'PRO_UID' => $process6->PRO_UID ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 1, 'USR_UID' => $application[9]->APP_INIT_USER, @@ -581,7 +577,7 @@ class DraftTest extends TestCase 'PRO_ID' => $process7->PRO_ID, 'PRO_UID' => $process7->PRO_UID ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 1, 'USR_UID' => $application[10]->APP_INIT_USER, @@ -591,7 +587,7 @@ class DraftTest extends TestCase 'PRO_ID' => $process8->PRO_ID, 'PRO_UID' => $process8->PRO_UID ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 1, 'USR_UID' => $application[11]->APP_INIT_USER, @@ -601,7 +597,7 @@ class DraftTest extends TestCase 'PRO_ID' => $process9->PRO_ID, 'PRO_UID' => $process9->PRO_UID ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 1, 'USR_UID' => $application[12]->APP_INIT_USER, @@ -611,7 +607,7 @@ class DraftTest extends TestCase 'PRO_ID' => $process10->PRO_ID, 'PRO_UID' => $process10->PRO_UID ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 1, 'USR_UID' => $application[13]->APP_INIT_USER, @@ -636,14 +632,14 @@ class DraftTest extends TestCase */ public function it_should_test_get_counters_by_processes_method_processes() { - $process = factory(Process::class)->create(); - $process2 = factory(Process::class)->create(); - $user = factory(User::class)->create(); - $application = factory(Application::class, 14)->states('draft')->create([ + $process = Process::factory()->create(); + $process2 = Process::factory()->create(); + $user = User::factory()->create(); + $application = Application::factory(14)->draft()->create([ 'APP_INIT_USER' => $user->USR_UID, 'APP_CUR_USER' => $user->USR_UID, ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 1, 'USR_UID' => $application[0]->APP_INIT_USER, @@ -653,7 +649,7 @@ class DraftTest extends TestCase 'PRO_ID' => $process->PRO_ID, 'PRO_UID' => $process->PRO_UID ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 1, 'USR_UID' => $application[1]->APP_INIT_USER, @@ -679,14 +675,14 @@ class DraftTest extends TestCase */ public function it_should_test_get_counters_by_range_method() { - $process1 = factory(Process::class)->create(); - $process2 = factory(Process::class)->create(); - $user = factory(User::class)->create(); - $application = factory(Application::class, 4)->states('draft')->create([ + $process1 = Process::factory()->create(); + $process2 = Process::factory()->create(); + $user = User::factory()->create(); + $application = Application::factory(4)->draft()->create([ 'APP_INIT_USER' => $user->USR_UID, 'APP_CUR_USER' => $user->USR_UID, ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 1, 'USR_UID' => $application[0]->APP_INIT_USER, @@ -697,7 +693,7 @@ class DraftTest extends TestCase 'PRO_UID' => $process1->PRO_UID, 'DEL_DELEGATE_DATE' => '2021-05-20 09:52:32' ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 1, 'USR_UID' => $application[1]->APP_INIT_USER, @@ -708,7 +704,7 @@ class DraftTest extends TestCase 'PRO_UID' => $process1->PRO_UID, 'DEL_DELEGATE_DATE' => '2021-05-21 09:52:32' ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 1, 'USR_UID' => $application[2]->APP_INIT_USER, @@ -719,7 +715,7 @@ class DraftTest extends TestCase 'PRO_UID' => $process1->PRO_UID, 'DEL_DELEGATE_DATE' => '2021-05-22 00:00:00' ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 1, 'USR_UID' => $application[3]->APP_INIT_USER, @@ -757,9 +753,8 @@ class DraftTest extends TestCase */ public function it_should_test_getCustomListCount_method() { - $this->markTestIncomplete('Illegal mix of collations'); $cases = $this->createManyDraft(3); - $additionalTables = factory(AdditionalTables::class)->create([ + $additionalTables = AdditionalTables::factory()->create([ 'PRO_UID' => $cases->PRO_UID ]); $query = "" @@ -771,10 +766,11 @@ class DraftTest extends TestCase . "`VAR2` varchar(255) DEFAULT NULL," . "`VAR3` varchar(255) DEFAULT NULL," . "PRIMARY KEY (`APP_UID`)," - . "KEY `indexTable` (`APP_UID`))"; + . "KEY `indexTable` (`APP_UID`)" + . ")ENGINE=InnoDB DEFAULT CHARSET='utf8'"; DB::statement($query); - $caseList = factory(CaseList::class)->create([ + $caseList = CaseList::factory()->create([ 'CAL_TYPE' => 'draft', 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID, 'USR_ID' => $cases->USR_ID @@ -809,13 +805,13 @@ class DraftTest extends TestCase $currentDate = $date->format('Y-m-d H:i:s'); $diff1Day = new DateInterval('P1D'); $diff2Days = new DateInterval('P2D'); - $process = factory(Process::class)->create(); - $user = factory(User::class)->create(); - $application = factory(Application::class, 14)->states('draft')->create([ + $process = Process::factory()->create(); + $user = User::factory()->create(); + $application = Application::factory(14)->draft()->create([ 'APP_INIT_USER' => $user->USR_UID, 'APP_CUR_USER' => $user->USR_UID, ]); - $del = factory(Delegation::class)->states('foreign_keys')->create([ + $del = Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 1, 'USR_UID' => $application[0]->APP_INIT_USER, @@ -846,13 +842,13 @@ class DraftTest extends TestCase $date = new DateTime('now'); $currentDate = $date->format('Y-m-d H:i:s'); $diff2Days = new DateInterval('P2D'); - $process = factory(Process::class)->create(); - $user = factory(User::class)->create(); - $application = factory(Application::class, 14)->states('draft')->create([ + $process = Process::factory()->create(); + $user = User::factory()->create(); + $application = Application::factory(14)->draft()->create([ 'APP_INIT_USER' => $user->USR_UID, 'APP_CUR_USER' => $user->USR_UID, ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 1, 'USR_UID' => $application[0]->APP_INIT_USER, @@ -883,13 +879,13 @@ class DraftTest extends TestCase $date = new DateTime('now'); $currentDate = $date->format('Y-m-d H:i:s'); $diff2Days = new DateInterval('P2D'); - $process = factory(Process::class)->create(); - $user = factory(User::class)->create(); - $application = factory(Application::class, 14)->states('draft')->create([ + $process = Process::factory()->create(); + $user = User::factory()->create(); + $application = Application::factory(14)->draft()->create([ 'APP_INIT_USER' => $user->USR_UID, 'APP_CUR_USER' => $user->USR_UID, ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 1, 'USR_UID' => $application[0]->APP_INIT_USER, diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/HomeTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/HomeTest.php index c3dbd7bc7..afd5f465d 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/HomeTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/HomeTest.php @@ -25,19 +25,19 @@ use Tests\TestCase; */ class HomeTest extends TestCase { - /** * setUp method. */ - public function setUp() + public function setUp(): void { parent::setUp(); + $this->truncateNonInitialModels(); } /** * tearDown method. */ - public function tearDown() + public function tearDown(): void { parent::tearDown(); } @@ -50,8 +50,8 @@ class HomeTest extends TestCase */ public function it_should_test_getDraft() { - $application = factory(Application::class)->states('draft')->create(); - factory(Delegation::class)->states('foreign_keys')->create([ + $application = Application::factory()->draft()->create(); + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 1, 'USR_UID' => $application->APP_INIT_USER, @@ -73,8 +73,8 @@ class HomeTest extends TestCase */ public function it_should_test_getInbox() { - $application = factory(Application::class)->states('todo')->create(); - factory(Delegation::class)->states('foreign_keys')->create([ + $application = Application::factory()->todo()->create(); + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 2 ]); @@ -93,30 +93,30 @@ class HomeTest extends TestCase */ public function it_should_test_getUnassigned() { - $user = factory(User::class)->create(); - $group = factory(Groupwf::class)->create(); - factory(GroupUser::class)->create([ + $user = User::factory()->create(); + $group = Groupwf::factory()->create(); + GroupUser::factory()->create([ 'GRP_UID' => $group->GRP_UID, 'GRP_ID' => $group->GRP_ID, 'USR_UID' => $user->USR_UID, ]); - $process = factory(Process::class)->create(); - $application = factory(Application::class)->create([ + $process = Process::factory()->create(); + $application = Application::factory()->create([ 'APP_STATUS_ID' => 2 ]); - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID, 'PRO_ID' => $process->PRO_ID, ]); - factory(TaskUser::class)->create([ + TaskUser::factory()->create([ 'TAS_UID' => $task->TAS_UID, 'USR_UID' => $user->USR_UID, 'TU_RELATION' => 1, 'TU_TYPE' => 1 ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, 'PRO_ID' => $process->PRO_ID, @@ -139,17 +139,17 @@ class HomeTest extends TestCase */ public function it_should_test_getPaused() { - $user = factory(User::class)->create(); - $process1 = factory(Process::class)->create(); - $task = factory(Task::class)->create([ + $user = User::factory()->create(); + $process1 = Process::factory()->create(); + $task = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => '', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process1->PRO_UID, 'TAS_TYPE' => 'NORMAL' ]); - $application1 = factory(Application::class)->create(); - $delegation1 = factory(Delegation::class)->create([ + $application1 = Application::factory()->create(); + $delegation1 = Delegation::factory()->create([ 'APP_NUMBER' => $application1->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, 'DEL_THREAD_STATUS' => 'CLOSED', @@ -161,9 +161,9 @@ class HomeTest extends TestCase 'DEL_INDEX' => 2 ]); - $process2 = factory(Process::class)->create(); - $application2 = factory(Application::class)->create(); - $delegation2 = factory(Delegation::class)->create([ + $process2 = Process::factory()->create(); + $application2 = Application::factory()->create(); + $delegation2 = Delegation::factory()->create([ 'APP_NUMBER' => $application2->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, 'DEL_THREAD_STATUS' => 'OPEN', @@ -174,7 +174,7 @@ class HomeTest extends TestCase 'DEL_PREVIOUS' => 1, 'DEL_INDEX' => 2 ]); - factory(AppDelay::class, 5)->create([ + AppDelay::factory(5)->create([ 'APP_DELEGATION_USER' => $user->USR_UID, 'PRO_UID' => $process2->PRO_UID, 'APP_NUMBER' => $delegation1->APP_NUMBER, @@ -182,7 +182,7 @@ class HomeTest extends TestCase 'APP_DISABLE_ACTION_USER' => 0, 'APP_TYPE' => 'PAUSE' ]); - factory(AppDelay::class, 5)->create([ + AppDelay::factory(5)->create([ 'APP_DELEGATION_USER' => $user->USR_UID, 'PRO_UID' => $process2->PRO_UID, 'APP_NUMBER' => $delegation2->APP_NUMBER, @@ -205,9 +205,8 @@ class HomeTest extends TestCase */ public function it_should_test_buildCustomCaseList() { - $this->markTestIncomplete('Illegal mix of collations'); - $user = factory(User::class)->create(); - $additionalTables = factory(AdditionalTables::class)->create(); + $user = User::factory()->create(); + $additionalTables = AdditionalTables::factory()->create(); $query = "" . "CREATE TABLE IF NOT EXISTS `{$additionalTables->ADD_TAB_NAME}` (" . "`APP_UID` varchar(32) NOT NULL," @@ -217,24 +216,25 @@ class HomeTest extends TestCase . "`VAR2` varchar(255) DEFAULT NULL," . "`VAR3` varchar(255) DEFAULT NULL," . "PRIMARY KEY (`APP_UID`)," - . "KEY `indexTable` (`APP_UID`))"; + . "KEY `indexTable` (`APP_UID`)" + . ")ENGINE=InnoDB DEFAULT CHARSET='utf8'"; DB::statement($query); - factory(Fields::class)->create([ + Fields::factory()->create([ 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID, 'FLD_NAME' => 'VAR1' ]); - factory(Fields::class)->create([ + Fields::factory()->create([ 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID, 'FLD_NAME' => 'VAR2' ]); - factory(Fields::class)->create([ + Fields::factory()->create([ 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID, 'FLD_NAME' => 'VAR3' ]); //for inbox $type = 'inbox'; - $caseList = factory(CaseList::class)->create([ + $caseList = CaseList::factory()->create([ 'CAL_TYPE' => $type, 'CAL_COLUMNS' => '[{"field":"case_number","enableFilter":false,"set":true},{"field":"case_title","enableFilter":false,"set":true},{"field":"process_name","enableFilter":false,"set":true},{"field":"task","enableFilter":false,"set":true},{"field":"send_by","enableFilter":false,"set":true},{"field":"due_date","enableFilter":false,"set":true},{"field":"delegation_date","enableFilter":false,"set":true},{"field":"priority","enableFilter":false,"set":true},{"field":"VAR1","enableFilter":false,"set":true},{"field":"VAR2","enableFilter":false,"set":true},{"field":"VAR3","enableFilter":false,"set":false}]', 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID, @@ -256,8 +256,7 @@ class HomeTest extends TestCase */ public function it_should_test_getCustomDraft() { - $this->markTestIncomplete('Illegal mix of collations'); - $additionalTables = factory(AdditionalTables::class)->create(); + $additionalTables = AdditionalTables::factory()->create(); $query = "" . "CREATE TABLE IF NOT EXISTS `{$additionalTables->ADD_TAB_NAME}` (" . "`APP_UID` varchar(32) NOT NULL," @@ -267,23 +266,24 @@ class HomeTest extends TestCase . "`VAR2` varchar(255) DEFAULT NULL," . "`VAR3` varchar(255) DEFAULT NULL," . "PRIMARY KEY (`APP_UID`)," - . "KEY `indexTable` (`APP_UID`))"; + . "KEY `indexTable` (`APP_UID`)" + . ")ENGINE=InnoDB DEFAULT CHARSET='utf8'"; DB::statement($query); - factory(Fields::class)->create([ + Fields::factory()->create([ 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID, 'FLD_NAME' => 'VAR1' ]); - factory(Fields::class)->create([ + Fields::factory()->create([ 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID, 'FLD_NAME' => 'VAR2' ]); - factory(Fields::class)->create([ + Fields::factory()->create([ 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID, 'FLD_NAME' => 'VAR3' ]); - $application = factory(Application::class)->states('draft')->create(); - factory(Delegation::class)->states('foreign_keys')->create([ + $application = Application::factory()->draft()->create(); + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 1, 'USR_UID' => $application->APP_INIT_USER, @@ -291,7 +291,7 @@ class HomeTest extends TestCase 'APP_NUMBER' => $application->APP_NUMBER, ]); - $caseList = factory(CaseList::class)->create([ + $caseList = CaseList::factory()->create([ 'CAL_TYPE' => 'draft', 'CAL_COLUMNS' => '[{"field":"case_number","enableFilter":false,"set":true},{"field":"case_title","enableFilter":false,"set":true},{"field":"process_name","enableFilter":false,"set":true},{"field":"task","enableFilter":false,"set":true},{"field":"send_by","enableFilter":false,"set":true},{"field":"due_date","enableFilter":false,"set":true},{"field":"delegation_date","enableFilter":false,"set":true},{"field":"priority","enableFilter":false,"set":true},{"field":"VAR1","enableFilter":false,"set":true},{"field":"VAR2","enableFilter":false,"set":true},{"field":"VAR3","enableFilter":false,"set":false}]', 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID @@ -313,8 +313,7 @@ class HomeTest extends TestCase */ public function it_should_test_getCustomInbox() { - $this->markTestIncomplete('Illegal mix of collations'); - $additionalTables = factory(AdditionalTables::class)->create(); + $additionalTables = AdditionalTables::factory()->create(); $query = "" . "CREATE TABLE IF NOT EXISTS `{$additionalTables->ADD_TAB_NAME}` (" . "`APP_UID` varchar(32) NOT NULL," @@ -324,28 +323,29 @@ class HomeTest extends TestCase . "`VAR2` varchar(255) DEFAULT NULL," . "`VAR3` varchar(255) DEFAULT NULL," . "PRIMARY KEY (`APP_UID`)," - . "KEY `indexTable` (`APP_UID`))"; + . "KEY `indexTable` (`APP_UID`)" + . ")ENGINE=InnoDB DEFAULT CHARSET='utf8'"; DB::statement($query); - factory(Fields::class)->create([ + Fields::factory()->create([ 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID, 'FLD_NAME' => 'VAR1' ]); - factory(Fields::class)->create([ + Fields::factory()->create([ 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID, 'FLD_NAME' => 'VAR2' ]); - factory(Fields::class)->create([ + Fields::factory()->create([ 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID, 'FLD_NAME' => 'VAR3' ]); - $application = factory(Application::class)->states('todo')->create(); - factory(Delegation::class)->states('foreign_keys')->create([ + $application = Application::factory()->todo()->create(); + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 2 ]); - $caseList = factory(CaseList::class)->create([ + $caseList = CaseList::factory()->create([ 'CAL_TYPE' => 'inbox', 'CAL_COLUMNS' => '[{"field":"case_number","enableFilter":false,"set":true},{"field":"case_title","enableFilter":false,"set":true},{"field":"process_name","enableFilter":false,"set":true},{"field":"task","enableFilter":false,"set":true},{"field":"send_by","enableFilter":false,"set":true},{"field":"due_date","enableFilter":false,"set":true},{"field":"delegation_date","enableFilter":false,"set":true},{"field":"priority","enableFilter":false,"set":true},{"field":"VAR1","enableFilter":false,"set":true},{"field":"VAR2","enableFilter":false,"set":true},{"field":"VAR3","enableFilter":false,"set":false}]', 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID @@ -367,8 +367,7 @@ class HomeTest extends TestCase */ public function it_should_test_getCustomUnassigned() { - $this->markTestIncomplete('Illegal mix of collations'); - $additionalTables = factory(AdditionalTables::class)->create(); + $additionalTables = AdditionalTables::factory()->create(); $query = "" . "CREATE TABLE IF NOT EXISTS `{$additionalTables->ADD_TAB_NAME}` (" . "`APP_UID` varchar(32) NOT NULL," @@ -378,45 +377,46 @@ class HomeTest extends TestCase . "`VAR2` varchar(255) DEFAULT NULL," . "`VAR3` varchar(255) DEFAULT NULL," . "PRIMARY KEY (`APP_UID`)," - . "KEY `indexTable` (`APP_UID`))"; + . "KEY `indexTable` (`APP_UID`)" + . ")ENGINE=InnoDB DEFAULT CHARSET='utf8'"; DB::statement($query); - factory(Fields::class)->create([ + Fields::factory()->create([ 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID, 'FLD_NAME' => 'VAR1' ]); - factory(Fields::class)->create([ + Fields::factory()->create([ 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID, 'FLD_NAME' => 'VAR2' ]); - factory(Fields::class)->create([ + Fields::factory()->create([ 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID, 'FLD_NAME' => 'VAR3' ]); - $user = factory(User::class)->create(); - $group = factory(Groupwf::class)->create(); - factory(GroupUser::class)->create([ + $user = User::factory()->create(); + $group = Groupwf::factory()->create(); + GroupUser::factory()->create([ 'GRP_UID' => $group->GRP_UID, 'GRP_ID' => $group->GRP_ID, 'USR_UID' => $user->USR_UID, ]); - $process = factory(Process::class)->create(); - $application = factory(Application::class)->create([ + $process = Process::factory()->create(); + $application = Application::factory()->create([ 'APP_STATUS_ID' => 2 ]); - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID, 'PRO_ID' => $process->PRO_ID, ]); - factory(TaskUser::class)->create([ + TaskUser::factory()->create([ 'TAS_UID' => $task->TAS_UID, 'USR_UID' => $user->USR_UID, 'TU_RELATION' => 1, 'TU_TYPE' => 1 ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, 'PRO_ID' => $process->PRO_ID, @@ -425,7 +425,7 @@ class HomeTest extends TestCase 'DEL_DELEGATE_DATE' => date('Y-m-d H:i:s', strtotime("-1 year")) ]); - $caseList = factory(CaseList::class)->create([ + $caseList = CaseList::factory()->create([ 'CAL_TYPE' => 'unassigned', 'CAL_COLUMNS' => '[{"field":"case_number","enableFilter":false,"set":true},{"field":"case_title","enableFilter":false,"set":true},{"field":"process_name","enableFilter":false,"set":true},{"field":"task","enableFilter":false,"set":true},{"field":"send_by","enableFilter":false,"set":true},{"field":"due_date","enableFilter":false,"set":true},{"field":"delegation_date","enableFilter":false,"set":true},{"field":"priority","enableFilter":false,"set":true},{"field":"VAR1","enableFilter":false,"set":true},{"field":"VAR2","enableFilter":false,"set":true},{"field":"VAR3","enableFilter":false,"set":false}]', 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID @@ -447,8 +447,7 @@ class HomeTest extends TestCase */ public function it_should_test_getCustomPaused() { - $this->markTestIncomplete('Illegal mix of collations'); - $additionalTables = factory(AdditionalTables::class)->create(); + $additionalTables = AdditionalTables::factory()->create(); $query = "" . "CREATE TABLE IF NOT EXISTS `{$additionalTables->ADD_TAB_NAME}` (" . "`APP_UID` varchar(32) NOT NULL," @@ -458,32 +457,33 @@ class HomeTest extends TestCase . "`VAR2` varchar(255) DEFAULT NULL," . "`VAR3` varchar(255) DEFAULT NULL," . "PRIMARY KEY (`APP_UID`)," - . "KEY `indexTable` (`APP_UID`))"; + . "KEY `indexTable` (`APP_UID`)" + . ")ENGINE=InnoDB DEFAULT CHARSET='utf8'"; DB::statement($query); - factory(Fields::class)->create([ + Fields::factory()->create([ 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID, 'FLD_NAME' => 'VAR1' ]); - factory(Fields::class)->create([ + Fields::factory()->create([ 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID, 'FLD_NAME' => 'VAR2' ]); - factory(Fields::class)->create([ + Fields::factory()->create([ 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID, 'FLD_NAME' => 'VAR3' ]); - $user = factory(User::class)->create(); - $process1 = factory(Process::class)->create(); - $task = factory(Task::class)->create([ + $user = User::factory()->create(); + $process1 = Process::factory()->create(); + $task = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => '', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process1->PRO_UID, 'TAS_TYPE' => 'NORMAL' ]); - $application1 = factory(Application::class)->create(); - $delegation1 = factory(Delegation::class)->create([ + $application1 = Application::factory()->create(); + $delegation1 = Delegation::factory()->create([ 'APP_NUMBER' => $application1->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, 'DEL_THREAD_STATUS' => 'CLOSED', @@ -495,9 +495,9 @@ class HomeTest extends TestCase 'DEL_INDEX' => 2 ]); - $process2 = factory(Process::class)->create(); - $application2 = factory(Application::class)->create(); - $delegation2 = factory(Delegation::class)->create([ + $process2 = Process::factory()->create(); + $application2 = Application::factory()->create(); + $delegation2 = Delegation::factory()->create([ 'APP_NUMBER' => $application2->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, 'DEL_THREAD_STATUS' => 'OPEN', @@ -508,7 +508,7 @@ class HomeTest extends TestCase 'DEL_PREVIOUS' => 1, 'DEL_INDEX' => 2 ]); - factory(AppDelay::class, 5)->create([ + AppDelay::factory(5)->create([ 'APP_DELEGATION_USER' => $user->USR_UID, 'PRO_UID' => $process2->PRO_UID, 'APP_NUMBER' => $delegation1->APP_NUMBER, @@ -516,7 +516,7 @@ class HomeTest extends TestCase 'APP_DISABLE_ACTION_USER' => 0, 'APP_TYPE' => 'PAUSE' ]); - factory(AppDelay::class, 5)->create([ + AppDelay::factory(5)->create([ 'APP_DELEGATION_USER' => $user->USR_UID, 'PRO_UID' => $process2->PRO_UID, 'APP_NUMBER' => $delegation2->APP_NUMBER, @@ -525,7 +525,7 @@ class HomeTest extends TestCase 'APP_TYPE' => 'PAUSE' ]); - $caseList = factory(CaseList::class)->create([ + $caseList = CaseList::factory()->create([ 'CAL_TYPE' => 'paused', 'CAL_COLUMNS' => '[{"field":"case_number","enableFilter":false,"set":true},{"field":"case_title","enableFilter":false,"set":true},{"field":"process_name","enableFilter":false,"set":true},{"field":"task","enableFilter":false,"set":true},{"field":"send_by","enableFilter":false,"set":true},{"field":"due_date","enableFilter":false,"set":true},{"field":"delegation_date","enableFilter":false,"set":true},{"field":"priority","enableFilter":false,"set":true},{"field":"VAR1","enableFilter":false,"set":true},{"field":"VAR2","enableFilter":false,"set":true},{"field":"VAR3","enableFilter":false,"set":false}]', 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InboxTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InboxTest.php index 2704fe5b9..d64ab12b8 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InboxTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/InboxTest.php @@ -4,15 +4,12 @@ namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases; use DateInterval; use Datetime; -use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Facades\DB; use ProcessMaker\BusinessModel\Cases\Inbox; use ProcessMaker\Model\AdditionalTables; -use ProcessMaker\Model\Application; use ProcessMaker\Model\CaseList; use ProcessMaker\Model\Delegation; use ProcessMaker\Model\Process; -use ProcessMaker\Model\Task; use ProcessMaker\Model\User; use Tests\TestCase; @@ -23,21 +20,20 @@ use Tests\TestCase; */ class InboxTest extends TestCase { - use DatabaseTransactions; - /** * Method set up. */ - public function setUp() + public function setUp(): void { parent::setUp(); - Delegation::truncate(); + $this->truncateNonInitialModels(); } /** * Method tearDown */ - public function tearDown() { + public function tearDown(): void + { parent::tearDown(); } @@ -50,7 +46,7 @@ class InboxTest extends TestCase */ public function createInbox() { - $delegation = factory(Delegation::class)->states('foreign_keys')->create([ + $delegation = Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_PREVIOUS' => 1, 'DEL_INDEX' => 2, @@ -67,10 +63,10 @@ class InboxTest extends TestCase */ public function createMultipleInbox($cases) { - $user = factory(\ProcessMaker\Model\User::class)->create(); + $user = \ProcessMaker\Model\User::factory()->create(); for ($i = 0; $i < $cases; $i = $i + 1) { - $delegation = factory(Delegation::class)->states('foreign_keys')->create([ + $delegation = Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 2, 'USR_UID' => $user->USR_UID, @@ -304,7 +300,7 @@ class InboxTest extends TestCase { // Create factories related to the to_do cases - $delegation = factory(Delegation::class)->states('foreign_keys')->create([ + $delegation = Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_PREVIOUS' => 1, 'DEL_INDEX' => 2, @@ -339,7 +335,7 @@ class InboxTest extends TestCase // Create factories related to the to_do cases $cases = $this->createInbox(); // Create the previous thread with the same user - $delegation = factory(Delegation::class)->states('foreign_keys')->create([ + $delegation = Delegation::factory()->foreign_keys()->create([ 'APP_NUMBER' => $cases->APP_NUMBER, 'APP_UID' => $cases->APP_UID, 'USR_ID' => $cases->USR_ID, @@ -420,10 +416,10 @@ class InboxTest extends TestCase */ public function it_should_test_get_counters_by_processes_method_no_filter() { - $user = factory(User::class)->create(); - $process = factory(Process::class)->create(); - $process2 = factory(Process::class)->create(); - factory(Delegation::class)->states('foreign_keys')->create([ + $user = User::factory()->create(); + $process = Process::factory()->create(); + $process2 = Process::factory()->create(); + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 2, 'USR_UID' => $user->USR_UID, @@ -431,7 +427,7 @@ class InboxTest extends TestCase 'PRO_ID' => $process->PRO_ID, 'PRO_UID' => $process->PRO_UID ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 2, 'USR_UID' => $user->USR_UID, @@ -454,14 +450,14 @@ class InboxTest extends TestCase */ public function it_should_test_get_counters_by_processes_method_category() { - $user = factory(User::class)->create(); - $process = factory(Process::class)->create([ + $user = User::factory()->create(); + $process = Process::factory()->create([ 'CATEGORY_ID' => 1 ]); - $process2 = factory(Process::class)->create([ + $process2 = Process::factory()->create([ 'CATEGORY_ID' => 2 ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 2, 'USR_UID' => $user->USR_UID, @@ -469,7 +465,7 @@ class InboxTest extends TestCase 'PRO_ID' => $process->PRO_ID, 'PRO_UID' => $process->PRO_UID ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 2, 'USR_UID' => $user->USR_UID, @@ -477,7 +473,7 @@ class InboxTest extends TestCase 'PRO_ID' => $process->PRO_ID, 'PRO_UID' => $process->PRO_UID ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 2, 'USR_UID' => $user->USR_UID, @@ -485,7 +481,7 @@ class InboxTest extends TestCase 'PRO_ID' => $process->PRO_ID, 'PRO_UID' => $process->PRO_UID ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 2, 'USR_UID' => $user->USR_UID, @@ -493,7 +489,7 @@ class InboxTest extends TestCase 'PRO_ID' => $process2->PRO_ID, 'PRO_UID' => $process2->PRO_UID ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 2, 'USR_UID' => $user->USR_UID, @@ -516,19 +512,19 @@ class InboxTest extends TestCase */ public function it_should_test_get_counters_by_processes_method_top_ten() { - $user = factory(User::class)->create(); - $process1 = factory(Process::class)->create(); - $process2 = factory(Process::class)->create(); - $process3 = factory(Process::class)->create(); - $process4 = factory(Process::class)->create(); - $process5 = factory(Process::class)->create(); - $process6 = factory(Process::class)->create(); - $process7 = factory(Process::class)->create(); - $process8 = factory(Process::class)->create(); - $process9 = factory(Process::class)->create(); - $process10 = factory(Process::class)->create(); - $process11 = factory(Process::class)->create(); - factory(Delegation::class)->states('foreign_keys')->create([ + $user = User::factory()->create(); + $process1 = Process::factory()->create(); + $process2 = Process::factory()->create(); + $process3 = Process::factory()->create(); + $process4 = Process::factory()->create(); + $process5 = Process::factory()->create(); + $process6 = Process::factory()->create(); + $process7 = Process::factory()->create(); + $process8 = Process::factory()->create(); + $process9 = Process::factory()->create(); + $process10 = Process::factory()->create(); + $process11 = Process::factory()->create(); + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 2, 'USR_UID' => $user->USR_UID, @@ -536,7 +532,7 @@ class InboxTest extends TestCase 'PRO_ID' => $process1->PRO_ID, 'PRO_UID' => $process1->PRO_UID ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 2, 'USR_UID' => $user->USR_UID, @@ -544,7 +540,7 @@ class InboxTest extends TestCase 'PRO_ID' => $process1->PRO_ID, 'PRO_UID' => $process1->PRO_UID ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 2, 'USR_UID' => $user->USR_UID, @@ -552,7 +548,7 @@ class InboxTest extends TestCase 'PRO_ID' => $process1->PRO_ID, 'PRO_UID' => $process1->PRO_UID ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 2, 'USR_UID' => $user->USR_UID, @@ -560,7 +556,7 @@ class InboxTest extends TestCase 'PRO_ID' => $process2->PRO_ID, 'PRO_UID' => $process2->PRO_UID ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 2, 'USR_UID' => $user->USR_UID, @@ -568,7 +564,7 @@ class InboxTest extends TestCase 'PRO_ID' => $process2->PRO_ID, 'PRO_UID' => $process2->PRO_UID ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 2, 'USR_UID' => $user->USR_UID, @@ -576,7 +572,7 @@ class InboxTest extends TestCase 'PRO_ID' => $process3->PRO_ID, 'PRO_UID' => $process3->PRO_UID ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 2, 'USR_UID' => $user->USR_UID, @@ -584,7 +580,7 @@ class InboxTest extends TestCase 'PRO_ID' => $process4->PRO_ID, 'PRO_UID' => $process4->PRO_UID ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 2, 'USR_UID' => $user->USR_UID, @@ -592,7 +588,7 @@ class InboxTest extends TestCase 'PRO_ID' => $process5->PRO_ID, 'PRO_UID' => $process5->PRO_UID ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 2, 'USR_UID' => $user->USR_UID, @@ -600,7 +596,7 @@ class InboxTest extends TestCase 'PRO_ID' => $process6->PRO_ID, 'PRO_UID' => $process6->PRO_UID ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 2, 'USR_UID' => $user->USR_UID, @@ -608,7 +604,7 @@ class InboxTest extends TestCase 'PRO_ID' => $process7->PRO_ID, 'PRO_UID' => $process7->PRO_UID ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 2, 'USR_UID' => $user->USR_UID, @@ -616,7 +612,7 @@ class InboxTest extends TestCase 'PRO_ID' => $process8->PRO_ID, 'PRO_UID' => $process8->PRO_UID ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 2, 'USR_UID' => $user->USR_UID, @@ -624,7 +620,7 @@ class InboxTest extends TestCase 'PRO_ID' => $process9->PRO_ID, 'PRO_UID' => $process9->PRO_UID ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 2, 'USR_UID' => $user->USR_UID, @@ -632,7 +628,7 @@ class InboxTest extends TestCase 'PRO_ID' => $process10->PRO_ID, 'PRO_UID' => $process10->PRO_UID ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 2, 'USR_UID' => $user->USR_UID, @@ -655,10 +651,10 @@ class InboxTest extends TestCase */ public function it_should_test_get_counters_by_processes_method_processes() { - $user = factory(User::class)->create(); - $process = factory(Process::class)->create(); - $process2 = factory(Process::class)->create(); - factory(Delegation::class)->states('foreign_keys')->create([ + $user = User::factory()->create(); + $process = Process::factory()->create(); + $process2 = Process::factory()->create(); + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 2, 'USR_UID' => $user->USR_UID, @@ -666,7 +662,7 @@ class InboxTest extends TestCase 'PRO_ID' => $process->PRO_ID, 'PRO_UID' => $process->PRO_UID ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 2, 'USR_UID' => $user->USR_UID, @@ -689,10 +685,10 @@ class InboxTest extends TestCase */ public function it_should_test_get_counters_by_range_method() { - $user = factory(User::class)->create(); - $process = factory(Process::class)->create(); - $process2 = factory(Process::class)->create(); - factory(Delegation::class)->states('foreign_keys')->create([ + $user = User::factory()->create(); + $process = Process::factory()->create(); + $process2 = Process::factory()->create(); + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 2, 'USR_UID' => $user->USR_UID, @@ -701,7 +697,7 @@ class InboxTest extends TestCase 'PRO_UID' => $process->PRO_UID, 'DEL_DELEGATE_DATE' => '2021-05-20 09:52:32' ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 2, 'USR_UID' => $user->USR_UID, @@ -736,10 +732,9 @@ class InboxTest extends TestCase */ public function it_should_test_getCustomListCounts_method() { - $this->markTestIncomplete('Illegal mix of collations'); $cases = $this->createMultipleInbox(3); - $additionalTables = factory(AdditionalTables::class)->create([ + $additionalTables = AdditionalTables::factory()->create([ 'PRO_UID' => $cases->PRO_UID ]); $query = "" @@ -751,10 +746,11 @@ class InboxTest extends TestCase . "`VAR2` varchar(255) DEFAULT NULL," . "`VAR3` varchar(255) DEFAULT NULL," . "PRIMARY KEY (`APP_UID`)," - . "KEY `indexTable` (`APP_UID`))"; + . "KEY `indexTable` (`APP_UID`)" + . ")ENGINE=InnoDB DEFAULT CHARSET='utf8'"; DB::statement($query); - $caseList = factory(CaseList::class)->create([ + $caseList = CaseList::factory()->create([ 'CAL_TYPE' => 'inbox', 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID, 'USR_ID' => $cases->USR_ID @@ -789,9 +785,9 @@ class InboxTest extends TestCase $currentDate = $date->format('Y-m-d H:i:s'); $diff1Day = new DateInterval('P1D'); $diff2Days = new DateInterval('P2D'); - $user = factory(User::class)->create(); - $process = factory(Process::class)->create(); - factory(Delegation::class)->states('foreign_keys')->create([ + $user = User::factory()->create(); + $process = Process::factory()->create(); + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 2, 'USR_UID' => $user->USR_UID, @@ -820,9 +816,9 @@ class InboxTest extends TestCase $date = new DateTime('now'); $currentDate = $date->format('Y-m-d H:i:s'); $diff2Days = new DateInterval('P2D'); - $user = factory(User::class)->create(); - $process = factory(Process::class)->create(); - factory(Delegation::class)->states('foreign_keys')->create([ + $user = User::factory()->create(); + $process = Process::factory()->create(); + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 2, 'USR_UID' => $user->USR_UID, @@ -851,9 +847,9 @@ class InboxTest extends TestCase $date = new DateTime('now'); $currentDate = $date->format('Y-m-d H:i:s'); $diff2Days = new DateInterval('P2D'); - $user = factory(User::class)->create(); - $process = factory(Process::class)->create(); - factory(Delegation::class)->states('foreign_keys')->create([ + $user = User::factory()->create(); + $process = Process::factory()->create(); + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 2, 'USR_UID' => $user->USR_UID, diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/ParticipatedTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/ParticipatedTest.php index 0d90d7148..07fd71606 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/ParticipatedTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/ParticipatedTest.php @@ -2,7 +2,6 @@ namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases; -use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Facades\DB; use ProcessMaker\BusinessModel\Cases\Participated; use ProcessMaker\Model\Application; @@ -16,16 +15,13 @@ use Tests\TestCase; */ class ParticipatedTest extends TestCase { - use DatabaseTransactions; - /** * Method set up. */ - public function setUp() + public function setUp(): void { parent::setUp(); - Delegation::truncate(); - Application::truncate(); + $this->truncateNonInitialModels(); } /** @@ -37,12 +33,12 @@ class ParticipatedTest extends TestCase */ public function createParticipated() { - $delegation = factory(Delegation::class)->states('foreign_keys')->create([ + $delegation = Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'CLOSED', 'DEL_INDEX' => 1, 'DEL_LAST_INDEX' => 0, ]); - $delegation = factory(Delegation::class)->states('last_thread')->create([ + $delegation = Delegation::factory()->last_thread()->create([ 'APP_NUMBER' => $delegation->APP_NUMBER, 'TAS_ID' => $delegation->TAS_ID, 'DEL_THREAD_STATUS' => 'OPEN', @@ -65,8 +61,8 @@ class ParticipatedTest extends TestCase */ public function createParticipatedDraft() { - $application = factory(Application::class)->states('draft')->create(); - $delegation = factory(Delegation::class)->states('foreign_keys')->create([ + $application = Application::factory()->draft()->create(); + $delegation = Delegation::factory()->foreign_keys()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'APP_UID' => $application->APP_UID, 'DEL_THREAD_STATUS' => 'OPEN', @@ -86,15 +82,15 @@ class ParticipatedTest extends TestCase */ public function createParticipatedCompleted() { - $application = factory(Application::class)->states('completed')->create(); - $delegation = factory(Delegation::class)->states('first_thread')->create([ + $application = Application::factory()->completed()->create(); + $delegation = Delegation::factory()->first_thread()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'APP_UID' => $application->APP_UID, 'DEL_THREAD_STATUS' => 'CLOSED', 'DEL_INDEX' => 1, 'DEL_LAST_INDEX' => 0, ]); - $delegation = factory(Delegation::class)->states('last_thread')->create([ + $delegation = Delegation::factory()->last_thread()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'APP_UID' => $application->APP_UID, 'DEL_THREAD_STATUS' => 'CLOSED', @@ -116,17 +112,17 @@ class ParticipatedTest extends TestCase */ public function createMultipleParticipated($cases = 2) { - $user = factory(\ProcessMaker\Model\User::class)->create(); + $user = \ProcessMaker\Model\User::factory()->create(); for ($i = 0; $i < $cases; $i = $i + 1) { - $delegation = factory(Delegation::class)->states('foreign_keys')->create([ + $delegation = Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'CLOSED', 'DEL_INDEX' => 1, 'USR_UID' => $user->USR_UID, 'USR_ID' => $user->USR_ID, 'DEL_LAST_INDEX' => 0, ]); - factory(Delegation::class)->states('last_thread')->create([ + Delegation::factory()->last_thread()->create([ 'APP_UID' => $delegation->APP_UID, 'APP_NUMBER' => $delegation->APP_NUMBER, 'TAS_ID' => $delegation->TAS_ID, diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/PausedTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/PausedTest.php index 098517c16..627dc0366 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/PausedTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/PausedTest.php @@ -4,7 +4,6 @@ namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases; use DateInterval; use Datetime; -use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Facades\DB; use ProcessMaker\BusinessModel\Cases\Paused; use ProcessMaker\Model\AdditionalTables; @@ -24,15 +23,13 @@ use Tests\TestCase; */ class PausedTest extends TestCase { - use DatabaseTransactions; - /** * Method set up. */ - public function setUp() + public function setUp(): void { parent::setUp(); - Delegation::truncate(); + $this->truncateNonInitialModels(); } /** @@ -45,29 +42,29 @@ class PausedTest extends TestCase public function createPaused() { //Create processes - $process1 = factory(Process::class)->create( + $process1 = Process::factory()->create( ['PRO_CATEGORY' => '1'] ); - $process2 = factory(Process::class)->create( + $process2 = Process::factory()->create( ['PRO_CATEGORY' => '2'] ); //Create user - $user = factory(User::class)->create(); + $user = User::factory()->create(); //Create a task - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => '', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process1->PRO_UID, 'TAS_TYPE' => 'NORMAL' ]); - $application1 = factory(Application::class)->create(); - $application2 = factory(Application::class)->create(); + $application1 = Application::factory()->create(); + $application2 = Application::factory()->create(); //Create the register in delegation - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_NUMBER' => $application1->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, 'DEL_THREAD_STATUS' => 'CLOSED', @@ -78,7 +75,7 @@ class PausedTest extends TestCase 'DEL_PREVIOUS' => 0, 'DEL_INDEX' => 1 ]); - $delegation1 = factory(Delegation::class)->create([ + $delegation1 = Delegation::factory()->create([ 'APP_NUMBER' => $application1->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, 'DEL_THREAD_STATUS' => 'CLOSED', @@ -90,7 +87,7 @@ class PausedTest extends TestCase 'DEL_INDEX' => 2 ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_NUMBER' => $application2->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, 'DEL_THREAD_STATUS' => 'OPEN', @@ -101,7 +98,7 @@ class PausedTest extends TestCase 'DEL_PREVIOUS' => 0, 'DEL_INDEX' => 1 ]); - $delegation2 = factory(Delegation::class)->create([ + $delegation2 = Delegation::factory()->create([ 'APP_NUMBER' => $application2->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, 'DEL_THREAD_STATUS' => 'OPEN', @@ -114,7 +111,7 @@ class PausedTest extends TestCase ]); //Create the registers in AppDelay - factory(AppDelay::class, 5)->create([ + AppDelay::factory(5)->create([ 'APP_DELEGATION_USER' => $user->USR_UID, 'PRO_UID' => $process2->PRO_UID, 'APP_NUMBER' => $delegation1->APP_NUMBER, @@ -123,7 +120,7 @@ class PausedTest extends TestCase 'APP_TYPE' => 'PAUSE' ]); //Create the registers in AppDelay - factory(AppDelay::class, 5)->create([ + AppDelay::factory(5)->create([ 'APP_DELEGATION_USER' => $user->USR_UID, 'PRO_UID' => $process2->PRO_UID, 'APP_NUMBER' => $delegation2->APP_NUMBER, @@ -144,24 +141,24 @@ class PausedTest extends TestCase public function createMultiplePaused($cases, $category = 1, $user = null) { if (is_null($user)) { - $user = factory(User::class)->create(); + $user = User::factory()->create(); } for ($i = 0; $i < $cases; $i = $i + 1) { - $process1 = factory(Process::class)->create( + $process1 = Process::factory()->create( ['PRO_CATEGORY' => 1, 'CATEGORY_ID' => $category] ); - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => '', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process1->PRO_UID, 'TAS_TYPE' => 'NORMAL' ]); - $application1 = factory(Application::class)->create(); + $application1 = Application::factory()->create(); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_UID' => $application1->APP_UID, 'APP_NUMBER' => $application1->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, @@ -173,7 +170,7 @@ class PausedTest extends TestCase 'DEL_PREVIOUS' => 0, 'DEL_INDEX' => 1 ]); - $delegation1 = factory(Delegation::class)->create([ + $delegation1 = Delegation::factory()->create([ 'APP_UID' => $application1->APP_UID, 'APP_NUMBER' => $application1->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, @@ -186,7 +183,7 @@ class PausedTest extends TestCase 'DEL_INDEX' => 2 ]); - factory(AppDelay::class)->create([ + AppDelay::factory()->create([ 'APP_DELEGATION_USER' => $user->USR_UID, 'PRO_UID' => $process1->PRO_UID, 'APP_NUMBER' => $delegation1->APP_NUMBER, @@ -371,7 +368,7 @@ class PausedTest extends TestCase // Set the title $paused->setCaseTitle($cases->DEL_TITLE); $res = $paused->getData(); - $this->assertNotEmpty($res); + $this->assertTrue(!empty($res)); } /** @@ -488,7 +485,7 @@ class PausedTest extends TestCase */ public function it_should_test_get_counters_by_processes_method_category() { - $user = factory(User::class)->create(); + $user = User::factory()->create(); $this->createMultiplePaused(3, 2, $user); $this->createMultiplePaused(2, 3, $user); $paused = new Paused(); @@ -506,7 +503,7 @@ class PausedTest extends TestCase */ public function it_should_test_get_counters_by_processes_method_top_ten() { - $user = factory(User::class)->create(); + $user = User::factory()->create(); $this->createMultiplePaused(20, 2, $user); $paused = new Paused(); $paused->setUserId($user->USR_ID); @@ -523,19 +520,19 @@ class PausedTest extends TestCase */ public function it_should_test_get_counters_by_processes_method_processes_filter() { - $user = factory(User::class)->create(); - $process1 = factory(Process::class)->create(); + $user = User::factory()->create(); + $process1 = Process::factory()->create(); - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => '', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process1->PRO_UID, 'TAS_TYPE' => 'NORMAL' ]); - $application1 = factory(Application::class)->create(); + $application1 = Application::factory()->create(); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_UID' => $application1->APP_UID, 'APP_NUMBER' => $application1->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, @@ -547,7 +544,7 @@ class PausedTest extends TestCase 'DEL_PREVIOUS' => 0, 'DEL_INDEX' => 1 ]); - $delegation1 = factory(Delegation::class)->create([ + $delegation1 = Delegation::factory()->create([ 'APP_UID' => $application1->APP_UID, 'APP_NUMBER' => $application1->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, @@ -560,7 +557,7 @@ class PausedTest extends TestCase 'DEL_INDEX' => 2 ]); - factory(AppDelay::class)->create([ + AppDelay::factory()->create([ 'APP_DELEGATION_USER' => $user->USR_UID, 'PRO_UID' => $process1->PRO_UID, 'APP_NUMBER' => $delegation1->APP_NUMBER, @@ -584,17 +581,17 @@ class PausedTest extends TestCase */ public function it_should_test_get_counters_by_range_method() { - $user = factory(User::class)->create(); - $process1 = factory(Process::class)->create(); - $task = factory(Task::class)->create([ + $user = User::factory()->create(); + $process1 = Process::factory()->create(); + $task = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => '', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process1->PRO_UID, 'TAS_TYPE' => 'NORMAL' ]); - $application1 = factory(Application::class)->create(); - factory(Delegation::class)->create([ + $application1 = Application::factory()->create(); + Delegation::factory()->create([ 'APP_UID' => $application1->APP_UID, 'APP_NUMBER' => $application1->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, @@ -606,7 +603,7 @@ class PausedTest extends TestCase 'DEL_PREVIOUS' => 0, 'DEL_INDEX' => 1 ]); - $delegation1 = factory(Delegation::class)->create([ + $delegation1 = Delegation::factory()->create([ 'APP_UID' => $application1->APP_UID, 'APP_NUMBER' => $application1->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, @@ -619,7 +616,7 @@ class PausedTest extends TestCase 'DEL_INDEX' => 2, 'DEL_DELEGATE_DATE' => '2021-05-23 00:00:00' ]); - factory(AppDelay::class)->create([ + AppDelay::factory()->create([ 'APP_DELEGATION_USER' => $user->USR_UID, 'PRO_UID' => $process1->PRO_UID, 'APP_NUMBER' => $delegation1->APP_NUMBER, @@ -628,8 +625,8 @@ class PausedTest extends TestCase 'APP_TYPE' => 'PAUSE' ]); - $application2 = factory(Application::class)->create(); - factory(Delegation::class)->create([ + $application2 = Application::factory()->create(); + Delegation::factory()->create([ 'APP_UID' => $application2->APP_UID, 'APP_NUMBER' => $application2->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, @@ -641,7 +638,7 @@ class PausedTest extends TestCase 'DEL_PREVIOUS' => 0, 'DEL_INDEX' => 1 ]); - $delegation2 = factory(Delegation::class)->create([ + $delegation2 = Delegation::factory()->create([ 'APP_UID' => $application2->APP_UID, 'APP_NUMBER' => $application2->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, @@ -654,7 +651,7 @@ class PausedTest extends TestCase 'DEL_INDEX' => 2, 'DEL_DELEGATE_DATE' => '2021-05-24 09:52:32' ]); - factory(AppDelay::class)->create([ + AppDelay::factory()->create([ 'APP_DELEGATION_USER' => $user->USR_UID, 'PRO_UID' => $process1->PRO_UID, 'APP_NUMBER' => $delegation2->APP_NUMBER, @@ -689,10 +686,9 @@ class PausedTest extends TestCase */ public function it_should_test_getCustomListCounts_method() { - $this->markTestIncomplete('Illegal mix of collations'); $cases = $this->createMultiplePaused(3); - $additionalTables = factory(AdditionalTables::class)->create([ + $additionalTables = AdditionalTables::factory()->create([ 'PRO_UID' => $cases->PRO_UID ]); $query = "" @@ -704,10 +700,11 @@ class PausedTest extends TestCase . "`VAR2` varchar(255) DEFAULT NULL," . "`VAR3` varchar(255) DEFAULT NULL," . "PRIMARY KEY (`APP_UID`)," - . "KEY `indexTable` (`APP_UID`))"; + . "KEY `indexTable` (`APP_UID`)" + . ")ENGINE=InnoDB DEFAULT CHARSET='utf8'"; DB::statement($query); - $caseList = factory(CaseList::class)->create([ + $caseList = CaseList::factory()->create([ 'CAL_TYPE' => 'paused', 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID, 'USR_ID' => $cases->USR_ID @@ -742,19 +739,19 @@ class PausedTest extends TestCase $currentDate = $date->format('Y-m-d H:i:s'); $diff1Day = new DateInterval('P1D'); $diff2Days = new DateInterval('P2D'); - $user = factory(User::class)->create(); - $process1 = factory(Process::class)->create(); + $user = User::factory()->create(); + $process1 = Process::factory()->create(); - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => '', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process1->PRO_UID, 'TAS_TYPE' => 'NORMAL' ]); - $application1 = factory(Application::class)->create(); + $application1 = Application::factory()->create(); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_UID' => $application1->APP_UID, 'APP_NUMBER' => $application1->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, @@ -769,7 +766,7 @@ class PausedTest extends TestCase 'DEL_RISK_DATE' => $date->add($diff1Day), 'DEL_TASK_DUE_DATE' => $date->add($diff2Days) ]); - $delegation1 = factory(Delegation::class)->create([ + $delegation1 = Delegation::factory()->create([ 'APP_UID' => $application1->APP_UID, 'APP_NUMBER' => $application1->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, @@ -785,7 +782,7 @@ class PausedTest extends TestCase 'DEL_TASK_DUE_DATE' => $date->add($diff2Days) ]); - factory(AppDelay::class)->create([ + AppDelay::factory()->create([ 'APP_DELEGATION_USER' => $user->USR_UID, 'PRO_UID' => $process1->PRO_UID, 'APP_NUMBER' => $delegation1->APP_NUMBER, @@ -812,19 +809,19 @@ class PausedTest extends TestCase $date = new DateTime('now'); $currentDate = $date->format('Y-m-d H:i:s'); $diff2Days = new DateInterval('P2D'); - $user = factory(User::class)->create(); - $process1 = factory(Process::class)->create(); + $user = User::factory()->create(); + $process1 = Process::factory()->create(); - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => '', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process1->PRO_UID, 'TAS_TYPE' => 'NORMAL' ]); - $application1 = factory(Application::class)->create(); + $application1 = Application::factory()->create(); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_UID' => $application1->APP_UID, 'APP_NUMBER' => $application1->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, @@ -839,7 +836,7 @@ class PausedTest extends TestCase 'DEL_RISK_DATE' => $currentDate, 'DEL_TASK_DUE_DATE' => $date->add($diff2Days) ]); - $delegation1 = factory(Delegation::class)->create([ + $delegation1 = Delegation::factory()->create([ 'APP_UID' => $application1->APP_UID, 'APP_NUMBER' => $application1->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, @@ -855,7 +852,7 @@ class PausedTest extends TestCase 'DEL_TASK_DUE_DATE' => $date->add($diff2Days) ]); - factory(AppDelay::class)->create([ + AppDelay::factory()->create([ 'APP_DELEGATION_USER' => $user->USR_UID, 'PRO_UID' => $process1->PRO_UID, 'APP_NUMBER' => $delegation1->APP_NUMBER, @@ -882,19 +879,19 @@ class PausedTest extends TestCase $date = new DateTime('now'); $currentDate = $date->format('Y-m-d H:i:s'); $diff2Days = new DateInterval('P2D'); - $user = factory(User::class)->create(); - $process1 = factory(Process::class)->create(); + $user = User::factory()->create(); + $process1 = Process::factory()->create(); - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => '', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process1->PRO_UID, 'TAS_TYPE' => 'NORMAL' ]); - $application1 = factory(Application::class)->create(); + $application1 = Application::factory()->create(); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_UID' => $application1->APP_UID, 'APP_NUMBER' => $application1->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, @@ -909,7 +906,7 @@ class PausedTest extends TestCase 'DEL_RISK_DATE' => $currentDate, 'DEL_TASK_DUE_DATE' => $date->sub($diff2Days) ]); - $delegation1 = factory(Delegation::class)->create([ + $delegation1 = Delegation::factory()->create([ 'APP_UID' => $application1->APP_UID, 'APP_NUMBER' => $application1->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, @@ -925,7 +922,7 @@ class PausedTest extends TestCase 'DEL_TASK_DUE_DATE' => $date->sub($diff2Days) ]); - factory(AppDelay::class)->create([ + AppDelay::factory()->create([ 'APP_DELEGATION_USER' => $user->USR_UID, 'PRO_UID' => $process1->PRO_UID, 'APP_NUMBER' => $delegation1->APP_NUMBER, diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/SearchTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/SearchTest.php index 3daf93c8f..1a2b57f3c 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/SearchTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/SearchTest.php @@ -2,7 +2,6 @@ namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases; -use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Facades\DB; use ProcessMaker\BusinessModel\Cases\Search; use ProcessMaker\Model\Application; @@ -16,16 +15,13 @@ use Tests\TestCase; */ class SearchTest extends TestCase { - use DatabaseTransactions; - /** * Set up function. */ - public function setUp() + public function setUp(): void { parent::setUp(); - Application::truncate(); - Delegation::truncate(); + $this->truncateNonInitialModels(); } /** @@ -37,7 +33,7 @@ class SearchTest extends TestCase */ public function createSearch($rows = 10) { - $delegation = factory(Delegation::class, $rows)->states('foreign_keys')->create(); + $delegation = Delegation::factory($rows)->foreign_keys()->create(); return $delegation; } @@ -213,7 +209,7 @@ class SearchTest extends TestCase // Get the data $res = $search->getData(); // Asserts - $this->assertNotEmpty($res); + $this->assertTrue(!empty($res)); } /** @@ -379,7 +375,7 @@ class SearchTest extends TestCase { // Create factories related to the delegation cases $cases = $this->createSearch(); - $casesNotSubmitted = factory(Delegation::class, 5)->states('web_entry')->create(); + $casesNotSubmitted = Delegation::factory(5)->web_entry()->create(); // Create new Search object $search = new Search(); $result = $search->getData(); diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/SupervisingTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/SupervisingTest.php index dca0559c3..fd21c11e5 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/SupervisingTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/SupervisingTest.php @@ -2,7 +2,6 @@ namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases; -use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Facades\DB; use ProcessMaker\BusinessModel\Cases\Supervising; use ProcessMaker\Model\Application; @@ -21,14 +20,13 @@ use Tests\TestCase; */ class SupervisingTest extends TestCase { - use DatabaseTransactions; - /** * Method set up. */ - public function setUp() + public function setUp(): void { parent::setUp(); + $this->truncateNonInitialModels(); } /** @@ -42,11 +40,11 @@ class SupervisingTest extends TestCase public function createSupervising(int $cases = 2) { // Create process - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); // Create user - $user = factory(User::class)->create(); + $user = User::factory()->create(); // Define this user like process supervisor - factory(ProcessUser::class)->create( + ProcessUser::factory()->create( [ 'PRO_UID' => $process->PRO_UID, 'USR_UID' => $user->USR_UID, @@ -54,12 +52,12 @@ class SupervisingTest extends TestCase ] ); // Create a task - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'NORMAL', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID, ]); - $task2 = factory(Task::class)->create([ + $task2 = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'NORMAL', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID, @@ -68,13 +66,13 @@ class SupervisingTest extends TestCase $delegation = []; for ($i = 0; $i < $cases; $i = $i + 1) { // Create case - $app = factory(Application::class)->states('todo')->create([ + $app = Application::factory()->todo()->create([ 'PRO_UID' => $process->PRO_UID, 'APP_INIT_USER' => $user->USR_UID, 'APP_CUR_USER' => $user->USR_UID, ]); // Create two threads - $delegation = factory(Delegation::class)->create([ + $delegation = Delegation::factory()->create([ 'APP_UID' => $app['APP_UID'], 'TAS_ID' => $task->TAS_ID, 'TAS_UID' => $task->TAS_UID, @@ -88,7 +86,7 @@ class SupervisingTest extends TestCase 'DEL_PREVIOUS' => 0, 'DEL_LAST_INDEX' => 0 ]); - $delegation = factory(Delegation::class)->create([ + $delegation = Delegation::factory()->create([ 'APP_UID' => $app['APP_UID'], 'TAS_ID' => $task2->TAS_ID, 'TAS_UID' => $task2->TAS_UID, @@ -118,15 +116,15 @@ class SupervisingTest extends TestCase public function createGroupSupervising(int $cases = 2) { // Create process - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); // Create user - $user = factory(User::class)->create(); + $user = User::factory()->create(); // Create group - $group = factory(GroupUser::class)->create([ + $group = GroupUser::factory()->create([ 'USR_UID' => $user->USR_UID, ]); // Define this group like process supervisor - factory(ProcessUser::class)->create( + ProcessUser::factory()->create( [ 'PRO_UID' => $process->PRO_UID, 'USR_UID' => $group->GRP_UID, @@ -134,12 +132,12 @@ class SupervisingTest extends TestCase ] ); // Create a task - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'NORMAL', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID, ]); - $task2 = factory(Task::class)->create([ + $task2 = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'NORMAL', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID, @@ -148,13 +146,13 @@ class SupervisingTest extends TestCase $delegation = []; for ($i = 0; $i < $cases; $i = $i + 1) { // Create case - $app = factory(Application::class)->states('todo')->create([ + $app = Application::factory()->todo()->create([ 'PRO_UID' => $process->PRO_UID, 'APP_INIT_USER' => $user->USR_UID, 'APP_CUR_USER' => $user->USR_UID, ]); // Create two threads - $delegation = factory(Delegation::class)->create([ + $delegation = Delegation::factory()->create([ 'APP_UID' => $app['APP_UID'], 'TAS_ID' => $task->TAS_ID, 'TAS_UID' => $task->TAS_UID, @@ -168,7 +166,7 @@ class SupervisingTest extends TestCase 'DEL_PREVIOUS' => 0, 'DEL_LAST_INDEX' => 0 ]); - $delegation = factory(Delegation::class)->create([ + $delegation = Delegation::factory()->create([ 'APP_UID' => $app['APP_UID'], 'TAS_ID' => $task2->TAS_ID, 'TAS_UID' => $task2->TAS_UID, @@ -243,7 +241,7 @@ class SupervisingTest extends TestCase */ public function it_should_test_the_get_data_method_when_the_user_is_not_supervisor() { - $user = factory(User::class)->create(); + $user = User::factory()->create(); $cases = $this->createSupervising(); // Instance the Supervising object $supervising = new Supervising(); diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/UnassignedTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/UnassignedTest.php index beebd3788..7af50742e 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/UnassignedTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/Cases/UnassignedTest.php @@ -4,7 +4,6 @@ namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases; use DateInterval; use Datetime; -use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Facades\DB; use ProcessMaker\BusinessModel\Cases\Unassigned; use ProcessMaker\Model\AdditionalTables; @@ -28,17 +27,13 @@ use Tests\TestCase; */ class UnassignedTest extends TestCase { - use DatabaseTransactions; - /** * Method set up. */ - public function setUp() + public function setUp(): void { parent::setUp(); - Delegation::truncate(); - Groupwf::truncate(); - Application::truncate(); + $this->truncateNonInitialModels(); } /** @@ -51,11 +46,11 @@ class UnassignedTest extends TestCase public function createSelfServiceUserOrGroup($relation = 1) { // Create user` - $user = factory(User::class)->create(); + $user = User::factory()->create(); // Create a group - $group = factory(Groupwf::class)->create(); + $group = Groupwf::factory()->create(); // Assign a user in the group - factory(GroupUser::class)->create([ + GroupUser::factory()->create([ 'GRP_UID' => $group->GRP_UID, 'GRP_ID' => $group->GRP_ID, 'USR_UID' => $user->USR_UID, @@ -63,34 +58,34 @@ class UnassignedTest extends TestCase // Create self-services for ($i = 1; $i <= 2; $i++) { //Create process - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); //Create application - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'APP_STATUS_ID' => 2 ]); //Create a task self service - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID, 'PRO_ID' => $process->PRO_ID, ]); //Assign a user in the task - $taskUser = factory(TaskUser::class)->create([ + $taskUser = TaskUser::factory()->create([ 'TAS_UID' => $task->TAS_UID, 'USR_UID' => $user->USR_UID, 'TU_RELATION' => $relation, //Related to the user 'TU_TYPE' => 1 ]); //Create the previous delegation before self-service - $delegation = factory(Delegation::class)->create([ + $delegation = Delegation::factory()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'PRO_ID' => $process->PRO_ID, 'DEL_THREAD_STATUS' => 'CLOSED', 'DEL_DELEGATE_DATE' => date('Y-m-d H:i:s', strtotime("-$i year")) ]); //Create the register in delegation relate to self-service - $delegation = factory(Delegation::class)->create([ + $delegation = Delegation::factory()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, 'PRO_ID' => $process->PRO_ID, @@ -118,11 +113,11 @@ class UnassignedTest extends TestCase public function createSelfServiceByVariable($relation = 1, $userAssignee = true) { // Create user` - $user = factory(User::class)->create(); + $user = User::factory()->create(); // Create a group - $group = factory(Groupwf::class)->create(); + $group = Groupwf::factory()->create(); // Assign a user in the group - factory(GroupUser::class)->create([ + GroupUser::factory()->create([ 'GRP_UID' => $group->GRP_UID, 'GRP_ID' => $group->GRP_ID, 'USR_UID' => $user->USR_UID, @@ -130,39 +125,39 @@ class UnassignedTest extends TestCase // Create self-services for ($i = 1; $i <= 2; $i++) { //Create process - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); //Create application - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'APP_STATUS_ID' => 2 ]); //Create a task self service - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '@@ARRAY_OF_USERS', 'PRO_UID' => $process->PRO_UID, 'PRO_ID' => $process->PRO_ID, ]); //Create the relation for the value assigned in the TAS_GROUP_VARIABLE - $appSelfValueUser = factory(AppAssignSelfServiceValue::class)->create([ + $appSelfValueUser = AppAssignSelfServiceValue::factory()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'DEL_INDEX' => 2, 'TAS_ID' => $task->TAS_ID ]); - $selfValueGroup = factory(AppAssignSelfServiceValueGroup::class)->create([ + $selfValueGroup = AppAssignSelfServiceValueGroup::factory()->create([ 'ID' => $appSelfValueUser->ID, 'GRP_UID' => $user->USR_UID, 'ASSIGNEE_ID' => ($userAssignee) ? $user->USR_ID : $group->GRP_ID, 'ASSIGNEE_TYPE' => $relation ]); //Create the previous delegation before self-service - $delegation = factory(Delegation::class)->create([ + $delegation = Delegation::factory()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'PRO_ID' => $process->PRO_ID, 'DEL_THREAD_STATUS' => 'CLOSED', 'DEL_DELEGATE_DATE' => date('Y-m-d H:i:s', strtotime("-$i year")) ]); //Create the register in delegation relate to self-service - $delegation = factory(Delegation::class)->create([ + $delegation = Delegation::factory()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'DEL_INDEX' => $appSelfValueUser->DEL_INDEX, 'TAS_ID' => $task->TAS_ID, @@ -189,26 +184,26 @@ class UnassignedTest extends TestCase */ public function createMultipleUnassigned($cases) { - $user = factory(\ProcessMaker\Model\User::class)->create(); + $user = \ProcessMaker\Model\User::factory()->create(); for ($i = 0; $i < $cases; $i = $i + 1) { - $process = factory(Process::class)->create(); - $application = factory(Application::class)->create([ + $process = Process::factory()->create(); + $application = Application::factory()->create([ 'APP_STATUS_ID' => 2 ]); - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID, 'PRO_ID' => $process->PRO_ID, ]); - factory(TaskUser::class)->create([ + TaskUser::factory()->create([ 'TAS_UID' => $task->TAS_UID, 'USR_UID' => $user->USR_UID, 'TU_RELATION' => 1, //Related to the user 'TU_TYPE' => 1 ]); - $delegation = factory(Delegation::class)->create([ + $delegation = Delegation::factory()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, 'PRO_ID' => $process->PRO_ID, @@ -516,7 +511,7 @@ class UnassignedTest extends TestCase // Get the data $res = $unassigned->getData(); // Asserts - $this->assertNotEmpty($res); + $this->assertTrue(!empty($res)); } /** @@ -594,29 +589,29 @@ class UnassignedTest extends TestCase */ public function it_should_test_get_counters_by_processes_method_category() { - $user = factory(User::class)->create(); - $process1 = factory(Process::class)->create([ + $user = User::factory()->create(); + $process1 = Process::factory()->create([ 'CATEGORY_ID' => 2 ]); - $process2 = factory(Process::class)->create([ + $process2 = Process::factory()->create([ 'CATEGORY_ID' => 3 ]); - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'APP_STATUS_ID' => 2 ]); - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process1->PRO_UID, 'PRO_ID' => $process1->PRO_ID, ]); - factory(TaskUser::class)->create([ + TaskUser::factory()->create([ 'TAS_UID' => $task->TAS_UID, 'USR_UID' => $user->USR_UID, 'TU_RELATION' => 1, 'TU_TYPE' => 1 ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, 'PRO_ID' => $process1->PRO_ID, @@ -624,19 +619,19 @@ class UnassignedTest extends TestCase 'USR_ID' => 0, 'DEL_DELEGATE_DATE' => date('Y-m-d H:i:s', strtotime("-1 year")) ]); - $task2 = factory(Task::class)->create([ + $task2 = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process2->PRO_UID, 'PRO_ID' => $process2->PRO_ID, ]); - factory(TaskUser::class)->create([ + TaskUser::factory()->create([ 'TAS_UID' => $task2->TAS_UID, 'USR_UID' => $user->USR_UID, 'TU_RELATION' => 1, 'TU_TYPE' => 1 ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'TAS_ID' => $task2->TAS_ID, 'PRO_ID' => $process2->PRO_ID, @@ -675,29 +670,29 @@ class UnassignedTest extends TestCase */ public function it_should_test_get_counters_by_processes_method_processes() { - $user = factory(User::class)->create(); - $process1 = factory(Process::class)->create([ + $user = User::factory()->create(); + $process1 = Process::factory()->create([ 'CATEGORY_ID' => 2 ]); - $process2 = factory(Process::class)->create([ + $process2 = Process::factory()->create([ 'CATEGORY_ID' => 3 ]); - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'APP_STATUS_ID' => 2 ]); - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process1->PRO_UID, 'PRO_ID' => $process1->PRO_ID, ]); - factory(TaskUser::class)->create([ + TaskUser::factory()->create([ 'TAS_UID' => $task->TAS_UID, 'USR_UID' => $user->USR_UID, 'TU_RELATION' => 1, 'TU_TYPE' => 1 ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, 'PRO_ID' => $process1->PRO_ID, @@ -705,19 +700,19 @@ class UnassignedTest extends TestCase 'USR_ID' => 0, 'DEL_DELEGATE_DATE' => date('Y-m-d H:i:s', strtotime("-1 year")) ]); - $task2 = factory(Task::class)->create([ + $task2 = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process2->PRO_UID, 'PRO_ID' => $process2->PRO_ID, ]); - factory(TaskUser::class)->create([ + TaskUser::factory()->create([ 'TAS_UID' => $task2->TAS_UID, 'USR_UID' => $user->USR_UID, 'TU_RELATION' => 1, 'TU_TYPE' => 1 ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'TAS_ID' => $task2->TAS_ID, 'PRO_ID' => $process2->PRO_ID, @@ -740,29 +735,29 @@ class UnassignedTest extends TestCase */ public function it_should_test_get_counters_by_range_method() { - $user = factory(User::class)->create(); - $process1 = factory(Process::class)->create([ + $user = User::factory()->create(); + $process1 = Process::factory()->create([ 'CATEGORY_ID' => 2 ]); - $process2 = factory(Process::class)->create([ + $process2 = Process::factory()->create([ 'CATEGORY_ID' => 3 ]); - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'APP_STATUS_ID' => 2 ]); - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process1->PRO_UID, 'PRO_ID' => $process1->PRO_ID, ]); - factory(TaskUser::class)->create([ + TaskUser::factory()->create([ 'TAS_UID' => $task->TAS_UID, 'USR_UID' => $user->USR_UID, 'TU_RELATION' => 1, 'TU_TYPE' => 1 ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, 'PRO_ID' => $process1->PRO_ID, @@ -770,19 +765,19 @@ class UnassignedTest extends TestCase 'USR_ID' => 0, 'DEL_DELEGATE_DATE' => '2021-05-21 09:52:32' ]); - $task2 = factory(Task::class)->create([ + $task2 = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process2->PRO_UID, 'PRO_ID' => $process2->PRO_ID, ]); - factory(TaskUser::class)->create([ + TaskUser::factory()->create([ 'TAS_UID' => $task2->TAS_UID, 'USR_UID' => $user->USR_UID, 'TU_RELATION' => 1, 'TU_TYPE' => 1 ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'TAS_ID' => $task2->TAS_ID, 'PRO_ID' => $process2->PRO_ID, @@ -817,9 +812,8 @@ class UnassignedTest extends TestCase */ public function it_should_test_getCustomListCount_method() { - $this->markTestIncomplete('Illegal mix of collations'); $cases = $this->createMultipleUnassigned(1); - $additionalTables = factory(AdditionalTables::class)->create([ + $additionalTables = AdditionalTables::factory()->create([ 'PRO_UID' => $cases['delegation']->PRO_UID ]); $query = "" @@ -831,10 +825,11 @@ class UnassignedTest extends TestCase . "`VAR2` varchar(255) DEFAULT NULL," . "`VAR3` varchar(255) DEFAULT NULL," . "PRIMARY KEY (`APP_UID`)," - . "KEY `indexTable` (`APP_UID`))"; + . "KEY `indexTable` (`APP_UID`)" + . ")ENGINE=InnoDB DEFAULT CHARSET='utf8'"; DB::statement($query); - $caseList = factory(CaseList::class)->create([ + $caseList = CaseList::factory()->create([ 'CAL_TYPE' => 'unassigned', 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID, 'USR_ID' => $cases['taskUser']->USR_ID @@ -887,26 +882,26 @@ class UnassignedTest extends TestCase $currentDate = $date->format('Y-m-d H:i:s'); $diff1Day = new DateInterval('P1D'); $diff2Days = new DateInterval('P2D'); - $user = factory(User::class)->create(); - $process1 = factory(Process::class)->create([ + $user = User::factory()->create(); + $process1 = Process::factory()->create([ 'CATEGORY_ID' => 2 ]); - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'APP_STATUS_ID' => 2 ]); - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process1->PRO_UID, 'PRO_ID' => $process1->PRO_ID, ]); - factory(TaskUser::class)->create([ + TaskUser::factory()->create([ 'TAS_UID' => $task->TAS_UID, 'USR_UID' => $user->USR_UID, 'TU_RELATION' => 1, 'TU_TYPE' => 1 ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, 'PRO_ID' => $process1->PRO_ID, @@ -935,26 +930,26 @@ class UnassignedTest extends TestCase $date = new DateTime('now'); $currentDate = $date->format('Y-m-d H:i:s'); $diff2Days = new DateInterval('P2D'); - $user = factory(User::class)->create(); - $process1 = factory(Process::class)->create([ + $user = User::factory()->create(); + $process1 = Process::factory()->create([ 'CATEGORY_ID' => 2 ]); - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'APP_STATUS_ID' => 2 ]); - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process1->PRO_UID, 'PRO_ID' => $process1->PRO_ID, ]); - factory(TaskUser::class)->create([ + TaskUser::factory()->create([ 'TAS_UID' => $task->TAS_UID, 'USR_UID' => $user->USR_UID, 'TU_RELATION' => 1, 'TU_TYPE' => 1 ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, 'PRO_ID' => $process1->PRO_ID, @@ -983,26 +978,26 @@ class UnassignedTest extends TestCase $date = new DateTime('now'); $currentDate = $date->format('Y-m-d H:i:s'); $diff2Days = new DateInterval('P2D'); - $user = factory(User::class)->create(); - $process1 = factory(Process::class)->create([ + $user = User::factory()->create(); + $process1 = Process::factory()->create([ 'CATEGORY_ID' => 2 ]); - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'APP_STATUS_ID' => 2 ]); - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process1->PRO_UID, 'PRO_ID' => $process1->PRO_ID, ]); - factory(TaskUser::class)->create([ + TaskUser::factory()->create([ 'TAS_UID' => $task->TAS_UID, 'USR_UID' => $user->USR_UID, 'TU_RELATION' => 1, 'TU_TYPE' => 1 ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, 'PRO_ID' => $process1->PRO_ID, diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/CasesTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/CasesTest.php index ba0e97d7e..7d5dcdf60 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/CasesTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/CasesTest.php @@ -28,12 +28,10 @@ class CasesTest extends TestCase /** * Set up method. */ - public function setUp() + public function setUp(): void { parent::setUp(); - Delegation::truncate(); - Documents::truncate(); - Application::truncate(); + $this->truncateNonInitialModels(); User::where('USR_ID', '=', 1) ->where('USR_ID', '=', 2) ->delete(); @@ -55,9 +53,11 @@ class CasesTest extends TestCase $RBAC = RBAC::getSingleton(); $RBAC->initRBAC(); - $application = factory(Application::class)->create(['APP_INIT_USER' => G::generateUniqueID()]); + $application = Application::factory()->create(['APP_INIT_USER' => G::generateUniqueID()]); // Tried to delete case $case = new Cases(); + + $this->expectException('Exception'); $case->deleteCase($application->APP_UID, $_SESSION['USER_LOGGED']); } @@ -77,9 +77,11 @@ class CasesTest extends TestCase $RBAC = RBAC::getSingleton(); $RBAC->initRBAC(); - $application = factory(Application::class)->create(['APP_STATUS' => 'TO_DO']); + $application = Application::factory()->create(['APP_STATUS' => 'TO_DO']); // Tried to delete case $case = new Cases(); + + $this->expectException('Exception'); $case->deleteCase($application->APP_UID, $_SESSION['USER_LOGGED']); } @@ -99,9 +101,11 @@ class CasesTest extends TestCase $RBAC = RBAC::getSingleton(); $RBAC->initRBAC(); - $application = factory(Application::class)->create(['APP_INIT_USER' => G::generateUniqueID()]); + $application = Application::factory()->create(['APP_INIT_USER' => G::generateUniqueID()]); // Tried to delete case $case = new Cases(); + + $this->expectException('Exception'); $case->deleteCase($application->APP_UID, $_SESSION['USER_LOGGED']); } @@ -114,8 +118,8 @@ class CasesTest extends TestCase */ public function it_should_upload_files_related_case_note() { - $application = factory(Application::class)->create(); - factory(Delegation::class)->states('foreign_keys')->create([ + $application = Application::factory()->create(); + Delegation::factory()->foreign_keys()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'APP_UID' => $application->APP_UID ]); @@ -150,11 +154,11 @@ class CasesTest extends TestCase */ public function it_should_test_upload_files_method() { - $user = factory(User::class)->create(); - $application = factory(Application::class)->create([ + $user = User::factory()->create(); + $application = Application::factory()->create([ 'APP_CUR_USER' => $user->USR_UID ]); - $delegation = factory(Delegation::class)->create([ + $delegation = Delegation::factory()->create([ 'APP_UID' => $application->APP_UID ]); $varName = "/tmp/test.pdf"; @@ -189,11 +193,11 @@ class CasesTest extends TestCase */ public function it_should_test_exception_in_upload_files_method() { - $user = factory(User::class)->create(); - $application = factory(Application::class)->create([ + $user = User::factory()->create(); + $application = Application::factory()->create([ 'APP_CUR_USER' => $user->USR_UID ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_UID' => $application->APP_UID ]); $varName = "/tmp/test.pdf"; @@ -216,11 +220,11 @@ class CasesTest extends TestCase */ public function it_should_test_the_exception_in_upload_files_method() { - $user = factory(User::class)->create(); - $application = factory(Application::class)->create([ + $user = User::factory()->create(); + $application = Application::factory()->create([ 'APP_CUR_USER' => $user->USR_UID ]); - $delegation = factory(Delegation::class)->create([ + $delegation = Delegation::factory()->create([ 'APP_UID' => $application->APP_UID ]); $varName = "/tmp/test.pdf"; @@ -250,22 +254,21 @@ class CasesTest extends TestCase */ public function it_execute_trigger_from_cases_with_self_service_timeout_every_time() { - ListUnassigned::truncate(); // Define the Execute Trigger = EVERY_TIME - $application = factory(Application::class)->states('foreign_keys')->create(); + $application = Application::factory()->foreign_keys()->create(); // Create a trigger - $trigger = factory(Triggers::class)->create([ + $trigger = Triggers::factory()->create([ 'PRO_UID' => $application->PRO_UID, 'TRI_WEBBOT' => 'echo(1);' ]); // Create a task with the configuration trigger execution - $task = factory(Task::class)->states('sef_service_timeout')->create([ + $task = Task::factory()->sef_service_timeout()->create([ 'PRO_UID' => $application->PRO_UID, 'TAS_SELFSERVICE_EXECUTION' => 'EVERY_TIME', 'TAS_SELFSERVICE_TRIGGER_UID' => $trigger->TRI_UID ]); // Create a unassigned cases - factory(ListUnassigned::class)->create([ + ListUnassigned::factory()->create([ 'TAS_UID' => $task->TAS_UID, 'TAS_ID' => $task->TAS_ID, 'APP_NUMBER' => $application->APP_NUMBER, @@ -289,22 +292,21 @@ class CasesTest extends TestCase */ public function it_execute_trigger_from_cases_with_self_service_timeout_once() { - ListUnassigned::truncate(); // Define the Execute Trigger = ONCE - $application = factory(Application::class)->states('foreign_keys')->create(); + $application = Application::factory()->foreign_keys()->create(); // Create a trigger - $trigger = factory(Triggers::class)->create([ + $trigger = Triggers::factory()->create([ 'PRO_UID' => $application->PRO_UID, 'TRI_WEBBOT' => 'echo(1);' ]); // Create a task with the configuration trigger execution - $task = factory(Task::class)->states('sef_service_timeout')->create([ + $task = Task::factory()->sef_service_timeout()->create([ 'PRO_UID' => $application->PRO_UID, 'TAS_SELFSERVICE_EXECUTION' => 'ONCE', 'TAS_SELFSERVICE_TRIGGER_UID' => $trigger->TRI_UID ]); // Create a unassigned cases - factory(ListUnassigned::class)->create([ + ListUnassigned::factory()->create([ 'TAS_UID' => $task->TAS_UID, 'TAS_ID' => $task->TAS_ID, 'APP_NUMBER' => $application->APP_NUMBER, @@ -329,20 +331,20 @@ class CasesTest extends TestCase public function it_should_test_get_dynaforms_by_application() { // Create a process - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); // Create a task related to the process - $task1 = factory(Task::class)->create([ + $task1 = Task::factory()->create([ 'PRO_UID' => $process->PRO_UID ]); // Created another task related to the process - $task2 = factory(Task::class)->create([ + $task2 = Task::factory()->create([ 'PRO_UID' => $process->PRO_UID ]); // Created a step related to the first task - factory(Step::class)->create([ + Step::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'TAS_UID' => $task1->TAS_UID, 'STEP_TYPE_OBJ' => 'DYNAFORM', @@ -352,7 +354,7 @@ class CasesTest extends TestCase // Created a step related to the second task and with a specific DynaForm Uid $dynUid = G::generateUniqueID(); - factory(Step::class)->create([ + Step::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'TAS_UID' => $task2->TAS_UID, 'STEP_TYPE_OBJ' => 'DYNAFORM', @@ -361,7 +363,7 @@ class CasesTest extends TestCase ]); // Create an application related to the process in draft status - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'APP_STATUS' => 'DRAFT' ]); @@ -392,7 +394,7 @@ class CasesTest extends TestCase public function it_should_test_case_status_info() { // Get status info when the case is PAUSED - $table = factory(AppDelay::class)->states('paused_foreign_keys')->create(); + $table = AppDelay::factory()->paused_foreign_keys()->create(); $cases = new Cases(); $result = $cases->getStatusInfo($table->APP_UID, $table->APP_DEL_INDEX, $table->APP_DELEGATION_USER); $this->assertNotEmpty($result); @@ -401,7 +403,7 @@ class CasesTest extends TestCase $this->assertArrayHasKey('PRO_UID', $result); // Get status info when the case is UNASSIGNED // Get status info when the case is TO_DO - $table = factory(Delegation::class)->states('foreign_keys')->create(); + $table = Delegation::factory()->foreign_keys()->create(); $cases = new Cases(); $result = $cases->getStatusInfo($table->APP_UID, $table->DEL_INDEX, $table->USR_UID); $this->assertNotEmpty($result); @@ -409,8 +411,8 @@ class CasesTest extends TestCase $this->assertArrayHasKey('DEL_INDEX', $result); $this->assertArrayHasKey('PRO_UID', $result); // Get status info when the case is COMPLETED - $table = factory(Application::class)->states('completed')->create(); - $table = factory(Delegation::class)->states('foreign_keys')->create([ + $table = Application::factory()->completed()->create(); + $table = Delegation::factory()->foreign_keys()->create([ 'APP_NUMBER' => $table->APP_NUMBER, 'APP_UID' => $table->APP_UID, ]); diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/EmailServerTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/EmailServerTest.php index 69bbf73ee..bfa3a6537 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/EmailServerTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/EmailServerTest.php @@ -19,13 +19,21 @@ class EmailServerTest extends TestCase /** * set up function. */ - public function setUp() + public function setUp(): void { parent::setUp(); $this->emailServer = new EmailServer(); $this->faker = Factory::create(); } + /** + * Call the tearDown method + */ + public function tearDown(): void + { + parent::tearDown(); // TODO: Change the autogenerated stub + } + /** * Get structure for registry the EMAIL_SERVER. * @return array @@ -109,7 +117,7 @@ class EmailServerTest extends TestCase $this->loadUserSession(); $faker = $this->faker; - $emailServer = factory(EmailServerModel::class)->create($this->getDataForEmailServerRegistry()); + $emailServer = EmailServerModel::factory()->create($this->getDataForEmailServerRegistry()); $data = $emailServer->toArray(); $this->emailServer->setContextLog([ @@ -247,7 +255,7 @@ class EmailServerTest extends TestCase $this->emailServer->setContextLog([ 'workspace' => 'workflow' ]); - $emailServer = factory(EmailServerModel::class)->create($this->getDataForEmailServerRegistry()); + $emailServer = EmailServerModel::factory()->create($this->getDataForEmailServerRegistry()); $emailServerUid = $emailServer->MESS_UID; $actual = $this->emailServer->getEmailServer($emailServerUid); $this->assertNotEmpty($actual); @@ -264,7 +272,7 @@ class EmailServerTest extends TestCase $this->emailServer->setContextLog([ 'workspace' => 'workflow' ]); - $emailServer = factory(EmailServerModel::class)->create($this->getDataForEmailServerRegistry()); + $emailServer = EmailServerModel::factory()->create($this->getDataForEmailServerRegistry()); $emailServerUid = $faker->regexify("/[a-zA-Z]{32}/"); $this->expectException(Exception::class); @@ -360,7 +368,7 @@ class EmailServerTest extends TestCase $emailServer = new EmailServer(); // This expects an exception message - $this->expectExceptionMessage("Undefined index: MESS_ENGINE"); + $this->expectExceptionMessage('Undefined array key "MESS_ENGINE"'); // Call the sendTestMail method $emailServer->sendTestMail($data); @@ -374,7 +382,7 @@ class EmailServerTest extends TestCase */ public function it_should_test_the_delete_method() { - $email = factory(EmailServerModel::class)->create(); + $email = EmailServerModel::factory()->create(); $emailServer = new EmailServer(); $res = $emailServer->delete($email['MESS_UID']); @@ -393,7 +401,7 @@ class EmailServerTest extends TestCase */ public function it_should_test_the_delete_method_with_imap() { - $email = factory(EmailServerModel::class)->create([ + $email = EmailServerModel::factory()->create([ 'MESS_ENGINE' => 'IMAP' ]); @@ -405,12 +413,4 @@ class EmailServerTest extends TestCase $this->expectExceptionMessage("**ID_EMAIL_SERVER_DOES_NOT_EXIST**"); $emailServer->getEmailServer($email['MESS_UID']); } - - /** - * Call the tearDown method - */ - public function tearDown() - { - parent::tearDown(); // TODO: Change the autogenerated stub - } } diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/FilesManagerTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/FilesManagerTest.php index 64331b600..19f2a0b1f 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/FilesManagerTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/FilesManagerTest.php @@ -20,7 +20,7 @@ class FilesManagerTest extends TestCase /** * Set up method. */ - public function setUp() + public function setUp(): void { parent::setUp(); $this->faker = Factory::create(); @@ -30,7 +30,7 @@ class FilesManagerTest extends TestCase /** * Tear down method. */ - public function tearDown() + public function tearDown(): void { parent::tearDown(); $this->directories = array_reverse($this->directories); @@ -46,9 +46,9 @@ class FilesManagerTest extends TestCase */ public function it_should_deleted_public_files_when_not_exist() { - $processFiles = factory(ProcessFilesModel::class)->create(); + $processFiles = ProcessFilesModel::factory()->create(); - $emailEvent = factory(EmailEventModel::class)->create([ + $emailEvent = EmailEventModel::factory()->create([ 'PRF_UID' => $processFiles->PRF_UID ]); @@ -77,11 +77,11 @@ class FilesManagerTest extends TestCase */ public function it_should_deleted_a_template_file($type, $separator) { - $user = factory(UserModel::class)->create([ + $user = UserModel::factory()->create([ 'USR_UID' => G::generateUniqueID() ]); - $process = factory(ProcessModel::class)->create([ + $process = ProcessModel::factory()->create([ 'PRO_UID' => G::generateUniqueID() ]); @@ -105,7 +105,7 @@ class FilesManagerTest extends TestCase $path = $directory . "/" . $fileName; file_put_contents($path, $this->faker->randomHtml()); - $processFiles = factory(ProcessFilesModel::class)->create([ + $processFiles = ProcessFilesModel::factory()->create([ 'PRF_UID' => G::generateUniqueID(), 'PRO_UID' => $process->PRO_UID, 'USR_UID' => $user->USR_UID, @@ -131,11 +131,11 @@ class FilesManagerTest extends TestCase */ public function it_should_deleted_a_public_file($type, $separator) { - $user = factory(UserModel::class)->create([ + $user = UserModel::factory()->create([ 'USR_UID' => G::generateUniqueID() ]); - $process = factory(ProcessModel::class)->create([ + $process = ProcessModel::factory()->create([ 'PRO_UID' => G::generateUniqueID() ]); @@ -159,7 +159,7 @@ class FilesManagerTest extends TestCase $path = $directory . "/" . $fileName; file_put_contents($path, $this->faker->randomHtml()); - $processFiles = factory(ProcessFilesModel::class)->create([ + $processFiles = ProcessFilesModel::factory()->create([ 'PRF_UID' => G::generateUniqueID(), 'PRO_UID' => $process->PRO_UID, 'USR_UID' => $user->USR_UID, @@ -185,22 +185,22 @@ class FilesManagerTest extends TestCase */ public function it_should_deleted_public_files_with_event_relation() { - $user = factory(UserModel::class)->create([ + $user = UserModel::factory()->create([ 'USR_UID' => G::generateUniqueID() ]); - $process = factory(ProcessModel::class)->create([ + $process = ProcessModel::factory()->create([ 'PRO_UID' => G::generateUniqueID() ]); - $processFiles = factory(ProcessFilesModel::class)->create([ + $processFiles = ProcessFilesModel::factory()->create([ 'PRF_UID' => G::generateUniqueID(), 'PRO_UID' => $process->PRO_UID, 'USR_UID' => $user->USR_UID, 'PRF_PATH' => '/' ]); - $emailEvent = factory(EmailEventModel::class)->create([ + $emailEvent = EmailEventModel::factory()->create([ 'PRF_UID' => $processFiles->PRF_UID ]); diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/GroupTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/GroupTest.php index d6a4b9c86..12ac6f79b 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/GroupTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/GroupTest.php @@ -40,7 +40,7 @@ class GroupTest extends TestCase /** * Sets up the unit tests. */ - protected function setUp() + public function setUp(): void { parent::setUp(); $this->setInstanceGroup(new Group()); @@ -51,7 +51,7 @@ class GroupTest extends TestCase * * @return array Definition Data Group */ - public function testDataGroup() + public function dataGroup() { $response = [ 'GRP_TITLE' => 'Group Test Unit', @@ -63,14 +63,13 @@ class GroupTest extends TestCase /** * Create group * - * @depends testDataGroup - * * @param array $dataGroup Information Group - * + * * @return string group Uid */ - public function testCreate($dataGroup) + public function testCreate(): string { + $dataGroup = $this->dataGroup(); $response = $this->getInstanceGroup()->create($dataGroup); $this->assertArrayHasKey('GRP_UID', $response); @@ -86,7 +85,7 @@ class GroupTest extends TestCase */ public function testGetUsersOfGroup($groupUid) { - $response = $this->getInstanceGroup()->getUsers('USERS', $groupUid); + $response = $this->group->getUsers('USERS', $groupUid); $this->assertCount(0, $response); } @@ -99,12 +98,12 @@ class GroupTest extends TestCase public function testGetUsersAvailable($groupUid) { $result = \ProcessMaker\Model\User::where('USERS.USR_STATUS', '<>', 'CLOSED') - ->whereNotIn('USERS.USR_UID', ['00000000000000000000000000000002']) - ->leftJoin('GROUP_USER', function($query) { - $query->on('GROUP_USER.USR_UID', '=', 'USERS.USR_UID'); - }) - ->get() - ->toArray(); + ->whereNotIn('USERS.USR_UID', ['00000000000000000000000000000002']) + ->leftJoin('GROUP_USER', function ($query) { + $query->on('GROUP_USER.USR_UID', '=', 'USERS.USR_UID'); + }) + ->get() + ->toArray(); $response = $this->getInstanceGroup()->getUsers('AVAILABLE-USERS', $groupUid); $this->assertCount(count($result), $response); @@ -127,12 +126,13 @@ class GroupTest extends TestCase * * @depends testCreate * @expectedException Exception - * * @param string $groupUid Uid Group */ public function testDelete($groupUid) { + $this->expectException('Exception'); $this->getInstanceGroup()->delete($groupUid); $this->getInstanceGroup()->getGroup($groupUid); } + } diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/ListsTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/ListsTest.php index 7afc0137e..1561318fd 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/ListsTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/ListsTest.php @@ -19,7 +19,7 @@ class ListsTest extends TestCase */ public function it_should_test_the_lists_construct() { - $user = factory(User::class)->create(); + $user = User::factory()->create(); $list = new Lists(); $res = $list->getList('inbox', ['userId' => $user->USR_UID]); diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/SkinsTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/SkinsTest.php index f18b3d98c..bc0ab56ab 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/SkinsTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/SkinsTest.php @@ -18,7 +18,7 @@ class SkinsTest extends TestCase /** * Sets up the unit test. */ - protected function setUp() + public function setUp(): void { parent::setUp(); $this->object = new Skins(); @@ -27,7 +27,7 @@ class SkinsTest extends TestCase /** * Tears down the unit test. */ - protected function tearDown() + public function tearDown(): void { parent::tearDown(); G::rm_dir(PATH_DATA . 'skins'); diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/TableTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/TableTest.php index 1344dafca..db7a2fc54 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/TableTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/TableTest.php @@ -11,16 +11,16 @@ class TableTest extends TestCase /** * Method setUp. */ - public function setUp() + public function setUp(): void { parent::setUp(); - AdditionalTables::truncate(); + $this->truncateNonInitialModels(); } /** * Method tearDown. */ - public function tearDown() + public function tearDown(): void { parent::tearDown(); } @@ -32,7 +32,7 @@ class TableTest extends TestCase */ public function it_should_test_getTables_method() { - $additionalTables = factory(AdditionalTables::class) + $additionalTables = AdditionalTables::factory() ->create(); $proUid = $additionalTables->PRO_UID; diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/TaskSchedulerBMTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/TaskSchedulerBMTest.php index ce454371a..0ec6773ea 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/TaskSchedulerBMTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/TaskSchedulerBMTest.php @@ -8,6 +8,16 @@ use Tests\TestCase; class TaskSchedulerBMTest extends TestCase { + /** + * Set up method. + * @return void + */ + public function setUp(): void + { + parent::setUp(); + $this->truncateNonInitialModels(); + } + /** * Test getSchedule method * @@ -16,13 +26,12 @@ class TaskSchedulerBMTest extends TestCase */ public function it_should_test_get_schedule_method() { - TaskScheduler::truncate(); $obj = new TaskSchedulerBM(); $res = $obj->getSchedule('emails_notifications'); $this->assertNotEmpty($res); - factory(TaskScheduler::class)->create(); + TaskScheduler::factory()->create(); $res = $obj->getSchedule('emails_notifications'); $this->assertNotEmpty(1, $res); @@ -50,7 +59,7 @@ class TaskSchedulerBMTest extends TestCase { $obj = new TaskSchedulerBM(); - $scheduler = factory(TaskScheduler::class)->create(); + $scheduler = TaskScheduler::factory()->create(); $request_data = [ "id" => $scheduler->id, @@ -85,7 +94,6 @@ class TaskSchedulerBMTest extends TestCase */ public function it_should_test_generate_initial_data_method() { - TaskScheduler::truncate(); $r = TaskScheduler::all()->toArray(); $this->assertEmpty($r); diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/ValidatorTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/ValidatorTest.php index dbbc875d6..1ff24b80c 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/ValidatorTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/ValidatorTest.php @@ -55,9 +55,10 @@ class ValidatorTest extends TestCase */ public function it_test_exception_dep_uid_exist() { - $table = factory(Department::class)->create(); + $table = Department::factory()->create(); DB::commit(); $result = Validator::depUid($table->DEP_UID); + $this->assertNotEmpty($result); } /** @@ -107,7 +108,7 @@ class ValidatorTest extends TestCase */ public function it_test_exception_usr_uid_exist() { - $table = factory(User::class)->create(); + $table = User::factory()->create(); DB::commit(); $result = Validator::usrUid($table->USR_UID); $this->assertNotEmpty($result); @@ -158,7 +159,7 @@ class ValidatorTest extends TestCase */ public function it_test_exception_app_uid_exist() { - $table = factory(Application::class)->create(); + $table = Application::factory()->create(); DB::commit(); $result = Validator::appUid($table->APP_UID); $this->assertNotEmpty($result); @@ -197,7 +198,7 @@ class ValidatorTest extends TestCase */ public function it_test_exception_tri_uid_exist() { - $table = factory(Triggers::class)->create(); + $table = Triggers::factory()->create(); DB::commit(); $result = Validator::triUid($table->TRI_UID); $this->assertNotEmpty($result); @@ -236,7 +237,7 @@ class ValidatorTest extends TestCase */ public function it_test_exception_pro_uid_exist() { - $table = factory(Process::class)->create(); + $table = Process::factory()->create(); DB::commit(); $result = Validator::proUid($table->PRO_UID); $this->assertNotEmpty($result); @@ -275,7 +276,7 @@ class ValidatorTest extends TestCase */ public function it_test_exception_cat_uid_exist() { - $table = factory(ProcessCategory::class)->create(); + $table = ProcessCategory::factory()->create(); DB::commit(); $result = Validator::catUid($table->CATEGORY_UID); $this->assertNotEmpty($result); diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/VariableTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/VariableTest.php index 29d819761..9676228c7 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/VariableTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/VariableTest.php @@ -21,11 +21,8 @@ class VariableTest extends TestCase /** * This method calls the parent setUp */ - public function setUp() + public function setUp(): void { - if (version_compare(phpversion(), 7.3, '>') ) { - $this->markTestSkipped('Illegal mix of collations'); - } parent::setUp(); } @@ -37,9 +34,9 @@ class VariableTest extends TestCase */ public function it_create_variable_by_process() { - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); - factory(ProcessVariables::class)->create([ + ProcessVariables::factory()->create([ 'PRJ_UID' => $process->PRO_UID, 'PRO_ID' => $process->PRO_ID, ]); @@ -83,8 +80,8 @@ class VariableTest extends TestCase */ public function it_return_an_exception_when_var_name_is_empty() { - $process = factory(Process::class)->create(); - factory(ProcessVariables::class)->create([ + $process = Process::factory()->create(); + ProcessVariables::factory()->create([ 'PRJ_UID' => $process->PRO_UID, 'PRO_ID' => $process->PRO_ID, ]); @@ -114,8 +111,8 @@ class VariableTest extends TestCase */ public function it_return_an_exception_when_var_field_type_is_empty() { - $process = factory(Process::class)->create(); - factory(ProcessVariables::class)->create([ + $process = Process::factory()->create(); + ProcessVariables::factory()->create([ 'PRJ_UID' => $process->PRO_UID, 'PRO_ID' => $process->PRO_ID, ]); @@ -145,8 +142,8 @@ class VariableTest extends TestCase */ public function it_return_an_exception_when_var_label_is_empty() { - $process = factory(Process::class)->create(); - factory(ProcessVariables::class)->create([ + $process = Process::factory()->create(); + ProcessVariables::factory()->create([ 'PRJ_UID' => $process->PRO_UID, 'PRO_ID' => $process->PRO_ID, ]); @@ -176,9 +173,9 @@ class VariableTest extends TestCase */ public function it_list_variables_by_process() { - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); - factory(ProcessVariables::class)->create([ + ProcessVariables::factory()->create([ 'PRJ_UID' => $process->PRO_UID, 'PRO_ID' => $process->PRO_ID, ]); @@ -209,11 +206,11 @@ class VariableTest extends TestCase */ public function it_list_variables_by_type_related_a_process() { - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); $varType = 'integer'; $varTypeId = 2; for ($x = 1; $x <= 5; $x++) { - $processVar = factory(ProcessVariables::class)->states('foreign_keys')->create([ + $processVar = ProcessVariables::factory()->foreign_keys()->create([ 'PRO_ID' => $process->PRO_ID, 'PRJ_UID' => $process->PRO_UID, 'VAR_FIELD_TYPE' => $varType, @@ -251,10 +248,10 @@ class VariableTest extends TestCase $data = file_get_contents($pathData); $json = json_decode($data); - $dynaform = factory(Dynaform::class)->create([ + $dynaform = Dynaform::factory()->create([ 'DYN_CONTENT' => $data ]); - $application = factory(Application::class)->create(); + $application = Application::factory()->create(); $proUid = ''; $params = [ @@ -295,15 +292,15 @@ class VariableTest extends TestCase //assert $this->expectException(Exception::class); // Create process variable - $variable = factory(ProcessVariables::class)->create(); + $variable = ProcessVariables::factory()->create(); $result = ProcessVariables::getVariable($variable->VAR_UID); $this->assertNotEmpty($result); // Create tables - $table = factory(AdditionalTables::class)->create([ + $table = AdditionalTables::factory()->create([ 'PRO_UID' => $variable->PRO_UID, ]); // Create fields - $fields = factory(Fields::class)->create([ + $fields = Fields::factory()->create([ 'ADD_TAB_UID' => $table->ADD_TAB_UID, 'FLD_NAME' => $variable->VAR_NAME, ]); diff --git a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/WebEntryTest.php b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/WebEntryTest.php index 0e49def9e..a3c779fac 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/WebEntryTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/BusinessModel/WebEntryTest.php @@ -29,7 +29,7 @@ class WebEntryTest extends TestCase $webEntryFilename = G::generateUniqueID(); // Create a Web Entry - $webEntry = factory(WebEntry::class)->create(['WE_DATA' => $webEntryFilename . $phpExtension]); + $webEntry = WebEntry::factory()->create(['WE_DATA' => $webEntryFilename . $phpExtension]); // Post file is from a valid Web Entry? $isWebEntry = BmWebEntry::isWebEntry($webEntry->PRO_UID, $webEntryFilename . $postFileExtension); @@ -55,7 +55,7 @@ class WebEntryTest extends TestCase $webEntryFilename = 'My_Custom_Form'; // Create a Web Entry - $webEntry = factory(WebEntry::class)->create(['WE_DATA' => $webEntryFilename . $phpExtension]); + $webEntry = WebEntry::factory()->create(['WE_DATA' => $webEntryFilename . $phpExtension]); // Post file is from a valid Web Entry? $isWebEntry = BmWebEntry::isWebEntry($webEntry->PRO_UID, $webEntryFilename . $postFileExtension); diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Cases/CasesTraitTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Cases/CasesTraitTest.php index 441cf4eb8..810476912 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Cases/CasesTraitTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Cases/CasesTraitTest.php @@ -30,7 +30,7 @@ class CasesTraitTest extends TestCase /** * Set up method. */ - public function setUp() + public function setUp(): void { parent::setUp(); } @@ -43,26 +43,26 @@ class CasesTraitTest extends TestCase { $user = User::where('USR_ID', '=', 1)->first(); - $process = factory(Process::class)->create([ + $process = Process::factory()->create([ 'PRO_CREATE_USER' => $user->USR_UID ]); - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'BALANCED', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID ]); - factory(TaskUser::class)->create([ + TaskUser::factory()->create([ 'TAS_UID' => $task->TAS_UID, 'USR_UID' => $user->USR_UID, 'TU_RELATION' => 1, 'TU_TYPE' => 1 ]); - $task2 = factory(Task::class)->create([ + $task2 = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'BALANCED', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID ]); - factory(TaskUser::class)->create([ + TaskUser::factory()->create([ 'TAS_UID' => $task2->TAS_UID, 'USR_UID' => $user->USR_UID, 'TU_RELATION' => 1, @@ -70,17 +70,17 @@ class CasesTraitTest extends TestCase ]); - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'PRO_UID' => $process->PRO_UID ]); - $appDelegation = factory(Delegation::class)->create([ + $appDelegation = Delegation::factory()->create([ 'USR_UID' => $user->USR_UID, 'PRO_UID' => $process->PRO_UID, 'APP_UID' => $application->APP_UID, 'TAS_UID' => $task->TAS_UID, 'DEL_INDEX' => 1, ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'USR_UID' => $user->USR_UID, 'PRO_UID' => $process->PRO_UID, 'APP_UID' => $application->APP_UID, @@ -88,13 +88,13 @@ class CasesTraitTest extends TestCase 'DEL_INDEX' => 2, 'DEL_PREVIOUS' => $appDelegation->DEL_INDEX ]); - factory(Route::class)->create([ + Route::factory()->create([ 'TAS_UID' => $task->TAS_UID, 'ROU_NEXT_TASK' => $task2->TAS_UID, 'PRO_UID' => $process->PRO_UID ]); - $step = factory(Step::class)->create([ + $step = Step::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'TAS_UID' => $appDelegation->TAS_UID, 'STEP_POSITION' => 2, @@ -102,11 +102,11 @@ class CasesTraitTest extends TestCase ]); - $triggers = factory(Triggers::class)->create([ + $triggers = Triggers::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'TRI_WEBBOT' => '$a = 0;' ]); - factory(StepTrigger::class)->create([ + StepTrigger::factory()->create([ 'STEP_UID' => -2, 'TAS_UID' => $task->TAS_UID, 'TRI_UID' => $triggers->TRI_UID, @@ -115,11 +115,11 @@ class CasesTraitTest extends TestCase ]); - $triggers = factory(Triggers::class)->create([ + $triggers = Triggers::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'TRI_WEBBOT' => '$b = 0;' ]); - factory(StepTrigger::class)->create([ + StepTrigger::factory()->create([ 'STEP_UID' => -2, 'TAS_UID' => $task->TAS_UID, 'TRI_UID' => $triggers->TRI_UID, @@ -304,49 +304,49 @@ class CasesTraitTest extends TestCase { $user = User::where('USR_ID', '=', 1)->first(); - $process = factory(Process::class)->create([ + $process = Process::factory()->create([ 'PRO_CREATE_USER' => $user->USR_UID ]); - $dynaform = factory(Dynaform::class)->create([ + $dynaform = Dynaform::factory()->create([ 'PRO_UID' => $process->PRO_UID ]); - $inpuDocument = factory(InputDocument::class)->create([ + $inpuDocument = InputDocument::factory()->create([ 'PRO_UID' => $process->PRO_UID ]); - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'BALANCED', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID ]); - factory(TaskUser::class)->create([ + TaskUser::factory()->create([ 'TAS_UID' => $task->TAS_UID, 'USR_UID' => $user->USR_UID, 'TU_RELATION' => 1, 'TU_TYPE' => 1 ]); - $task2 = factory(Task::class)->create([ + $task2 = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'BALANCED', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID ]); - factory(TaskUser::class)->create([ + TaskUser::factory()->create([ 'TAS_UID' => $task2->TAS_UID, 'USR_UID' => $user->USR_UID, 'TU_RELATION' => 1, 'TU_TYPE' => 1 ]); - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'PRO_UID' => $process->PRO_UID ]); - $delegation1 = factory(Delegation::class)->create([ + $delegation1 = Delegation::factory()->create([ 'USR_UID' => $user->USR_UID, 'PRO_UID' => $process->PRO_UID, 'APP_UID' => $application->APP_UID, 'TAS_UID' => $task->TAS_UID, 'DEL_INDEX' => 1, ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'USR_UID' => $user->USR_UID, 'PRO_UID' => $process->PRO_UID, 'APP_UID' => $application->APP_UID, @@ -354,14 +354,14 @@ class CasesTraitTest extends TestCase 'DEL_INDEX' => 2, 'DEL_PREVIOUS' => $delegation1->DEL_INDEX ]); - factory(Route::class)->create([ + Route::factory()->create([ 'TAS_UID' => $task->TAS_UID, 'ROU_NEXT_TASK' => $task2->TAS_UID, 'PRO_UID' => $process->PRO_UID ]); - $emailServer = factory(EmailServerModel::class)->create(); - $abeConfiguration = factory(AbeConfiguration::class)->create([ + $emailServer = EmailServerModel::factory()->create(); + $abeConfiguration = AbeConfiguration::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'DYN_UID' => $dynaform->DYN_UID, 'TAS_UID' => $task2->TAS_UID, @@ -369,7 +369,7 @@ class CasesTraitTest extends TestCase 'ABE_TYPE' => 'LINK', 'ABE_CASE_NOTE_IN_RESPONSE' => 1, ]); - $abeRequest = factory(AbeRequest::class)->create([ + $abeRequest = AbeRequest::factory()->create([ 'ABE_UID' => $abeConfiguration->ABE_UID, 'APP_UID' => $application->APP_UID, 'DEL_INDEX' => $delegation1->DEL_INDEX, @@ -410,9 +410,9 @@ class CasesTraitTest extends TestCase */ public function it_should_verify_if_abe_has_not_completed() { - $delegation1 = factory(Delegation::class)->state('closed')->create(); - $abeRequest = factory(AbeRequest::class)->create(); - $dynaform = factory(Dynaform::class)->create([ + $delegation1 = Delegation::factory()->closed()->create(); + $abeRequest = AbeRequest::factory()->create(); + $dynaform = Dynaform::factory()->create([ 'PRO_UID' => $delegation1->PRO_UID ]); @@ -437,9 +437,9 @@ class CasesTraitTest extends TestCase */ public function it_should_test_an_exception_if_the_case_throws_an_incorrect_state() { - $delegation1 = factory(Delegation::class)->create(); - $abeRequest = factory(AbeRequest::class)->create(); - $dynaform = factory(Dynaform::class)->create([ + $delegation1 = Delegation::factory()->create(); + $abeRequest = AbeRequest::factory()->create(); + $dynaform = Dynaform::factory()->create([ 'PRO_UID' => $delegation1->PRO_UID ]); diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Core/JobsManagerTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Core/JobsManagerTest.php index 2d16c443e..dd8f92ece 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Core/JobsManagerTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Core/JobsManagerTest.php @@ -16,7 +16,7 @@ class JobsManagerTest extends TestCase * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. */ - protected function setUp() + public function setUp(): void { parent::setUp(); $this->object = new JobsManager; @@ -26,7 +26,7 @@ class JobsManagerTest extends TestCase * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. */ - protected function tearDown() + public function tearDown(): void { parent::tearDown(); } diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Core/SystemTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Core/SystemTest.php index 56d03ba37..2e7446db0 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Core/SystemTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Core/SystemTest.php @@ -14,9 +14,10 @@ class SystemTest extends TestCase /** * Define the required variables */ - public function setUp() + public function setUp(): void { parent::setUp(); + $this->truncateNonInitialModels(); } /** @@ -26,8 +27,6 @@ class SystemTest extends TestCase */ public function it_should_init_laravel_configurations() { - $this->markTestIncomplete("@todo: Please correct this unit test"); - $object = new System(); $object->initLaravel(); @@ -48,12 +47,11 @@ class SystemTest extends TestCase $system = new System(); //default values - EmailServerModel::truncate(); $actual = $system->getEmailConfiguration(); $this->assertEmpty($actual); //new instance - $emailServer = factory(EmailServerModel::class)->create([ + $emailServer = EmailServerModel::factory()->create([ 'MESS_DEFAULT' => 1 ]); $actual = $system->getEmailConfiguration(); diff --git a/tests/unit/workflow/engine/src/ProcessMaker/GmailOAuth/GmailOAuthTest.php b/tests/unit/workflow/engine/src/ProcessMaker/GmailOAuth/GmailOAuthTest.php index 4b968615e..17612a9d7 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/GmailOAuth/GmailOAuthTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/GmailOAuth/GmailOAuthTest.php @@ -24,7 +24,7 @@ class GmailOAuthTest extends TestCase /** * Init properties */ - public function setUp() + public function setUp(): void { if (version_compare(phpversion(), 7.3, '>') ) { $this->markTestSkipped('The changes in third party are not available'); diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Importer/ImporterTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Importer/ImporterTest.php index fe93291c4..e5d73431c 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Importer/ImporterTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Importer/ImporterTest.php @@ -18,7 +18,7 @@ class ImporterTest extends TestCase /** * Declared to avoid the incompatibility exception */ - public function setUp() + public function setUp(): void { parent::setUp(); error_reporting(E_ALL & ~E_DEPRECATED & ~E_STRICT); @@ -52,7 +52,7 @@ class ImporterTest extends TestCase 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( + $process = Process::factory()->create( ['PRO_CREATE_DATE' => '2019-07-10 10:00:00'] ); @@ -276,7 +276,7 @@ class ImporterTest extends TestCase // Mock the load method $importer->method("load") ->willReturn($array); - $importer->setData("usr_uid", factory(User::class)->create()->USR_UID); + $importer->setData("usr_uid", User::factory()->create()->USR_UID); // Call the import method $res = $importer->import(Importer::IMPORT_OPTION_KEEP_WITHOUT_CHANGING_AND_CREATE_NEW, @@ -301,10 +301,10 @@ class ImporterTest extends TestCase 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( + $process = Process::factory()->create( ['PRO_CREATE_DATE' => '2019-07-10 10:00:00'] ); - factory(BpmnProject::class)->create( + BpmnProject::factory()->create( ['PRJ_UID' => $process['PRO_UID']] ); @@ -528,7 +528,7 @@ class ImporterTest extends TestCase // Mock the load method $importer->method("load") ->willReturn($array); - $importer->setData("usr_uid", factory(User::class)->create()->USR_UID); + $importer->setData("usr_uid", User::factory()->create()->USR_UID); // Call the setProtectedProperty method $this->setProtectedProperty($importer, 'metadata', ['uid' => $process['PRO_UID']]); diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Importer/XmlImporterTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Importer/XmlImporterTest.php index dda3d3677..6f04a79c8 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Importer/XmlImporterTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Importer/XmlImporterTest.php @@ -19,10 +19,10 @@ class XmlImporterTest extends TestCase /** * Set up unit tests. */ - public function setUp() + public function setUp(): void { parent::setUp(); - $this->user = factory(User::class)->create(); + $this->user = User::factory()->create(); Groupwf::truncate(); $cached = ["jXsSi94bkRUcVZyRStNVExlTXhEclVadGRRcG9xbjNvTWVFQUF3cklKQVBiVT0=" => 1]; @@ -52,10 +52,10 @@ class XmlImporterTest extends TestCase */ public function it_should_matter_with_import_option_keep_without_changing_and_create_new_and_group_import_option_merge_preexistent() { - factory(\ProcessMaker\Model\Groupwf::class)->create([ + \ProcessMaker\Model\Groupwf::factory()->create([ 'GRP_TITLE' => 'group1' ]); - factory(\ProcessMaker\Model\Groupwf::class)->create([ + \ProcessMaker\Model\Groupwf::factory()->create([ 'GRP_TITLE' => 'group2' ]); $regenerateUids = false; @@ -74,10 +74,10 @@ class XmlImporterTest extends TestCase */ public function it_should_matter_with_import_option_overwrite_and_group_import_option_rename() { - factory(\ProcessMaker\Model\Groupwf::class)->create([ + \ProcessMaker\Model\Groupwf::factory()->create([ 'GRP_TITLE' => 'group1' ]); - factory(\ProcessMaker\Model\Groupwf::class)->create([ + \ProcessMaker\Model\Groupwf::factory()->create([ 'GRP_TITLE' => 'group2' ]); $filename = PATH_TRUNK . "tests/resources/p1normal-1.pmx"; @@ -196,10 +196,10 @@ class XmlImporterTest extends TestCase */ public function it_should_matter_with_import_option_overwrite_and_group_import_option_create_new_with_groups() { - factory(\ProcessMaker\Model\Groupwf::class)->create([ + \ProcessMaker\Model\Groupwf::factory()->create([ 'GRP_TITLE' => 'group1' ]); - factory(\ProcessMaker\Model\Groupwf::class)->create([ + \ProcessMaker\Model\Groupwf::factory()->create([ 'GRP_TITLE' => 'group2' ]); $filename = PATH_TRUNK . "tests/resources/p1normal-1.pmx"; @@ -237,7 +237,7 @@ class XmlImporterTest extends TestCase */ public function it_should_matter_with_import_option_create_new_and_group_import_option_create_new_try_rename_title() { - factory(\ProcessMaker\Model\Process::class)->create([ + \ProcessMaker\Model\Process::factory()->create([ 'PRO_TITLE' => 'p1normalWithoutTitle' ]); @@ -249,7 +249,7 @@ class XmlImporterTest extends TestCase $result = $importer->import(XmlImporter::IMPORT_OPTION_CREATE_NEW, XmlImporter::GROUP_IMPORT_OPTION_CREATE_NEW, false); $this->assertNotNull($result); - factory(\ProcessMaker\Model\Process::class)->create([ + \ProcessMaker\Model\Process::factory()->create([ 'PRO_TITLE' => 'p1normalWithoutTitle2' ]); diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/AbeConfigurationTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/AbeConfigurationTest.php index 3b89ac90e..9c32cc755 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Model/AbeConfigurationTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Model/AbeConfigurationTest.php @@ -23,7 +23,7 @@ class AbeConfigurationTest extends TestCase /** * Call the setUp parent method */ - public function setUp() + public function setUp(): void { parent::setUp(); // TODO: Change the autogenerated stub } @@ -31,7 +31,7 @@ class AbeConfigurationTest extends TestCase /** * Call the tearDown parent method */ - public function tearDown() + public function tearDown(): void { parent::tearDown(); // TODO: Change the autogenerated stub } @@ -45,21 +45,21 @@ class AbeConfigurationTest extends TestCase public function it_should_test_the_get_abe_request_method() { //Create the Task factory - factory(Task::class)->create(); + Task::factory()->create(); //Create the Process factory - factory(Process::class)->create(); + Process::factory()->create(); //Create the Dynaform factory - factory(Dynaform::class)->create(); + Dynaform::factory()->create(); //Create the EmailServerModel factory - factory(EmailServerModel::class)->create(); + EmailServerModel::factory()->create(); //Create the Application factory - factory(Application::class)->create(); + Application::factory()->create(); //Create the Delegation factory - $delegation = factory(Delegation::class)->create(); + $delegation = Delegation::factory()->create(); //Create the AbeConfiguration factory - $abeConfiguration = factory(AbeConfiguration::class)->create(); + $abeConfiguration = AbeConfiguration::factory()->create(); //Create the AbeConfiguration factory - factory(AbeRequest::class)->create([ + AbeRequest::factory()->create([ 'ABE_UID' => $abeConfiguration->ABE_UID, 'APP_UID' => $delegation->APP_UID, 'DEL_INDEX' => $delegation->DEL_INDEX, @@ -84,21 +84,21 @@ class AbeConfigurationTest extends TestCase public function it_should_test_the_get_abe_request_method_when_the_result_is_empty() { //Creates the Task factory - factory(Task::class)->create(); + Task::factory()->create(); //Creates the Process factory - factory(Process::class)->create(); + Process::factory()->create(); //Creates the Dynaform factory - factory(Dynaform::class)->create(); + Dynaform::factory()->create(); //Creates the EmailServer factory - factory(EmailServerModel::class)->create(); + EmailServerModel::factory()->create(); //Creates the Application factory - factory(Application::class)->create(); + Application::factory()->create(); //Creates the Delegation factory - $delegation = factory(Delegation::class)->create(); + $delegation = Delegation::factory()->create(); //Creates the AbeConfiguration factory - $abeConfiguration = factory(AbeConfiguration::class)->create(); + $abeConfiguration = AbeConfiguration::factory()->create(); //Creates the AbeConfiguration factory - factory(AbeRequest::class)->create([ + AbeRequest::factory()->create([ 'ABE_UID' => $abeConfiguration->ABE_UID, 'APP_UID' => $delegation->APP_UID, 'DEL_INDEX' => $delegation->DEL_INDEX, @@ -120,9 +120,9 @@ class AbeConfigurationTest extends TestCase */ public function it_should_test_the_update_abe_configuration_receiver_uid_method() { - $emailServer = factory(EmailServerModel::class)->create(); + $emailServer = EmailServerModel::factory()->create(); - $abeConfigurationFactory = factory(AbeConfiguration::class)->create([ + $abeConfigurationFactory = AbeConfiguration::factory()->create([ 'ABE_EMAIL_SERVER_UID' => $emailServer['MESS_UID'] ]); @@ -145,9 +145,9 @@ class AbeConfigurationTest extends TestCase public function it_should_test_the_update_abe_configuration_email_server_uid_method_when_there_is_not_a_default_server() { EmailServerModel::query()->delete(); - $emailServer = factory(EmailServerModel::class)->create(); + $emailServer = EmailServerModel::factory()->create(); - $abeConfigurationFactory = factory(AbeConfiguration::class)->create([ + $abeConfigurationFactory = AbeConfiguration::factory()->create([ 'ABE_EMAIL_SERVER_UID' => $emailServer['MESS_UID'] ]); @@ -170,13 +170,13 @@ class AbeConfigurationTest extends TestCase public function it_should_test_the_update_abe_configuration_email_server_uid_method_when_there_is_a_default_server() { EmailServerModel::query()->delete(); - $emailServer = factory(EmailServerModel::class)->create(); + $emailServer = EmailServerModel::factory()->create(); - $defaultServer = factory(EmailServerModel::class)->create([ + $defaultServer = EmailServerModel::factory()->create([ 'MESS_DEFAULT' => 1 ]); - $abeConfigurationFactory = factory(AbeConfiguration::class)->create([ + $abeConfigurationFactory = AbeConfiguration::factory()->create([ 'ABE_EMAIL_SERVER_UID' => $emailServer['MESS_UID'] ]); diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/AbeRequestTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/AbeRequestTest.php index b1518c4e3..31e7f619a 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Model/AbeRequestTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Model/AbeRequestTest.php @@ -25,9 +25,9 @@ class AbeRequestTest extends TestCase */ public function it_has_one_application() { - $table = factory(AbeRequest::class)->create([ + $table = AbeRequest::factory()->create([ 'APP_UID' => function () { - return factory(Application::class)->create()->APP_UID; + return Application::factory()->create()->APP_UID; } ]); $this->assertInstanceOf(Application::class, $table->application); @@ -41,9 +41,9 @@ class AbeRequestTest extends TestCase */ public function it_has_one_abe_configuration() { - $table = factory(AbeRequest::class)->create([ + $table = AbeRequest::factory()->create([ 'ABE_UID' => function () { - return factory(AbeConfiguration::class)->create()->ABE_UID; + return AbeConfiguration::factory()->create()->ABE_UID; } ]); $this->assertInstanceOf(AbeConfiguration::class, $table->abeConfiguration); diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/AdditionalTablesTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/AdditionalTablesTest.php index 6ff4e3f4a..57d8b140e 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Model/AdditionalTablesTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Model/AdditionalTablesTest.php @@ -21,9 +21,9 @@ class AdditionalTablesTest extends TestCase */ public function it_has_a_columns_defined() { - $table = factory(AdditionalTables::class)->create([ + $table = AdditionalTables::factory()->create([ 'ADD_TAB_UID' => function () { - return factory(Fields::class)->create()->ADD_TAB_UID; + return Fields::factory()->create()->ADD_TAB_UID; } ]); $this->assertInstanceOf(Fields::class, $table->columns); @@ -37,8 +37,8 @@ class AdditionalTablesTest extends TestCase */ public function it_filter_offline_table() { - factory(AdditionalTables::class)->create(['ADD_TAB_OFFLINE' => 0]); - $table = factory(AdditionalTables::class)->create([ + AdditionalTables::factory()->create(['ADD_TAB_OFFLINE' => 0]); + $table = AdditionalTables::factory()->create([ 'ADD_TAB_OFFLINE' => 1 ]); $this->assertCount(1, $table->offline([$table->ADD_TAB_OFFLINE])->get()); @@ -52,7 +52,7 @@ class AdditionalTablesTest extends TestCase */ public function it_filter_process() { - $table = factory(AdditionalTables::class)->create(); + $table = AdditionalTables::factory()->create(); $this->assertCount(1, $table->process($table->PRO_UID)->get()); } @@ -64,7 +64,7 @@ class AdditionalTablesTest extends TestCase */ public function it_get_tables_related_to_process() { - $table = factory(AdditionalTables::class)->create(); + $table = AdditionalTables::factory()->create(); $result = AdditionalTables::getTables($table->PRO_UID); $this->assertNotEmpty($result); } @@ -77,7 +77,7 @@ class AdditionalTablesTest extends TestCase */ public function it_get_structure_from_offline_tables() { - factory(Fields::class)->states('foreign_keys')->create(); + Fields::factory()->foreign_keys()->create(); $results = AdditionalTables::getTablesOfflineStructure(); $this->assertNotEmpty($results); foreach ($results as $row) { @@ -97,7 +97,7 @@ class AdditionalTablesTest extends TestCase */ public function it_get_data_from_offline_tables() { - factory(Fields::class)->states('foreign_keys')->create(); + Fields::factory()->foreign_keys()->create(); $results = AdditionalTables::getTablesOfflineData(); $this->assertNotEmpty($results); foreach ($results as $row) { @@ -117,7 +117,7 @@ class AdditionalTablesTest extends TestCase */ public function it_update_property_offline() { - $pmTable = factory(AdditionalTables::class)->create(['ADD_TAB_OFFLINE' => 0]); + $pmTable = AdditionalTables::factory()->create(['ADD_TAB_OFFLINE' => 0]); $results = AdditionalTables::updatePropertyOffline([$pmTable->ADD_TAB_UID], 1); // Check the update $pmTableQuery = AdditionalTables::query()->select(['ADD_TAB_OFFLINE']); diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/AppAssignSelfServiceValueGroupTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/AppAssignSelfServiceValueGroupTest.php index 93fbd3aab..cb22e3c55 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Model/AppAssignSelfServiceValueGroupTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Model/AppAssignSelfServiceValueGroupTest.php @@ -24,9 +24,9 @@ class AppAssignSelfServiceValueGroupTest extends TestCase */ public function it_has_a_id_defined() { - $table = factory(AppAssignSelfServiceValueGroup::class)->create([ + $table = AppAssignSelfServiceValueGroup::factory()->create([ 'ID' => function () { - return factory(AppAssignSelfServiceValue::class)->create()->ID; + return AppAssignSelfServiceValue::factory()->create()->ID; } ]); $this->assertInstanceOf(AppAssignSelfServiceValue::class, $table->appSelfService); diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/AppAssignSelfServiceValueTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/AppAssignSelfServiceValueTest.php index 9211574e0..fe829d114 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Model/AppAssignSelfServiceValueTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Model/AppAssignSelfServiceValueTest.php @@ -30,9 +30,9 @@ class AppAssignSelfServiceValueTest extends TestCase */ public function it_belong_app_number() { - $table = factory(AppAssignSelfServiceValue::class)->create([ + $table = AppAssignSelfServiceValue::factory()->create([ 'APP_NUMBER' => function () { - return factory(Delegation::class)->create()->APP_NUMBER; + return Delegation::factory()->create()->APP_NUMBER; } ]); $this->assertInstanceOf(Delegation::class, $table->appNumber); @@ -46,9 +46,9 @@ class AppAssignSelfServiceValueTest extends TestCase */ public function it_belong_index() { - $table = factory(AppAssignSelfServiceValue::class)->create([ + $table = AppAssignSelfServiceValue::factory()->create([ 'DEL_INDEX' => function () { - return factory(Delegation::class)->create()->DEL_INDEX; + return Delegation::factory()->create()->DEL_INDEX; } ]); $this->assertInstanceOf(Delegation::class, $table->index); @@ -62,9 +62,9 @@ class AppAssignSelfServiceValueTest extends TestCase */ public function it_belong_task() { - $table = factory(AppAssignSelfServiceValue::class)->create([ + $table = AppAssignSelfServiceValue::factory()->create([ 'TAS_ID' => function () { - return factory(Task::class)->create()->TAS_ID; + return Task::factory()->create()->TAS_ID; } ]); $this->assertInstanceOf(Task::class, $table->task); @@ -79,22 +79,22 @@ class AppAssignSelfServiceValueTest extends TestCase public function it_should_self_service_by_value() { // Assign user in a group - $rbacUser = factory(RbacUsers::class)->create(); - $user = factory(User::class)->create([ + $rbacUser = RbacUsers::factory()->create(); + $user = User::factory()->create([ 'USR_UID' => $rbacUser['USR_UID'] ]); - $group = factory(Groupwf::class)->create(); - $table = factory(GroupUser::class)->create([ + $group = Groupwf::factory()->create(); + $table = GroupUser::factory()->create([ 'GRP_UID' => $group['GRP_UID'], 'GRP_ID' => $group['GRP_ID'], 'USR_UID' => $user['USR_UID'], 'USR_ID' => $user['USR_ID'], ]); // Create the selfservice - $self = factory(AppAssignSelfServiceValue::class)->create([ + $self = AppAssignSelfServiceValue::factory()->create([ 'GRP_UID' => $group['GRP_UID'], ]); - $table = factory(AppAssignSelfServiceValueGroup::class)->create([ + $table = AppAssignSelfServiceValueGroup::factory()->create([ 'ID' => $self['ID'], 'GRP_UID' => $group['GRP_UID'], 'ASSIGNEE_ID' => $group['GRP_ID'], diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/AppDelayTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/AppDelayTest.php index b703b5bc3..71ac1209d 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Model/AppDelayTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Model/AppDelayTest.php @@ -2,7 +2,6 @@ namespace Tests\unit\workflow\engine\src\ProcessMaker\Model; -use Illuminate\Foundation\Testing\DatabaseTransactions; use ProcessMaker\Model\AppDelay; use Tests\TestCase; @@ -13,15 +12,13 @@ use Tests\TestCase; */ class AppDelayTest extends TestCase { - use DatabaseTransactions; - /** * Set up function. */ - public function setUp() + public function setUp(): void { parent::setUp(); - AppDelay::truncate(); + $this->truncateNonInitialModels(); } /** @@ -32,7 +29,7 @@ class AppDelayTest extends TestCase */ public function it_return_scope_type() { - $table = factory(AppDelay::class)->states('paused_foreign_keys')->create(); + $table = AppDelay::factory()->paused_foreign_keys()->create(); $this->assertCount(1, $table->type('PAUSE')->get()); } @@ -44,7 +41,7 @@ class AppDelayTest extends TestCase */ public function it_return_scope_not_action_disable() { - $table = factory(AppDelay::class)->states('paused_foreign_keys')->create(); + $table = AppDelay::factory()->paused_foreign_keys()->create(); $this->assertCount(1, $table->notDisabled()->get()); } @@ -56,7 +53,7 @@ class AppDelayTest extends TestCase */ public function it_return_scope_case() { - $table = factory(AppDelay::class)->states('paused_foreign_keys')->create(); + $table = AppDelay::factory()->paused_foreign_keys()->create(); $this->assertCount(1, $table->case($table->APP_NUMBER)->get()); } @@ -68,7 +65,7 @@ class AppDelayTest extends TestCase */ public function it_return_scope_index() { - $table = factory(AppDelay::class)->states('paused_foreign_keys')->create(); + $table = AppDelay::factory()->paused_foreign_keys()->create(); $this->assertCount(1, $table->index($table->APP_DEL_INDEX)->get()); } @@ -80,7 +77,7 @@ class AppDelayTest extends TestCase */ public function it_return_scope_delegate_user() { - $table = factory(AppDelay::class)->states('paused_foreign_keys')->create(); + $table = AppDelay::factory()->paused_foreign_keys()->create(); $this->assertCount(1, $table->delegateUser($table->APP_DELEGATION_USER)->get()); } @@ -95,7 +92,7 @@ class AppDelayTest extends TestCase */ public function it_return_paused_threads() { - $table = factory(AppDelay::class)->states('paused_foreign_keys')->create(); + $table = AppDelay::factory()->paused_foreign_keys()->create(); $result = AppDelay::getPaused($table->APP_NUMBER, $table->APP_DEL_INDEX, $table->APP_DELEGATION_USER); $this->assertNotEmpty($result); } diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/AppNotesTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/AppNotesTest.php index 9c0f1fd0b..c75007aa1 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Model/AppNotesTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Model/AppNotesTest.php @@ -25,8 +25,8 @@ class AppNotesTest extends TestCase */ public function createCaseNotes($rows = 10) { - $application = factory(Application::class)->create(); - $notes = factory(AppNotes::class, $rows)->states('foreign_keys')->create([ + $application = Application::factory()->create(); + $notes = AppNotes::factory($rows)->foreign_keys()->create([ 'APP_UID' => $application->APP_UID, 'APP_NUMBER' => $application->APP_NUMBER ]); diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/AppThreadTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/AppThreadTest.php index b683fb3c3..94f642646 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Model/AppThreadTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Model/AppThreadTest.php @@ -18,7 +18,7 @@ class AppThreadTest extends TestCase /** * Set up function. */ - public function setUp() + public function setUp(): void { parent::setUp(); } @@ -31,7 +31,7 @@ class AppThreadTest extends TestCase */ public function it_return_scope_app_uid() { - $table = factory(AppThread::class)->create(); + $table = AppThread::factory()->create(); $this->assertCount(1, $table->appUid($table->APP_UID)->get()); } @@ -43,7 +43,7 @@ class AppThreadTest extends TestCase */ public function it_return_scope_index() { - $table = factory(AppThread::class)->create(); + $table = AppThread::factory()->create(); $this->assertCount(1, $table->index($table->DEL_INDEX)->get()); } @@ -57,7 +57,7 @@ class AppThreadTest extends TestCase */ public function it_return_thread() { - $table = factory(AppThread::class)->create(); + $table = AppThread::factory()->create(); $result = AppThread::getThread($table->APP_UID, $table->DEL_INDEX); $this->assertNotEmpty($result); } diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/AppTimeoutActionTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/AppTimeoutActionTest.php index a5c7057f8..d67ebe3a0 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Model/AppTimeoutActionTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Model/AppTimeoutActionTest.php @@ -24,8 +24,8 @@ class AppTimeoutActionTest extends TestCase */ public function it_set_get_case_uid() { - factory(AppTimeoutAction::class)->create(); - $timeout = factory(AppTimeoutAction::class)->create(); + AppTimeoutAction::factory()->create(); + $timeout = AppTimeoutAction::factory()->create(); $timeout->setCaseUid($timeout->APP_UID); $this->assertEquals($timeout->getCaseUid(), $timeout->APP_UID); } @@ -39,8 +39,8 @@ class AppTimeoutActionTest extends TestCase */ public function it_set_get_index() { - factory(AppTimeoutAction::class)->create(); - $timeout = factory(AppTimeoutAction::class)->create(); + AppTimeoutAction::factory()->create(); + $timeout = AppTimeoutAction::factory()->create(); $timeout->setIndex($timeout->DEL_INDEX); $this->assertEquals($timeout->getIndex(), $timeout->DEL_INDEX); } @@ -53,8 +53,8 @@ class AppTimeoutActionTest extends TestCase */ public function it_filter_a_specific_case() { - factory(AppTimeoutAction::class)->create(); - $timeout = factory(AppTimeoutAction::class)->create(); + AppTimeoutAction::factory()->create(); + $timeout = AppTimeoutAction::factory()->create(); $this->assertCount(1, $timeout->case($timeout->APP_UID)->get()); } @@ -66,8 +66,8 @@ class AppTimeoutActionTest extends TestCase */ public function it_filter_a_specific_index() { - factory(AppTimeoutAction::class)->create(); - $timeout = factory(AppTimeoutAction::class)->create(); + AppTimeoutAction::factory()->create(); + $timeout = AppTimeoutAction::factory()->create(); $this->assertCount(1, $timeout->case($timeout->APP_UID)->index($timeout->DEL_INDEX)->get()); } @@ -79,7 +79,7 @@ class AppTimeoutActionTest extends TestCase */ public function it_return_the_case_executed_once_one_thread() { - $records = factory(AppTimeoutAction::class, 5)->create(); + $records = AppTimeoutAction::factory(5)->create(); foreach ($records as $row) { $appUid = $row->APP_UID; $delIndex = $row->DEL_INDEX; @@ -100,13 +100,13 @@ class AppTimeoutActionTest extends TestCase */ public function it_return_the_case_executed_once_more_than_one_thread() { - $records = factory(AppTimeoutAction::class, 5)->create(); + $records = AppTimeoutAction::factory(5)->create(); foreach ($records as $row) { $appUid = $row->APP_UID; $delIndex = $row->DEL_INDEX; } // Create other thread in the same case - factory(AppTimeoutAction::class)->create([ + AppTimeoutAction::factory()->create([ 'APP_UID' => $appUid, 'DEL_INDEX' => $delIndex + 1, ]); diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/ApplicationTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/ApplicationTest.php index 2b9e5b92c..af820fc3a 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Model/ApplicationTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Model/ApplicationTest.php @@ -3,7 +3,6 @@ namespace Tests\unit\workflow\engine\src\ProcessMaker\Model; use G; -use Illuminate\Foundation\Testing\DatabaseTransactions; use ProcessMaker\Model\Application; use ProcessMaker\Model\Delegation; use ProcessMaker\Model\Process; @@ -17,15 +16,13 @@ use Tests\TestCase; */ class ApplicationTest extends TestCase { - use DatabaseTransactions; - /** * Set up function. */ - public function setUp() + public function setUp(): void { parent::setUp(); - Application::truncate(); + $this->truncateNonInitialModels(); } /** @@ -36,9 +33,9 @@ class ApplicationTest extends TestCase */ public function it_has_a_current_user() { - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'APP_CUR_USER' => function () { - return factory(User::class)->create()->USR_UID; + return User::factory()->create()->USR_UID; } ]); $this->assertInstanceOf(User::class, $application->currentUser); @@ -52,9 +49,9 @@ class ApplicationTest extends TestCase */ public function it_has_a_creator_user() { - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'APP_INIT_USER' => function () { - return factory(User::class)->create()->USR_UID; + return User::factory()->create()->USR_UID; } ]); $this->assertInstanceOf(User::class, $application->creatorUser); @@ -68,9 +65,9 @@ class ApplicationTest extends TestCase */ public function it_has_a_init_user() { - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'APP_INIT_USER' => function () { - return factory(User::class)->create()->USR_UID; + return User::factory()->create()->USR_UID; } ]); $this->assertInstanceOf(User::class, $application->creatoruser); @@ -85,9 +82,9 @@ class ApplicationTest extends TestCase */ public function it_return_scope_user_id() { - $table = factory(Application::class)->states('foreign_keys')->create(); + $table = Application::factory()->foreign_keys()->create(); $usrId = User::getId($table->APP_INIT_USER); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'APP_UID' => $table->APP_UID, 'APP_NUMBER' => $table->APP_NUMBER, 'USR_ID' => $usrId, @@ -103,7 +100,7 @@ class ApplicationTest extends TestCase */ public function it_return_scope_creator() { - $table = factory(Application::class)->states('foreign_keys')->create(); + $table = Application::factory()->foreign_keys()->create(); $this->assertCount(1, $table->creator($table->APP_INIT_USER_ID)->get()); } @@ -115,7 +112,7 @@ class ApplicationTest extends TestCase */ public function it_return_scope_case_uids() { - $table = factory(Application::class)->states('foreign_keys')->create(); + $table = Application::factory()->foreign_keys()->create(); $this->assertCount(1, $table->specificCasesByUid([$table->APP_UID])->get()); } @@ -127,7 +124,7 @@ class ApplicationTest extends TestCase */ public function it_return_scope_case() { - $table = factory(Application::class)->states('foreign_keys')->create(); + $table = Application::factory()->foreign_keys()->create(); $this->assertCount(1, $table->case($table->APP_NUMBER)->get()); } @@ -139,7 +136,7 @@ class ApplicationTest extends TestCase */ public function it_return_scope_positive_cases() { - $table = factory(Application::class)->states('foreign_keys')->create(); + $table = Application::factory()->foreign_keys()->create(); $this->assertCount(1, $table->positiveCases()->get()); } @@ -151,7 +148,7 @@ class ApplicationTest extends TestCase */ public function it_return_scope_specific_case_numbers() { - $table = factory(Application::class)->states('foreign_keys')->create(); + $table = Application::factory()->foreign_keys()->create(); $this->assertCount(1, $table->specificCases([$table->APP_NUMBER])->get()); } @@ -163,7 +160,7 @@ class ApplicationTest extends TestCase */ public function it_return_scope_range_of_cases() { - $table = factory(Application::class)->states('foreign_keys')->create(); + $table = Application::factory()->foreign_keys()->create(); $this->assertCount(1, $table->rangeOfCases([$table->APP_NUMBER.'-'.$table->APP_NUMBER])->get()); } @@ -175,7 +172,7 @@ class ApplicationTest extends TestCase */ public function it_return_scope_cases_or_range_of_cases() { - $table = factory(Application::class)->states('foreign_keys')->create(); + $table = Application::factory()->foreign_keys()->create(); $cases = [$table->APP_NUMBER]; $rangeCases = [$table->APP_NUMBER.'-'.$table->APP_NUMBER]; $this->assertCount(1, $table->casesOrRangeOfCases($cases, $rangeCases)->get()); @@ -189,7 +186,7 @@ class ApplicationTest extends TestCase */ public function it_return_scope_case_from() { - $table = factory(Application::class)->states('foreign_keys')->create(); + $table = Application::factory()->foreign_keys()->create(); $this->assertCount(1, $table->casesFrom($table->APP_NUMBER)->get()); } @@ -201,7 +198,7 @@ class ApplicationTest extends TestCase */ public function it_return_scope_case_to() { - $table = factory(Application::class)->states('foreign_keys')->create(); + $table = Application::factory()->foreign_keys()->create(); $this->assertCount(1, $table->casesTo($table->APP_NUMBER)->get()); } @@ -213,7 +210,7 @@ class ApplicationTest extends TestCase */ public function it_return_cases_by_status_id() { - $table = factory(Application::class)->create(); + $table = Application::factory()->create(); $this->assertCount(1, $table->statusId($table->APP_STATUS_ID)->get()); } @@ -225,7 +222,7 @@ class ApplicationTest extends TestCase */ public function it_return_cases_by_status_ids() { - $table = factory(Application::class)->create(); + $table = Application::factory()->create(); $this->assertCount(1, $table->statusIds([$table->APP_STATUS_ID])->get()); } @@ -237,7 +234,7 @@ class ApplicationTest extends TestCase */ public function it_return_start_date_from() { - $table = factory(Application::class)->create(); + $table = Application::factory()->create(); $this->assertCount(1, $table->startDateFrom($table->APP_CREATE_DATE->format("Y-m-d H:i:s"))->get()); } @@ -249,7 +246,7 @@ class ApplicationTest extends TestCase */ public function it_return_start_date_to() { - $table = factory(Application::class)->create(); + $table = Application::factory()->create(); $this->assertCount(1, $table->startDateTo($table->APP_CREATE_DATE->format("Y-m-d H:i:s"))->get()); } @@ -261,7 +258,7 @@ class ApplicationTest extends TestCase */ public function it_return_finish_date_from() { - $table = factory(Application::class)->create(); + $table = Application::factory()->create(); $this->assertCount(1, $table->finishCaseFrom($table->APP_FINISH_DATE->format("Y-m-d H:i:s"))->get()); } @@ -273,7 +270,7 @@ class ApplicationTest extends TestCase */ public function it_return_finish_date_to() { - $table = factory(Application::class)->create(); + $table = Application::factory()->create(); $this->assertCount(1, $table->finishCaseTo($table->APP_FINISH_DATE->format("Y-m-d H:i:s"))->get()); } @@ -286,8 +283,8 @@ class ApplicationTest extends TestCase */ public function it_return_scope_task() { - $table = factory(Application::class)->create(); - $tableJoin = factory(Delegation::class)->states('foreign_keys')->create([ + $table = Application::factory()->create(); + $tableJoin = Delegation::factory()->foreign_keys()->create([ 'APP_UID' => $table->APP_UID, 'APP_NUMBER' => $table->APP_NUMBER, ]); @@ -303,7 +300,7 @@ class ApplicationTest extends TestCase */ public function it_return_scope_join_process() { - $table = factory(Application::class)->create(); + $table = Application::factory()->create(); $this->assertCount(1, $table->joinProcess()->get()); } @@ -316,8 +313,8 @@ class ApplicationTest extends TestCase */ public function it_return_cases_by_process() { - $process = factory(Process::class)->create(); - factory(Application::class, 5)->create(['PRO_UID' => $process->PRO_UID]); + $process = Process::factory()->create(); + Application::factory(5)->create(['PRO_UID' => $process->PRO_UID]); $cases = Application::getByProUid($process->PRO_UID); foreach ($cases as $case) { $this->assertEquals($case->PRO_UID, $process->PRO_UID); @@ -333,7 +330,7 @@ class ApplicationTest extends TestCase */ public function it_return_case_information() { - $application = factory(Application::class)->create(); + $application = Application::factory()->create(); $result = Application::getCase($application->APP_UID); $this->assertArrayHasKey('APP_STATUS', $result); $this->assertArrayHasKey('APP_INIT_USER', $result); @@ -347,7 +344,7 @@ class ApplicationTest extends TestCase */ public function it_get_case_number() { - $application = factory(Application::class)->create(); + $application = Application::factory()->create(); $result = Application::getCaseNumber($application->APP_UID); // When the application exist $this->assertEquals($result, $application->APP_NUMBER); @@ -366,22 +363,22 @@ class ApplicationTest extends TestCase public function it_update_columns() { // No column will be updated - $application = factory(Application::class)->create(); + $application = Application::factory()->create(); $result = Application::updateColumns($application->APP_UID, []); $this->isEmpty($result); // Tried to update APP_ROUTING_DATA - $application = factory(Application::class)->create(); + $application = Application::factory()->create(); $result = Application::updateColumns($application->APP_UID, ['APP_ROUTING_DATA' => '']); $this->assertArrayHasKey('APP_ROUTING_DATA', $result); // We can not update with a empty user - $application = factory(Application::class)->create(); + $application = Application::factory()->create(); $result = Application::updateColumns($application->APP_UID, ['APP_CUR_USER' => '']); $this->assertArrayNotHasKey('APP_CUR_USER', $result); // Tried to update APP_CUR_USER - $application = factory(Application::class)->create(); + $application = Application::factory()->create(); $result = Application::updateColumns($application->APP_UID, ['APP_CUR_USER' => '00000000000000000000000000000001']); $this->assertArrayHasKey('APP_CUR_USER', $result); } @@ -397,8 +394,8 @@ class ApplicationTest extends TestCase */ public function it_count_cases_by_process() { - $process = factory(Process::class)->create(); - factory(Application::class, 5)->create(['PRO_UID' => $process->PRO_UID]); + $process = Process::factory()->create(); + Application::factory(5)->create(['PRO_UID' => $process->PRO_UID]); $result = Application::getCountByProUid($process->PRO_UID); $this->assertEquals($result, 5); } diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/BpmnProjectTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/BpmnProjectTest.php index 976098fed..2d861bcaa 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Model/BpmnProjectTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Model/BpmnProjectTest.php @@ -23,7 +23,7 @@ class BpmnProjectTest extends TestCase */ public function it_is_bpmn_process() { - $table = factory(BpmnProject::class)->create(); + $table = BpmnProject::factory()->create(); $result = BpmnProject::isBpmnProcess($table->PRJ_UID); $this->assertEquals($result, 1); } diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/CaseListTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/CaseListTest.php index 8c2b56ec5..0bf6d2024 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Model/CaseListTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Model/CaseListTest.php @@ -16,15 +16,16 @@ class CaseListTest extends TestCase /** * setUp method. */ - public function setUp() + public function setUp(): void { parent::setUp(); + $this->truncateNonInitialModels(); } /** * teardown method. */ - public function tearDown() + public function tearDown(): void { parent::tearDown(); } @@ -262,8 +263,6 @@ class CaseListTest extends TestCase */ public function it_should_test_getSetting() { - CaseList::truncate(); - $data = [ 'type' => 'inbox', 'name' => 'test1', @@ -322,7 +321,7 @@ class CaseListTest extends TestCase */ public function it_should_test_import() { - $additionalTables = factory(AdditionalTables::class)->create(); + $additionalTables = AdditionalTables::factory()->create(); $data = [ 'type' => 'inbox', 'name' => 'test1', @@ -370,7 +369,6 @@ class CaseListTest extends TestCase */ public function it_should_test_export() { - CaseList::truncate(); $data = [ 'type' => 'inbox', 'name' => 'test export', @@ -406,25 +404,25 @@ class CaseListTest extends TestCase */ public function it_should_test_formattingColumns() { - $additionalTables = factory(\ProcessMaker\Model\AdditionalTables::class)->create(); + $additionalTables = \ProcessMaker\Model\AdditionalTables::factory()->create(); - $fields = factory(\ProcessMaker\Model\Fields::class, 5)->create([ + $fields = \ProcessMaker\Model\Fields::factory(5)->create([ 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID ]); - factory(CaseList::class)->create([ + CaseList::factory()->create([ 'CAL_TYPE' => 'inbox', 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID ]); - factory(CaseList::class)->create([ + CaseList::factory()->create([ 'CAL_TYPE' => 'draft', 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID ]); - factory(CaseList::class)->create([ + CaseList::factory()->create([ 'CAL_TYPE' => 'paused', 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID ]); - factory(CaseList::class)->create([ + CaseList::factory()->create([ 'CAL_TYPE' => 'unassigned', 'ADD_TAB_UID' => $additionalTables->ADD_TAB_UID ]); @@ -490,8 +488,7 @@ class CaseListTest extends TestCase */ public function it_should_test_getReportTables() { - AdditionalTables::truncate(); - $additionalTables = factory(AdditionalTables::class, 10)->create(); + $additionalTables = AdditionalTables::factory(10)->create(); $search = ''; $result = CaseList::getReportTables($search); diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/ConsolidatedTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/ConsolidatedTest.php index 5642e6741..2ff7cbf3d 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Model/ConsolidatedTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Model/ConsolidatedTest.php @@ -20,7 +20,7 @@ class ConsolidatedTest extends TestCase /** * Method set up. */ - public function setUp() + public function setUp(): void { parent::setUp(); } @@ -33,9 +33,9 @@ class ConsolidatedTest extends TestCase */ public function it_has_a_task() { - $table = factory(Consolidated::class)->create([ + $table = Consolidated::factory()->create([ 'TAS_UID' => function () { - return factory(Task::class)->create()->TAS_UID; + return Task::factory()->create()->TAS_UID; } ]); $this->assertInstanceOf(Task::class, $table->task); @@ -48,8 +48,8 @@ class ConsolidatedTest extends TestCase */ public function createConsolidated() { - $consolidated = factory(Consolidated::class)->states('foreign_keys')->create(); - $delegation = factory(Delegation::class)->states('foreign_keys')->create([ + $consolidated = Consolidated::factory()->foreign_keys()->create(); + $delegation = Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'TAS_UID' => $consolidated->TAS_UID, ]); @@ -102,7 +102,7 @@ class ConsolidatedTest extends TestCase */ public function it_should_test_scope_join_process() { - $query = factory(Consolidated::class)->states('foreign_keys')->create(); + $query = Consolidated::factory()->foreign_keys()->create(); $consolidated = new Consolidated(); $this->assertCount(1, $consolidated->scopeJoinProcess($query)->get()); } @@ -115,7 +115,7 @@ class ConsolidatedTest extends TestCase */ public function it_should_test_scope_join_task() { - $query = factory(Consolidated::class)->states('foreign_keys')->create(); + $query = Consolidated::factory()->foreign_keys()->create(); $consolidated = new Consolidated(); $this->assertCount(1, $consolidated->scopeJoinTask($query)->get()); } diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/DelegationTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/DelegationTest.php index f6d6e2c5e..c6a6f04e2 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Model/DelegationTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Model/DelegationTest.php @@ -5,7 +5,6 @@ namespace Tests\unit\workflow\src\ProcessMaker\Model; use DateInterval; use Datetime; use G; -use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Facades\DB; use ProcessMaker\Model\AppAssignSelfServiceValue; use ProcessMaker\Model\AppAssignSelfServiceValueGroup; @@ -30,17 +29,22 @@ use Tests\TestCase; */ class DelegationTest extends TestCase { - use DatabaseTransactions; - /** * Set up function. */ - public function setUp() + public function setUp(): void { parent::setUp(); - Delegation::truncate(); - AppThread::truncate(); - Application::truncate(); + $this->truncateNonInitialModels(); + } + + /** + * Tear down function. + * @return void + */ + public function tearDown(): void + { + parent::tearDown(); } /** @@ -51,9 +55,9 @@ class DelegationTest extends TestCase */ public function it_has_an_application() { - $delegation = factory(Delegation::class)->create([ + $delegation = Delegation::factory()->create([ 'APP_UID' => function () { - return factory(Application::class)->create()->APP_UID; + return Application::factory()->create()->APP_UID; } ]); $this->assertInstanceOf(Application::class, $delegation->application); @@ -67,9 +71,9 @@ class DelegationTest extends TestCase */ public function it_has_an_user() { - $delegation = factory(Delegation::class)->create([ + $delegation = Delegation::factory()->create([ 'USR_ID' => function () { - return factory(User::class)->create()->USR_ID; + return User::factory()->create()->USR_ID; } ]); $this->assertInstanceOf(User::class, $delegation->user); @@ -83,9 +87,9 @@ class DelegationTest extends TestCase */ public function it_has_a_task() { - $delegation = factory(Delegation::class)->create([ + $delegation = Delegation::factory()->create([ 'TAS_ID' => function () { - return factory(Task::class)->create()->TAS_ID; + return Task::factory()->create()->TAS_ID; } ]); $this->assertInstanceOf(Task::class, $delegation->task); @@ -99,9 +103,9 @@ class DelegationTest extends TestCase */ public function it_has_a_process() { - $delegation = factory(Delegation::class)->create([ + $delegation = Delegation::factory()->create([ 'PRO_ID' => function () { - return factory(Process::class)->create()->PRO_ID; + return Process::factory()->create()->PRO_ID; } ]); $this->assertInstanceOf(Process::class, $delegation->process); @@ -115,7 +119,7 @@ class DelegationTest extends TestCase */ public function it_return_scope_priority() { - $table = factory(Delegation::class)->states('foreign_keys')->create(); + $table = Delegation::factory()->foreign_keys()->create(); $this->assertCount(1, $table->priority($table->DEL_PRIORITY)->get()); } @@ -127,7 +131,7 @@ class DelegationTest extends TestCase */ public function it_return_scope_priorities() { - $table = factory(Delegation::class)->states('foreign_keys')->create(); + $table = Delegation::factory()->foreign_keys()->create(); $this->assertCount(1, $table->priorities([$table->DEL_PRIORITY])->get()); } @@ -139,7 +143,7 @@ class DelegationTest extends TestCase */ public function it_return_scope_thread_open() { - $table = factory(Delegation::class)->states('foreign_keys')->create(); + $table = Delegation::factory()->foreign_keys()->create(); $this->assertCount(1, $table->threadOpen()->get()); } @@ -163,7 +167,7 @@ class DelegationTest extends TestCase */ public function it_return_scope_thread_pause() { - $table = factory(Delegation::class)->states('foreign_keys')->create(); + $table = Delegation::factory()->foreign_keys()->create(); $this->assertCount(0, $table->threadPause()->get()); } /** @@ -174,7 +178,7 @@ class DelegationTest extends TestCase */ public function it_return_scope_thread_open_and_pause() { - $table = factory(Delegation::class)->states('foreign_keys')->create(); + $table = Delegation::factory()->foreign_keys()->create(); $this->assertCount(1, $table->openAndPause()->get()); } @@ -186,7 +190,7 @@ class DelegationTest extends TestCase */ public function it_return_scope_case_started() { - $table = factory(Delegation::class)->states('first_thread')->create(); + $table = Delegation::factory()->first_thread()->create(); $this->assertCount(1, $table->caseStarted($table->DEL_INDEX)->get()); } @@ -198,7 +202,7 @@ class DelegationTest extends TestCase */ public function it_return_scope_case_in_progress() { - $table = factory(Delegation::class)->states('foreign_keys')->create(); + $table = Delegation::factory()->foreign_keys()->create(); $this->assertCount(1, $table->joinApplication()->casesInProgress([2])->get()); } @@ -210,7 +214,7 @@ class DelegationTest extends TestCase */ public function it_return_scope_case_done() { - $table = factory(Delegation::class)->states('foreign_keys')->create(); + $table = Delegation::factory()->foreign_keys()->create(); $this->assertCount(1, $table->joinApplication()->casesDone([2])->get()); } @@ -222,7 +226,7 @@ class DelegationTest extends TestCase */ public function it_return_scope_index() { - $table = factory(Delegation::class)->states('foreign_keys')->create(); + $table = Delegation::factory()->foreign_keys()->create(); $this->assertCount(1, $table->index($table->DEL_INDEX)->get()); } @@ -234,8 +238,8 @@ class DelegationTest extends TestCase */ public function it_return_scope_case_to_do() { - $application = factory(Application::class)->states('todo')->create(); - $table = factory(Delegation::class)->states('foreign_keys')->create([ + $application = Application::factory()->todo()->create(); + $table = Delegation::factory()->foreign_keys()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'APP_UID' => $application->APP_UID, ]); @@ -250,8 +254,8 @@ class DelegationTest extends TestCase */ public function it_return_scope_case_completed() { - $application = factory(Application::class)->states('completed')->create(); - $table = factory(Delegation::class)->states('foreign_keys')->create([ + $application = Application::factory()->completed()->create(); + $table = Delegation::factory()->foreign_keys()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'APP_UID' => $application->APP_UID, ]); @@ -266,8 +270,8 @@ class DelegationTest extends TestCase */ public function it_return_scope_case_canceled() { - $application = factory(Application::class)->states('canceled')->create(); - $table = factory(Delegation::class)->states('foreign_keys')->create([ + $application = Application::factory()->canceled()->create(); + $table = Delegation::factory()->foreign_keys()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'APP_UID' => $application->APP_UID, ]); @@ -282,8 +286,8 @@ class DelegationTest extends TestCase */ public function it_return_scope_status() { - $application = factory(Application::class)->states('todo')->create(); - $table = factory(Delegation::class)->states('foreign_keys')->create([ + $application = Application::factory()->todo()->create(); + $table = Delegation::factory()->foreign_keys()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'APP_UID' => $application->APP_UID, ]); @@ -298,8 +302,8 @@ class DelegationTest extends TestCase */ public function it_return_scope_status_ids() { - $application = factory(Application::class)->states('todo')->create(); - $table = factory(Delegation::class)->states('foreign_keys')->create([ + $application = Application::factory()->todo()->create(); + $table = Delegation::factory()->foreign_keys()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'APP_UID' => $application->APP_UID, ]); @@ -314,8 +318,8 @@ class DelegationTest extends TestCase */ public function it_return_scope_start_date_from() { - $application = factory(Application::class)->states('todo')->create(); - $table = factory(Delegation::class)->states('foreign_keys')->create([ + $application = Application::factory()->todo()->create(); + $table = Delegation::factory()->foreign_keys()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'APP_UID' => $application->APP_UID, ]); @@ -330,8 +334,8 @@ class DelegationTest extends TestCase */ public function it_return_scope_start_date_to() { - $application = factory(Application::class)->states('todo')->create(); - $table = factory(Delegation::class)->states('foreign_keys')->create([ + $application = Application::factory()->todo()->create(); + $table = Delegation::factory()->foreign_keys()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'APP_UID' => $application->APP_UID, ]); @@ -346,8 +350,8 @@ class DelegationTest extends TestCase */ public function it_return_scope_finish_case_date_from() { - $application = factory(Application::class)->states('todo')->create(); - $table = factory(Delegation::class)->states('foreign_keys')->create([ + $application = Application::factory()->todo()->create(); + $table = Delegation::factory()->foreign_keys()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'APP_UID' => $application->APP_UID, ]); @@ -362,8 +366,8 @@ class DelegationTest extends TestCase */ public function it_return_scope_finish_case_date_to() { - $application = factory(Application::class)->states('todo')->create(); - $table = factory(Delegation::class)->states('foreign_keys')->create([ + $application = Application::factory()->todo()->create(); + $table = Delegation::factory()->foreign_keys()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'APP_UID' => $application->APP_UID, ]); @@ -378,7 +382,7 @@ class DelegationTest extends TestCase */ public function it_return_scope_delegate_date_from() { - $table = factory(Delegation::class)->states('foreign_keys')->create(); + $table = Delegation::factory()->foreign_keys()->create(); $this->assertCount(1, $table->delegateDateFrom($table->DEL_DELEGATE_DATE->format("Y-m-d H:i:s"))->get()); } @@ -390,7 +394,7 @@ class DelegationTest extends TestCase */ public function it_return_scope_delegate_date_to() { - $table = factory(Delegation::class)->states('foreign_keys')->create(); + $table = Delegation::factory()->foreign_keys()->create(); $this->assertCount(1, $table->delegateDateTo($table->DEL_DELEGATE_DATE->format("Y-m-d H:i:s"))->get()); } @@ -402,7 +406,7 @@ class DelegationTest extends TestCase */ public function it_return_scope_finish_date_from() { - $table = factory(Delegation::class)->states('closed')->create(); + $table = Delegation::factory()->closed()->create(); $this->assertCount(1, $table->finishDateFrom($table->DEL_FINISH_DATE)->get()); } @@ -414,7 +418,7 @@ class DelegationTest extends TestCase */ public function it_return_scope_finish_date_to() { - $table = factory(Delegation::class)->states('closed')->create(); + $table = Delegation::factory()->closed()->create(); $this->assertCount(1, $table->finishDateTo($table->DEL_FINISH_DATE)->get()); } @@ -426,7 +430,7 @@ class DelegationTest extends TestCase */ public function it_return_scope_due_date_from() { - $table = factory(Delegation::class)->states('closed')->create(); + $table = Delegation::factory()->closed()->create(); $this->assertCount(1, $table->dueFrom($table->DEL_TASK_DUE_DATE)->get()); } @@ -438,7 +442,7 @@ class DelegationTest extends TestCase */ public function it_return_scope_due_date_to() { - $table = factory(Delegation::class)->states('closed')->create(); + $table = Delegation::factory()->closed()->create(); $this->assertCount(1, $table->dueTo($table->DEL_TASK_DUE_DATE)->get()); } @@ -450,7 +454,7 @@ class DelegationTest extends TestCase */ public function it_return_scope_on_time() { - $table = factory(Delegation::class)->states('closed')->create(); + $table = Delegation::factory()->closed()->create(); $this->assertCount(1, $table->onTime($table->DEL_DELEGATE_DATE)->get()); } @@ -466,7 +470,7 @@ class DelegationTest extends TestCase $currentDate = $date->format('Y-m-d H:i:s'); $diff2Days = new DateInterval('P2D'); - $table = factory(Delegation::class)->create([ + $table = Delegation::factory()->create([ 'DEL_THREAD_STATUS' => 'CLOSED', 'DEL_DELEGATE_DATE' => $currentDate, 'DEL_RISK_DATE' => $currentDate, @@ -487,7 +491,7 @@ class DelegationTest extends TestCase $currentDate = $date->format('Y-m-d H:i:s'); $diff2Days = new DateInterval('P2D'); - $table = factory(Delegation::class)->create([ + $table = Delegation::factory()->create([ 'DEL_THREAD_STATUS' => 'CLOSED', 'DEL_DELEGATE_DATE' => $currentDate, 'DEL_RISK_DATE' => $currentDate, @@ -504,7 +508,7 @@ class DelegationTest extends TestCase */ public function it_return_scope_case() { - $table = factory(Delegation::class)->states('foreign_keys')->create(); + $table = Delegation::factory()->foreign_keys()->create(); $this->assertCount(1, $table->case($table->APP_NUMBER)->get()); } @@ -516,7 +520,7 @@ class DelegationTest extends TestCase */ public function it_return_scope_specific_cases() { - $table = factory(Delegation::class)->states('foreign_keys')->create(); + $table = Delegation::factory()->foreign_keys()->create(); $this->assertCount(1, $table->specificCases([$table->APP_NUMBER])->get()); } @@ -528,7 +532,7 @@ class DelegationTest extends TestCase */ public function it_return_scope_cases_from() { - $table = factory(Delegation::class)->states('foreign_keys')->create(); + $table = Delegation::factory()->foreign_keys()->create(); $this->assertCount(1, $table->casesFrom($table->APP_NUMBER)->get()); } @@ -540,7 +544,7 @@ class DelegationTest extends TestCase */ public function it_return_scope_cases_to() { - $table = factory(Delegation::class)->states('foreign_keys')->create(); + $table = Delegation::factory()->foreign_keys()->create(); $this->assertCount(1, $table->casesTo($table->APP_NUMBER)->get()); } @@ -552,7 +556,7 @@ class DelegationTest extends TestCase */ public function it_return_scope_positive_cases() { - $table = factory(Delegation::class)->states('foreign_keys')->create(); + $table = Delegation::factory()->foreign_keys()->create(); $this->assertCount(1, $table->positiveCases()->get()); } @@ -564,7 +568,7 @@ class DelegationTest extends TestCase */ public function it_return_scope_cases_and_range_of_cases() { - $table = factory(Delegation::class)->states('foreign_keys')->create(); + $table = Delegation::factory()->foreign_keys()->create(); $cases = [$table->APP_NUMBER]; $rangeCases = [$table->APP_NUMBER . '-' . $table->APP_NUMBER]; $this->assertCount(1, $table->casesOrRangeOfCases($cases, $rangeCases)->get()); @@ -578,7 +582,7 @@ class DelegationTest extends TestCase */ public function it_return_scope_range_of_cases() { - $table = factory(Delegation::class)->states('foreign_keys')->create(); + $table = Delegation::factory()->foreign_keys()->create(); $this->assertCount(1, $table->rangeOfCases([$table->APP_NUMBER . '-' . $table->APP_NUMBER])->get()); } @@ -590,7 +594,7 @@ class DelegationTest extends TestCase */ public function it_return_scope_app_uid() { - $table = factory(Delegation::class)->states('foreign_keys')->create(); + $table = Delegation::factory()->foreign_keys()->create(); $this->assertCount(1, $table->appUid($table->APP_UID)->get()); } @@ -602,7 +606,7 @@ class DelegationTest extends TestCase */ public function it_return_scope_last_thread() { - $table = factory(Delegation::class)->states('foreign_keys')->create(); + $table = Delegation::factory()->foreign_keys()->create(); $this->assertCount(1, $table->lastThread()->get()); } @@ -614,7 +618,7 @@ class DelegationTest extends TestCase */ public function it_return_scope_specific_cases_uid() { - $table = factory(Delegation::class)->states('foreign_keys')->create(); + $table = Delegation::factory()->foreign_keys()->create(); $this->assertCount(1, $table->specificCasesByUid([$table->APP_UID])->get()); } @@ -626,7 +630,7 @@ class DelegationTest extends TestCase */ public function it_return_scope_user_id() { - $table = factory(Delegation::class)->states('foreign_keys')->create(); + $table = Delegation::factory()->foreign_keys()->create(); $this->assertCount(1, $table->userId($table->USR_ID)->get()); } @@ -638,7 +642,7 @@ class DelegationTest extends TestCase */ public function it_return_scope_without_user_id() { - $table = factory(Delegation::class)->states('foreign_keys')->create([ + $table = Delegation::factory()->foreign_keys()->create([ 'USR_ID' => 0 ]); $this->assertCount(1, $table->withoutUserId($table->TAS_ID)->get()); @@ -652,7 +656,7 @@ class DelegationTest extends TestCase */ public function it_return_scope_process_id() { - $table = factory(Delegation::class)->states('foreign_keys')->create(); + $table = Delegation::factory()->foreign_keys()->create(); $this->assertCount(1, $table->processId($table->PRO_ID)->get()); } @@ -664,7 +668,7 @@ class DelegationTest extends TestCase */ public function it_return_scope_task_id() { - $table = factory(Delegation::class)->states('foreign_keys')->create(); + $table = Delegation::factory()->foreign_keys()->create(); $this->assertCount(1, $table->task($table->TAS_ID)->get()); } @@ -676,7 +680,7 @@ class DelegationTest extends TestCase */ public function it_return_scope_task() { - $table = factory(Delegation::class)->states('foreign_keys')->create(); + $table = Delegation::factory()->foreign_keys()->create(); $this->assertCount(1, $table->task($table->TAS_ID)->get()); } @@ -688,7 +692,7 @@ class DelegationTest extends TestCase */ public function it_return_scope_specific_tasks() { - $table = factory(Delegation::class)->states('foreign_keys')->create(); + $table = Delegation::factory()->foreign_keys()->create(); $this->assertCount(1, $table->specificTasks([$table->TAS_ID])->get()); } @@ -700,7 +704,7 @@ class DelegationTest extends TestCase */ public function it_return_scope_assign_type() { - $table = factory(Delegation::class)->states('foreign_keys')->create(); + $table = Delegation::factory()->foreign_keys()->create(); $this->assertCount(1, $table->taskAssignType('NORMAL')->get()); } @@ -712,7 +716,7 @@ class DelegationTest extends TestCase */ public function it_return_scope_exclude_tas_types() { - $table = factory(Delegation::class)->states('foreign_keys')->create(); + $table = Delegation::factory()->foreign_keys()->create(); $this->assertNotEmpty($table->excludeTaskTypes(['ADHOC'])->get()); } @@ -724,7 +728,7 @@ class DelegationTest extends TestCase */ public function it_return_scope_specific_tas_types() { - $table = factory(Delegation::class)->states('foreign_keys')->create(); + $table = Delegation::factory()->foreign_keys()->create(); $this->assertCount(1, $table->specificTaskTypes(['NORMAL'])->get()); } @@ -736,11 +740,11 @@ class DelegationTest extends TestCase */ public function it_return_scope_status_id() { - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'APP_STATUS_ID' => 2, 'APP_STATUS' => 'TO_DO' ]); - $table = factory(Delegation::class)->states('foreign_keys')->create([ + $table = Delegation::factory()->foreign_keys()->create([ 'APP_NUMBER' => $application->APP_NUMBER ]); $this->assertCount(1, $table->appStatusId()->get()); @@ -754,8 +758,8 @@ class DelegationTest extends TestCase */ public function it_return_scope_process_in_list() { - $process = factory(Process::class)->create(); - $table = factory(Delegation::class)->states('foreign_keys')->create([ + $process = Process::factory()->create(); + $table = Delegation::factory()->foreign_keys()->create([ 'PRO_ID' => $process->PRO_ID ]); $this->assertCount(1, $table->joinProcess()->processInList([$table->PRO_ID])->get()); @@ -769,7 +773,7 @@ class DelegationTest extends TestCase */ public function it_return_scope_participated() { - $table = factory(Delegation::class)->states('foreign_keys')->create(); + $table = Delegation::factory()->foreign_keys()->create(); $this->assertCount(1, $table->participated($table->USR_ID)->get()); } @@ -781,8 +785,8 @@ class DelegationTest extends TestCase */ public function it_return_scope_category() { - $process = factory(Process::class)->create(); - $table = factory(Delegation::class)->states('foreign_keys')->create([ + $process = Process::factory()->create(); + $table = Delegation::factory()->foreign_keys()->create([ 'PRO_ID' => $process->PRO_ID ]); $this->assertCount(1, $table->joinProcess()->categoryId($process->CATEGORY_ID)->get()); @@ -796,11 +800,11 @@ class DelegationTest extends TestCase */ public function it_return_scope_join_category_process() { - $category = factory(ProcessCategory::class)->create(); - $process = factory(Process::class)->create([ + $category = ProcessCategory::factory()->create(); + $process = Process::factory()->create([ 'PRO_CATEGORY' => $category->CATEGORY_UID ]); - $table = factory(Delegation::class)->states('foreign_keys')->create([ + $table = Delegation::factory()->foreign_keys()->create([ 'PRO_ID' => $process->PRO_ID ]); $this->assertCount(1, $table->joinCategoryProcess($category->CATEGORY_UID)->get()); @@ -814,8 +818,8 @@ class DelegationTest extends TestCase */ public function it_return_scope_join_previous_index() { - $previous = factory(Delegation::class)->states('foreign_keys')->create(); - $table = factory(Delegation::class)->states('foreign_keys')->create([ + $previous = Delegation::factory()->foreign_keys()->create(); + $table = Delegation::factory()->foreign_keys()->create([ 'APP_NUMBER' => $previous->APP_NUMBER, 'DEL_INDEX' => $previous->DEL_INDEX + 1, 'DEL_PREVIOUS' => $previous->DEL_INDEX @@ -831,8 +835,8 @@ class DelegationTest extends TestCase */ public function it_return_scope_join_process() { - $process = factory(Process::class)->create(); - $table = factory(Delegation::class)->states('foreign_keys')->create([ + $process = Process::factory()->create(); + $table = Delegation::factory()->foreign_keys()->create([ 'PRO_ID' => $process->PRO_ID ]); $this->assertCount(1, $table->joinProcess()->get()); @@ -846,8 +850,8 @@ class DelegationTest extends TestCase */ public function it_return_scope_join_task() { - $task = factory(Task::class)->create(); - $table = factory(Delegation::class)->states('foreign_keys')->create([ + $task = Task::factory()->create(); + $table = Delegation::factory()->foreign_keys()->create([ 'TAS_ID' => $task->TAS_ID ]); $this->assertCount(1, $table->joinTask()->get()); @@ -861,8 +865,8 @@ class DelegationTest extends TestCase */ public function it_return_scope_join_user() { - $user = factory(User::class)->create(); - $table = factory(Delegation::class)->states('foreign_keys')->create([ + $user = User::factory()->create(); + $table = Delegation::factory()->foreign_keys()->create([ 'USR_ID' => $user->USR_ID ]); $this->assertCount(1, $table->joinUser()->get()); @@ -876,8 +880,8 @@ class DelegationTest extends TestCase */ public function it_return_scope_join_application() { - $application = factory(Application::class)->create(); - $table = factory(Delegation::class)->states('foreign_keys')->create([ + $application = Application::factory()->create(); + $table = Delegation::factory()->foreign_keys()->create([ 'APP_NUMBER' => $application->APP_NUMBER ]); $this->assertCount(1, $table->joinApplication()->get()); @@ -892,13 +896,13 @@ class DelegationTest extends TestCase */ public function it_return_scope_join_app_delay_pause() { - $user = factory(User::class)->create(); - $delay = factory(AppDelay::class)->create([ + $user = User::factory()->create(); + $delay = AppDelay::factory()->create([ 'APP_TYPE' => 'PAUSE', 'APP_DISABLE_ACTION_USER' => '0', 'APP_DELEGATION_USER' => $user->USR_UID, ]); - $table = factory(Delegation::class)->states('foreign_keys')->create([ + $table = Delegation::factory()->foreign_keys()->create([ 'USR_ID' => $user->USR_ID, 'USR_UID' => $user->USR_UID, 'APP_NUMBER' => $delay->APP_NUMBER, @@ -915,7 +919,7 @@ class DelegationTest extends TestCase */ public function it_should_return_pages_of_data() { - factory(Delegation::class, 51)->states('foreign_keys')->create(); + Delegation::factory(51)->foreign_keys()->create(); // Get first page, which is 25 $results = Delegation::search(null, 0, 25, null, null, null, null, null, null, null, null, 'APP_NUMBER'); $this->assertCount(25, $results['data']); @@ -935,8 +939,8 @@ class DelegationTest extends TestCase */ public function it_should_return_pages_of_data_unassigned() { - factory(Delegation::class, 50)->states('foreign_keys')->create(); - factory(Delegation::class, 1)->states('foreign_keys')->create([ + Delegation::factory(50)->foreign_keys()->create(); + Delegation::factory(1)->foreign_keys()->create([ 'USR_ID' => 0 // A self service delegation ]); // Get first page, which is 25 @@ -959,8 +963,8 @@ class DelegationTest extends TestCase public function it_should_return_process_of_data() { - $process = factory(Process::class)->create(); - factory(Delegation::class, 51)->states('foreign_keys')->create([ + $process = Process::factory()->create(); + Delegation::factory(51)->foreign_keys()->create([ 'PRO_ID' => $process->PRO_ID ]); // Get first page, which is 25 @@ -983,11 +987,11 @@ class DelegationTest extends TestCase */ public function it_should_return_status_draft_of_data() { - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'APP_STATUS_ID' => 1, 'APP_STATUS' => 'DRAFT' ]); - factory(Delegation::class, 51)->states('foreign_keys')->create([ + Delegation::factory(51)->foreign_keys()->create([ 'APP_NUMBER' => $application->APP_NUMBER ]); // Review the filter by status DRAFT @@ -1011,11 +1015,11 @@ class DelegationTest extends TestCase */ public function it_should_return_status_todo_of_data() { - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'APP_STATUS_ID' => 2, 'APP_STATUS' => 'TO_DO' ]); - factory(Delegation::class, 51)->states('foreign_keys')->create([ + Delegation::factory(51)->foreign_keys()->create([ 'APP_NUMBER' => $application->APP_NUMBER ]); // Review the filter by status TO_DO @@ -1039,11 +1043,11 @@ class DelegationTest extends TestCase */ public function it_should_return_status_completed_of_data() { - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'APP_STATUS_ID' => 3, 'APP_STATUS' => 'COMPLETED', ]); - factory(Delegation::class, 51)->states('foreign_keys')->create([ + Delegation::factory(51)->foreign_keys()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'DEL_LAST_INDEX' => 1 ]); @@ -1068,11 +1072,11 @@ class DelegationTest extends TestCase */ public function it_should_return_status_cancelled_of_data() { - $application = factory(Application::class)->create([ + $application = Application::factory()->create([ 'APP_STATUS_ID' => 4, 'APP_STATUS' => 'CANCELLED' ]); - factory(Delegation::class, 51)->states('foreign_keys')->create([ + Delegation::factory(51)->foreign_keys()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'DEL_LAST_INDEX' => 1 ]); @@ -1097,9 +1101,9 @@ class DelegationTest extends TestCase public function it_should_return_one_result_for_specified_user() { // Create our unique user, with a unique username - $user = factory(User::class)->create(); + $user = User::factory()->create(); // Create a new delegation, but for this specific user - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'USR_UID' => $user->USR_UID, 'USR_ID' => $user->USR_ID ]); @@ -1118,8 +1122,8 @@ class DelegationTest extends TestCase public function it_should_search_and_filter_by_app_number() { for ($x = 1; $x <= 10; $x++) { - $application = factory(Application::class)->create(); - factory(Delegation::class)->states('foreign_keys')->create([ + $application = Application::factory()->create(); + Delegation::factory()->foreign_keys()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'DEL_THREAD_STATUS' => 'OPEN' ]); @@ -1168,9 +1172,9 @@ class DelegationTest extends TestCase */ public function it_should_search_and_filter_by_app_title() { - $delegations = factory(Delegation::class, 1)->states('foreign_keys')->create([ + $delegations = Delegation::factory(1)->foreign_keys()->create([ 'APP_NUMBER' => function () { - return factory(Application::class)->create()->APP_NUMBER; + return Application::factory()->create()->APP_NUMBER; } ]); $title = $delegations->last()->DEL_TITLE; @@ -1221,13 +1225,13 @@ class DelegationTest extends TestCase */ public function it_should_search_and_order_by_task_title() { - factory(Delegation::class, 5)->states('foreign_keys')->create([ + Delegation::factory(5)->foreign_keys()->create([ 'TAS_ID' => function () { - return factory(Task::class)->create()->TAS_ID; + return Task::factory()->create()->TAS_ID; } ]); - $task = factory(Task::class)->create(); - factory(Delegation::class)->states('foreign_keys')->create([ + $task = Task::factory()->create(); + Delegation::factory()->foreign_keys()->create([ 'TAS_ID' => $task->TAS_ID ]); // Get the order taskTitle in ASC mode @@ -1305,7 +1309,7 @@ class DelegationTest extends TestCase */ public function it_should_sort_by_case_id() { - factory(Delegation::class, 2)->states('foreign_keys')->create(); + Delegation::factory(2)->foreign_keys()->create(); // Get first page, the minor case id $results = Delegation::search(null, 0, 2, null, null, null, 'ASC', 'APP_NUMBER'); $this->assertCount(2, $results['data']); @@ -1324,7 +1328,7 @@ class DelegationTest extends TestCase */ public function it_should_sort_by_case_title() { - factory(Delegation::class, 2)->states('foreign_keys')->create(); + Delegation::factory(2)->foreign_keys()->create(); // Get first page, the minor case title $results = Delegation::search(null, 0, 2, null, null, null, 'ASC', 'APP_TITLE'); $this->assertCount(2, $results['data']); @@ -1343,9 +1347,9 @@ class DelegationTest extends TestCase */ public function it_should_sort_by_process() { - factory(Delegation::class, 3)->states('foreign_keys')->create([ + Delegation::factory(3)->foreign_keys()->create([ 'PRO_ID' => function () { - return factory(Process::class)->create()->PRO_ID; + return Process::factory()->create()->PRO_ID; } ]); // Get first page, all process ordering ASC @@ -1366,9 +1370,9 @@ class DelegationTest extends TestCase */ public function it_should_sort_by_task_title() { - factory(Delegation::class, 2)->states('foreign_keys')->create([ + Delegation::factory(2)->foreign_keys()->create([ 'TAS_ID' => function () { - return factory(Task::class)->create()->TAS_ID; + return Task::factory()->create()->TAS_ID; } ]); // Get first page, all titles ordering ASC @@ -1389,9 +1393,9 @@ class DelegationTest extends TestCase */ public function it_should_sort_by_user() { - factory(Delegation::class, 2)->states('foreign_keys')->create([ + Delegation::factory(2)->foreign_keys()->create([ 'USR_ID' => function () { - return factory(User::class)->create()->USR_ID; + return User::factory()->create()->USR_ID; } ]); // Get first page, order by User ordering ASC @@ -1412,9 +1416,9 @@ class DelegationTest extends TestCase */ public function it_should_sort_by_last_modified() { - factory(Delegation::class, 2)->states('foreign_keys')->create([ + Delegation::factory(2)->foreign_keys()->create([ 'APP_NUMBER' => function () { - return factory(Application::class)->create()->APP_NUMBER; + return Application::factory()->create()->APP_NUMBER; } ]); // Get first page, the minor last modified @@ -1435,7 +1439,7 @@ class DelegationTest extends TestCase */ public function it_should_sort_by_due_date() { - factory(Delegation::class, 10)->states('foreign_keys')->create(); + Delegation::factory(10)->foreign_keys()->create(); // Get first page, the minor due date $results = Delegation::search(null, 0, 10, null, null, null, 'ASC', 'DEL_TASK_DUE_DATE'); $this->assertCount(10, $results['data']); @@ -1454,27 +1458,27 @@ class DelegationTest extends TestCase */ public function it_should_sort_by_status() { - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'APP_NUMBER' => function () { - return factory(Application::class)->create(['APP_STATUS' => 'DRAFT', 'APP_STATUS_ID' => 1])->APP_NUMBER; + return Application::factory()->create(['APP_STATUS' => 'DRAFT', 'APP_STATUS_ID' => 1])->APP_NUMBER; } ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'APP_NUMBER' => function () { - return factory(Application::class)->create(['APP_STATUS' => 'TO_DO', 'APP_STATUS_ID' => 2])->APP_NUMBER; + return Application::factory()->create(['APP_STATUS' => 'TO_DO', 'APP_STATUS_ID' => 2])->APP_NUMBER; } ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'APP_NUMBER' => function () { - return factory(Application::class)->create([ + return Application::factory()->create([ 'APP_STATUS' => 'COMPLETED', 'APP_STATUS_ID' => 3 ])->APP_NUMBER; } ]); - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'APP_NUMBER' => function () { - return factory(Application::class)->create([ + return Application::factory()->create([ 'APP_STATUS' => 'CANCELLED', 'APP_STATUS_ID' => 4 ])->APP_NUMBER; @@ -1497,21 +1501,21 @@ class DelegationTest extends TestCase public function it_should_return_data_filtered_by_process_category() { // Dummy Processes - factory(ProcessCategory::class, 4)->create(); - factory(Process::class, 4)->create([ + ProcessCategory::factory(4)->create(); + Process::factory(4)->create([ 'PRO_CATEGORY' => ProcessCategory::all()->random()->CATEGORY_UID ]); // Dummy Delegations - factory(Delegation::class, 100)->create([ + Delegation::factory(100)->create([ 'PRO_ID' => Process::all()->random()->PRO_ID ]); // Process with the category to search - $category = factory(ProcessCategory::class)->create(); - $processSearch = factory(Process::class)->create([ + $category = ProcessCategory::factory()->create(); + $processSearch = Process::factory()->create([ 'PRO_CATEGORY' => $category->CATEGORY_UID ]); // Delegations to found - factory(Delegation::class, 51)->states('foreign_keys')->create([ + Delegation::factory(51)->foreign_keys()->create([ 'PRO_ID' => $processSearch->PRO_ID ]); // Get first page, which is 25 @@ -1533,16 +1537,16 @@ class DelegationTest extends TestCase */ public function it_should_return_right_data_between_two_dates() { - factory(Delegation::class, 10)->states('foreign_keys')->create([ + Delegation::factory(10)->foreign_keys()->create([ 'DEL_DELEGATE_DATE' => '2019-01-02 00:00:00' ]); - factory(Delegation::class, 10)->states('foreign_keys')->create([ + Delegation::factory(10)->foreign_keys()->create([ 'DEL_DELEGATE_DATE' => '2019-01-03 00:00:00' ]); - factory(Delegation::class, 10)->states('foreign_keys')->create([ + Delegation::factory(10)->foreign_keys()->create([ 'DEL_DELEGATE_DATE' => '2019-01-04 00:00:00' ]); - factory(Delegation::class, 10)->states('foreign_keys')->create([ + Delegation::factory(10)->foreign_keys()->create([ 'DEL_DELEGATE_DATE' => '2019-01-05 00:00:00' ]); $results = Delegation::search( @@ -1562,7 +1566,7 @@ class DelegationTest extends TestCase foreach ($results['data'] as $value) { $this->assertGreaterThanOrEqual('2019-01-02 00:00:00', $value['DEL_DELEGATE_DATE']); $this->assertLessThanOrEqual('2019-01-03 00:00:00', $value['DEL_DELEGATE_DATE']); - $this->assertRegExp('(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}) ', $value['DEL_DELEGATE_DATE']); + $this->assertMatchesRegularExpression('(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}) ', $value['DEL_DELEGATE_DATE']); } } @@ -1574,16 +1578,16 @@ class DelegationTest extends TestCase */ public function it_should_return_right_data_with_filters_dates_parameter() { - factory(Delegation::class, 10)->states('foreign_keys')->create([ + Delegation::factory(10)->foreign_keys()->create([ 'DEL_DELEGATE_DATE' => '2019-01-02 00:00:00' ]); - factory(Delegation::class, 10)->states('foreign_keys')->create([ + Delegation::factory(10)->foreign_keys()->create([ 'DEL_DELEGATE_DATE' => '2019-01-03 00:00:00' ]); - factory(Delegation::class, 10)->states('foreign_keys')->create([ + Delegation::factory(10)->foreign_keys()->create([ 'DEL_DELEGATE_DATE' => '2019-01-04 00:00:00' ]); - factory(Delegation::class, 10)->states('foreign_keys')->create([ + Delegation::factory(10)->foreign_keys()->create([ 'DEL_DELEGATE_DATE' => '2019-01-05 00:00:00' ]); // Search setting only from @@ -1602,7 +1606,7 @@ class DelegationTest extends TestCase $this->assertCount(40, $results['data']); foreach ($results['data'] as $value) { $this->assertGreaterThanOrEqual('2019-01-02 00:00:00', $value['DEL_DELEGATE_DATE']); - $this->assertRegExp('(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}) ', $value['DEL_DELEGATE_DATE']); + $this->assertMatchesRegularExpression('(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}) ', $value['DEL_DELEGATE_DATE']); } // Search setting only to $results = Delegation::search( @@ -1620,7 +1624,7 @@ class DelegationTest extends TestCase ); foreach ($results['data'] as $value) { $this->assertLessThanOrEqual('2019-01-04 00:00:00', $value['DEL_DELEGATE_DATE']); - $this->assertRegExp('(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}) ', $value['DEL_DELEGATE_DATE']); + $this->assertMatchesRegularExpression('(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}) ', $value['DEL_DELEGATE_DATE']); } } @@ -1633,13 +1637,13 @@ class DelegationTest extends TestCase public function it_should_return_empty_when_parallel_tasks_has_threads_closed() { // Create a process - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); // Create a task - $parallelTask = factory(Task::class)->create(); + $parallelTask = Task::factory()->create(); // Create a case - $application = factory(Application::class)->create(); + $application = Application::factory()->create(); // Create the threads for a parallel process - factory(Delegation::class, 5)->states('foreign_keys')->create([ + Delegation::factory(5)->foreign_keys()->create([ 'PRO_ID' => $process->PRO_ID, 'TAS_ID' => $parallelTask->TAS_ID, 'APP_NUMBER' => $application->APP_NUMBER, @@ -1653,7 +1657,7 @@ class DelegationTest extends TestCase $application->APP_NUMBER, null, null, - null, + 'asc', 'TAS_TITLE', null, null, @@ -1672,13 +1676,13 @@ class DelegationTest extends TestCase public function it_should_return_data_when_parallel_tasks_has_threads_open() { // Create a process - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); // Create a task - $parallelTask = factory(Task::class)->create(); + $parallelTask = Task::factory()->create(); // Create a case - $application = factory(Application::class)->create(); + $application = Application::factory()->create(); // Create the threads for a parallel process - factory(Delegation::class, 5)->states('foreign_keys')->create([ + Delegation::factory(5)->foreign_keys()->create([ 'PRO_ID' => $process->PRO_ID, 'TAS_ID' => $parallelTask->TAS_ID, 'APP_NUMBER' => $application->APP_NUMBER, @@ -1699,13 +1703,13 @@ class DelegationTest extends TestCase public function it_should_return_data_in_sequential_tasks_with_intermediate_dummy_task() { // Create a process - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); // Create a task - $parallelTask = factory(Task::class)->create(); + $parallelTask = Task::factory()->create(); // Create a case - $application = factory(Application::class)->create(['APP_STATUS_ID' => 2]); + $application = Application::factory()->create(['APP_STATUS_ID' => 2]); // Create the threads for a parallel process closed - factory(Delegation::class)->states('closed')->create([ + Delegation::factory()->closed()->create([ 'PRO_ID' => $process->PRO_ID, 'PRO_UID' => $process->PRO_UID, 'TAS_ID' => $parallelTask->TAS_ID, @@ -1713,7 +1717,7 @@ class DelegationTest extends TestCase 'DEL_INDEX' => 1 ]); // Create the threads for a parallel process closed - factory(Delegation::class)->states('open')->create([ + Delegation::factory()->open()->create([ 'PRO_ID' => $process->PRO_ID, 'PRO_UID' => $process->PRO_UID, 'TAS_ID' => $parallelTask->TAS_ID, @@ -1747,9 +1751,9 @@ class DelegationTest extends TestCase */ public function it_should_return_status_empty() { - factory(Delegation::class, 5)->states('foreign_keys')->create([ + Delegation::factory(5)->foreign_keys()->create([ 'APP_NUMBER' => function () { - return factory(Application::class)->create(['APP_STATUS' => ''])->APP_NUMBER; + return Application::factory()->create(['APP_STATUS' => ''])->APP_NUMBER; } ]); // Review the filter by status empty @@ -1766,15 +1770,15 @@ class DelegationTest extends TestCase public function it_should_return_empty_when_process_and_category_does_not_have_a_relation() { // Create a categories - $category = factory(ProcessCategory::class, 2)->create(); + $category = ProcessCategory::factory(2)->create(); //Create a process with category - $processWithCat = factory(Process::class)->create(['PRO_CATEGORY' => $category[0]->CATEGORY_UID]); - factory(Delegation::class)->states('foreign_keys')->create([ + $processWithCat = Process::factory()->create(['PRO_CATEGORY' => $category[0]->CATEGORY_UID]); + Delegation::factory()->foreign_keys()->create([ 'PRO_ID' => $processWithCat->PRO_ID ]); // Create a process without category - $processWithoutCat = factory(Process::class)->create(['PRO_CATEGORY' => '']); - factory(Delegation::class, 5)->states('foreign_keys')->create([ + $processWithoutCat = Process::factory()->create(['PRO_CATEGORY' => '']); + Delegation::factory(5)->foreign_keys()->create([ 'PRO_ID' => $processWithoutCat->PRO_ID ]); // Search the cases when the process has related to the category and search by another category @@ -1840,23 +1844,25 @@ class DelegationTest extends TestCase public function it_should_return_data_when_process_and_category_does_have_a_relation() { //Create a category - $category = factory(ProcessCategory::class)->create(); + $category = ProcessCategory::factory()->create(); //Define a process related with he previous category - $processWithCat = factory(Process::class)->create([ + $processWithCat = Process::factory()->create([ 'PRO_CATEGORY' => $category->CATEGORY_UID ]); //Create a delegation related to this process - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'PRO_ID' => $processWithCat->PRO_ID ]); //Define a process related with he previous category - $process = factory(Process::class)->create([ + $process = Process::factory()->create([ 'PRO_CATEGORY' => '' ]); //Create a delegation related to other process - factory(Delegation::class, 5)->create([ + $delegation = Delegation::factory(5)->create([ 'PRO_ID' => $process->PRO_ID, ]); + + $this->assertEquals($process->PRO_ID, $delegation[0]->PRO_ID); } /** @@ -1868,17 +1874,17 @@ class DelegationTest extends TestCase public function it_should_return_participation_info() { // Creating one application with two delegations - factory(User::class, 100)->create(); - $process = factory(Process::class)->create(); - $application = factory(Application::class)->create([ + User::factory(100)->create(); + $process = Process::factory()->create(); + $application = Application::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'APP_UID' => G::generateUniqueID() ]); - factory(Delegation::class)->states('closed')->create([ + Delegation::factory()->closed()->create([ 'PRO_UID' => $process->PRO_UID, 'APP_UID' => $application->APP_UID ]); - factory(Delegation::class)->states('open')->create([ + Delegation::factory()->open()->create([ 'PRO_UID' => $process->PRO_UID, 'APP_UID' => $application->APP_UID, 'DEL_INDEX' => 2 @@ -1915,24 +1921,24 @@ class DelegationTest extends TestCase public function it_should_get_query_cases_by_user_with_self_service_user_assigned() { //Create process - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); //Create user - $user = factory(User::class)->create(); + $user = User::factory()->create(); //Create a task self service - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID ]); //Assign a user in the task - factory(TaskUser::class)->create([ + TaskUser::factory()->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([ + Delegation::factory(25)->create([ 'TAS_ID' => $task->TAS_ID, 'DEL_THREAD_STATUS' => 'OPEN', 'USR_ID' => 0, @@ -1952,31 +1958,31 @@ class DelegationTest extends TestCase public function it_should_get_query_cases_by_user_with_self_service_value_based_usr_uid() { //Create process - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); //Create a case - $application = factory(Application::class)->create(); + $application = Application::factory()->create(); //Create user - $user = factory(User::class)->create(); + $user = User::factory()->create(); //Create a task self service value based - $task = factory(Task::class)->create([ + $task = Task::factory()->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([ + $appSelfValue = AppAssignSelfServiceValue::factory()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'DEL_INDEX' => 2, 'TAS_ID' => $task->TAS_ID ]); - factory(AppAssignSelfServiceValueGroup::class)->create([ + AppAssignSelfServiceValueGroup::factory()->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([ + Delegation::factory(25)->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'DEL_INDEX' => $appSelfValue->DEL_INDEX, 'TAS_ID' => $task->TAS_ID, @@ -1997,32 +2003,32 @@ class DelegationTest extends TestCase public function it_should_get_query_cases_by_user_with_self_service_group_assigned() { //Create process - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); //Create group - $group = factory(Groupwf::class)->create(); + $group = Groupwf::factory()->create(); //Create user - $user = factory(User::class)->create(); + $user = User::factory()->create(); //Assign a user in the group - factory(GroupUser::class)->create([ + GroupUser::factory()->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([ + $task = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID ]); //Assign a user in the task - factory(TaskUser::class)->create([ + TaskUser::factory()->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([ + Delegation::factory(25)->create([ 'TAS_ID' => $task->TAS_ID, 'DEL_THREAD_STATUS' => 'OPEN', 'USR_ID' => 0, @@ -2042,44 +2048,44 @@ class DelegationTest extends TestCase public function it_should_get_query_cases_by_user_with_self_service_value_based_grp_uid() { //Create process - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); //Create a task self service value based - $task = factory(Task::class)->create([ + $task = Task::factory()->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(); + $application = Application::factory()->create(); //Create group - $group = factory(Groupwf::class)->create(); + $group = Groupwf::factory()->create(); //Create user - $user = factory(User::class)->create([ + $user = User::factory()->create([ 'USR_USERNAME' => 'gary', 'USR_LASTNAME' => 'Gary', 'USR_FIRSTNAME' => 'Bailey', ]); //Assign a user in the group - factory(GroupUser::class)->create([ + GroupUser::factory()->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([ + $appSelfValue = AppAssignSelfServiceValue::factory()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'APP_UID' => $application->APP_UID, 'DEL_INDEX' => 2, 'TAS_ID' => $task->TAS_ID ]); - factory(AppAssignSelfServiceValueGroup::class)->create([ + AppAssignSelfServiceValueGroup::factory()->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([ + Delegation::factory(25)->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'DEL_INDEX' => 2, 'TAS_ID' => $task->TAS_ID, @@ -2100,62 +2106,62 @@ class DelegationTest extends TestCase public function it_should_get_query_cases_by_user_with_self_service_and_self_service_value_based() { //Create process - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); //Create group - $group = factory(Groupwf::class)->create(); + $group = Groupwf::factory()->create(); //Create user - $user = factory(User::class)->create(); + $user = User::factory()->create(); //Assign a user in the group - factory(GroupUser::class)->create([ + GroupUser::factory()->create([ 'GRP_UID' => $group->GRP_UID, 'GRP_ID' => $group->GRP_ID, 'USR_UID' => $user->USR_UID ]); //Create a task self service - $taskSelfService = factory(Task::class)->create([ + $taskSelfService = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID ]); //Assign a user in the task - factory(TaskUser::class)->create([ + TaskUser::factory()->create([ 'TAS_UID' => $taskSelfService->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)->create([ + Delegation::factory()->create([ 'TAS_ID' => $taskSelfService->TAS_ID, 'DEL_THREAD_STATUS' => 'OPEN', 'USR_ID' => 0, ]); //Create a task self service value based - $taskSelfServiceByVariable = factory(Task::class)->create([ + $taskSelfServiceByVariable = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID ]); //Assign a user in the task - factory(TaskUser::class)->create([ + TaskUser::factory()->create([ 'TAS_UID' => $taskSelfServiceByVariable->TAS_UID, 'USR_UID' => $group->GRP_UID, 'TU_RELATION' => 2, //Related to the group 'TU_TYPE' => 1 ]); //Create the relation for the value assigned in the TAS_GROUP_VARIABLE - $appAssignSelfService = factory(AppAssignSelfServiceValue::class)->create([ + $appAssignSelfService = AppAssignSelfServiceValue::factory()->create([ 'TAS_ID' => $taskSelfServiceByVariable->TAS_ID ]); - factory(AppAssignSelfServiceValueGroup::class)->create([ + AppAssignSelfServiceValueGroup::factory()->create([ 'ID' => $appAssignSelfService->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 value based - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_NUMBER' => $appAssignSelfService->APP_NUMBER, 'DEL_INDEX' => $appAssignSelfService->DEL_INDEX, 'TAS_ID' => $taskSelfServiceByVariable->TAS_ID, @@ -2177,89 +2183,89 @@ class DelegationTest extends TestCase public function it_should_get_query_cases_by_user_with_self_service_user_and_group_assigned_parallel_task() { //Create process - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); //Create group - $group = factory(Groupwf::class)->create(); + $group = Groupwf::factory()->create(); //Create user - $user = factory(User::class)->create(); + $user = User::factory()->create(); //Assign a user in the group - factory(GroupUser::class)->create([ + GroupUser::factory()->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([ + $task1 = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID ]); //Assign a user in the task1 - factory(TaskUser::class)->create([ + TaskUser::factory()->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([ + $task2 = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID ]); //Assign a user in the task2 - factory(TaskUser::class)->create([ + TaskUser::factory()->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([ + $task3 = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID ]); //Assign a user in the task - factory(TaskUser::class)->create([ + TaskUser::factory()->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([ + $task4 = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID ]); //Assign a user in the task - factory(TaskUser::class)->create([ + TaskUser::factory()->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([ + Delegation::factory(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([ + Delegation::factory(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([ + Delegation::factory(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([ + Delegation::factory(10)->create([ 'TAS_ID' => $task4->TAS_ID, 'DEL_THREAD_STATUS' => 'OPEN', 'USR_ID' => 0, @@ -2279,30 +2285,30 @@ class DelegationTest extends TestCase public function it_should_get_query_cases_by_user_with_self_service_value_based_usr_uid_and_grp_uid() { //Create process - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); //Create a case - $application = factory(Application::class)->create(); + $application = Application::factory()->create(); //Create user - $user = factory(User::class)->create(); + $user = User::factory()->create(); //Create a task1 self service value based - $task1 = factory(Task::class)->create([ + $task1 = Task::factory()->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([ + $appSelfValue = AppAssignSelfServiceValue::factory()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'TAS_ID' => $task1->TAS_ID ]); - factory(AppAssignSelfServiceValueGroup::class)->create([ + AppAssignSelfServiceValueGroup::factory()->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([ + Delegation::factory(10)->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'DEL_INDEX' => $appSelfValue->DEL_INDEX, 'TAS_ID' => $task1->TAS_ID, @@ -2310,24 +2316,24 @@ class DelegationTest extends TestCase 'USR_ID' => 0, ]); //Create a task2 self service value based - $task2 = factory(Task::class)->create([ + $task2 = Task::factory()->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([ + $appSelfValue = AppAssignSelfServiceValue::factory()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'TAS_ID' => $task2->TAS_ID ]); - factory(AppAssignSelfServiceValueGroup::class)->create([ + AppAssignSelfServiceValueGroup::factory()->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([ + Delegation::factory(15)->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'DEL_INDEX' => $appSelfValue->DEL_INDEX, 'TAS_ID' => $task2->TAS_ID, @@ -2348,24 +2354,24 @@ class DelegationTest extends TestCase public function it_should_get_cases_by_user_with_self_service_user_assigned() { //Create process - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); //Create user - $user = factory(User::class)->create(); + $user = User::factory()->create(); //Create a task self service - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID ]); //Assign a user in the task - factory(TaskUser::class)->create([ + TaskUser::factory()->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([ + Delegation::factory(25)->create([ 'TAS_ID' => $task->TAS_ID, 'DEL_THREAD_STATUS' => 'OPEN', 'USR_ID' => 0, @@ -2387,31 +2393,31 @@ class DelegationTest extends TestCase public function it_should_get_cases_by_user_with_self_service_value_based_usr_uid() { //Create process - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); //Create a case - $application = factory(Application::class)->create(); + $application = Application::factory()->create(); //Create user - $user = factory(User::class)->create(); + $user = User::factory()->create(); //Create a task self service value based - $task = factory(Task::class)->create([ + $task = Task::factory()->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([ + $appSelfValue = AppAssignSelfServiceValue::factory()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'DEL_INDEX' => 2, 'TAS_ID' => $task->TAS_ID ]); - factory(AppAssignSelfServiceValueGroup::class)->create([ + AppAssignSelfServiceValueGroup::factory()->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([ + Delegation::factory(25)->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'DEL_INDEX' => $appSelfValue->DEL_INDEX, 'TAS_ID' => $task->TAS_ID, @@ -2432,32 +2438,32 @@ class DelegationTest extends TestCase public function it_should_get_cases_by_user_with_self_service_group_assigned() { //Create process - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); //Create group - $group = factory(Groupwf::class)->create(); + $group = Groupwf::factory()->create(); //Create user - $user = factory(User::class)->create(); + $user = User::factory()->create(); //Assign a user in the group - factory(GroupUser::class)->create([ + GroupUser::factory()->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([ + $task = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID ]); //Assign a user in the task - factory(TaskUser::class)->create([ + TaskUser::factory()->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([ + Delegation::factory(25)->create([ 'TAS_ID' => $task->TAS_ID, 'DEL_THREAD_STATUS' => 'OPEN', 'USR_ID' => 0, @@ -2477,44 +2483,44 @@ class DelegationTest extends TestCase public function it_should_get_cases_by_user_with_self_service_value_based_grp_uid() { //Create process - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); //Create a task self service value based - $task = factory(Task::class)->create([ + $task = Task::factory()->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(); + $application = Application::factory()->create(); //Create group - $group = factory(Groupwf::class)->create(); + $group = Groupwf::factory()->create(); //Create user - $user = factory(User::class)->create([ + $user = User::factory()->create([ 'USR_USERNAME' => 'gary', 'USR_LASTNAME' => 'Gary', 'USR_FIRSTNAME' => 'Bailey', ]); //Assign a user in the group - factory(GroupUser::class)->create([ + GroupUser::factory()->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([ + $appSelfValue = AppAssignSelfServiceValue::factory()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'APP_UID' => $application->APP_UID, 'DEL_INDEX' => 2, 'TAS_ID' => $task->TAS_ID ]); - factory(AppAssignSelfServiceValueGroup::class)->create([ + AppAssignSelfServiceValueGroup::factory()->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([ + Delegation::factory(25)->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'DEL_INDEX' => 2, 'TAS_ID' => $task->TAS_ID, @@ -2535,62 +2541,62 @@ class DelegationTest extends TestCase public function it_should_get_cases_by_user_with_self_service_and_self_service_value_based() { //Create process - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); //Create group - $group = factory(Groupwf::class)->create(); + $group = Groupwf::factory()->create(); //Create user - $user = factory(User::class)->create(); + $user = User::factory()->create(); //Assign a user in the group - factory(GroupUser::class)->create([ + GroupUser::factory()->create([ 'GRP_UID' => $group->GRP_UID, 'GRP_ID' => $group->GRP_ID, 'USR_UID' => $user->USR_UID ]); //Create a task self service - $taskSelfService = factory(Task::class)->create([ + $taskSelfService = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID ]); //Assign a user in the task - factory(TaskUser::class)->create([ + TaskUser::factory()->create([ 'TAS_UID' => $taskSelfService->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)->create([ + Delegation::factory()->create([ 'TAS_ID' => $taskSelfService->TAS_ID, 'DEL_THREAD_STATUS' => 'OPEN', 'USR_ID' => 0, ]); //Create a task self service value based - $taskSelfServiceByVariable = factory(Task::class)->create([ + $taskSelfServiceByVariable = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID ]); //Assign a user in the task - factory(TaskUser::class)->create([ + TaskUser::factory()->create([ 'TAS_UID' => $taskSelfServiceByVariable->TAS_UID, 'USR_UID' => $group->GRP_UID, 'TU_RELATION' => 2, //Related to the group 'TU_TYPE' => 1 ]); //Create the relation for the value assigned in the TAS_GROUP_VARIABLE - $appAssignSelfService = factory(AppAssignSelfServiceValue::class)->create([ + $appAssignSelfService = AppAssignSelfServiceValue::factory()->create([ 'TAS_ID' => $taskSelfServiceByVariable->TAS_ID ]); - factory(AppAssignSelfServiceValueGroup::class)->create([ + AppAssignSelfServiceValueGroup::factory()->create([ 'ID' => $appAssignSelfService->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 value based - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_NUMBER' => $appAssignSelfService->APP_NUMBER, 'DEL_INDEX' => $appAssignSelfService->DEL_INDEX, 'TAS_ID' => $taskSelfServiceByVariable->TAS_ID, @@ -2612,89 +2618,89 @@ class DelegationTest extends TestCase public function it_should_get_cases_by_user_with_self_service_user_and_group_assigned_parallel_task() { //Create process - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); //Create group - $group = factory(Groupwf::class)->create(); + $group = Groupwf::factory()->create(); //Create user - $user = factory(User::class)->create(); + $user = User::factory()->create(); //Assign a user in the group - factory(GroupUser::class)->create([ + GroupUser::factory()->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([ + $task1 = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID ]); //Assign a user in the task1 - factory(TaskUser::class)->create([ + TaskUser::factory()->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([ + $task2 = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID ]); //Assign a user in the task2 - factory(TaskUser::class)->create([ + TaskUser::factory()->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([ + $task3 = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID ]); //Assign a user in the task - factory(TaskUser::class)->create([ + TaskUser::factory()->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([ + $task4 = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID ]); //Assign a user in the task - factory(TaskUser::class)->create([ + TaskUser::factory()->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([ + Delegation::factory(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([ + Delegation::factory(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([ + Delegation::factory(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([ + Delegation::factory(10)->create([ 'TAS_ID' => $task4->TAS_ID, 'DEL_THREAD_STATUS' => 'OPEN', 'USR_ID' => 0, @@ -2714,30 +2720,30 @@ class DelegationTest extends TestCase public function it_should_get_cases_by_user_with_self_service_value_based_usr_uid_and_grp_uid() { //Create process - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); //Create a case - $application = factory(Application::class)->create(); + $application = Application::factory()->create(); //Create user - $user = factory(User::class)->create(); + $user = User::factory()->create(); //Create a task1 self service value based - $task1 = factory(Task::class)->create([ + $task1 = Task::factory()->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([ + $appSelfValue = AppAssignSelfServiceValue::factory()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'TAS_ID' => $task1->TAS_ID ]); - factory(AppAssignSelfServiceValueGroup::class)->create([ + AppAssignSelfServiceValueGroup::factory()->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([ + Delegation::factory(10)->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'DEL_INDEX' => $appSelfValue->DEL_INDEX, 'TAS_ID' => $task1->TAS_ID, @@ -2745,24 +2751,24 @@ class DelegationTest extends TestCase 'USR_ID' => 0, ]); //Create a task2 self service value based - $task2 = factory(Task::class)->create([ + $task2 = Task::factory()->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([ + $appSelfValue = AppAssignSelfServiceValue::factory()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'TAS_ID' => $task2->TAS_ID ]); - factory(AppAssignSelfServiceValueGroup::class)->create([ + AppAssignSelfServiceValueGroup::factory()->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([ + Delegation::factory(15)->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'DEL_INDEX' => $appSelfValue->DEL_INDEX, 'TAS_ID' => $task2->TAS_ID, @@ -2783,24 +2789,24 @@ class DelegationTest extends TestCase public function it_should_count_cases_by_user_with_self_service_user_assigned() { //Create process - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); //Create user - $user = factory(User::class)->create(); + $user = User::factory()->create(); //Create a task self service - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID ]); //Assign a user in the task - factory(TaskUser::class)->create([ + TaskUser::factory()->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([ + Delegation::factory(25)->create([ 'TAS_ID' => $task->TAS_ID, 'DEL_THREAD_STATUS' => 'OPEN', 'USR_ID' => 0, @@ -2820,31 +2826,31 @@ class DelegationTest extends TestCase public function it_should_count_cases_by_user_with_self_service_value_based_usr_uid() { //Create process - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); //Create a case - $application = factory(Application::class)->create(); + $application = Application::factory()->create(); //Create user - $user = factory(User::class)->create(); + $user = User::factory()->create(); //Create a task self service value based - $task = factory(Task::class)->create([ + $task = Task::factory()->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([ + $appSelfValue = AppAssignSelfServiceValue::factory()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'DEL_INDEX' => 2, 'TAS_ID' => $task->TAS_ID ]); - factory(AppAssignSelfServiceValueGroup::class)->create([ + AppAssignSelfServiceValueGroup::factory()->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([ + Delegation::factory(25)->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'DEL_INDEX' => $appSelfValue->DEL_INDEX, 'TAS_ID' => $task->TAS_ID, @@ -2865,32 +2871,32 @@ class DelegationTest extends TestCase public function it_should_count_cases_by_user_with_self_service_group_assigned() { //Create process - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); //Create group - $group = factory(Groupwf::class)->create(); + $group = Groupwf::factory()->create(); //Create user - $user = factory(User::class)->create(); + $user = User::factory()->create(); //Assign a user in the group - factory(GroupUser::class)->create([ + GroupUser::factory()->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([ + $task = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID ]); //Assign a user in the task - factory(TaskUser::class)->create([ + TaskUser::factory()->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([ + Delegation::factory(25)->create([ 'TAS_ID' => $task->TAS_ID, 'DEL_THREAD_STATUS' => 'OPEN', 'USR_ID' => 0, @@ -2910,44 +2916,44 @@ class DelegationTest extends TestCase public function it_should_count_cases_by_user_with_self_service_value_based_grp_uid() { //Create process - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); //Create a task self service value based - $task = factory(Task::class)->create([ + $task = Task::factory()->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(); + $application = Application::factory()->create(); //Create group - $group = factory(Groupwf::class)->create(); + $group = Groupwf::factory()->create(); //Create user - $user = factory(User::class)->create([ + $user = User::factory()->create([ 'USR_USERNAME' => 'gary', 'USR_LASTNAME' => 'Gary', 'USR_FIRSTNAME' => 'Bailey', ]); //Assign a user in the group - factory(GroupUser::class)->create([ + GroupUser::factory()->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([ + $appSelfValue = AppAssignSelfServiceValue::factory()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'APP_UID' => $application->APP_UID, 'DEL_INDEX' => 2, 'TAS_ID' => $task->TAS_ID ]); - factory(AppAssignSelfServiceValueGroup::class)->create([ + AppAssignSelfServiceValueGroup::factory()->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([ + Delegation::factory(25)->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'DEL_INDEX' => 2, 'TAS_ID' => $task->TAS_ID, @@ -2968,62 +2974,62 @@ class DelegationTest extends TestCase public function it_should_count_cases_by_user_with_self_service_and_self_service_value_based() { //Create process - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); //Create group - $group = factory(Groupwf::class)->create(); + $group = Groupwf::factory()->create(); //Create user - $user = factory(User::class)->create(); + $user = User::factory()->create(); //Assign a user in the group - factory(GroupUser::class)->create([ + GroupUser::factory()->create([ 'GRP_UID' => $group->GRP_UID, 'GRP_ID' => $group->GRP_ID, 'USR_UID' => $user->USR_UID ]); //Create a task self service - $taskSelfService = factory(Task::class)->create([ + $taskSelfService = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID ]); //Assign a user in the task - factory(TaskUser::class)->create([ + TaskUser::factory()->create([ 'TAS_UID' => $taskSelfService->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)->create([ + Delegation::factory()->create([ 'TAS_ID' => $taskSelfService->TAS_ID, 'DEL_THREAD_STATUS' => 'OPEN', 'USR_ID' => 0, ]); //Create a task self service value based - $taskSelfServiceByVariable = factory(Task::class)->create([ + $taskSelfServiceByVariable = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID ]); //Assign a user in the task - factory(TaskUser::class)->create([ + TaskUser::factory()->create([ 'TAS_UID' => $taskSelfServiceByVariable->TAS_UID, 'USR_UID' => $group->GRP_UID, 'TU_RELATION' => 2, //Related to the group 'TU_TYPE' => 1 ]); //Create the relation for the value assigned in the TAS_GROUP_VARIABLE - $appAssignSelfService = factory(AppAssignSelfServiceValue::class)->create([ + $appAssignSelfService = AppAssignSelfServiceValue::factory()->create([ 'TAS_ID' => $taskSelfServiceByVariable->TAS_ID ]); - factory(AppAssignSelfServiceValueGroup::class)->create([ + AppAssignSelfServiceValueGroup::factory()->create([ 'ID' => $appAssignSelfService->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 value based - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_NUMBER' => $appAssignSelfService->APP_NUMBER, 'DEL_INDEX' => $appAssignSelfService->DEL_INDEX, 'TAS_ID' => $taskSelfServiceByVariable->TAS_ID, @@ -3045,89 +3051,89 @@ class DelegationTest extends TestCase public function it_should_count_cases_by_user_with_self_service_user_and_group_assigned_parallel_task() { //Create process - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); //Create group - $group = factory(Groupwf::class)->create(); + $group = Groupwf::factory()->create(); //Create user - $user = factory(User::class)->create(); + $user = User::factory()->create(); //Assign a user in the group - factory(GroupUser::class)->create([ + GroupUser::factory()->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([ + $task1 = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID ]); //Assign a user in the task1 - factory(TaskUser::class)->create([ + TaskUser::factory()->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([ + $task2 = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID ]); //Assign a user in the task2 - factory(TaskUser::class)->create([ + TaskUser::factory()->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([ + $task3 = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID ]); //Assign a user in the task - factory(TaskUser::class)->create([ + TaskUser::factory()->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([ + $task4 = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID ]); //Assign a user in the task - factory(TaskUser::class)->create([ + TaskUser::factory()->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([ + Delegation::factory(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([ + Delegation::factory(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([ + Delegation::factory(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([ + Delegation::factory(10)->create([ 'TAS_ID' => $task4->TAS_ID, 'DEL_THREAD_STATUS' => 'OPEN', 'USR_ID' => 0, @@ -3147,30 +3153,30 @@ class DelegationTest extends TestCase public function it_should_count_cases_by_user_with_self_service_value_based_usr_uid_and_grp_uid() { //Create process - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); //Create a case - $application = factory(Application::class)->create(); + $application = Application::factory()->create(); //Create user - $user = factory(User::class)->create(); + $user = User::factory()->create(); //Create a task1 self service value based - $task1 = factory(Task::class)->create([ + $task1 = Task::factory()->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([ + $appSelfValue = AppAssignSelfServiceValue::factory()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'TAS_ID' => $task1->TAS_ID ]); - factory(AppAssignSelfServiceValueGroup::class)->create([ + AppAssignSelfServiceValueGroup::factory()->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([ + Delegation::factory(10)->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'DEL_INDEX' => $appSelfValue->DEL_INDEX, 'TAS_ID' => $task1->TAS_ID, @@ -3178,24 +3184,24 @@ class DelegationTest extends TestCase 'USR_ID' => 0, ]); //Create a task2 self service value based - $task2 = factory(Task::class)->create([ + $task2 = Task::factory()->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([ + $appSelfValue = AppAssignSelfServiceValue::factory()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'TAS_ID' => $task2->TAS_ID ]); - factory(AppAssignSelfServiceValueGroup::class)->create([ + AppAssignSelfServiceValueGroup::factory()->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([ + Delegation::factory(15)->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'DEL_INDEX' => $appSelfValue->DEL_INDEX, 'TAS_ID' => $task2->TAS_ID, @@ -3216,19 +3222,19 @@ class DelegationTest extends TestCase public function it_should_return_current_user_for_thread_open() { //Create process - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); //Create a case - $application = factory(Application::class)->create(); + $application = Application::factory()->create(); //Create user - $user = factory(User::class)->create(); + $user = User::factory()->create(); //Create a delegation - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 2, 'USR_UID' => $user->USR_UID, ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'DEL_THREAD_STATUS' => 'CLOSED', 'DEL_INDEX' => 1, @@ -3249,19 +3255,19 @@ class DelegationTest extends TestCase public function it_should_return_current_user_for_thread_closed() { //Create process - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); //Create a case - $application = factory(Application::class)->create(); + $application = Application::factory()->create(); //Create user - $user = factory(User::class)->create(); + $user = User::factory()->create(); //Create a delegation - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'DEL_THREAD_STATUS' => 'CLOSED', 'DEL_INDEX' => 1, 'USR_UID' => $user->USR_UID, ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 2, @@ -3282,19 +3288,19 @@ class DelegationTest extends TestCase public function it_should_return_empty_when_row_does_not_exist() { //Create process - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); //Create a case - $application = factory(Application::class)->create(); + $application = Application::factory()->create(); //Create user - $user = factory(User::class)->create(); + $user = User::factory()->create(); //Create a delegation - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'DEL_THREAD_STATUS' => 'CLOSED', 'DEL_INDEX' => 1, 'USR_UID' => $user->USR_UID, ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 2, @@ -3318,15 +3324,15 @@ class DelegationTest extends TestCase public function it_should_return_thread_open() { //Create process - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); //Create a case - $application = factory(Application::class)->create(); + $application = Application::factory()->create(); //Create user - $user = factory(User::class)->create(); + $user = User::factory()->create(); //Create task - $task = factory(Task::class)->create(); + $task = Task::factory()->create(); //Create a delegation - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_FINISH_DATE' => null, 'APP_NUMBER' => $application->APP_NUMBER, @@ -3345,13 +3351,13 @@ class DelegationTest extends TestCase public function it_should_return_empty_when_thread_is_closed() { //Create process - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); //Create a case - $application = factory(Application::class)->create(); + $application = Application::factory()->create(); //Create task - $task = factory(Task::class)->create(); + $task = Task::factory()->create(); //Create a delegation - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'DEL_THREAD_STATUS' => 'CLOSED', 'APP_NUMBER' => $application->APP_NUMBER, 'TAS_UID' => $task->TAS_UID, @@ -3369,15 +3375,15 @@ class DelegationTest extends TestCase public function it_should_return_empty_when_thread_finish_date_is_not_null() { //Create process - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); //Create a case - $application = factory(Application::class)->create(); + $application = Application::factory()->create(); //Create user - $user = factory(User::class)->create(); + $user = User::factory()->create(); //Create task - $task = factory(Task::class)->create(); + $task = Task::factory()->create(); //Create a delegation - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'DEL_THREAD_STATUS' => 'CLOSED', 'APP_NUMBER' => $application->APP_NUMBER, 'TAS_UID' => $task->TAS_UID, @@ -3394,12 +3400,12 @@ class DelegationTest extends TestCase */ public function it_when_the_user_does_have_participation() { - factory(Process::class)->create(); + Process::factory()->create(); //Create user - $user = factory(User::class)->create(); - $application = factory(Application::class)->create(); + $user = User::factory()->create(); + $application = Application::factory()->create(); //Create a delegation - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'APP_UID' => $application->APP_UID, 'USR_ID' => $user->USR_ID, @@ -3417,12 +3423,12 @@ class DelegationTest extends TestCase */ public function it_when_the_user_does_not_have_participation() { - factory(Process::class)->create(); + Process::factory()->create(); //Create user - $user = factory(User::class)->create(); - $application = factory(Application::class)->create(); + $user = User::factory()->create(); + $application = Application::factory()->create(); //Create a delegation - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'APP_UID' => $application->APP_UID ]); @@ -3438,7 +3444,7 @@ class DelegationTest extends TestCase */ public function it_get_thread_title() { - $delegation = factory(Delegation::class)->states('foreign_keys')->create(); + $delegation = Delegation::factory()->foreign_keys()->create(); $result = Delegation::getThreadTitle($delegation->TAS_UID, $delegation->APP_NUMBER, $delegation->DEL_PREVIOUS, []); $this->assertNotEmpty($result); } @@ -3451,7 +3457,7 @@ class DelegationTest extends TestCase */ public function it_get_thread_info() { - $delegation = factory(Delegation::class)->states('foreign_keys')->create(); + $delegation = Delegation::factory()->foreign_keys()->create(); $result = Delegation::getThreadInfo($delegation->APP_NUMBER, $delegation->DEL_INDEX); $this->assertNotEmpty($result); } @@ -3464,7 +3470,7 @@ class DelegationTest extends TestCase */ public function it_get_thread_dates() { - $delegation = factory(Delegation::class)->states('foreign_keys')->create(); + $delegation = Delegation::factory()->foreign_keys()->create(); $task = new Task(); $taskInfo = $task->load($delegation->TAS_UID); $taskInfo = head($taskInfo); @@ -3486,7 +3492,7 @@ class DelegationTest extends TestCase */ public function it_get_threads_pending() { - $delegation = factory(Delegation::class)->states('foreign_keys')->create(); + $delegation = Delegation::factory()->foreign_keys()->create(); $result = Delegation::getPendingThreads($delegation->APP_NUMBER); $this->assertNotEmpty($result); $result = Delegation::getPendingThreads($delegation->APP_NUMBER, false); @@ -3501,7 +3507,7 @@ class DelegationTest extends TestCase */ public function it_get_task_pending() { - $delegation = factory(Delegation::class)->states('foreign_keys')->create(); + $delegation = Delegation::factory()->foreign_keys()->create(); $result = Delegation::getPendingTask($delegation->APP_NUMBER); $this->assertNotEmpty($result); } @@ -3514,7 +3520,7 @@ class DelegationTest extends TestCase */ public function it_get_last_thread() { - $delegation = factory(Delegation::class)->states('foreign_keys')->create(); + $delegation = Delegation::factory()->foreign_keys()->create(); $result = Delegation::getLastThread($delegation->APP_NUMBER); $this->assertNotEmpty($result); } @@ -3527,7 +3533,7 @@ class DelegationTest extends TestCase */ public function it_should_test_the_get_del_title_method() { - $delegation = factory(Delegation::class)->create([ + $delegation = Delegation::factory()->create([ 'DEL_TITLE' => "test" ]); $result = Delegation::getDeltitle($delegation->APP_NUMBER, $delegation->DEL_INDEX); @@ -3543,24 +3549,24 @@ class DelegationTest extends TestCase */ public function it_should_test_the_has_active_parents_cases_method() { - $process = factory(Process::class)->create(); - $processParent = factory(Process::class, 3)->create(); - factory(SubProcess::class)->create([ + $process = Process::factory()->create(); + $processParent = Process::factory(3)->create(); + SubProcess::factory()->create([ 'PRO_UID' => $process['PRO_UID'], 'PRO_PARENT' => $processParent[0]['PRO_UID'] ]); - factory(SubProcess::class)->create([ + SubProcess::factory()->create([ 'PRO_UID' => $process['PRO_UID'], 'PRO_PARENT' => $processParent[1]['PRO_UID'] ]); - factory(SubProcess::class)->create([ + SubProcess::factory()->create([ 'PRO_UID' => $process['PRO_UID'], 'PRO_PARENT' => $processParent[2]['PRO_UID'] ]); $parents = SubProcess::getProParents($process['PRO_UID']); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'PRO_UID' => $parents[0]['PRO_PARENT'], 'TAS_UID' => $parents[0]['TAS_PARENT'], 'DEL_THREAD_STATUS' => 'OPEN' @@ -3580,7 +3586,7 @@ class DelegationTest extends TestCase */ public function it_get_cases_completed_by_specific_user() { - $delegation = factory(Delegation::class)->states('last_thread')->create(); + $delegation = Delegation::factory()->last_thread()->create(); $result = Delegation::casesCompletedBy($delegation->USR_ID); $this->assertNotEmpty($result); } @@ -3593,7 +3599,7 @@ class DelegationTest extends TestCase */ public function it_get_cases_started_by_specific_user() { - $delegation = factory(Delegation::class)->states('first_thread')->create(); + $delegation = Delegation::factory()->first_thread()->create(); $result = Delegation::casesStartedBy($delegation->USR_ID); $this->assertNotEmpty($result); } @@ -3606,9 +3612,9 @@ class DelegationTest extends TestCase */ public function it_get_cases_thread_title() { - $delegation = factory(Delegation::class)->states('foreign_keys')->create(); + $delegation = Delegation::factory()->foreign_keys()->create(); $result = Delegation::casesThreadTitle($delegation->DEL_TITLE); - $this->assertNotEmpty($result); + $this->assertTrue(isset($result[0])); } /** @@ -3619,8 +3625,8 @@ class DelegationTest extends TestCase */ public function it_return_scope_participated_user() { - $application = factory(Application::class)->states('completed')->create(); - $table = factory(Delegation::class)->states('foreign_keys')->create([ + $application = Application::factory()->completed()->create(); + $table = Delegation::factory()->foreign_keys()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'APP_UID' => $application->APP_UID, ]); @@ -3636,8 +3642,8 @@ class DelegationTest extends TestCase */ public function it_tests_scope_inbox_metrics() { - $application = factory(Application::class)->states('todo')->create(); - $table = factory(Delegation::class)->states('foreign_keys')->create([ + $application = Application::factory()->todo()->create(); + $table = Delegation::factory()->foreign_keys()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'APP_UID' => $application->APP_UID, ]); @@ -3653,8 +3659,8 @@ class DelegationTest extends TestCase */ public function it_tests_scope_draft_metrics() { - $application = factory(Application::class)->states('draft')->create(); - $table = factory(Delegation::class)->states('foreign_keys')->create([ + $application = Application::factory()->draft()->create(); + $table = Delegation::factory()->foreign_keys()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'APP_UID' => $application->APP_UID, ]); @@ -3670,12 +3676,12 @@ class DelegationTest extends TestCase */ public function it_tests_scope_paused_metrics() { - $application = factory(Application::class)->states('paused')->create(); - $appDelay = factory(AppDelay::class)->states('paused_foreign_keys')->create([ + $application = Application::factory()->paused()->create(); + $appDelay = AppDelay::factory()->paused_foreign_keys()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'APP_UID' => $application->APP_UID, ]); - $table = factory(Delegation::class)->states('foreign_keys')->create([ + $table = Delegation::factory()->foreign_keys()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'APP_UID' => $application->APP_UID, 'DEL_INDEX' => $appDelay->APP_DEL_INDEX, @@ -3692,11 +3698,11 @@ class DelegationTest extends TestCase */ public function it_tests_scope_self_service_metrics() { - $application = factory(Application::class)->states('paused')->create(); - $task = factory(Task::class)->create([ + $application = Application::factory()->paused()->create(); + $task = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', ]); - $delegation = factory(Delegation::class)->states('foreign_keys')->create([ + $delegation = Delegation::factory()->foreign_keys()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'APP_UID' => $application->APP_UID, 'TAS_ID' => $task->TAS_ID, diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/DocumentsTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/DocumentsTest.php index f47de791e..af49f7982 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Model/DocumentsTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Model/DocumentsTest.php @@ -23,7 +23,7 @@ class DocumentsTest extends TestCase */ public function it_test_get_case_note_files() { - $appDoc = factory(Documents::class)->states('case_notes')->create(); + $appDoc =Documents::factory()->case_notes()->create(); $doc = new Documents(); $res = $doc->getAppFiles($appDoc->APP_UID, Documents::DOC_TYPE_CASE_NOTE); $this->assertNotEmpty($res); @@ -37,8 +37,8 @@ class DocumentsTest extends TestCase */ public function it_should_test_get_attached_files_from_the_casenote() { - $appNote = factory(AppNotes::class)->create(); - $appDocument = factory(Documents::class)->create([ + $appNote =AppNotes::factory()->create(); + $appDocument =Documents::factory()->create([ 'DOC_ID' => $appNote->NOTE_ID ]); @@ -57,8 +57,8 @@ class DocumentsTest extends TestCase */ public function it_should_test_get_files() { - $appNote = factory(AppNotes::class)->create(); - $appDocument = factory(Documents::class)->create([ + $appNote =AppNotes::factory()->create(); + $appDocument =Documents::factory()->create([ 'DOC_ID' => $appNote->NOTE_ID ]); $result = Documents::getFiles($appDocument->DOC_ID); diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/DynaformTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/DynaformTest.php index 75718d73f..ff4fbd05a 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Model/DynaformTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Model/DynaformTest.php @@ -19,7 +19,7 @@ class DynaformTest extends TestCase /** * Call the setUp parent method */ - public function setUp() + public function setUp(): void { parent::setUp(); } @@ -31,9 +31,9 @@ class DynaformTest extends TestCase */ public function it_has_a_process() { - $dynaForm = factory(Dynaform::class)->create([ + $dynaForm =Dynaform::factory()->create([ 'PRO_UID' => function () { - return factory(Process::class)->create()->PRO_UID; + return Process::factory()->create()->PRO_UID; } ]); $this->assertInstanceOf(Process::class, $dynaForm->process); @@ -47,7 +47,7 @@ class DynaformTest extends TestCase */ public function it_tests_get_by_pro_uid() { - $dynaForm = factory(Dynaform::class)->states('foreign_keys')->create(); + $dynaForm = Dynaform::factory()->foreign_keys()->create(); $result = Dynaform::getByProUid($dynaForm->PRO_UID); $this->assertNotEmpty($result); } @@ -60,7 +60,7 @@ class DynaformTest extends TestCase */ public function it_tests_get_by_dyn_uid() { - $dynaForm = factory(Dynaform::class)->states('foreign_keys')->create(); + $dynaForm = Dynaform::factory()->foreign_keys()->create(); $result = Dynaform::getByDynUid($dynaForm->DYN_UID); $this->assertNotEmpty($result); } @@ -73,7 +73,7 @@ class DynaformTest extends TestCase */ public function it_tests_get_by_process_exclude_dyn_uid() { - $dynaForm = factory(Dynaform::class)->states('foreign_keys')->create(); + $dynaForm = Dynaform::factory()->foreign_keys()->create(); $result = Dynaform::getByProUidExceptDynUid($dynaForm->PRO_UID, $dynaForm->DYN_UID); $this->assertEmpty($result); } @@ -86,23 +86,23 @@ class DynaformTest extends TestCase */ public function it_should_test_process_scope_in_dynaform_model() { - $process = factory(Process::class, 3)->create(); + $process = Process::factory(3)->create(); - factory(Dynaform::class)->create( + Dynaform::factory()->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( + Dynaform::factory()->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( + Dynaform::factory()->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":""}]}]}' diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/EmailEventTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/EmailEventTest.php index 60cdff1cd..4674851cb 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Model/EmailEventTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Model/EmailEventTest.php @@ -16,11 +16,19 @@ class EmailEventTest extends TestCase /** * Call the setUp parent method */ - public function setUp() + public function setUp(): void { parent::setUp(); // TODO: Change the autogenerated stub } + /** + * Call the tearDown parent method + */ + public function tearDown(): void + { + parent::tearDown(); // TODO: Change the autogenerated stub + } + /** * It tests the updateServerAndFromToDefaultOrEmpty method * @@ -30,8 +38,8 @@ class EmailEventTest extends TestCase public function it_should_test_the_update_event_method() { EmailServerModel::query()->delete(); - $emailServer = factory(EmailServerModel::class)->create(); - $emailEventFactory = factory(EmailEvent::class)->create([ + $emailServer = EmailServerModel::factory()->create(); + $emailEventFactory = EmailEvent::factory()->create([ 'EMAIL_SERVER_UID' => $emailServer['MESS_UID'] ]); @@ -54,11 +62,11 @@ class EmailEventTest extends TestCase public function it_should_test_the_update_event_method_with_a_default_email_server() { EmailServerModel::query()->delete(); - $emailServer = factory(EmailServerModel::class)->create(); - $emailServerDefault = factory(EmailServerModel::class)->create([ + $emailServer = EmailServerModel::factory()->create(); + $emailServerDefault = EmailServerModel::factory()->create([ 'MESS_DEFAULT' => 1 ]); - $emailEventFactory = factory(EmailEvent::class)->create([ + $emailEventFactory = EmailEvent::factory()->create([ 'EMAIL_SERVER_UID' => $emailServer['MESS_UID'] ]); @@ -71,12 +79,4 @@ class EmailEventTest extends TestCase $this->assertEquals($updatedEmailEvent[0]['EMAIL_SERVER_UID'], $emailServerDefault['MESS_UID']); } - - /** - * Call the tearDown parent method - */ - public function tearDown() - { - parent::tearDown(); // TODO: Change the autogenerated stub - } } \ No newline at end of file diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/EmailServerModelTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/EmailServerModelTest.php index f586d43cb..601c9c7a4 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Model/EmailServerModelTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Model/EmailServerModelTest.php @@ -15,7 +15,7 @@ class EmailServerModelTest extends TestCase /** * Call the setUp parent method */ - public function setUp() + public function setUp(): void { parent::setUp(); // TODO: Change the autogenerated stub } @@ -23,7 +23,7 @@ class EmailServerModelTest extends TestCase /** * Call the tearDown parent method */ - public function tearDown() + public function tearDown(): void { parent::tearDown(); // TODO: Change the autogenerated stub } @@ -37,7 +37,7 @@ class EmailServerModelTest extends TestCase public function it_should_test_the_get_email_server_method() { //Create the EmailServerModel factory - $emailServer = factory(EmailServerModel::class)->create(); + $emailServer = EmailServerModel::factory()->create(); //Create the EmailServerModel object $email = new EmailServerModel(); @@ -59,7 +59,7 @@ class EmailServerModelTest extends TestCase public function it_should_test_the_get_email_server_method_with_an_empty_result() { //Create the EmailServerModel factory - $emailServer = factory(EmailServerModel::class)->create(); + $emailServer = EmailServerModel::factory()->create(); //Create the EmailServerModel object $email = new EmailServerModel(); @@ -79,7 +79,7 @@ class EmailServerModelTest extends TestCase public function it_should_test_the_get_email_server_default() { //Create the EmailServer factory - $emailServer = factory(EmailServerModel::class)->create([ + $emailServer = EmailServerModel::factory()->create([ 'MESS_DEFAULT' => 1 ]); @@ -101,7 +101,7 @@ class EmailServerModelTest extends TestCase public function it_should_test_the_is_imap_method_when_there_is_an_imap_server() { EmailServerModel::query()->delete(); - $emailServer = factory(EmailServerModel::class)->create([ + $emailServer = EmailServerModel::factory()->create([ 'MESS_ENGINE' => 'IMAP' ]); $emailServerModel = new EmailServerModel(); @@ -119,7 +119,7 @@ class EmailServerModelTest extends TestCase public function it_should_test_the_is_imap_method_when_there_is_not_an_imap_server() { EmailServerModel::query()->delete(); - $emailServer = factory(EmailServerModel::class)->create(); + $emailServer = EmailServerModel::factory()->create(); $emailServerModel = new EmailServerModel(); $r = $emailServerModel->isImap($emailServer['MESS_UID']); diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/FieldsTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/FieldsTest.php index 4bac32be7..64c5b81c0 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Model/FieldsTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Model/FieldsTest.php @@ -21,9 +21,9 @@ class FieldsTest extends TestCase */ public function it_has_a_columns_defined() { - $tableColumns = factory(Fields::class)->create([ + $tableColumns = Fields::factory()->create([ 'ADD_TAB_UID' => function () { - return factory(AdditionalTables::class)->create()->ADD_TAB_UID; + return AdditionalTables::factory()->create()->ADD_TAB_UID; } ]); $this->assertInstanceOf(AdditionalTables::class, $tableColumns->table); @@ -38,7 +38,7 @@ class FieldsTest extends TestCase */ public function it_get_fields_from_specific_table() { - $fields = factory(Fields::class)->create(); + $fields = Fields::factory()->create(); $result = Fields::getFields($fields->ADD_TAB_UID); $this->assertNotEmpty($result); } @@ -53,7 +53,7 @@ class FieldsTest extends TestCase */ public function it_search_field() { - $fields = factory(Fields::class)->create(); + $fields = Fields::factory()->create(); $result = Fields::searchVariable($fields->ADD_TAB_UID, $fields->FLD_NAME); $this->assertNotEmpty($result); } diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/GroupUserTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/GroupUserTest.php index 09f69c48e..c85920fea 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Model/GroupUserTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Model/GroupUserTest.php @@ -2,7 +2,6 @@ namespace Tests\unit\workflow\engine\src\ProcessMaker\Model; -use Illuminate\Foundation\Testing\DatabaseTransactions; use ProcessMaker\Model\GroupUser; use ProcessMaker\Model\Groupwf; use ProcessMaker\Model\RbacUsers; @@ -16,15 +15,13 @@ use Tests\TestCase; */ class GroupUserTest extends TestCase { - use DatabaseTransactions; - /** * Method set up. */ - public function setUp() + public function setUp(): void { parent::setUp(); - GroupUser::truncate(); + $this->truncateNonInitialModels(); } /** @@ -35,9 +32,9 @@ class GroupUserTest extends TestCase */ public function it_belong_user() { - $table = factory(GroupUser::class)->create([ + $table = GroupUser::factory()->create([ 'USR_UID' => function () { - return factory(User::class)->create()->USR_UID; + return User::factory()->create()->USR_UID; } ]); $this->assertInstanceOf(User::class, $table->user); @@ -51,9 +48,9 @@ class GroupUserTest extends TestCase */ public function it_belong_group() { - $table = factory(GroupUser::class)->create([ + $table = GroupUser::factory()->create([ 'GRP_ID' => function () { - return factory(Groupwf::class)->create()->GRP_ID; + return Groupwf::factory()->create()->GRP_ID; } ]); $this->assertInstanceOf(Groupwf::class, $table->groupsWf); @@ -67,7 +64,7 @@ class GroupUserTest extends TestCase */ public function it_return_scope_user() { - $table = factory(GroupUser::class)->states('foreign_keys')->create(); + $table = GroupUser::factory()->foreign_keys()->create(); $this->assertNotEmpty($table->user($table->USR_UID)->get()); } @@ -80,24 +77,24 @@ class GroupUserTest extends TestCase public function it_should_test_message() { // When the user does not exist - $user = factory(User::class)->create(); - $group = factory(Groupwf::class)->create(); + $user = User::factory()->create(); + $group = Groupwf::factory()->create(); $result = GroupUser::assignUserToGroup('', 0, '', 0); $this->assertNotEmpty($result); // When the group does not exist - $rbacUser = factory(RbacUsers::class)->create(); - $user = factory(User::class)->create([ + $rbacUser = RbacUsers::factory()->create(); + $user = User::factory()->create([ 'USR_UID' => $rbacUser['USR_UID'] ]); - $group = factory(Groupwf::class)->create(); + $group = Groupwf::factory()->create(); $result = GroupUser::assignUserToGroup($user['USR_UID'], 0, '', 0); $this->assertNotEmpty($result); // When the user already exist in a group - $rbacUser = factory(RbacUsers::class)->create(); - $user = factory(User::class)->create([ + $rbacUser = RbacUsers::factory()->create(); + $user = User::factory()->create([ 'USR_UID' => $rbacUser['USR_UID'] ]); - $group = factory(Groupwf::class)->create(); + $group = Groupwf::factory()->create(); GroupUser::assignUserToGroup($user['USR_UID'], $user['USR_ID'], $group['GRP_UID'], $group['GRP_ID']); $result = GroupUser::assignUserToGroup($user['USR_UID'], $user['USR_ID'], $group['GRP_UID'], $group['GRP_ID']); $this->assertNotEmpty($result); @@ -111,8 +108,8 @@ class GroupUserTest extends TestCase */ public function it_should_test_the_assign_user_to_group_method() { - $rbacUser = factory(RbacUsers::class)->create(); - $user = factory(User::class)->create([ + $rbacUser = RbacUsers::factory()->create(); + $user = User::factory()->create([ 'USR_UID' => $rbacUser['USR_UID'], 'USR_USERNAME' => $rbacUser['USR_USERNAME'], 'USR_PASSWORD' => $rbacUser['USR_PASSWORD'], @@ -120,7 +117,7 @@ class GroupUserTest extends TestCase 'USR_LASTNAME' => $rbacUser['USR_LASTNAME'], 'USR_EMAIL' => $rbacUser['USR_EMAIL'], ]); - $group = factory(Groupwf::class)->create(); + $group = Groupwf::factory()->create(); GroupUser::assignUserToGroup($rbacUser['USR_UID'], $user['USR_ID'], $group['GRP_UID'], $group['GRP_ID']); @@ -138,8 +135,8 @@ class GroupUserTest extends TestCase */ public function it_should_test_the_verify_user_is_in_group_method() { - $rbacUser = factory(RbacUsers::class)->create(); - $user = factory(User::class)->create([ + $rbacUser = RbacUsers::factory()->create(); + $user = User::factory()->create([ 'USR_UID' => $rbacUser['USR_UID'], 'USR_USERNAME' => $rbacUser['USR_USERNAME'], 'USR_PASSWORD' => $rbacUser['USR_PASSWORD'], @@ -147,7 +144,7 @@ class GroupUserTest extends TestCase 'USR_LASTNAME' => $rbacUser['USR_LASTNAME'], 'USR_EMAIL' => $rbacUser['USR_EMAIL'], ]); - $group = factory(Groupwf::class)->create(); + $group = Groupwf::factory()->create(); $res = GroupUser::verifyUserIsInGroup($user['USR_ID'], $group['GRP_ID']); $this->assertFalse($res); diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/GroupwfTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/GroupwfTest.php index ef7e585db..77b4f22af 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Model/GroupwfTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Model/GroupwfTest.php @@ -2,7 +2,6 @@ namespace Tests\unit\workflow\engine\src\ProcessMaker\Model; -use Illuminate\Foundation\Testing\DatabaseTransactions; use ProcessMaker\Model\GroupUser; use ProcessMaker\Model\Groupwf; use Tests\TestCase; @@ -14,15 +13,13 @@ use Tests\TestCase; */ class GroupwfTest extends TestCase { - use DatabaseTransactions; - /** * Method set up. */ - public function setUp() + public function setUp(): void { parent::setUp(); - Groupwf::truncate(); + $this->truncateNonInitialModels(); } /** @@ -33,9 +30,9 @@ class GroupwfTest extends TestCase */ public function it_belong_group() { - $table = factory(Groupwf::class)->create([ + $table = Groupwf::factory()->create([ 'GRP_ID' => function () { - return factory(GroupUser::class)->create()->GRP_ID; + return GroupUser::factory()->create()->GRP_ID; } ]); $this->assertInstanceOf(GroupUser::class, $table->groupUsers); @@ -49,7 +46,7 @@ class GroupwfTest extends TestCase */ public function it_return_scope_active() { - $table = factory(Groupwf::class)->create(); + $table = Groupwf::factory()->create(); $this->assertNotEmpty($table->active()->get()); } @@ -60,7 +57,7 @@ class GroupwfTest extends TestCase */ public function it_should_test_the_verify_group_exists_method() { - $groupWf = factory(Groupwf::class)->create(); + $groupWf = Groupwf::factory()->create(); $res = Groupwf::verifyGroupExists($groupWf['GRP_UID']); $this->assertTrue($res); @@ -76,7 +73,7 @@ class GroupwfTest extends TestCase */ public function it_should_test_the_get_group_id_method() { - $groupWf = factory(Groupwf::class)->create(); + $groupWf = Groupwf::factory()->create(); $res = Groupwf::getGroupId($groupWf['GRP_UID']); $this->assertNotEmpty($res); diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/InputDocumentTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/InputDocumentTest.php index 912ef35c6..38edff54a 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Model/InputDocumentTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Model/InputDocumentTest.php @@ -24,9 +24,9 @@ class InputDocumentTest extends TestCase */ public function it_has_a_process_defined() { - $table = factory(InputDocument::class)->create([ + $table = InputDocument::factory()->create([ 'PRO_UID' => function () { - return factory(Process::class)->create()->PRO_UID; + return Process::factory()->create()->PRO_UID; } ]); $this->assertInstanceOf(Process::class, $table->process); @@ -40,7 +40,7 @@ class InputDocumentTest extends TestCase */ public function it_get_by_process() { - $table = factory(InputDocument::class)->create(); + $table = InputDocument::factory()->create(); $result = InputDocument::getByProUid($table->PRO_UID); $this->assertNotEmpty($result); } @@ -53,7 +53,7 @@ class InputDocumentTest extends TestCase */ public function it_get_by_uid() { - $table = factory(InputDocument::class)->create(); + $table = InputDocument::factory()->create(); $result = InputDocument::getByInpDocUid($table->INP_DOC_UID); $this->assertNotEmpty($result); } diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/OutputDocumentTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/OutputDocumentTest.php index a32aa8329..28a9fe1a6 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Model/OutputDocumentTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Model/OutputDocumentTest.php @@ -24,9 +24,9 @@ class OutputDocumentTest extends TestCase */ public function it_has_a_process_defined() { - $table = factory(OutputDocument::class)->create([ + $table = OutputDocument::factory()->create([ 'PRO_UID' => function () { - return factory(Process::class)->create()->PRO_UID; + return Process::factory()->create()->PRO_UID; } ]); $this->assertInstanceOf(Process::class, $table->process); @@ -40,7 +40,7 @@ class OutputDocumentTest extends TestCase */ public function it_get_by_process() { - $table = factory(OutputDocument::class)->create(); + $table = OutputDocument::factory()->create(); $result = OutputDocument::getByProUid($table->PRO_UID); $this->assertNotEmpty($result); } @@ -53,7 +53,7 @@ class OutputDocumentTest extends TestCase */ public function it_get_by_uid() { - $table = factory(OutputDocument::class)->create(); + $table = OutputDocument::factory()->create(); $result = OutputDocument::getByOutDocUid($table->OUT_DOC_UID); $this->assertNotEmpty($result); } diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/ProcessCategoryTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/ProcessCategoryTest.php index 1cca9ddc0..da3d1ccf8 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Model/ProcessCategoryTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Model/ProcessCategoryTest.php @@ -18,7 +18,7 @@ class ProcessCategoryTest extends TestCase /** * Call the setUp parent method */ - public function setUp() + public function setUp(): void { parent::setUp(); ProcessCategory::query()->delete(); @@ -32,7 +32,7 @@ class ProcessCategoryTest extends TestCase */ public function it_tests_get_categories() { - $processCategory = factory(ProcessCategory::class)->create(); + $processCategory = ProcessCategory::factory()->create(); $result = ProcessCategory::getCategories(); $this->assertNotEmpty($result); @@ -47,16 +47,16 @@ class ProcessCategoryTest extends TestCase */ public function it_tests_get_process_categories_method_without_paremeters() { - factory(ProcessCategory::class)->create([ + ProcessCategory::factory()->create([ 'CATEGORY_ID' => 1 ]); - factory(ProcessCategory::class)->create([ + ProcessCategory::factory()->create([ 'CATEGORY_ID' => 2 ]); - factory(ProcessCategory::class)->create([ + ProcessCategory::factory()->create([ 'CATEGORY_ID' => 3 ]); - factory(ProcessCategory::class)->create([ + ProcessCategory::factory()->create([ 'CATEGORY_ID' => 4 ]); $result = ProcessCategory::getProcessCategories(); @@ -73,19 +73,19 @@ class ProcessCategoryTest extends TestCase */ public function it_tests_get_process_categories_method_filter_by_name() { - factory(ProcessCategory::class)->create([ + ProcessCategory::factory()->create([ 'CATEGORY_ID' => 1, 'CATEGORY_NAME' => 'Category1' ]); - factory(ProcessCategory::class)->create([ + ProcessCategory::factory()->create([ 'CATEGORY_ID' => 2, 'CATEGORY_NAME' => 'Category2' ]); - factory(ProcessCategory::class)->create([ + ProcessCategory::factory()->create([ 'CATEGORY_ID' => 3, 'CATEGORY_NAME' => 'Category3' ]); - factory(ProcessCategory::class)->create([ + ProcessCategory::factory()->create([ 'CATEGORY_ID' => 4, 'CATEGORY_NAME' => 'Category4' ]); @@ -103,16 +103,16 @@ class ProcessCategoryTest extends TestCase */ public function it_tests_get_process_categories_method_with_start_limit() { - factory(ProcessCategory::class)->create([ + ProcessCategory::factory()->create([ 'CATEGORY_ID' => 1, ]); - factory(ProcessCategory::class)->create([ + ProcessCategory::factory()->create([ 'CATEGORY_ID' => 2, ]); - factory(ProcessCategory::class)->create([ + ProcessCategory::factory()->create([ 'CATEGORY_ID' => 3, ]); - factory(ProcessCategory::class)->create([ + ProcessCategory::factory()->create([ 'CATEGORY_ID' => 4, ]); $result = ProcessCategory::getProcessCategories(null, 1, 3); @@ -128,7 +128,7 @@ class ProcessCategoryTest extends TestCase */ public function it_tests_get_category_id_method() { - $processCategory = factory(ProcessCategory::class)->create(); + $processCategory = ProcessCategory::factory()->create(); $result = ProcessCategory::getCategoryId($processCategory->CATEGORY_UID); $this->assertEquals($processCategory->CATEGORY_ID, $result); @@ -143,7 +143,7 @@ class ProcessCategoryTest extends TestCase */ public function it_tests_get_category() { - $processCategory = factory(ProcessCategory::class)->create(); + $processCategory = ProcessCategory::factory()->create(); $result = ProcessCategory::getCategory($processCategory->CATEGORY_ID); $this->assertNotEmpty($result); diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/ProcessTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/ProcessTest.php index 1ce21d7e3..57bbd44df 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Model/ProcessTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Model/ProcessTest.php @@ -23,7 +23,7 @@ class ProcessTest extends TestCase /** * Call the setUp parent method */ - public function setUp() + public function setUp(): void { parent::setUp(); Process::query()->delete(); @@ -37,8 +37,8 @@ class ProcessTest extends TestCase */ public function it_has_tasks() { - $process = factory(Process::class)->create(); - factory(Task::class)->create([ + $process = Process::factory()->create(); + Task::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'PRO_ID' => $process->PRO_ID ]); @@ -53,9 +53,9 @@ class ProcessTest extends TestCase */ public function it_has_a_creator() { - $process = factory(Process::class)->create([ + $process = Process::factory()->create([ 'PRO_CREATE_USER' => function () { - return factory(User::class)->create()->USR_UID; + return User::factory()->create()->USR_UID; } ]); $this->assertInstanceOf(User::class, $process->creator); @@ -69,9 +69,9 @@ class ProcessTest extends TestCase */ public function it_has_an_category() { - $process = factory(Process::class)->create([ + $process = Process::factory()->create([ 'PRO_CATEGORY' => function () { - return factory(ProcessCategory::class)->create()->CATEGORY_UID; + return ProcessCategory::factory()->create()->CATEGORY_UID; } ]); $this->assertInstanceOf(ProcessCategory::class, $process->category); @@ -86,7 +86,7 @@ class ProcessTest extends TestCase public function it_should_return_all_the_processes_for_an_specific_user() { //Create process - $process = factory(Process::class, 2)->states('foreign_keys')->create([]); + $process = Process::factory(2)->foreign_keys()->create([]); //Create a Process object $pro = new Process(); //Call the getProcessList() method @@ -111,13 +111,13 @@ class ProcessTest extends TestCase $catUid2 = G::generateUniqueID(); //Create user - $user = factory(User::class)->create(); + $user = User::factory()->create(); //Create process - $process1 = factory(Process::class)->create([ + $process1 = Process::factory()->create([ 'PRO_CREATE_USER' => $user['USR_UID'], 'PRO_CATEGORY' => $catUid1 ]); - $process2 = factory(Process::class)->create([ + $process2 = Process::factory()->create([ 'PRO_CREATE_USER' => $user['USR_UID'], 'PRO_CATEGORY' => $catUid2 ]); @@ -146,7 +146,7 @@ class ProcessTest extends TestCase public function it_should_return_empty_if_no_processes_where_found() { //Create user - $user = factory(User::class)->create(); + $user = User::factory()->create(); //Create a Process object $process = new Process(); //Call the getProcessList() method @@ -165,17 +165,17 @@ class ProcessTest extends TestCase public function it_should_return_all_the_processes_in_status_active() { //Create user - $user = factory(User::class)->create(); + $user = User::factory()->create(); //Create process - $process1 = factory(Process::class)->create([ + $process1 = Process::factory()->create([ 'PRO_CREATE_USER' => $user['USR_UID'], 'PRO_STATUS' => 'ACTIVE' ]); - $process2 = factory(Process::class)->create([ + $process2 = Process::factory()->create([ 'PRO_CREATE_USER' => $user['USR_UID'], 'PRO_STATUS' => 'INACTIVE' ]); - $process3 = factory(Process::class)->create([ + $process3 = Process::factory()->create([ 'PRO_CREATE_USER' => $user['USR_UID'], 'PRO_STATUS' => 'DISABLED' ]); @@ -205,10 +205,10 @@ class ProcessTest extends TestCase public function it_should_test_the_get_process_private_list_by_user_method() { //Create user - $user = factory(User::class)->create(); + $user = User::factory()->create(); //Create process - factory(Process::class)->create([ + Process::factory()->create([ 'PRO_CREATE_USER' => $user['USR_UID'], 'PRO_STATUS' => 'ACTIVE', 'PRO_TYPE_PROCESS' => 'PRIVATE', @@ -233,10 +233,10 @@ class ProcessTest extends TestCase public function it_should_test_the_convert_private_processes_to_public_method() { //Create user - $user = factory(User::class)->create(); + $user = User::factory()->create(); //Create process - $pro = factory(Process::class)->create([ + $pro = Process::factory()->create([ 'PRO_CREATE_USER' => $user['USR_UID'], 'PRO_STATUS' => 'ACTIVE', 'PRO_TYPE_PROCESS' => 'PRIVATE', @@ -288,7 +288,7 @@ class ProcessTest extends TestCase */ public function it_should_test_process_without_filter() { - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); $result = Process::getProcessesFilter( null, null, @@ -311,16 +311,16 @@ class ProcessTest extends TestCase */ public function it_should_test_process_with_category_filter() { - $process = factory(Process::class)->create([ + $process = Process::factory()->create([ 'PRO_CATEGORY' => function () { - return factory(ProcessCategory::class)->create()->CATEGORY_UID; + return ProcessCategory::factory()->create()->CATEGORY_UID; } ]); $result = Process::getProcessesFilter($process->PRO_CATEGORY); // Assert with the specific category $this->assertEquals($process->PRO_CATEGORY, $result[0]['PRO_CATEGORY']); - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); $result = Process::getProcessesFilter('NONE'); // Assert when the category is empty $this->assertEmpty($result); @@ -338,7 +338,7 @@ class ProcessTest extends TestCase */ public function it_should_test_process_with_process_filter() { - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); $result = Process::getProcessesFilter( null, $process->PRO_UID @@ -358,7 +358,7 @@ class ProcessTest extends TestCase */ public function it_should_test_process_with_title_filter() { - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); $result = Process::getProcessesFilter( null, null, @@ -379,7 +379,7 @@ class ProcessTest extends TestCase */ public function it_should_test_process_subprocess_filter() { - $process = factory(Process::class)->create([ + $process = Process::factory()->create([ 'PRO_SUBPROCESS' => 1 ]); $result = Process::getProcessesFilter( @@ -406,7 +406,7 @@ class ProcessTest extends TestCase */ public function it_should_test_count_process() { - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); $total = Process::getCounter($process->PRO_CREATE_USER); $this->assertEquals(1, $total); } @@ -422,26 +422,26 @@ class ProcessTest extends TestCase public function it_should_test_get_processes_for_home() { // Create a process category - $processCategory = factory(ProcessCategory::class)->create(); + $processCategory = ProcessCategory::factory()->create(); // Create five processes (4 active, 1 inactive) - factory(Process::class)->create([ + Process::factory()->create([ 'PRO_TITLE' => 'My Process 1', 'PRO_CATEGORY' => $processCategory->CATEGORY_UID, 'CATEGORY_ID' => $processCategory->CATEGORY_ID ]); - factory(Process::class)->create([ + Process::factory()->create([ 'PRO_TITLE' => 'My Process 2', 'PRO_CATEGORY' => $processCategory->CATEGORY_UID, 'CATEGORY_ID' => $processCategory->CATEGORY_ID ]); - factory(Process::class)->create([ + Process::factory()->create([ 'PRO_TITLE' => 'My Process 3', ]); - factory(Process::class)->create([ + Process::factory()->create([ 'PRO_TITLE' => 'Another Process', ]); - factory(Process::class)->create([ + Process::factory()->create([ 'PRO_TITLE' => 'Inactive Process', 'PRO_STATUS' => 'INACTIVE' ]); @@ -462,7 +462,7 @@ class ProcessTest extends TestCase */ public function it_should_test_get_id() { - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); $result = Process::getIds($process->PRO_UID, 'PRO_UID'); $this->assertEquals($process->PRO_ID, $result[0]['PRO_ID']); } @@ -475,7 +475,7 @@ class ProcessTest extends TestCase */ public function it_should_test_is_active() { - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); $total = Process::isActive($process->PRO_ID); $this->assertEquals(1, $total); } diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/ProcessUserTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/ProcessUserTest.php index 23a0e3762..01a136d12 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Model/ProcessUserTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Model/ProcessUserTest.php @@ -26,7 +26,7 @@ class ProcessUserTest extends TestCase */ public function it_get_process_of_supervisor() { - $table = factory(ProcessUser::class)->states('foreign_keys')->create(); + $table = ProcessUser::factory()->foreign_keys()->create(); $result = ProcessUser::getProcessesOfSupervisor($table->USR_UID); $this->assertNotEmpty($result); } diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/ProcessVariablesTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/ProcessVariablesTest.php index bbe19a0c4..54343a203 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Model/ProcessVariablesTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Model/ProcessVariablesTest.php @@ -19,23 +19,23 @@ class ProcessVariablesTest extends TestCase */ public function it_should_test_process_scope_in_process_variables_model() { - $process = factory(Process::class, 2)->create(); + $process = Process::factory(2)->create(); - factory(ProcessVariables::class)->create( + ProcessVariables::factory()->create( [ 'PRJ_UID' => $process[0]['PRO_UID'], 'VAR_SQL' => 'SELECT * FROM USERS WHERE USR_UID="213" UNION SELECT * from PROCESS' ] ); - factory(ProcessVariables::class)->create( + ProcessVariables::factory()->create( [ 'PRJ_UID' => $process[1]['PRO_UID'], 'VAR_SQL' => '' ] ); - factory(ProcessVariables::class)->create( + ProcessVariables::factory()->create( [ 'PRJ_UID' => $process[0]['PRO_UID'], 'VAR_SQL' => '' @@ -62,7 +62,7 @@ class ProcessVariablesTest extends TestCase */ public function it_get_variable() { - $table = factory(ProcessVariables::class)->create(); + $table = ProcessVariables::factory()->create(); $result = ProcessVariables::getVariable($table->VAR_UID); $this->assertNotEmpty($result); } @@ -75,9 +75,9 @@ class ProcessVariablesTest extends TestCase */ public function it_list_variables_by_process() { - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); - factory(ProcessVariables::class)->create([ + ProcessVariables::factory()->create([ 'PRJ_UID' => $process->PRO_UID, 'PRO_ID' => $process->PRO_ID, ] @@ -96,11 +96,11 @@ class ProcessVariablesTest extends TestCase */ public function it_list_variables_type_by_process() { - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); $varType = 'integer'; $varTypeId = 2; for ($x = 1; $x <= 5; $x++) { - $processVar = factory(ProcessVariables::class)->states('foreign_keys')->create([ + $processVar = ProcessVariables::factory()->foreign_keys()->create([ 'PRO_ID' => $process->PRO_ID, 'PRJ_UID' => $process->PRO_UID, 'VAR_FIELD_TYPE' => $varType, diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/RbacRolesTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/RbacRolesTest.php index 8e0945b79..e4f9fc93b 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Model/RbacRolesTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Model/RbacRolesTest.php @@ -22,7 +22,7 @@ class RbacRolesTest extends TestCase */ public function it_should_test_the_get_rol_uid_by_code_method() { - $rol1 = factory(RbacRoles::class)->create([ + $rol1 = RbacRoles::factory()->create([ 'ROL_CODE' => 'TEST_ROLE' ]); diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/RbacUsersTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/RbacUsersTest.php index 9779caee5..2ae1454e0 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Model/RbacUsersTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Model/RbacUsersTest.php @@ -24,7 +24,7 @@ class RbacUsersTest extends TestCase */ public function it_should_test_the_verify_username_exists_method() { - $rbacUser = factory(RbacUsers::class)->create([ + $rbacUser = RbacUsers::factory()->create([ 'USR_USERNAME' => 'test' ]); @@ -42,7 +42,7 @@ class RbacUsersTest extends TestCase */ public function it_should_test_the_create_user_method() { - $roles = factory(RbacRoles::class)->create(); + $roles = RbacRoles::factory()->create(); $data = [ 'USR_UID' => G::generateUniqueID(), 'USR_USERNAME' => 'test', @@ -71,7 +71,7 @@ class RbacUsersTest extends TestCase */ public function it_should_test_the_verify_user_exists_method() { - $rbacUser = factory(RbacUsers::class)->create(); + $rbacUser = RbacUsers::factory()->create(); $res = RbacUsers::verifyUserExists($rbacUser['USR_UID']); $this->assertTrue($res); diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/StepTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/StepTest.php index b83832dfc..bf62b3576 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Model/StepTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Model/StepTest.php @@ -23,7 +23,7 @@ class StepTest extends TestCase */ public function it_get_specific_step() { - $table = factory(Step::class)->create(); + $table = Step::factory()->create(); $result = Step::getByProcessTaskAndStepType( $table->PRO_UID, $table->TAS_UID, diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/SubProcessTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/SubProcessTest.php index a7e04038b..3cbf5c7c8 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Model/SubProcessTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Model/SubProcessTest.php @@ -19,7 +19,7 @@ class SubProcessTest extends TestCase /** * Call the setUp parent method */ - public function setUp() + public function setUp(): void { parent::setUp(); } @@ -32,17 +32,17 @@ class SubProcessTest extends TestCase */ public function it_should_test_the_get_pro_parents_method() { - $process = factory(Process::class)->create(); - $processParent = factory(Process::class, 3)->create(); - factory(SubProcess::class)->create([ + $process = Process::factory()->create(); + $processParent = Process::factory(3)->create(); + SubProcess::factory()->create([ 'PRO_UID' => $process['PRO_UID'], 'PRO_PARENT' => $processParent[0]['PRO_UID'] ]); - factory(SubProcess::class)->create([ + SubProcess::factory()->create([ 'PRO_UID' => $process['PRO_UID'], 'PRO_PARENT' => $processParent[1]['PRO_UID'] ]); - factory(SubProcess::class)->create([ + SubProcess::factory()->create([ 'PRO_UID' => $process['PRO_UID'], 'PRO_PARENT' => $processParent[2]['PRO_UID'] ]); diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/TaskTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/TaskTest.php index c6b294bd2..3170cf0f3 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Model/TaskTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Model/TaskTest.php @@ -3,7 +3,6 @@ namespace Tests\unit\workflow\engine\src\ProcessMaker\Model; use G; -use Illuminate\Foundation\Testing\DatabaseTransactions; use ProcessMaker\Model\Delegation; use ProcessMaker\Model\ElementTaskRelation; use ProcessMaker\Model\Process; @@ -18,7 +17,15 @@ use Tests\TestCase; class TaskTest extends TestCase { - use DatabaseTransactions; + /** + * Set up method. + * @return void + */ + public function setUp(): void + { + parent::setUp(); + $this->truncateNonInitialModels(); + } /** * It tests the get taskId @@ -28,7 +35,7 @@ class TaskTest extends TestCase */ public function it_get_task() { - $task = factory(Task::class)->create(); + $task = Task::factory()->create(); $result = Task::getTask($task->TAS_ID); $this->assertNotEmpty($result); } @@ -41,7 +48,7 @@ class TaskTest extends TestCase */ public function it_scope_exclude_tasks() { - $table = factory(Task::class)->create(); + $table = Task::factory()->create(); $this->assertNotEmpty($table->excludedTasks()->get()); } @@ -54,7 +61,7 @@ class TaskTest extends TestCase public function it_should_return_title_of_event_task() { // Intermediate email event - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'TAS_TITLE' => 'INTERMEDIATE-THROW-EMAIL-EVENT', 'TAS_TYPE' => 'INTERMEDIATE-THROW-EMAIL-EVENT' ]); @@ -62,7 +69,7 @@ class TaskTest extends TestCase $title = $taskInstance->title($task->TAS_ID); $this->assertEquals($title['title'], G::LoadTranslation('ID_INTERMEDIATE_THROW_EMAIL_EVENT')); // Intermediate throw message event - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'TAS_TITLE' => 'INTERMEDIATE-THROW-MESSAGE-EVENT', 'TAS_TYPE' => 'INTERMEDIATE-THROW-MESSAGE-EVENT' ]); @@ -70,7 +77,7 @@ class TaskTest extends TestCase $title = $taskInstance->title($task->TAS_ID); $this->assertEquals($title['title'], G::LoadTranslation('ID_INTERMEDIATE_THROW_MESSAGE_EVENT')); // Intermediate catch message event - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'TAS_TITLE' => 'INTERMEDIATE-CATCH-MESSAGE-EVENT', 'TAS_TYPE' => 'INTERMEDIATE-CATCH-MESSAGE-EVENT' ]); @@ -78,7 +85,7 @@ class TaskTest extends TestCase $title = $taskInstance->title($task->TAS_ID); $this->assertEquals($title['title'], G::LoadTranslation('ID_INTERMEDIATE_CATCH_MESSAGE_EVENT')); // Intermediate timer event - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'TAS_TITLE' => 'INTERMEDIATE-CATCH-TIMER-EVENT', 'TAS_TYPE' => 'INTERMEDIATE-CATCH-TIMER-EVENT' ]); @@ -86,7 +93,7 @@ class TaskTest extends TestCase $title = $taskInstance->title($task->TAS_ID); $this->assertEquals($title['title'], G::LoadTranslation('ID_INTERMEDIATE_CATCH_TIMER_EVENT')); // Script task - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'TAS_TITLE' => 'SCRIPT-TASK', 'TAS_TYPE' => 'SCRIPT-TASK' ]); @@ -94,7 +101,7 @@ class TaskTest extends TestCase $title = $taskInstance->title($task->TAS_ID); $this->assertEquals($title['title'], G::LoadTranslation('ID_SCRIPT_TASK_UNTITLED')); // Service task - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'TAS_TITLE' => 'SERVICE-TASK', 'TAS_TYPE' => 'SERVICE-TASK' ]); @@ -102,7 +109,7 @@ class TaskTest extends TestCase $title = $taskInstance->title($task->TAS_ID); $this->assertEquals($title['title'], G::LoadTranslation('ID_SERVICE_TASK_UNTITLED')); // None - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'TAS_TITLE' => 'SUBPROCESS', 'TAS_TYPE' => 'SUBPROCESS' ]); @@ -119,7 +126,7 @@ class TaskTest extends TestCase */ public function it_should_return_task() { - $task = factory(Task::class)->create(); + $task = Task::factory()->create(); $taskInstance = new Task(); $properties = $taskInstance->load($task->TAS_UID); @@ -134,10 +141,10 @@ class TaskTest extends TestCase */ public function it_should_return_task_information_from_user_task() { - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'TAS_TYPE' => 'NORMAL' ]); - $del = factory(Delegation::class)->states('closed')->create([ + $del = Delegation::factory()->closed()->create([ 'PRO_UID' => $task->PRO_UID, 'TAS_ID' => $task->TAS_ID, 'TAS_UID' => $task->TAS_UID, @@ -161,10 +168,10 @@ class TaskTest extends TestCase */ public function it_should_return_task_information_from_automatic_task() { - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'TAS_TYPE' => 'SCRIPT-TASK' ]); - $del = factory(Delegation::class)->states('closed')->create([ + $del = Delegation::factory()->closed()->create([ 'PRO_UID' => $task->PRO_UID, 'TAS_ID' => $task->TAS_ID, 'TAS_UID' => $task->TAS_UID, @@ -188,11 +195,11 @@ class TaskTest extends TestCase */ public function it_should_test_set_task_title_method() { - $project = factory(Process::class)->create(); - $task = factory(Task::class)->create([ + $project = Process::factory()->create(); + $task = Task::factory()->create([ 'TAS_DEF_TITLE' => 'something' ]); - $elementTask = factory(ElementTaskRelation::class)->create([ + $elementTask = ElementTaskRelation::factory()->create([ 'PRJ_UID' => $project->PRO_UID, 'TAS_UID' => $task->TAS_UID, ]); @@ -212,11 +219,11 @@ class TaskTest extends TestCase */ public function it_should_test_get_task_def_title_method() { - $project = factory(Process::class)->create(); - $task = factory(Task::class)->create([ + $project = Process::factory()->create(); + $task = Task::factory()->create([ 'TAS_DEF_TITLE' => 'something' ]); - $elementTask = factory(ElementTaskRelation::class)->create([ + $elementTask = ElementTaskRelation::factory()->create([ 'PRJ_UID' => $project->PRO_UID, 'TAS_UID' => $task->TAS_UID, ]); @@ -234,7 +241,7 @@ class TaskTest extends TestCase */ public function it_get_case_title() { - $task = factory(Task::class)->create(); + $task = Task::factory()->create(); $tas = new Task(); $result = $tas->taskCaseTitle($task->TAS_UID); $this->assertNotEmpty($result); @@ -250,30 +257,27 @@ class TaskTest extends TestCase */ public function it_should_test_get_tasks_for_home_method() { - Task::truncate(); - Process::truncate(); - - $process1 = factory(Process::class)->create(); - $process2 = factory(Process::class)->create(); + $process1 = Process::factory()->create(); + $process2 = Process::factory()->create(); - factory(Task::class)->create([ + Task::factory()->create([ 'PRO_UID' => $process1->PRO_UID, 'TAS_TITLE' => 'Task 1' ]); - factory(Task::class)->create([ + Task::factory()->create([ 'PRO_UID' => $process1->PRO_UID, 'TAS_TITLE' => 'Task 2' ]); - factory(Task::class)->create([ + Task::factory()->create([ 'PRO_UID' => $process1->PRO_UID, 'TAS_TITLE' => 'Task 3' ]); - factory(Task::class)->create([ + Task::factory()->create([ 'PRO_UID' => $process2->PRO_UID, 'TAS_TITLE' => 'Task 1' ]); - factory(Task::class)->create([ + Task::factory()->create([ 'PRO_UID' => $process2->PRO_UID, 'TAS_TITLE' => 'Task 2' ]); diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/TaskUserTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/TaskUserTest.php index add792ba9..54e05f014 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Model/TaskUserTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Model/TaskUserTest.php @@ -29,15 +29,15 @@ class TaskUserTest extends TestCase { if ($type === 'NORMAL'){ if ($relation === 'USER'){ - $assigment = factory(TaskUser::class)->states('normal_assigment_user')->create(); + $assigment = TaskUser::factory()->normal_assigment_user()->create(); } else { - $assigment = factory(TaskUser::class)->states('normal_assigment_group')->create(); + $assigment = TaskUser::factory()->normal_assigment_group()->create(); } } else { if ($relation === 'USER'){ - $assigment = factory(TaskUser::class)->states('adhoc_assigment_user')->create(); + $assigment = TaskUser::factory()->adhoc_assigment_user()->create(); } else { - $assigment = factory(TaskUser::class)->states('adhoc_assigment_group')->create(); + $assigment = TaskUser::factory()->adhoc_assigment_group()->create(); } } @@ -51,9 +51,9 @@ class TaskUserTest extends TestCase */ public function it_has_a_task() { - $assigment = factory(TaskUser::class)->create([ + $assigment = TaskUser::factory()->create([ 'TAS_UID' => function () { - return factory(Task::class)->create()->TAS_UID; + return Task::factory()->create()->TAS_UID; } ]); $this->assertInstanceOf(Task::class, $assigment->task); @@ -67,9 +67,9 @@ class TaskUserTest extends TestCase */ public function it_has_a_user() { - $assigment = factory(TaskUser::class)->create([ + $assigment = TaskUser::factory()->create([ 'USR_UID' => function () { - return factory(User::class)->create()->USR_UID; + return User::factory()->create()->USR_UID; } ]); $this->assertInstanceOf(User::class, $assigment->user); diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/TriggersTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/TriggersTest.php index dfc1b5df2..7663354b3 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Model/TriggersTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Model/TriggersTest.php @@ -26,8 +26,8 @@ class TriggersTest extends TestCase */ public function it_set_get_trigger() { - factory(Triggers::class)->create(); - $trigger = factory(Triggers::class)->create(); + Triggers::factory()->create(); + $trigger = Triggers::factory()->create(); $trigger->setTrigger($trigger->TRI_UID); $this->assertEquals($trigger->getTrigger(), $trigger->TRI_UID); } @@ -40,8 +40,8 @@ class TriggersTest extends TestCase */ public function it_should_test_process_scope_in_trigger_model() { - $process = factory(Process::class, 3)->create(); - factory(Triggers::class)->create( + $process = Process::factory(3)->create(); + Triggers::factory()->create( [ 'PRO_UID' => $process[0]['PRO_UID'], 'TRI_WEBBOT' => '$text=222; @@ -68,21 +68,21 @@ class TriggersTest extends TestCase ] ); - factory(Triggers::class)->create( + Triggers::factory()->create( [ 'PRO_UID' => $process[1]['PRO_UID'], 'TRI_WEBBOT' => 'die();' ] ); - factory(Triggers::class)->create( + Triggers::factory()->create( [ 'PRO_UID' => $process[2]['PRO_UID'], 'TRI_WEBBOT' => 'executeQuery("select * from USERS");' ] ); - factory(Triggers::class)->create( + Triggers::factory()->create( [ 'PRO_UID' => $process[2]['PRO_UID'], 'TRI_WEBBOT' => 'executeQuery();' @@ -109,8 +109,8 @@ class TriggersTest extends TestCase */ public function it_filter_specific_tasks() { - factory(Triggers::class)->create(); - $trigger = factory(Triggers::class)->create(); + Triggers::factory()->create(); + $trigger = Triggers::factory()->create(); $this->assertCount(1, $trigger->trigger($trigger->TRI_UID)->get()); } @@ -122,7 +122,7 @@ class TriggersTest extends TestCase */ public function it_return_specific_trigger_information() { - $triggers = factory(Triggers::class, 5)->create(); + $triggers = Triggers::factory(5)->create(); $trigger = new Triggers(); $trigger->setTrigger($triggers[0]->TRI_UID); $triggersList = $trigger->triggers(); @@ -138,7 +138,7 @@ class TriggersTest extends TestCase */ public function it_return_empty_when_the_trigger_not_exist() { - factory(Triggers::class)->create(); + Triggers::factory()->create(); $trigger = new Triggers(); $trigger->setTrigger(G::generateUniqueID()); $triggersList = $trigger->triggers(); diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/UserConfigTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/UserConfigTest.php index 49701cc77..9688498a2 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Model/UserConfigTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Model/UserConfigTest.php @@ -16,16 +16,16 @@ class UserConfigTest extends TestCase /** * Setup method, */ - public function setUp() + public function setUp(): void { parent::setUp(); - UserConfig::truncate(); + $this->truncateNonInitialModels(); } /** * Teardown method. */ - public function tearDown() + public function tearDown(): void { parent::tearDown(); } diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Model/UserTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Model/UserTest.php index d0725a2ec..ce8b0593f 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Model/UserTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Model/UserTest.php @@ -19,7 +19,7 @@ class UserTest extends TestCase /** * Set up function. */ - public function setUp() + public function setUp(): void { parent::setUp(); User::query()->delete(); @@ -32,7 +32,7 @@ class UserTest extends TestCase */ public function it_should_test_the_users_filters_scope_with_usr_uid() { - $user = factory(User::class, 4)->create(); + $user = User::factory(4)->create(); $filters = ['USR_UID' => $user[0]['USR_UID']]; $userQuery = User::query()->select(); @@ -54,7 +54,7 @@ class UserTest extends TestCase */ public function it_should_test_the_users_filters_scope_with_usr_id() { - $user = factory(User::class, 4)->create(); + $user = User::factory(4)->create(); $filters = ['USR_ID' => $user[0]['USR_ID']]; $userQuery = User::query()->select(); $userQuery->userFilters($filters); @@ -76,7 +76,7 @@ class UserTest extends TestCase */ public function it_should_test_the_exception_in_users_filters_scope() { - factory(User::class, 4)->create(); + User::factory(4)->create(); $filters = []; $userQuery = User::query()->select(); @@ -98,28 +98,28 @@ class UserTest extends TestCase public function it_should_test_get_users_for_home() { // Create five users (3 active, 1 on vacation, 1 inactive) - factory(User::class)->create([ + User::factory()->create([ 'USR_USERNAME' => 'jsmith', 'USR_FIRSTNAME' => 'John', 'USR_LASTNAME' => 'Smith', ]); - factory(User::class)->create([ + User::factory()->create([ 'USR_USERNAME' => 'asmith', 'USR_FIRSTNAME' => 'Adam', 'USR_LASTNAME' => 'Smith', ]); - factory(User::class)->create([ + User::factory()->create([ 'USR_USERNAME' => 'wsmith', 'USR_FIRSTNAME' => 'Will', 'USR_LASTNAME' => 'Smith', ]); - factory(User::class)->create([ + User::factory()->create([ 'USR_USERNAME' => 'wwallace', 'USR_FIRSTNAME' => 'Williams', 'USR_LASTNAME' => 'Wallace', 'USR_STATUS' => 'VACATION', ]); - factory(User::class)->create([ + User::factory()->create([ 'USR_USERNAME' => 'msmith', 'USR_FIRSTNAME' => 'Marcus', 'USR_LASTNAME' => 'Smith', @@ -146,7 +146,7 @@ class UserTest extends TestCase */ public function it_get_usr_id() { - $user = factory(User::class)->create(); + $user = User::factory()->create(); // When the user exist $results = User::getId($user->USR_UID); $this->assertGreaterThan(0, $results); @@ -164,7 +164,7 @@ class UserTest extends TestCase */ public function it_get_information() { - $user = factory(User::class)->create(); + $user = User::factory()->create(); // When the user exist $results = User::getInformation($user->USR_ID); $this->assertNotEmpty($results); @@ -184,7 +184,7 @@ class UserTest extends TestCase */ public function it_get_all_information() { - $user = factory(User::class)->create(); + $user = User::factory()->create(); // When the user exist $results = User::getAllInformation($user->USR_ID); $this->assertNotEmpty($results); @@ -223,6 +223,6 @@ class UserTest extends TestCase 'ROL_CODE' => 0 ]; $res = User::createUser($usrData); - $this->assertInternalType('integer', $res); + $this->assertIsInt($res); } } \ No newline at end of file diff --git a/tests/unit/workflow/engine/src/ProcessMaker/PDF/BasicStructTest.php b/tests/unit/workflow/engine/src/ProcessMaker/PDF/BasicStructTest.php index 1dbbc9f75..a6e53549d 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/PDF/BasicStructTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/PDF/BasicStructTest.php @@ -26,7 +26,7 @@ class BasicStructTest extends TestCase /** * setUp method. */ - public function setUp() + public function setUp(): void { parent::setUp(); $this->faker = Factory::create(); @@ -36,7 +36,7 @@ class BasicStructTest extends TestCase /** * tearDown method. */ - public function tearDown() + public function tearDown(): void { parent::tearDown(); } diff --git a/tests/unit/workflow/engine/src/ProcessMaker/PDF/FooterStructTest.php b/tests/unit/workflow/engine/src/ProcessMaker/PDF/FooterStructTest.php index 11f82d0fa..a8b6538aa 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/PDF/FooterStructTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/PDF/FooterStructTest.php @@ -26,7 +26,7 @@ class FooterStructTest extends TestCase /** * setUp method. */ - public function setUp() + public function setUp(): void { parent::setUp(); $this->faker = Factory::create(); @@ -36,7 +36,7 @@ class FooterStructTest extends TestCase /** * tearDown method. */ - public function tearDown() + public function tearDown(): void { parent::tearDown(); } diff --git a/tests/unit/workflow/engine/src/ProcessMaker/PDF/HeaderStructTest.php b/tests/unit/workflow/engine/src/ProcessMaker/PDF/HeaderStructTest.php index 6d018d8b4..dcfea30fc 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/PDF/HeaderStructTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/PDF/HeaderStructTest.php @@ -20,7 +20,7 @@ class HeaderStructTest extends TestCase /** * setUp method. */ - public function setUp() + public function setUp(): void { parent::setUp(); $this->faker = Factory::create(); @@ -30,7 +30,7 @@ class HeaderStructTest extends TestCase /** * tearDown method. */ - public function tearDown() + public function tearDown(): void { parent::tearDown(); } diff --git a/tests/unit/workflow/engine/src/ProcessMaker/PDF/TCPDFHeaderFooterTest.php b/tests/unit/workflow/engine/src/ProcessMaker/PDF/TCPDFHeaderFooterTest.php index 86270cd5d..1b5731048 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/PDF/TCPDFHeaderFooterTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/PDF/TCPDFHeaderFooterTest.php @@ -20,7 +20,7 @@ class TCPDFHeaderFooterTest extends TestCase /** * setUp method. */ - protected function setUp() + protected function setUp(): void { parent::setUp(); $this->object = new TCPDFHeaderFooter('P', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); @@ -36,7 +36,7 @@ class TCPDFHeaderFooterTest extends TestCase /** * tearDown method. */ - protected function tearDown() + protected function tearDown(): void { parent::tearDown(); } diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Project/Adapter/BpmnWorkflowTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Project/Adapter/BpmnWorkflowTest.php index 03c586245..8681d7a3f 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Project/Adapter/BpmnWorkflowTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Project/Adapter/BpmnWorkflowTest.php @@ -19,11 +19,11 @@ class BpmnWorkflowTest extends TestCase /** * Set up testing. */ - public function setUp() + public function setUp(): void { parent::setUp(); - $this->user = factory(User::class)->create(); - Process::truncate(); + $this->truncateNonInitialModels(); + $this->user = User::factory()->create(); } /** @@ -79,7 +79,7 @@ class BpmnWorkflowTest extends TestCase { $faker = Factory::create(); $title = $faker->title; - factory(\ProcessMaker\Model\Process::class)->create([ + \ProcessMaker\Model\Process::factory()->create([ 'PRO_TITLE' => $title ]); @@ -115,7 +115,9 @@ class BpmnWorkflowTest extends TestCase $projectData["process"]["pro_id"] = $faker->randomDigit; $bpmnWorkflow = new BpmnWorkflow(); - $bpmnWorkflow->createFromStruct($projectData, true, null); + $result = $bpmnWorkflow->createFromStruct($projectData, true, null); + $result = json_encode($result); + $this->assertStringContainsString($projectData['prj_uid'], $result); } /** @@ -158,11 +160,11 @@ class BpmnWorkflowTest extends TestCase $bpmnWorkflow = new BpmnWorkflow(); - factory(\ProcessMaker\Model\BpmnProject::class)->create([ + \ProcessMaker\Model\BpmnProject::factory()->create([ 'PRJ_NAME' => $projectData['prj_name'] ]); - factory(\ProcessMaker\Model\Process::class)->create([ + \ProcessMaker\Model\Process::factory()->create([ 'PRO_TITLE' => $projectData['prj_name'] ]); diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Project/WorkflowTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Project/WorkflowTest.php index 98ba3a1c4..9d3dd1184 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Project/WorkflowTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Project/WorkflowTest.php @@ -21,7 +21,7 @@ class WorkflowTest extends TestCase /** * This method sets the values before starting any test. */ - public function setUp() + public function setUp(): void { parent::setUp(); $this->workflow = new Workflow(); @@ -33,7 +33,7 @@ class WorkflowTest extends TestCase /** * This method is executed after each test. */ - public function tearDown() + public function tearDown(): void { parent::tearDown(); foreach ($this->files as $value) { @@ -51,11 +51,11 @@ class WorkflowTest extends TestCase */ public function it_should_return_the_data_when_the_project_id_is_valid() { - $process = factory(Process::class)->create(); - $dynaforms = factory(Dynaform::class, 5)->create([ + $process = Process::factory()->create(); + $dynaforms = Dynaform::factory(5)->create([ 'PRO_UID' => $process->PRO_UID ]); - factory(WebEntry::class, 5)->create([ + WebEntry::factory(5)->create([ 'PRO_UID' => $process->PRO_UID ]); diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Report/ReportingTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Report/ReportingTest.php index 6c0cd3712..546c12481 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Report/ReportingTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Report/ReportingTest.php @@ -21,7 +21,7 @@ class ReportingTest extends TestCase /** * Method setUp. */ - public function setUp() + public function setUp(): void { parent::setUp(); $this->reporting = new Reporting(); @@ -30,7 +30,7 @@ class ReportingTest extends TestCase /** * Method tearDown. */ - public function tearDown() + public function tearDown(): void { parent::tearDown(); } @@ -45,7 +45,7 @@ class ReportingTest extends TestCase $dateInit = date("YYYY-MM-DD"); $dateFinish = date("YYYY-MM-DD"); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'DEL_DELEGATE_DATE' => $dateInit ]); @@ -81,7 +81,7 @@ class ReportingTest extends TestCase $dateInit = date("YYYY-MM-DD"); $dateFinish = date("YYYY-MM-DD"); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'DEL_DELEGATE_DATE' => $dateInit ]); diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Services/Api/CasesTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Services/Api/CasesTest.php index 39aa594aa..d04c961d2 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Services/Api/CasesTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Services/Api/CasesTest.php @@ -66,7 +66,7 @@ class CasesTest extends TestCase */ public function it_should_test_isAllowed_method_try_exception() { - $user = factory(\ProcessMaker\Model\User::class)->create(); + $user = \ProcessMaker\Model\User::factory()->create(); $rest = $this->initializeRestApi($user->USR_UID); //assert exception @@ -84,21 +84,21 @@ class CasesTest extends TestCase */ public function it_should_test_isAllowed_method_doGetCaseVariables_option() { - $user = factory(\ProcessMaker\Model\User::class)->create(); - $process = factory(\ProcessMaker\Model\Process::class)->create(); - $task = factory(\ProcessMaker\Model\Task::class)->create([ + $user = \ProcessMaker\Model\User::factory()->create(); + $process = \ProcessMaker\Model\Process::factory()->create(); + $task = \ProcessMaker\Model\Task::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'PRO_ID' => $process->PRO_ID ]); - $dynaform = factory(\ProcessMaker\Model\Dynaform::class)->create([ + $dynaform = \ProcessMaker\Model\Dynaform::factory()->create([ 'PRO_UID' => $process->PRO_UID ]); - $application = factory(\ProcessMaker\Model\Application::class)->create([ + $application = \ProcessMaker\Model\Application::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'APP_INIT_USER' => $user->USR_UID, 'APP_CUR_USER' => $user->USR_UID ]); - $delegation = factory(\ProcessMaker\Model\Delegation::class)->create([ + $delegation = \ProcessMaker\Model\Delegation::factory()->create([ 'APP_UID' => $application->APP_UID, 'APP_NUMBER' => $application->APP_NUMBER, 'DEL_INDEX' => 1, @@ -138,16 +138,16 @@ class CasesTest extends TestCase */ public function it_should_test_isAllowed_method_doGetCaseVariables_option_without_delegation_user() { - $user = factory(\ProcessMaker\Model\User::class)->create(); - $process = factory(\ProcessMaker\Model\Process::class)->create(); - $task = factory(\ProcessMaker\Model\Task::class)->create([ + $user = \ProcessMaker\Model\User::factory()->create(); + $process = \ProcessMaker\Model\Process::factory()->create(); + $task = \ProcessMaker\Model\Task::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'PRO_ID' => $process->PRO_ID ]); - $dynaform = factory(\ProcessMaker\Model\Dynaform::class)->create([ + $dynaform = \ProcessMaker\Model\Dynaform::factory()->create([ 'PRO_UID' => $process->PRO_UID ]); - $application = factory(\ProcessMaker\Model\Application::class)->create([ + $application = \ProcessMaker\Model\Application::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'APP_INIT_USER' => $user->USR_UID, 'APP_CUR_USER' => $user->USR_UID @@ -181,16 +181,16 @@ class CasesTest extends TestCase */ public function it_should_test_isAllowed_method_doGetCaseVariables_option_with_guest_user() { - $user = factory(\ProcessMaker\Model\User::class)->create(); - $process = factory(\ProcessMaker\Model\Process::class)->create(); - $task = factory(\ProcessMaker\Model\Task::class)->create([ + $user = \ProcessMaker\Model\User::factory()->create(); + $process = \ProcessMaker\Model\Process::factory()->create(); + $task = \ProcessMaker\Model\Task::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'PRO_ID' => $process->PRO_ID ]); - $dynaform = factory(\ProcessMaker\Model\Dynaform::class)->create([ + $dynaform = \ProcessMaker\Model\Dynaform::factory()->create([ 'PRO_UID' => $process->PRO_UID ]); - $application = factory(\ProcessMaker\Model\Application::class)->create([ + $application = \ProcessMaker\Model\Application::factory()->create([ 'PRO_UID' => $process->PRO_UID, 'APP_INIT_USER' => $user->USR_UID, 'APP_CUR_USER' => $user->USR_UID @@ -225,11 +225,11 @@ class CasesTest extends TestCase */ public function test_upload_document_to_case_method() { - $user = factory(User::class)->create(); - $application = factory(Application::class)->create([ + $user = User::factory()->create(); + $application = Application::factory()->create([ 'APP_CUR_USER' => $user->USR_UID ]); - $delegation = factory(Delegation::class)->create([ + $delegation = Delegation::factory()->create([ 'APP_UID' => $application->APP_UID ]); $varName = "/tmp/test.pdf"; @@ -266,11 +266,11 @@ class CasesTest extends TestCase */ public function test_exception_upload_document_to_case_method() { - $user = factory(User::class)->create(); - $application = factory(Application::class)->create([ + $user = User::factory()->create(); + $application = Application::factory()->create([ 'APP_CUR_USER' => $user->USR_UID ]); - $delegation = factory(Delegation::class)->create([ + $delegation = Delegation::factory()->create([ 'APP_UID' => $application->APP_UID ]); $varName = "/tmp/test.pdf"; diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Services/Api/LightTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Services/Api/LightTest.php index d8d9aeb05..3aa3a5590 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Services/Api/LightTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Services/Api/LightTest.php @@ -32,9 +32,10 @@ class LightTest extends TestCase * This is using instead of DatabaseTransactions * @todo DatabaseTransactions is having conflicts with propel */ - protected function setUp() + public function setUp(): void { parent::setUp(); + $this->truncateNonInitialModels(); $this->workspace = env("DB_DATABASE", "test"); $this->clientId = config("oauthClients.pm.clientId"); $this->clientSecret = config("oauthClients.pm.clientSecret"); @@ -126,7 +127,7 @@ class LightTest extends TestCase $faker = $faker = Factory::create(); //Create process - $process = factory(Process::class)->create(); + $process = Process::factory()->create(); //Tasks created in the factory process are cleaned because it does not meet the test rules Task::where('PRO_UID', $process->PRO_UID)->delete(); @@ -137,14 +138,14 @@ class LightTest extends TestCase ->first(); //Create a task self service - $task = factory(Task::class)->create([ + $task = Task::factory()->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([ + TaskUser::factory(1)->create([ 'TAS_UID' => $task->TAS_UID, 'USR_UID' => $user->USR_UID, 'TU_RELATION' => 1, //Related to the user @@ -155,7 +156,7 @@ class LightTest extends TestCase ListUnassigned::truncate(); //Create a record in list unassigned - $listUnassigned = factory(ListUnassigned::class, 15)->create([ + $listUnassigned = ListUnassigned::factory(15)->create([ 'TAS_ID' => $task->TAS_ID, 'DEL_PREVIOUS_USR_UID' => $user->USR_UID ]); diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Services/Api/MetricsTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Services/Api/MetricsTest.php index 55c28af22..324ba808e 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Services/Api/MetricsTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Services/Api/MetricsTest.php @@ -2,7 +2,6 @@ namespace Tests\unit\workflow\engine\src\ProcessMaker\Services\Api; -use Illuminate\Foundation\Testing\DatabaseTransactions; use Luracast\Restler\Data\ApiMethodInfo; use Luracast\Restler\Defaults; use Luracast\Restler\HumanReadableCache; @@ -30,15 +29,13 @@ use Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel\Cases\UnassignedTe */ class MetricsTest extends TestCase { - use DatabaseTransactions; - /** * Method set up. */ - public function setUp() + public function setUp(): void { parent::setUp(); - Delegation::truncate(); + $this->truncateNonInitialModels(); } /** * Initialize Rest API. @@ -88,9 +85,7 @@ class MetricsTest extends TestCase */ public function it_tests_get_counters_list_method_empty_lists() { - ApplicationModel::truncate(); - - $user = factory(\ProcessMaker\Model\User::class)->create(); + $user = \ProcessMaker\Model\User::factory()->create(); $this->initializeRestApi($user->USR_UID); $metrics = new Metrics(); @@ -172,7 +167,7 @@ class MetricsTest extends TestCase */ public function it_tests_get_process_total_cases_inbox() { - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_PREVIOUS' => 1, 'DEL_INDEX' => 2, @@ -189,8 +184,8 @@ class MetricsTest extends TestCase */ public function it_tests_get_process_total_cases_draft() { - $application = factory(ApplicationModel::class)->states('draft')->create(); - factory(Delegation::class)->states('foreign_keys')->create([ + $application = ApplicationModel::factory()->draft()->create(); + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 1, 'USR_UID' => $application->APP_INIT_USER, @@ -210,22 +205,22 @@ class MetricsTest extends TestCase */ public function it_tests_get_process_total_cases_paused() { - $process1 = factory(Process::class)->create( + $process1 = Process::factory()->create( ['PRO_CATEGORY' => '1'] ); - $process2 = factory(Process::class)->create( + $process2 = Process::factory()->create( ['PRO_CATEGORY' => '2'] ); - $user = factory(User::class)->create(); - $task = factory(Task::class)->create([ + $user = User::factory()->create(); + $task = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => '', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process1->PRO_UID, 'TAS_TYPE' => 'NORMAL' ]); - $application1 = factory(ApplicationModel::class)->create(); - $application2 = factory(ApplicationModel::class)->create(); - factory(Delegation::class)->create([ + $application1 = ApplicationModel::factory()->create(); + $application2 = ApplicationModel::factory()->create(); + Delegation::factory()->create([ 'APP_NUMBER' => $application1->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, 'DEL_THREAD_STATUS' => 'CLOSED', @@ -236,7 +231,7 @@ class MetricsTest extends TestCase 'DEL_PREVIOUS' => 0, 'DEL_INDEX' => 1 ]); - $delegation1 = factory(Delegation::class)->create([ + $delegation1 = Delegation::factory()->create([ 'APP_NUMBER' => $application1->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, 'DEL_THREAD_STATUS' => 'CLOSED', @@ -247,7 +242,7 @@ class MetricsTest extends TestCase 'DEL_PREVIOUS' => 1, 'DEL_INDEX' => 2 ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_NUMBER' => $application2->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, 'DEL_THREAD_STATUS' => 'OPEN', @@ -258,7 +253,7 @@ class MetricsTest extends TestCase 'DEL_PREVIOUS' => 0, 'DEL_INDEX' => 1 ]); - $delegation2 = factory(Delegation::class)->create([ + $delegation2 = Delegation::factory()->create([ 'APP_NUMBER' => $application2->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, 'DEL_THREAD_STATUS' => 'OPEN', @@ -269,7 +264,7 @@ class MetricsTest extends TestCase 'DEL_PREVIOUS' => 1, 'DEL_INDEX' => 2 ]); - factory(AppDelay::class, 5)->create([ + AppDelay::factory(5)->create([ 'APP_DELEGATION_USER' => $user->USR_UID, 'PRO_UID' => $process2->PRO_UID, 'APP_NUMBER' => $delegation1->APP_NUMBER, @@ -277,7 +272,7 @@ class MetricsTest extends TestCase 'APP_DISABLE_ACTION_USER' => 0, 'APP_TYPE' => 'PAUSE' ]); - factory(AppDelay::class, 5)->create([ + AppDelay::factory(5)->create([ 'APP_DELEGATION_USER' => $user->USR_UID, 'PRO_UID' => $process2->PRO_UID, 'APP_NUMBER' => $delegation2->APP_NUMBER, @@ -297,24 +292,24 @@ class MetricsTest extends TestCase */ public function it_tests_get_process_total_cases_unassigned() { - $user = factory(\ProcessMaker\Model\User::class)->create(); - $process = factory(Process::class)->create(); - $application = factory(ApplicationModel::class)->create([ + $user = \ProcessMaker\Model\User::factory()->create(); + $process = Process::factory()->create(); + $application = ApplicationModel::factory()->create([ 'APP_STATUS_ID' => 2 ]); - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID, 'PRO_ID' => $process->PRO_ID, ]); - factory(TaskUser::class)->create([ + TaskUser::factory()->create([ 'TAS_UID' => $task->TAS_UID, 'USR_UID' => $user->USR_UID, 'TU_RELATION' => 1, 'TU_TYPE' => 1 ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, 'PRO_ID' => $process->PRO_ID, @@ -334,7 +329,7 @@ class MetricsTest extends TestCase */ public function it_tests_get_total_cases_by_range_inbox() { - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_PREVIOUS' => 1, 'DEL_INDEX' => 2, @@ -351,8 +346,8 @@ class MetricsTest extends TestCase */ public function it_tests_get_total_cases_by_range_draft() { - $application = factory(ApplicationModel::class)->states('draft')->create(); - factory(Delegation::class)->states('foreign_keys')->create([ + $application = ApplicationModel::factory()->draft()->create(); + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 1, 'USR_UID' => $application->APP_INIT_USER, @@ -372,22 +367,22 @@ class MetricsTest extends TestCase */ public function it_tests_get_total_cases_by_range_paused() { - $process1 = factory(Process::class)->create( + $process1 = Process::factory()->create( ['PRO_CATEGORY' => '1'] ); - $process2 = factory(Process::class)->create( + $process2 = Process::factory()->create( ['PRO_CATEGORY' => '2'] ); - $user = factory(User::class)->create(); - $task = factory(Task::class)->create([ + $user = User::factory()->create(); + $task = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => '', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process1->PRO_UID, 'TAS_TYPE' => 'NORMAL' ]); - $application1 = factory(ApplicationModel::class)->create(); - $application2 = factory(ApplicationModel::class)->create(); - factory(Delegation::class)->create([ + $application1 = ApplicationModel::factory()->create(); + $application2 = ApplicationModel::factory()->create(); + Delegation::factory()->create([ 'APP_NUMBER' => $application1->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, 'DEL_THREAD_STATUS' => 'CLOSED', @@ -398,7 +393,7 @@ class MetricsTest extends TestCase 'DEL_PREVIOUS' => 0, 'DEL_INDEX' => 1 ]); - $delegation1 = factory(Delegation::class)->create([ + $delegation1 = Delegation::factory()->create([ 'APP_NUMBER' => $application1->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, 'DEL_THREAD_STATUS' => 'CLOSED', @@ -409,7 +404,7 @@ class MetricsTest extends TestCase 'DEL_PREVIOUS' => 1, 'DEL_INDEX' => 2 ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_NUMBER' => $application2->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, 'DEL_THREAD_STATUS' => 'OPEN', @@ -420,7 +415,7 @@ class MetricsTest extends TestCase 'DEL_PREVIOUS' => 0, 'DEL_INDEX' => 1 ]); - $delegation2 = factory(Delegation::class)->create([ + $delegation2 = Delegation::factory()->create([ 'APP_NUMBER' => $application2->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, 'DEL_THREAD_STATUS' => 'OPEN', @@ -431,7 +426,7 @@ class MetricsTest extends TestCase 'DEL_PREVIOUS' => 1, 'DEL_INDEX' => 2 ]); - factory(AppDelay::class, 5)->create([ + AppDelay::factory(5)->create([ 'APP_DELEGATION_USER' => $user->USR_UID, 'PRO_UID' => $process2->PRO_UID, 'APP_NUMBER' => $delegation1->APP_NUMBER, @@ -439,7 +434,7 @@ class MetricsTest extends TestCase 'APP_DISABLE_ACTION_USER' => 0, 'APP_TYPE' => 'PAUSE' ]); - factory(AppDelay::class, 5)->create([ + AppDelay::factory(5)->create([ 'APP_DELEGATION_USER' => $user->USR_UID, 'PRO_UID' => $process2->PRO_UID, 'APP_NUMBER' => $delegation2->APP_NUMBER, @@ -459,24 +454,24 @@ class MetricsTest extends TestCase */ public function it_tests_get_total_cases_by_range_unassigned() { - $user = factory(\ProcessMaker\Model\User::class)->create(); - $process = factory(Process::class)->create(); - $application = factory(ApplicationModel::class)->create([ + $user = \ProcessMaker\Model\User::factory()->create(); + $process = Process::factory()->create(); + $application = ApplicationModel::factory()->create([ 'APP_STATUS_ID' => 2 ]); - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID, 'PRO_ID' => $process->PRO_ID, ]); - factory(TaskUser::class)->create([ + TaskUser::factory()->create([ 'TAS_UID' => $task->TAS_UID, 'USR_UID' => $user->USR_UID, 'TU_RELATION' => 1, 'TU_TYPE' => 1 ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, 'PRO_ID' => $process->PRO_ID, @@ -496,8 +491,8 @@ class MetricsTest extends TestCase */ public function it_tests_get_cases_risk_by_process_inbox() { - $process = factory(Process::class)->create(); - $delegation = factory(Delegation::class)->states('foreign_keys')->create([ + $process = Process::factory()->create(); + $delegation = Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_PREVIOUS' => 1, 'DEL_INDEX' => 2, @@ -517,9 +512,9 @@ class MetricsTest extends TestCase */ public function it_tests_get_cases_risk_by_process_draft() { - $process = factory(Process::class)->create(); - $application = factory(ApplicationModel::class)->states('draft')->create(); - $delegation = factory(Delegation::class)->states('foreign_keys')->create([ + $process = Process::factory()->create(); + $application = ApplicationModel::factory()->draft()->create(); + $delegation = Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_INDEX' => 1, 'USR_UID' => $application->APP_INIT_USER, @@ -542,22 +537,22 @@ class MetricsTest extends TestCase */ public function it_tests_get_cases_risk_by_process_paused() { - $process1 = factory(Process::class)->create( + $process1 = Process::factory()->create( ['PRO_CATEGORY' => '1'] ); - $process2 = factory(Process::class)->create( + $process2 = Process::factory()->create( ['PRO_CATEGORY' => '2'] ); - $user = factory(User::class)->create(); - $task = factory(Task::class)->create([ + $user = User::factory()->create(); + $task = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => '', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process1->PRO_UID, 'TAS_TYPE' => 'NORMAL' ]); - $application1 = factory(ApplicationModel::class)->create(); - $application2 = factory(ApplicationModel::class)->create(); - factory(Delegation::class)->create([ + $application1 = ApplicationModel::factory()->create(); + $application2 = ApplicationModel::factory()->create(); + Delegation::factory()->create([ 'APP_NUMBER' => $application1->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, 'DEL_THREAD_STATUS' => 'CLOSED', @@ -570,7 +565,7 @@ class MetricsTest extends TestCase 'DEL_RISK_DATE' => date('Y-m-d H:i:s'), 'DEL_TASK_DUE_DATE' => date('Y-m-d H:i:s', strtotime("+1 hour")) ]); - $delegation1 = factory(Delegation::class)->create([ + $delegation1 = Delegation::factory()->create([ 'APP_NUMBER' => $application1->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, 'DEL_THREAD_STATUS' => 'CLOSED', @@ -583,7 +578,7 @@ class MetricsTest extends TestCase 'DEL_RISK_DATE' => date('Y-m-d H:i:s'), 'DEL_TASK_DUE_DATE' => date('Y-m-d H:i:s', strtotime("+1 hour")) ]); - factory(Delegation::class)->create([ + Delegation::factory()->create([ 'APP_NUMBER' => $application2->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, 'DEL_THREAD_STATUS' => 'OPEN', @@ -596,7 +591,7 @@ class MetricsTest extends TestCase 'DEL_RISK_DATE' => date('Y-m-d H:i:s'), 'DEL_TASK_DUE_DATE' => date('Y-m-d H:i:s', strtotime("+1 hour")) ]); - $delegation2 = factory(Delegation::class)->create([ + $delegation2 = Delegation::factory()->create([ 'APP_NUMBER' => $application2->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, 'DEL_THREAD_STATUS' => 'OPEN', @@ -609,7 +604,7 @@ class MetricsTest extends TestCase 'DEL_RISK_DATE' => date('Y-m-d H:i:s'), 'DEL_TASK_DUE_DATE' => date('Y-m-d H:i:s', strtotime("+1 hour")) ]); - factory(AppDelay::class, 5)->create([ + AppDelay::factory(5)->create([ 'APP_DELEGATION_USER' => $user->USR_UID, 'PRO_UID' => $process2->PRO_UID, 'APP_NUMBER' => $delegation1->APP_NUMBER, @@ -617,7 +612,7 @@ class MetricsTest extends TestCase 'APP_DISABLE_ACTION_USER' => 0, 'APP_TYPE' => 'PAUSE' ]); - factory(AppDelay::class, 5)->create([ + AppDelay::factory(5)->create([ 'APP_DELEGATION_USER' => $user->USR_UID, 'PRO_UID' => $process2->PRO_UID, 'APP_NUMBER' => $delegation2->APP_NUMBER, @@ -637,24 +632,24 @@ class MetricsTest extends TestCase */ public function it_tests_get_cases_risk_by_process_unassigned() { - $user = factory(\ProcessMaker\Model\User::class)->create(); - $process = factory(Process::class)->create(); - $application = factory(ApplicationModel::class)->create([ + $user = \ProcessMaker\Model\User::factory()->create(); + $process = Process::factory()->create(); + $application = ApplicationModel::factory()->create([ 'APP_STATUS_ID' => 2 ]); - $task = factory(Task::class)->create([ + $task = Task::factory()->create([ 'TAS_ASSIGN_TYPE' => 'SELF_SERVICE', 'TAS_GROUP_VARIABLE' => '', 'PRO_UID' => $process->PRO_UID, 'PRO_ID' => $process->PRO_ID, ]); - factory(TaskUser::class)->create([ + TaskUser::factory()->create([ 'TAS_UID' => $task->TAS_UID, 'USR_UID' => $user->USR_UID, 'TU_RELATION' => 1, 'TU_TYPE' => 1 ]); - $delegation = factory(Delegation::class)->create([ + $delegation = Delegation::factory()->create([ 'APP_NUMBER' => $application->APP_NUMBER, 'TAS_ID' => $task->TAS_ID, 'PRO_ID' => $process->PRO_ID, @@ -677,13 +672,13 @@ class MetricsTest extends TestCase */ public function it_tests_get_process_total_cases_exception() { - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_PREVIOUS' => 1, 'DEL_INDEX' => 2, ]); $metrics = new Metrics(); - $this->expectExceptionMessage("Undefined variable: list"); + $this->expectExceptionMessage('Undefined variable $list'); $metrics->getProcessTotalCases(12, 123, "asda"); } @@ -694,13 +689,13 @@ class MetricsTest extends TestCase */ public function it_tests_get_total_cases_by_range_exception() { - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_PREVIOUS' => 1, 'DEL_INDEX' => 2, ]); $metrics = new Metrics(); - $this->expectExceptionMessage("Undefined variable: list"); + $this->expectExceptionMessage('Undefined variable $list'); $metrics->getTotalCasesByRange(12, 123, "asda"); } @@ -711,13 +706,13 @@ class MetricsTest extends TestCase */ public function it_tests_get_counters_list_exception() { - factory(Delegation::class)->states('foreign_keys')->create([ + Delegation::factory()->foreign_keys()->create([ 'DEL_THREAD_STATUS' => 'OPEN', 'DEL_PREVIOUS' => 1, 'DEL_INDEX' => 2, ]); $metrics = new Metrics(); - $this->expectExceptionMessage("Undefined variable: list"); + $this->expectExceptionMessage('Undefined variable $list'); $metrics->getCasesRiskByProcess(12, 123, "asda"); } } diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Services/Api/ProjectTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Services/Api/ProjectTest.php index cd532281e..f844d318c 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Services/Api/ProjectTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Services/Api/ProjectTest.php @@ -15,10 +15,10 @@ class ProjectTest extends TestCase { private $user; - public function setUp() + public function setUp(): void { parent::setUp(); - $this->user = factory(User::class)->create(); + $this->user = User::factory()->create(); } /** @@ -51,10 +51,9 @@ class ProjectTest extends TestCase */ public function it_should_test_the_do_get_process_method() { - $this->expectException(RestException::class); //Create user - $user = factory(User::class)->create(); - factory(RbacUsers::class)->create([ + $user = User::factory()->create(); + RbacUsers::factory()->create([ 'USR_UID' => $user->USR_UID, 'USR_USERNAME' => $user->USR_USERNAME, 'USR_FIRSTNAME' => $user->USR_FIRSTNAME, @@ -62,7 +61,7 @@ class ProjectTest extends TestCase ]); //Create process - $process = factory(Process::class)->create([ + $process = Process::factory()->create([ 'PRO_CREATE_USER' => $user->USR_UID, 'PRO_STATUS' => 'ACTIVE', 'PRO_TYPE_PROCESS' => 'PRIVATE', diff --git a/tests/unit/workflow/engine/src/ProcessMaker/TaskScheduler/TaskTest.php b/tests/unit/workflow/engine/src/ProcessMaker/TaskScheduler/TaskTest.php index bf6720f2c..53b789972 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/TaskScheduler/TaskTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/TaskScheduler/TaskTest.php @@ -23,22 +23,17 @@ class TaskTest extends TestCase /** * Method setUp. */ - protected function setUp() + public function setUp(): void { - if (version_compare(phpversion(), 7.3, '>') ) { - $this->markTestSkipped('The changes in third party are not available'); - } parent::setUp(); + $this->truncateNonInitialModels(); $this->faker = Factory::create(); - Delegation::truncate(); - AppThread::truncate(); - Application::truncate(); } /** * Method tearDown. */ - protected function tearDown() + public function tearDown(): void { parent::tearDown(); } @@ -72,7 +67,7 @@ class TaskTest extends TestCase //assert if message is contained in output buffer if ($asynchronous === false) { - $this->assertRegExp("/{$message}/", $printing); + $this->assertMatchesRegularExpression("/{$message}/", $printing); } //assert if not showing message if ($asynchronous === true) { @@ -97,7 +92,7 @@ class TaskTest extends TestCase $printing = ob_get_clean(); //assert if message is contained in output buffer if ($asynchronous === false) { - $this->assertRegExp("/{$message}/", $printing); + $this->assertMatchesRegularExpression("/{$message}/", $printing); } //assert if not showing message if ($asynchronous === true) { @@ -109,7 +104,7 @@ class TaskTest extends TestCase $printing = ob_get_clean(); //assert if message is contained in output buffer if ($asynchronous === false) { - $this->assertRegExp("/{$message}/", $printing); + $this->assertMatchesRegularExpression("/{$message}/", $printing); } //assert if not showing message if ($asynchronous === true) { @@ -121,7 +116,7 @@ class TaskTest extends TestCase $printing = ob_get_clean(); //assert if message is contained in output buffer if ($asynchronous === false) { - $this->assertRegExp("/{$message}/", $printing); + $this->assertMatchesRegularExpression("/{$message}/", $printing); } //assert if not showing message if ($asynchronous === true) { @@ -149,7 +144,7 @@ class TaskTest extends TestCase $task->saveLog('', '', $description); $contentLog = file_get_contents($file); - $this->assertRegExp("/{$description}/", $contentLog); + $this->assertMatchesRegularExpression("/{$description}/", $contentLog); } if ($asynchronous === true) { $description = $this->faker->paragraph; @@ -157,7 +152,7 @@ class TaskTest extends TestCase $task->saveLog('', '', $description); $contentLog = file_get_contents($file); - $this->assertNotRegExp("/{$description}/", $contentLog); + $this->assertDoesNotMatchRegularExpression("/{$description}/", $contentLog); } } @@ -178,7 +173,7 @@ class TaskTest extends TestCase ob_start(); $task->resendEmails('', $dateSystem); $printing = ob_get_clean(); - $this->assertRegExp("/DONE/", $printing); + $this->assertMatchesRegularExpression("/DONE/", $printing); } //assert asynchronous for job process @@ -204,16 +199,16 @@ class TaskTest extends TestCase //assert synchronous for cron file if ($asynchronous === false) { ob_start(); - $task->unpauseApplications(''); + $task->unpauseApplications(date('Y-m-d')); $printing = ob_get_clean(); - $this->assertRegExp("/DONE/", $printing); + $this->assertMatchesRegularExpression("/DONE/", $printing); } //assert asynchronous for job process if ($asynchronous === true) { Queue::fake(); Queue::assertNothingPushed(); - $task->unpauseApplications(''); + $task->unpauseApplications(date('Y-m-d')); Queue::assertPushed(TaskScheduler::class); } } @@ -234,7 +229,7 @@ class TaskTest extends TestCase ob_start(); $task->calculateDuration(); $printing = ob_get_clean(); - $this->assertRegExp("/DONE/", $printing); + $this->assertMatchesRegularExpression("/DONE/", $printing); } //assert asynchronous for job process @@ -261,7 +256,7 @@ class TaskTest extends TestCase ob_start(); $task->executeCaseSelfService(); $printing = ob_get_clean(); - $this->assertRegExp("/Unassigned case/", $printing); + $this->assertMatchesRegularExpression("/Unassigned case/", $printing); } // Assert asynchronous for job process @@ -289,7 +284,7 @@ class TaskTest extends TestCase ob_start(); $task->calculateAppDuration(); $printing = ob_get_clean(); - $this->assertRegExp("/DONE/", $printing); + $this->assertMatchesRegularExpression("/DONE/", $printing); } //assert asynchronous for job process @@ -317,7 +312,7 @@ class TaskTest extends TestCase ob_start(); $task->cleanSelfServiceTables(); $printing = ob_get_clean(); - $this->assertRegExp("/DONE/", $printing); + $this->assertMatchesRegularExpression("/DONE/", $printing); } //assert asynchronous for job process @@ -345,7 +340,7 @@ class TaskTest extends TestCase ob_start(); $task->executePlugins(); $printing = ob_get_clean(); - $this->assertRegExp("/plugins/", $printing); + $this->assertMatchesRegularExpression("/plugins/", $printing); } //assert asynchronous for job process @@ -375,7 +370,7 @@ class TaskTest extends TestCase ob_start(); $task->fillReportByUser($dateInit, $dateFinish); $printing = ob_get_clean(); - $this->assertRegExp("/User Reporting/", $printing); + $this->assertMatchesRegularExpression("/User Reporting/", $printing); } //assert asynchronous for job process @@ -405,7 +400,7 @@ class TaskTest extends TestCase ob_start(); $task->fillReportByProcess($dateInit, $dateFinish); $printing = ob_get_clean(); - $this->assertRegExp("/Process Reporting/", $printing); + $this->assertMatchesRegularExpression("/Process Reporting/", $printing); } //assert asynchronous for job process @@ -433,7 +428,7 @@ class TaskTest extends TestCase ob_start(); $task->ldapcron(false); $printing = ob_get_clean(); - $this->assertRegExp("/\+---/", $printing); + $this->assertMatchesRegularExpression("/\+---/", $printing); } //assert asynchronous for job process @@ -461,7 +456,7 @@ class TaskTest extends TestCase ob_start(); $task->sendNotifications(); $printing = ob_get_clean(); - $this->assertRegExp("/Resending Notifications/", $printing); + $this->assertMatchesRegularExpression("/Resending Notifications/", $printing); } //assert asynchronous for job process @@ -517,7 +512,7 @@ class TaskTest extends TestCase ob_start(); $task->messageeventcron(); $printing = ob_get_clean(); - $this->assertRegExp("/Message-Events/", $printing); + $this->assertMatchesRegularExpression("/Message-Events/", $printing); } //assert asynchronous for job process @@ -550,7 +545,7 @@ class TaskTest extends TestCase //Gets the result $printing = ob_get_clean(); //Asserts the result is printing that there is no exisiting records to continue a case in the determined date - $this->assertRegExp('/There are no records to start new cases, on date "' . $date . '/', $printing); + $this->assertMatchesRegularExpression('/There are no records to start new cases, on date "' . $date . '/', $printing); } //assert asynchronous for job process if ($asynchronous === true) { diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Util/Helpers/UpdateUserLastLoginTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Util/Helpers/UpdateUserLastLoginTest.php index e29379f34..1cbb8fc56 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Util/Helpers/UpdateUserLastLoginTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Util/Helpers/UpdateUserLastLoginTest.php @@ -14,7 +14,7 @@ class UpdateUserLastLoginTest extends TestCase */ public function it_should_test_the_update_last_login_date_function_when_it_does_not_fail() { - $user = factory(User::class)->create(); + $user = User::factory()->create(); $userLog = ['USR_UID' => $user['USR_UID'], 'LOG_INIT_DATE' => date('Y-m-d H:i:s')]; @@ -32,12 +32,12 @@ class UpdateUserLastLoginTest extends TestCase */ public function it_should_test_the_update_last_login_date_function_when_it_fails() { - $user = factory(User::class)->create(); + $user = User::factory()->create(); $userLog = ['USR_UID' => $user['USR_UID']]; // Assert the expected exception - $this->expectExceptionMessage("Undefined index: LOG_INIT_DATE"); + $this->expectExceptionMessage('Undefined array key "LOG_INIT_DATE"'); // Call the updateUserLastLogin function updateUserLastLogin($userLog); diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Validation/MySQL57Test.php b/tests/unit/workflow/engine/src/ProcessMaker/Validation/MySQL57Test.php index cd0a35877..49ab2fec7 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Validation/MySQL57Test.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Validation/MySQL57Test.php @@ -21,16 +21,16 @@ class MySQL57Test extends TestCase */ public function it_should_test_incompatibilities_with_dynaforms() { - $process = factory(Process::class, 2)->create(); + $process = Process::factory(2)->create(); - factory(Dynaform::class)->create( + Dynaform::factory()->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( + Dynaform::factory()->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":""}]}]}' @@ -68,16 +68,16 @@ class MySQL57Test extends TestCase */ public function it_should_test_incompatibilities_with_variables() { - $process = factory(Process::class, 2)->create(); + $process = Process::factory(2)->create(); - factory(ProcessVariables::class)->create( + ProcessVariables::factory()->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( + $variables = ProcessVariables::factory()->create( [ 'PRJ_UID' => $process[1]['PRO_UID'], 'VAR_SQL' => '', @@ -119,8 +119,8 @@ class MySQL57Test extends TestCase */ public function it_should_test_incompatibilities_with_triggers() { - $process = factory(Process::class, 3)->create(); - factory(Triggers::class)->create( + $process = Process::factory(3)->create(); + Triggers::factory()->create( [ 'PRO_UID' => $process[0]['PRO_UID'], 'TRI_WEBBOT' => '$text=222; @@ -147,14 +147,14 @@ class MySQL57Test extends TestCase ] ); - factory(Triggers::class)->create( + Triggers::factory()->create( [ 'PRO_UID' => $process[1]['PRO_UID'], 'TRI_WEBBOT' => 'die();' ] ); - factory(Triggers::class)->create( + Triggers::factory()->create( [ 'PRO_UID' => $process[2]['PRO_UID'], 'TRI_WEBBOT' => 'executeQuery("select * from USERS");' diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Validation/SqlBlacklistTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Validation/SqlBlacklistTest.php index 321be5815..4e9a927ef 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Validation/SqlBlacklistTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Validation/SqlBlacklistTest.php @@ -23,7 +23,7 @@ class SqlBlacklistTest extends TestCase /** * Method setUp. */ - public function setUp() + public function setUp(): void { parent::setUp(); $this->content = ""; @@ -36,7 +36,7 @@ class SqlBlacklistTest extends TestCase /** * Method tearDown. */ - public function tearDown() + public function tearDown(): void { parent::tearDown(); $path = PATH_CONFIG . 'execute-query-blacklist.ini'; diff --git a/tests/unit/workflow/engine/src/ProcessMaker/Validation/ValidationUploadedFilesTest.php b/tests/unit/workflow/engine/src/ProcessMaker/Validation/ValidationUploadedFilesTest.php index d4b8f2edf..037095994 100644 --- a/tests/unit/workflow/engine/src/ProcessMaker/Validation/ValidationUploadedFilesTest.php +++ b/tests/unit/workflow/engine/src/ProcessMaker/Validation/ValidationUploadedFilesTest.php @@ -14,7 +14,7 @@ class ValidationUploadedFilesTest extends TestCase /** * It copies the images for the test */ - public function setUp() + public function setUp(): void { parent::setUp(); // TODO: Change the autogenerated stub copy(PATH_HTML . 'images/1.png', PATH_DATA . '1.PNG'); @@ -22,6 +22,23 @@ class ValidationUploadedFilesTest extends TestCase copy(PATH_HTML . 'images/1.png', PATH_DATA . '1.PnG'); } + /** + * It deletes the images created + */ + public function tearDown(): void + { + parent::tearDown(); // TODO: Change the autogenerated stub + if (file_exists(PATH_DATA . '1.PNG')) { + unlink(PATH_DATA . '1.PNG'); + } + if (file_exists(PATH_DATA . '1.png')) { + unlink(PATH_DATA . '1.png'); + } + if (file_exists(PATH_DATA . '1.PnG')) { + unlink(PATH_DATA . '1.PnG'); + } + } + /** * It tests the runRules method when the file extension is in upper case * @@ -148,21 +165,4 @@ class ValidationUploadedFilesTest extends TestCase $this->assertEmpty($result->getMessage()); $this->assertEquals(0, $result->getStatus()); } - - /** - * It deletes the images created - */ - public function tearDown() - { - parent::tearDown(); // TODO: Change the autogenerated stub - if (file_exists(PATH_DATA . '1.PNG')) { - unlink(PATH_DATA . '1.PNG'); - } - if (file_exists(PATH_DATA . '1.png')) { - unlink(PATH_DATA . '1.png'); - } - if (file_exists(PATH_DATA . '1.PnG')) { - unlink(PATH_DATA . '1.PnG'); - } - } } diff --git a/thirdparty/HTMLPurifier/HTMLPurifier.autoload.php b/thirdparty/HTMLPurifier/HTMLPurifier.autoload.php index c3ea67e81..1bde22ea2 100644 --- a/thirdparty/HTMLPurifier/HTMLPurifier.autoload.php +++ b/thirdparty/HTMLPurifier/HTMLPurifier.autoload.php @@ -6,22 +6,9 @@ * It also does some sanity checks. */ -if (function_exists('spl_autoload_register') && function_exists('spl_autoload_unregister')) { - // We need unregister for our pre-registering functionality - HTMLPurifier_Bootstrap::registerAutoload(); - if (function_exists('__autoload')) { - // Be polite and ensure that userland autoload gets retained - spl_autoload_register('__autoload'); - } -} elseif (!function_exists('__autoload')) { - function __autoload($class) - { - return HTMLPurifier_Bootstrap::autoload($class); - } -} - -if (ini_get('zend.ze1_compatibility_mode')) { - trigger_error("HTML Purifier is not compatible with zend.ze1_compatibility_mode; please turn it off", E_USER_ERROR); -} +spl_autoload_register(function($class) +{ + return HTMLPurifier_Bootstrap::autoload($class); +}); // vim: et sw=4 sts=4 diff --git a/thirdparty/HTMLPurifier/HTMLPurifier/ChildDef/Custom.php b/thirdparty/HTMLPurifier/HTMLPurifier/ChildDef/Custom.php index 128132e96..f515888a1 100644 --- a/thirdparty/HTMLPurifier/HTMLPurifier/ChildDef/Custom.php +++ b/thirdparty/HTMLPurifier/HTMLPurifier/ChildDef/Custom.php @@ -45,7 +45,7 @@ class HTMLPurifier_ChildDef_Custom extends HTMLPurifier_ChildDef protected function _compileRegex() { $raw = str_replace(' ', '', $this->dtd_regex); - if ($raw{0} != '(') { + if ($raw[0] != '(') { $raw = "($raw)"; } $el = '[#a-zA-Z0-9_.-]+'; diff --git a/thirdparty/HTMLPurifier/HTMLPurifier/Config.php b/thirdparty/HTMLPurifier/HTMLPurifier/Config.php index 7ada59b94..4bf8fa19e 100644 --- a/thirdparty/HTMLPurifier/HTMLPurifier/Config.php +++ b/thirdparty/HTMLPurifier/HTMLPurifier/Config.php @@ -784,17 +784,17 @@ class HTMLPurifier_Config * @param array $array $_GET or $_POST array to import * @param string|bool $index Index/name that the config variables are in * @param array|bool $allowed List of allowed namespaces/directives - * @param bool $mq_fix Boolean whether or not to enable magic quotes fix + * @param bool $mq_fix Boolean whether or not to enable magic quotes fix (DEPRECATED, now is always in false) * @param HTMLPurifier_ConfigSchema $schema Schema to use, if not global copy * * @return array */ - public static function prepareArrayFromForm($array, $index = false, $allowed = true, $mq_fix = true, $schema = null) + public static function prepareArrayFromForm($array, $index = false, $allowed = true, $mq_fix = false, $schema = null) { if ($index !== false) { $array = (isset($array[$index]) && is_array($array[$index])) ? $array[$index] : array(); } - $mq = $mq_fix && function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc(); + $mq = $mq_fix; $allowed = HTMLPurifier_Config::getAllowedDirectivesForForm($allowed, $schema); $ret = array(); diff --git a/thirdparty/HTMLPurifier/HTMLPurifier/Encoder.php b/thirdparty/HTMLPurifier/HTMLPurifier/Encoder.php index fef9b5890..80e94a20c 100644 --- a/thirdparty/HTMLPurifier/HTMLPurifier/Encoder.php +++ b/thirdparty/HTMLPurifier/HTMLPurifier/Encoder.php @@ -154,7 +154,7 @@ class HTMLPurifier_Encoder $len = strlen($str); for ($i = 0; $i < $len; $i++) { - $in = ord($str{$i}); + $in = ord($str[$i]); $char .= $str[$i]; // append byte to char if (0 == $mState) { // When mState is zero we expect either a US-ASCII character diff --git a/thirdparty/HTMLPurifier/HTMLPurifier/Printer/HTMLDefinition.php b/thirdparty/HTMLPurifier/HTMLPurifier/Printer/HTMLDefinition.php index 5f2f2f8a7..ae8639176 100644 --- a/thirdparty/HTMLPurifier/HTMLPurifier/Printer/HTMLDefinition.php +++ b/thirdparty/HTMLPurifier/HTMLPurifier/Printer/HTMLDefinition.php @@ -43,8 +43,8 @@ class HTMLPurifier_Printer_HTMLDefinition extends HTMLPurifier_Printer $ret .= $this->element('caption', 'Doctype'); $ret .= $this->row('Name', $doctype->name); $ret .= $this->row('XML', $doctype->xml ? 'Yes' : 'No'); - $ret .= $this->row('Default Modules', implode($doctype->modules, ', ')); - $ret .= $this->row('Default Tidy Modules', implode($doctype->tidyModules, ', ')); + $ret .= $this->row('Default Modules', implode(', ', $doctype->modules)); + $ret .= $this->row('Default Tidy Modules', implode(', ', $doctype->tidyModules)); $ret .= $this->end('table'); return $ret; } diff --git a/thirdparty/HTMLPurifier/HTMLPurifier/TagTransform/Font.php b/thirdparty/HTMLPurifier/HTMLPurifier/TagTransform/Font.php index 7853d90bc..768c9b153 100644 --- a/thirdparty/HTMLPurifier/HTMLPurifier/TagTransform/Font.php +++ b/thirdparty/HTMLPurifier/HTMLPurifier/TagTransform/Font.php @@ -75,7 +75,7 @@ class HTMLPurifier_TagTransform_Font extends HTMLPurifier_TagTransform if (isset($attr['size'])) { // normalize large numbers if ($attr['size'] !== '') { - if ($attr['size']{0} == '+' || $attr['size']{0} == '-') { + if ($attr['size'][0] == '+' || $attr['size'][0] == '-') { $size = (int)$attr['size']; if ($size < -2) { $attr['size'] = '-2'; diff --git a/thirdparty/creole/Creole.php b/thirdparty/creole/Creole.php index c3ffd7ea2..ede7189a1 100644 --- a/thirdparty/creole/Creole.php +++ b/thirdparty/creole/Creole.php @@ -22,13 +22,7 @@ include_once 'creole/SQLException.php'; include_once 'creole/Connection.php'; -// static: -// track errors is used by drivers to get better error messages -// make sure it's set. - -@ini_set('track_errors', true); - - use ProcessMaker\Core\System; +use ProcessMaker\Core\System; /** * This is the class that manages the database drivers. diff --git a/thirdparty/creole/contrib/DBArrayConnection.php b/thirdparty/creole/contrib/DBArrayConnection.php index 9b8edef71..628765671 100644 --- a/thirdparty/creole/contrib/DBArrayConnection.php +++ b/thirdparty/creole/contrib/DBArrayConnection.php @@ -83,7 +83,7 @@ class DBArrayResultSet extends ResultSetCommon implements ResultSet public function getString($column) { $idx = (is_int($column) ? $column - 1 : $column); - if (!array_key_exists($idx, $this->fields)) { + if (is_array($this->fields) && !array_key_exists($idx, $this->fields)) { throw new SQLException("Invalid resultset column: " . $column); } if ($this->fields[$idx] === null) { diff --git a/thirdparty/creole/drivers/mssql/MSSQLConnection.php b/thirdparty/creole/drivers/mssql/MSSQLConnection.php index 6cd443b84..c0f8cd6c8 100644 --- a/thirdparty/creole/drivers/mssql/MSSQLConnection.php +++ b/thirdparty/creole/drivers/mssql/MSSQLConnection.php @@ -84,7 +84,9 @@ class MSSQLConnection extends ConnectionCommon implements Connection 'UID' => $user, 'PWD' => $pw, 'Database' => $dsninfo['database'], - 'CharacterSet' => 'UTF-8' + 'CharacterSet' => 'UTF-8', + 'Encrypt' => true, + 'TrustServerCertificate' => true ]; // SQLSrv is persistent always $conn = sqlsrv_connect($dbhost, $opt); diff --git a/thirdparty/creole/drivers/mysql/MySQLConnection.php b/thirdparty/creole/drivers/mysql/MySQLConnection.php deleted file mode 100644 index b41c69faa..000000000 --- a/thirdparty/creole/drivers/mysql/MySQLConnection.php +++ /dev/null @@ -1,294 +0,0 @@ -. - */ - -require_once 'creole/Connection.php'; -require_once 'creole/common/ConnectionCommon.php'; -include_once 'creole/drivers/mysql/MySQLResultSet.php'; - -/** - * MySQL implementation of Connection. - * - * - * @author Hans Lellelid - * @author Stig Bakken - * @author Lukas Smith - * @version $Revision: 1.18 $ - * @package creole.drivers.mysql - */ -class MySQLConnection extends ConnectionCommon implements Connection { - - /** Current database (used in mysql_select_db()). */ - private $database; - - /** - * Connect to a database and log in as the specified user. - * - * @param $dsn the data source name (see DB::parseDSN for syntax) - * @param $flags Any conneciton flags. - * @access public - * @throws SQLException - * @return void - */ - function connect($dsninfo, $flags = 0) - { - if (!extension_loaded('mysql')) { - throw new SQLException('mysql extension not loaded'); - } - - $this->dsn = $dsninfo; - $this->flags = $flags; - - $persistent = ($flags & Creole::PERSISTENT) === Creole::PERSISTENT; - - if (isset($dsninfo['protocol']) && $dsninfo['protocol'] == 'unix') { - $dbhost = ':' . $dsninfo['socket']; - } else { - $dbhost = $dsninfo['hostspec'] ? $dsninfo['hostspec'] : 'localhost'; - if (!empty($dsninfo['port'])) { - $dbhost .= ':' . $dsninfo['port']; - } - } - $user = $dsninfo['username']; - $pw = $dsninfo['password']; - - $encoding = !empty($dsninfo['encoding']) ? $dsninfo['encoding'] : null; - - $connect_function = $persistent ? 'mysql_pconnect' : 'mysql_connect'; - - @ini_set('track_errors', true); - if ($dbhost && $user && $pw) { - $conn = @$connect_function($dbhost, $user, $pw); - } elseif ($dbhost && $user) { - $conn = @$connect_function($dbhost, $user); - } elseif ($dbhost) { - $conn = @$connect_function($dbhost); - } else { - $conn = false; - } - @ini_restore('track_errors'); - if (empty($conn)) { - if (($err = @mysql_error()) != '') { - throw new SQLException("connect failed", $err); - } elseif (empty($php_errormsg)) { - throw new SQLException("connect failed"); - } else { - throw new SQLException("connect failed", $php_errormsg); - } - } - - if ($dsninfo['database']) { - if (!@mysql_select_db($dsninfo['database'], $conn)) { - switch(mysql_errno($conn)) { - case 1049: - $exc = new SQLException("no such database", mysql_error($conn)); - break; - case 1044: - $exc = new SQLException("access violation", mysql_error($conn)); - break; - default: - $exc = new SQLException("cannot select database", mysql_error($conn)); - } - - throw $exc; - - } - // fix to allow calls to different databases in the same script - $this->database = $dsninfo['database']; - } - - $this->dblink = $conn; - - if ($encoding) { - $this->executeUpdate("SET NAMES " . $encoding); - } - } - - /** - * @see Connection::getDatabaseInfo() - */ - public function getDatabaseInfo() - { - return new MySQLDatabaseInfo($this); - } - - /** - * @see Connection::getIdGenerator() - */ - public function getIdGenerator() - { - return new MySQLIdGenerator($this); - } - - /** - * @see Connection::prepareStatement() - */ - public function prepareStatement($sql) - { - return new MySQLPreparedStatement($this, $sql); - } - - /** - * @see Connection::prepareCall() - */ - public function prepareCall($sql) { - throw new SQLException('MySQL does not support stored procedures.'); - } - - /** - * @see Connection::createStatement() - */ - public function createStatement() - { - return new MySQLStatement($this); - } - - /** - * @see Connection::disconnect() - */ - function close() - { - $ret = mysql_close($this->dblink); - $this->dblink = null; - return $ret; - } - - /** - * @see Connection::applyLimit() - */ - public function applyLimit(&$sql, $offset, $limit) - { - if ( $limit > 0 ) { - $sql .= " LIMIT " . ($offset > 0 ? $offset . ", " : "") . $limit; - } else if ( $offset > 0 ) { - $sql .= " LIMIT " . $offset . ", 18446744073709551615"; - } - } - - /** - * @see Connection::executeQuery() - */ - function executeQuery($sql, $fetchmode = null) - { - $this->lastQuery = $sql; - if ($this->database) { - if (!@mysql_select_db($this->database, $this->dblink)) { - throw new SQLException('No database selected', mysql_error($this->dblink)); - } - }//echo $sql . '

'; - $result = @mysql_query($sql, $this->dblink); - - if (!$result) { - if (!defined('DEBUG_SQL')) { - define('DEBUG_SQL', 0); - } - if (DEBUG_SQL == 1) { - throw new SQLException('Could not execute query', mysql_error($this->dblink), $sql); - } else { - throw new SQLException('It is not possible to execute the query. Please contact your system administrator'); - } - } - return new MySQLResultSet($this, $result, $fetchmode); - } - - /** - * @see Connection::executeUpdate() - */ - function executeUpdate($sql) - { - $this->lastQuery = $sql; - - if ($this->database) { - if (!@mysql_select_db($this->database, $this->dblink)) { - throw new SQLException('No database selected', mysql_error($this->dblink)); - } - } - - $result = @mysql_query($sql, $this->dblink); - if (!$result) { - throw new SQLException('Could not execute update', mysql_error($this->dblink), $sql); - } - return (int) mysql_affected_rows($this->dblink); - } - - /** - * Start a database transaction. - * @throws SQLException - * @return void - */ - protected function beginTrans() - { - $result = @mysql_query('SET AUTOCOMMIT=0', $this->dblink); - $result = @mysql_query('BEGIN', $this->dblink); - if (!$result) { - throw new SQLException('Could not begin transaction', mysql_error($this->dblink)); - } - } - - /** - * Commit the current transaction. - * @throws SQLException - * @return void - */ - protected function commitTrans() - { - if ($this->database) { - if (!@mysql_select_db($this->database, $this->dblink)) { - throw new SQLException('No database selected', mysql_error($this->dblink)); - } - } - $result = @mysql_query('COMMIT', $this->dblink); - $result = @mysql_query('SET AUTOCOMMIT=1', $this->dblink); - if (!$result) { - throw new SQLException('Can not commit transaction', mysql_error($this->dblink)); - } - } - - /** - * Roll back (undo) the current transaction. - * @throws SQLException - * @return void - */ - protected function rollbackTrans() - { - if ($this->database) { - if (!@mysql_select_db($this->database, $this->dblink)) { - throw new SQLException('No database selected', mysql_error($this->dblink)); - } - } - $result = @mysql_query('ROLLBACK', $this->dblink); - $result = @mysql_query('SET AUTOCOMMIT=1', $this->dblink); - if (!$result) { - throw new SQLException('Could not rollback transaction', mysql_error($this->dblink)); - } - } - - /** - * Gets the number of rows affected by the data manipulation - * query. - * - * @return int Number of rows affected by the last query. - */ - function getUpdateCount() - { - return (int) @mysql_affected_rows($this->dblink); - } - -} diff --git a/thirdparty/creole/drivers/mysql/MySQLIdGenerator.php b/thirdparty/creole/drivers/mysql/MySQLIdGenerator.php deleted file mode 100644 index db211ae11..000000000 --- a/thirdparty/creole/drivers/mysql/MySQLIdGenerator.php +++ /dev/null @@ -1,75 +0,0 @@ - - * @version $Revision: 1.6 $ - * @package creole.drivers.mysql - */ -class MySQLIdGenerator implements IdGenerator { - - /** Connection object that instantiated this class */ - private $conn; - - /** - * Creates a new IdGenerator class, saves passed connection for use - * later by getId() method. - * @param Connection $conn - */ - public function __construct(Connection $conn) - { - $this->conn = $conn; - } - - /** - * @see IdGenerator::isBeforeInsert() - */ - public function isBeforeInsert() - { - return false; - } - - /** - * @see IdGenerator::isAfterInsert() - */ - public function isAfterInsert() - { - return true; - } - - /** - * @see IdGenerator::getIdMethod() - */ - public function getIdMethod() - { - return self::AUTOINCREMENT; - } - - /** - * Returns last-generated auto-increment ID. - * - * Note that for very large values (2,147,483,648 to 9,223,372,036,854,775,807) a string - * will be returned, because these numbers are larger than supported by PHP's native - * numeric datatypes. - * - * @see IdGenerator::getId() - */ - public function getId($unused = null) - { - $insert_id = mysql_insert_id($this->conn->getResource()); - if ( $insert_id < 0 ) { - $insert_id = null; - $result = mysql_query('SELECT LAST_INSERT_ID()', $this->conn->getResource()); - if ( $result ) { - $row = mysql_fetch_row($result); - $insert_id = $row ? $row[0] : null; - } - } - return $insert_id; - } - -} - diff --git a/thirdparty/creole/drivers/mysql/MySQLPreparedStatement.php b/thirdparty/creole/drivers/mysql/MySQLPreparedStatement.php deleted file mode 100644 index a56f4d4e2..000000000 --- a/thirdparty/creole/drivers/mysql/MySQLPreparedStatement.php +++ /dev/null @@ -1,44 +0,0 @@ -. - */ - -require_once 'creole/PreparedStatement.php'; -require_once 'creole/common/PreparedStatementCommon.php'; - -/** - * MySQL subclass for prepared statements. - * - * @author Hans Lellelid - * @version $Revision: 1.7 $ - * @package creole.drivers.mysql - */ -class MySQLPreparedStatement extends PreparedStatementCommon implements PreparedStatement { - - /** - * Quotes string using native mysql function (mysql_real_escape_string()). - * @param string $str - * @return string - */ - protected function escape($str) - { - return mysql_real_escape_string($str, $this->conn->getResource()); - } - -} diff --git a/thirdparty/creole/drivers/mysql/MySQLResultSet.php b/thirdparty/creole/drivers/mysql/MySQLResultSet.php deleted file mode 100644 index 99586d29d..000000000 --- a/thirdparty/creole/drivers/mysql/MySQLResultSet.php +++ /dev/null @@ -1,165 +0,0 @@ -. - */ - -require_once 'creole/ResultSet.php'; -require_once 'creole/common/ResultSetCommon.php'; - -/** - * MySQL implementation of ResultSet class. - * - * MySQL supports OFFSET / LIMIT natively; this means that no adjustments or checking - * are performed. We will assume that if the lmitSQL() operation failed that an - * exception was thrown, and that OFFSET/LIMIT will never be emulated for MySQL. - * - * @author Hans Lellelid - * @version $Revision: 1.24 $ - * @package creole.drivers.mysql - */ -class MySQLResultSet extends ResultSetCommon implements ResultSet { - - /** - * @see ResultSet::seek() - */ - public function seek($rownum) - { - // MySQL rows start w/ 0, but this works, because we are - // looking to move the position _before_ the next desired position - if (!@mysql_data_seek($this->result, $rownum)) { - return false; - } - $this->cursorPos = $rownum; - return true; - } - - /** - * @see ResultSet::next() - */ - public function next() - { - $this->fields = mysql_fetch_array($this->result, $this->fetchmode); - - if (!$this->fields) { - $errno = mysql_errno($this->conn->getResource()); - if (!$errno) { - // We've advanced beyond end of recordset. - $this->afterLast(); - return false; - } else { - throw new SQLException("Error fetching result", mysql_error($this->conn->getResource())); - } - } - /*else { - if (is_array($this->fields)) { - foreach ($this->fields as $sKey => $sValue) { - if (function_exists('mb_detect_encoding')) { - if (strtoupper(mb_detect_encoding($sValue)) == 'UTF-8') { - $this->fields[$sKey] = utf8_encode($sValue); - } - } - } - } - }*/ - - if ($this->fetchmode === ResultSet::FETCHMODE_ASSOC && $this->lowerAssocCase) { - $this->fields = array_change_key_case($this->fields, CASE_LOWER); - } - - // Advance cursor position - $this->cursorPos++; - return true; - } - - /** - * @see ResultSet::getRecordCount() - */ - function getRecordCount() - { - $rows = @mysql_num_rows($this->result); - if ($rows === null) { - throw new SQLException("Error fetching num rows", mysql_error($this->conn->getResource())); - } - return (int) $rows; - } - - /** - * @see ResultSet::close() - */ - function close() - { - if(is_resource($this->result)) - @mysql_free_result($this->result); - $this->fields = array(); - } - - /** - * Get string version of column. - * No rtrim() necessary for MySQL, as this happens natively. - * @see ResultSet::getString() - */ - public function getString($column) - { - $idx = (is_int($column) ? $column - 1 : $column); - if (!array_key_exists($idx, $this->fields)) { throw new SQLException("Invalid resultset column: " . $column); } - if ($this->fields[$idx] === null) { return null; } - return (string) $this->fields[$idx]; - } - - /** - * Returns a unix epoch timestamp based on either a TIMESTAMP or DATETIME field. - * @param mixed $column Column name (string) or index (int) starting with 1. - * @return string - * @throws SQLException - If the column specified is not a valid key in current field array. - */ - function getTimestamp($column, $format='Y-m-d H:i:s') - { - if (is_int($column)) { $column--; } // because Java convention is to start at 1 - if (!array_key_exists($column, $this->fields)) { throw new SQLException("Invalid resultset column: " . (is_int($column) ? $column + 1 : $column)); } - if ($this->fields[$column] === null) { return null; } - - if (($this->fields[$column] == '0000-00-00 00:00:00') || ($this->fields[$column] == '0000-00-00')) { - $ts = '943916400'; - } - else { - $ts = strtotime($this->fields[$column]); - } - if ($ts === -1 || $ts === false) { // in PHP 5.1 return value changes to FALSE - // otherwise it's an ugly MySQL timestamp! - // YYYYMMDDHHMMSS - if (preg_match('/([\d]{4})([\d]{2})([\d]{2})([\d]{2})([\d]{2})([\d]{2})/', $this->fields[$column], $matches)) { - // YYYY MM DD HH MM SS - // $1 $2 $3 $4 $5 $6 - $ts = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); - } - } - if ($ts === -1 || $ts === false) { // if it's still -1, then there's nothing to be done; use a different method. - throw new SQLException("Unable to convert value at column " . (is_int($column) ? $column + 1 : $column) . " to timestamp: " . $this->fields[$column]); - } - if ($format === null) { - return $ts; - } - if (strpos($format, '%') !== false) { - return strftime($format, $ts); - } else { - return date($format, $ts); - } - } - -} diff --git a/thirdparty/creole/drivers/mysql/MySQLStatement.php b/thirdparty/creole/drivers/mysql/MySQLStatement.php deleted file mode 100644 index fbd3e2482..000000000 --- a/thirdparty/creole/drivers/mysql/MySQLStatement.php +++ /dev/null @@ -1,36 +0,0 @@ -. - */ - -require_once 'creole/Statement.php'; -require_once 'creole/common/StatementCommon.php'; - -/** - * MySQL Statement - * - * @author Hans Lellelid - * @author Stig Bakken - * @author Lukas Smith - * @version $Revision: 1.1 $ - * @package creole.drivers.mysql - */ -class MySQLStatement extends StatementCommon implements Statement { - -} diff --git a/thirdparty/creole/drivers/mysql/MySQLTypes.php b/thirdparty/creole/drivers/mysql/MySQLTypes.php deleted file mode 100644 index 27205e039..000000000 --- a/thirdparty/creole/drivers/mysql/MySQLTypes.php +++ /dev/null @@ -1,102 +0,0 @@ -. - */ - -require_once 'creole/CreoleTypes.php'; - -/** - * MySQL types / type map. - * - * @author Hans Lellelid - * @version $Revision: 1.8 $ - * @package creole.drivers.mysql - */ -class MySQLTypes extends CreoleTypes { - - /** Map MySQL native types to Creole (JDBC) types. */ - private static $typeMap = array( - 'tinyint' => CreoleTypes::TINYINT, - 'smallint' => CreoleTypes::SMALLINT, - 'mediumint' => CreoleTypes::SMALLINT, - 'int' => CreoleTypes::INTEGER, - 'integer' => CreoleTypes::INTEGER, - 'bigint' => CreoleTypes::BIGINT, - 'int24' => CreoleTypes::BIGINT, - 'real' => CreoleTypes::REAL, - 'float' => CreoleTypes::FLOAT, - 'decimal' => CreoleTypes::DECIMAL, - 'numeric' => CreoleTypes::NUMERIC, - 'double' => CreoleTypes::DOUBLE, - 'char' => CreoleTypes::CHAR, - 'varchar' => CreoleTypes::VARCHAR, - 'date' => CreoleTypes::DATE, - 'time' => CreoleTypes::TIME, - 'year' => CreoleTypes::YEAR, - 'datetime' => CreoleTypes::TIMESTAMP, - 'timestamp' => CreoleTypes::TIMESTAMP, - 'tinyblob' => CreoleTypes::BINARY, - 'blob' => CreoleTypes::VARBINARY, - 'mediumblob' => CreoleTypes::VARBINARY, - 'longblob' => CreoleTypes::VARBINARY, - 'longtext' => CreoleTypes::LONGVARCHAR, - 'tinytext' => CreoleTypes::VARCHAR, - 'mediumtext' => CreoleTypes::LONGVARCHAR, - 'text' => CreoleTypes::LONGVARCHAR, - 'enum' => CreoleTypes::CHAR, - 'set' => CreoleTypes::CHAR, - ); - - /** Reverse mapping, created on demand. */ - private static $reverseMap = null; - - /** - * This method returns the generic Creole (JDBC-like) type - * when given the native db type. - * @param string $nativeType DB native type (e.g. 'TEXT', 'byetea', etc.). - * @return int Creole native type (e.g. CreoleTypes::LONGVARCHAR, CreoleTypes::BINARY, etc.). - */ - public static function getType($nativeType) - { - $t = strtolower($nativeType); - if (isset(self::$typeMap[$t])) { - return self::$typeMap[$t]; - } else { - return CreoleTypes::OTHER; - } - } - - /** - * This method will return a native type that corresponds to the specified - * Creole (JDBC-like) type. - * If there is more than one matching native type, then the LAST defined - * native type will be returned. - * @param int $creoleType - * @return string Native type string. - */ - public static function getNativeType($creoleType) - { - if (self::$reverseMap === null) { - self::$reverseMap = array_flip(self::$typeMap); - } - return @self::$reverseMap[$creoleType]; - } - -} \ No newline at end of file diff --git a/thirdparty/creole/drivers/mysql/metadata/MySQLDatabaseInfo.php b/thirdparty/creole/drivers/mysql/metadata/MySQLDatabaseInfo.php deleted file mode 100644 index 0e032cc2c..000000000 --- a/thirdparty/creole/drivers/mysql/metadata/MySQLDatabaseInfo.php +++ /dev/null @@ -1,66 +0,0 @@ -. - */ - -require_once 'creole/metadata/DatabaseInfo.php'; - -/** - * MySQL implementation of DatabaseInfo. - * - * @author Hans Lellelid - * @version $Revision: 1.13 $ - * @package creole.drivers.mysql.metadata - */ -class MySQLDatabaseInfo extends DatabaseInfo { - - /** - * @throws SQLException - * @return void - */ - protected function initTables() - { - include_once 'creole/drivers/mysql/metadata/MySQLTableInfo.php'; - // using $this->dblink was causing tests to break - // perhaps dblink is changed by another test ... ? - $result = @mysql_query("SHOW TABLES FROM `" . $this->dbname . "`", $this->conn->getResource()); - - if (!$result) { - throw new SQLException("Could not list tables", mysql_error($this->conn->getResource())); - } - - while ($row = mysql_fetch_row($result)) { - $this->tables[strtoupper($row[0])] = new MySQLTableInfo($this, $row[0]); - } - - $this->tablesLoaded = true; - - } - - /** - * MySQL does not support sequences. - * - * @return void - * @throws SQLException - */ - protected function initSequences() - { - // throw new SQLException("MySQL does not support sequences natively."); - } -} diff --git a/thirdparty/creole/drivers/mysql/metadata/MySQLTableInfo.php b/thirdparty/creole/drivers/mysql/metadata/MySQLTableInfo.php deleted file mode 100644 index 18d412747..000000000 --- a/thirdparty/creole/drivers/mysql/metadata/MySQLTableInfo.php +++ /dev/null @@ -1,252 +0,0 @@ -. - */ - -require_once 'creole/metadata/TableInfo.php'; - -/** - * MySQL implementation of TableInfo. - * - * @author Hans Lellelid - * @version $Revision: 1.20 $ - * @package creole.drivers.mysql.metadata - */ -class MySQLTableInfo extends TableInfo { - - /** Loads the columns for this table. */ - protected function initColumns() - { - include_once 'creole/metadata/ColumnInfo.php'; - include_once 'creole/drivers/mysql/MySQLTypes.php'; - - if (!@mysql_select_db($this->dbname, $this->conn->getResource())) { - throw new SQLException('No database selected'); - } - - // To get all of the attributes we need, we use - // the MySQL "SHOW COLUMNS FROM $tablename" SQL. We cannot - // use the API functions (e.g. mysql_list_fields() because they - // do not return complete information -- e.g. precision / scale, default - // values). - - $res = mysql_query("SHOW COLUMNS FROM `" . $this->name . "`", $this->conn->getResource()); - - $defaults = array(); - $nativeTypes = array(); - $precisions = array(); - - while($row = mysql_fetch_assoc($res)) { - $name = $row['Field']; - $is_nullable = ($row['Null'] == 'YES'); - $is_auto_increment = (strpos($row['Extra'], 'auto_increment') !== false); - $size = null; - $precision = null; - $scale = null; - - if (preg_match('/^(\w+)[\(]?([\d,]*)[\)]?( |$)/', $row['Type'], $matches)) { - // colname[1] size/precision[2] - $nativeType = $matches[1]; - if ($matches[2]) { - if ( ($cpos = strpos($matches[2], ',')) !== false) { - $size = (int) substr($matches[2], 0, $cpos); - $precision = $size; - $scale = (int) substr($matches[2], $cpos + 1); - } else { - $size = (int) $matches[2]; - } - } - } elseif (preg_match('/^(\w+)\(/', $row['Type'], $matches)) { - $nativeType = $matches[1]; - } else { - $nativeType = $row['Type']; - } - //BLOBs can't have any default values in MySQL - $default = preg_match('~blob|text~', $nativeType) ? null : $row['Default']; - $this->columns[$name] = new ColumnInfo($this, - $name, - MySQLTypes::getType($nativeType), - $nativeType, - $size, - $precision, - $scale, - $is_nullable, - $default, - $is_auto_increment, - $row); - } - - $this->colsLoaded = true; - } - - /** Loads the primary key information for this table. */ - protected function initPrimaryKey() - { - include_once 'creole/metadata/PrimaryKeyInfo.php'; - - // columns have to be loaded first - if (!$this->colsLoaded) $this->initColumns(); - - if (!@mysql_select_db($this->dbname, $this->conn->getResource())) { - throw new SQLException('No database selected'); - } - - // Primary Keys - $res = mysql_query("SHOW KEYS FROM `" . $this->name . "`", $this->conn->getResource()); - - // Loop through the returned results, grouping the same key_name together - // adding each column for that key. - - while($row = mysql_fetch_assoc($res)) { - // Skip any non-primary keys. - if ($row['Key_name'] !== 'PRIMARY') { - continue; - } - $name = $row["Column_name"]; - if (!isset($this->primaryKey)) { - $this->primaryKey = new PrimaryKeyInfo($name, $row); - } - $this->primaryKey->addColumn($this->columns[$name]); - } - - $this->pkLoaded = true; - } - - /** Loads the indexes for this table. */ - protected function initIndexes() { - - include_once 'creole/metadata/IndexInfo.php'; - - // columns have to be loaded first - if (!$this->colsLoaded) $this->initColumns(); - - if (!@mysql_select_db($this->dbname, $this->conn->getResource())) { - throw new SQLException('No database selected'); - } - - // Indexes - $res = mysql_query("SHOW INDEX FROM `" . $this->name . "`", $this->conn->getResource()); - - // Loop through the returned results, grouping the same key_name together - // adding each column for that key. - - while($row = mysql_fetch_assoc($res)) { - $colName = $row["Column_name"]; - $name = $row["Key_name"]; - - if($name == "PRIMARY") { - continue; - } - - if (!isset($this->indexes[$name])) { - $isUnique = ($row["Non_unique"] == 0); - $this->indexes[$name] = new IndexInfo($name, $isUnique, $row); - } - $this->indexes[$name]->addColumn($this->columns[$colName]); - } - - $this->indexesLoaded = true; - } - - /** - * Load foreign keys for supporting versions of MySQL. - * @author Tony Bibbs - */ - protected function initForeignKeys() { - - // First make sure we have supported version of MySQL: - $res = mysql_query("SELECT VERSION()"); - $row = mysql_fetch_row($res); - - // Yes, it is OK to hardcode this...this was the first version of MySQL - // that supported foreign keys - if ($row[0] < '3.23.44') { - $this->fksLoaded = true; - return; - } - - include_once 'creole/metadata/ForeignKeyInfo.php'; - - // columns have to be loaded first - if (!$this->colsLoaded) $this->initColumns(); - if (!@mysql_select_db($this->dbname, $this->conn->getResource())) { - throw new SQLException('No database selected'); - } - // Get the CREATE TABLE syntax - $res = mysql_query("SHOW CREATE TABLE `" . $this->name . "`", $this->conn->getResource()); - $row = mysql_fetch_row($res); - - // Get the information on all the foreign keys - $regEx = '/FOREIGN KEY \(`([^`]*)`\) REFERENCES `([^`]*)` \(`([^`]*)`\)(.*)/'; - if (preg_match_all($regEx,$row[1],$matches)) { - $tmpArray = array_keys($matches[0]); - foreach ($tmpArray as $curKey) { - $name = $matches[1][$curKey]; - $ftbl = $matches[2][$curKey]; - $fcol = $matches[3][$curKey]; - $fkey = $matches[4][$curKey]; - if (!isset($this->foreignKeys[$name])) { - $this->foreignKeys[$name] = new ForeignKeyInfo($name); - if ($this->database->hasTable($ftbl)) { - $foreignTable = $this->database->getTable($ftbl); - } else { - $foreignTable = new MySQLTableInfo($this->database, $ftbl); - $this->database->addTable($foreignTable); - } - if ($foreignTable->hasColumn($fcol)) { - $foreignCol = $foreignTable->getColumn($fcol); - } else { - $foreignCol = new ColumnInfo($foreignTable, $fcol); - $foreignTable->addColumn($foreignCol); - } - - //typical for mysql is RESTRICT - $fkactions = array( - 'ON DELETE' => ForeignKeyInfo::RESTRICT, - 'ON UPDATE' => ForeignKeyInfo::RESTRICT, - ); - - if ($fkey) { - //split foreign key information -> search for ON DELETE and afterwords for ON UPDATE action - foreach (array_keys($fkactions) as $fkaction) { - $result = NULL; - preg_match('/' . $fkaction . ' (' . ForeignKeyInfo::CASCADE . '|' . ForeignKeyInfo::SETNULL . ')/', $fkey, $result); - if ($result && is_array($result) && isset($result[1])) { - $fkactions[$fkaction] = $result[1]; - } - } - } - - $this->foreignKeys[$name]->addReference($this->columns[$name], $foreignCol, $fkactions['ON DELETE'], $fkactions['ON UPDATE']); - } - } - } - $this->fksLoaded = true; - - } - - protected function initVendorSpecificInfo() - { - $res = mysql_query("SHOW TABLE STATUS LIKE '" . $this->name . "'", $this->conn->getResource()); - $this->vendorSpecificInfo = mysql_fetch_assoc($res); - - $this->vendorLoaded = true; - } - -} diff --git a/thirdparty/creole/drivers/mysqli/MySQLiConnection.php b/thirdparty/creole/drivers/mysqli/MySQLiConnection.php index 684544e81..66747a03e 100644 --- a/thirdparty/creole/drivers/mysqli/MySQLiConnection.php +++ b/thirdparty/creole/drivers/mysqli/MySQLiConnection.php @@ -75,11 +75,9 @@ class MySQLiConnection extends ConnectionCommon implements Connection { $encoding = !empty($dsninfo['encoding']) ? $dsninfo['encoding'] : null; - @ini_set('track_errors', true); - - $conn = mysqli_connect($host, $user, $pw, $database, $port, $socket); - - @ini_restore('track_errors'); + $conn = mysqli_connect($host, $user, $pw, $database, $port, $socket); + $errorGetLast = error_get_last(); + $php_errormsg = isset($errorGetLast['message']) ? $errorGetLast['message'] : ''; if (empty($conn)) { if (($err = @mysqli_error()) != '') { diff --git a/thirdparty/creole/drivers/oracle/OCI8Connection.php b/thirdparty/creole/drivers/oracle/OCI8Connection.php index 5a6a34ef9..39f05e562 100644 --- a/thirdparty/creole/drivers/oracle/OCI8Connection.php +++ b/thirdparty/creole/drivers/oracle/OCI8Connection.php @@ -76,8 +76,6 @@ class OCI8Connection extends ConnectionCommon implements Connection ? 'oci_pconnect' : 'oci_connect'; $encoding = !empty($dsninfo['encoding']) ? $dsninfo['encoding'] : null; - - @ini_set( 'track_errors', true ); if ( $hostspec && $port ) { diff --git a/thirdparty/creole/drivers/pgsql/PgSQLConnection.php b/thirdparty/creole/drivers/pgsql/PgSQLConnection.php index a6095295b..4a7a8130a 100644 --- a/thirdparty/creole/drivers/pgsql/PgSQLConnection.php +++ b/thirdparty/creole/drivers/pgsql/PgSQLConnection.php @@ -53,9 +53,7 @@ class PgSQLConnection extends ConnectionCommon implements Connection { * @return void */ function connect($dsninfo, $flags = 0) - { - global $php_errormsg; - + { if (!extension_loaded('pgsql')) { throw new SQLException('pgsql extension not loaded'); } @@ -100,9 +98,13 @@ class PgSQLConnection extends ConnectionCommon implements Connection { } if (!$conn) { + // Set message error + $lastError = error_get_last(); + $errorMessage = $lastError['message'] ?? 'Connection error.'; + // hide the password from connstr $cleanconnstr = preg_replace('/password=\'.*?\'($|\s)/', 'password=\'*********\'', $connstr); - throw new SQLException('Could not connect', $php_errormsg, $cleanconnstr); + throw new SQLException('Could not connect', $errorMessage, $cleanconnstr); } $this->dblink = $conn; diff --git a/thirdparty/creole/drivers/pgsql/PgSQLResultSet.php b/thirdparty/creole/drivers/pgsql/PgSQLResultSet.php index 77c400f4f..3ef66968e 100644 --- a/thirdparty/creole/drivers/pgsql/PgSQLResultSet.php +++ b/thirdparty/creole/drivers/pgsql/PgSQLResultSet.php @@ -137,7 +137,7 @@ class PgSQLResultSet extends ResultSetCommon implements ResultSet { $res[] = $this->strToArray(implode(',', $subarr[$in_subarr])); $in_subarr--; } - } elseif ($tok{0} === '{') { // we're inside a new sub-array + } elseif ($tok[0] === '{') { // we're inside a new sub-array if ('}' !== substr($tok, -1, 1)) { $in_subarr++; // if sub-array has more than one element diff --git a/thirdparty/creole/util/sql/SQLStatementExtractor.php b/thirdparty/creole/util/sql/SQLStatementExtractor.php index f4c79a4e8..ca14b51ee 100644 --- a/thirdparty/creole/util/sql/SQLStatementExtractor.php +++ b/thirdparty/creole/util/sql/SQLStatementExtractor.php @@ -143,7 +143,7 @@ class SQLStatementExtractor { trigger_error("substring(), Endindex out of bounds must be $startpos - * @version $Id: aliased.php 785 2006-07-19 10:09:45Z oracleshinoda $ - */ - -// Your config here -define("SOURCE_ROOT", "/var/www/your/source/root/"); - -// Assume you've put geshi in the include_path already -require_once("geshi.php"); - -// Get path info -$path = SOURCE_ROOT.$_SERVER['PATH_INFO']; - -// Check for dickheads trying to use '../' to get to sensitive areas -$base_path_len = strlen(SOURCE_ROOT); -$real_path = realpath($path); -if(strncmp($real_path, SOURCE_ROOT, $base_path_len)) { - exit("Stop that."); -} - -// Check file exists -if(!file_exists($path)) { - exit("File not found ($path)."); -} - -// Gather contents -$contents = file_get_contents($path); - -// Prepare GeSHi instance -$geshi =& new GeSHi($contents, "PHP"); -$geshi->set_header_type(GESHI_HEADER_PRE); -$geshi->enable_classes(); -$geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS, 10); -$geshi->set_overall_style('color: #000066; border: 1px solid #d0d0d0; background-color: #f0f0f0;', true); -$geshi->set_line_style('font: normal normal 95% \'Courier New\', Courier, monospace; color: #003030;', 'font-weight: bold; color: #006060;', true); -$geshi->set_code_style('color: #000020;', 'color: #000020;'); -$geshi->set_link_styles(GESHI_LINK, 'color: #000060;'); -$geshi->set_link_styles(GESHI_HOVER, 'background-color: #f0f000;'); -$geshi->set_header_content('Source code viewer'); -$geshi->set_header_content_style('font-family: Verdana, Arial, sans-serif; color: #808080; font-size: 70%; font-weight: bold; background-color: #f0f0ff; border-bottom: 1px solid #d0d0d0; padding: 2px;'); -$geshi->set_footer_content('Parsed in