Fix conflicts with develop branch
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -42,3 +42,4 @@ test_shared/
|
||||
**/cache/
|
||||
storage/
|
||||
phpunit.xml
|
||||
!/workflow/engine/plugins/.gitignore
|
||||
@@ -31,9 +31,9 @@
|
||||
"laravel/framework": "5.7.*",
|
||||
"luracast/restler": "^3.0",
|
||||
"bshaffer/oauth2-server-php": "v1.0",
|
||||
"colosa/pmUI": "release/3.4.0-dev",
|
||||
"colosa/MichelangeloFE": "release/3.4.0-dev",
|
||||
"colosa/pmdynaform": "release/3.4.0-dev",
|
||||
"colosa/pmui": "release/3.4.5-dev",
|
||||
"colosa/michelangelofe": "release/3.4.5-dev",
|
||||
"colosa/pmdynaform": "release/3.4.5-dev",
|
||||
"google/apiclient": "1.1.6",
|
||||
"dapphp/securimage": "^3.6",
|
||||
"psr/log": "1.0.0",
|
||||
@@ -45,14 +45,15 @@
|
||||
"pear/console_getopt": "1.4.*",
|
||||
"typo3/class-alias-loader": "^1.0",
|
||||
"ralouphie/getallheaders": "^2.0",
|
||||
"smarty/smarty": "2.6.30",
|
||||
"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",
|
||||
"league/oauth2-client": "^2.4",
|
||||
"league/oauth2-google": "^3.0"
|
||||
"league/oauth2-google": "^3.0",
|
||||
"tecnickcom/tcpdf": "6.3.*"
|
||||
},
|
||||
"require-dev": {
|
||||
"fzaninotto/faker": "^1.7",
|
||||
|
||||
1300
composer.lock
generated
1300
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -87,6 +87,7 @@ return [
|
||||
'css' => ['text/css', 'text/plain'],
|
||||
'cst' => 'application/x-director',
|
||||
'cxt' => 'application/x-director',
|
||||
'csv' => ['text/csv', 'text/plain'],
|
||||
'cxx' => ['text/x-c', 'text/plain'],
|
||||
'dataless' => 'application/vnd.fdsn.seed',
|
||||
'dcr' => 'application/x-director',
|
||||
@@ -468,6 +469,7 @@ return [
|
||||
'spr' => 'application/x-sprite',
|
||||
'sprite' => 'application/x-sprite',
|
||||
'spx' => 'audio/ogg',
|
||||
'sql' => ['application/sql', 'text/plain'],
|
||||
'src' => 'application/x-wais-source',
|
||||
'ssi' => 'text/x-server-parsed-html',
|
||||
'ssm' => 'application/streamingmedia',
|
||||
|
||||
@@ -38,7 +38,7 @@ return [
|
||||
'charset' => 'utf8mb4',
|
||||
'collation' => 'utf8mb4_unicode_ci',
|
||||
'prefix' => '',
|
||||
'strict' => true,
|
||||
'strict' => env('DB_STRICT', false),
|
||||
'engine' => null,
|
||||
]
|
||||
],
|
||||
|
||||
@@ -82,6 +82,11 @@ workflow/engine/methods/setup/webServices.php
|
||||
workflow/engine/methods/setup/webServicesAjax.php
|
||||
workflow/engine/methods/setup/webServicesList.php
|
||||
workflow/engine/methods/users/data_usersList.php
|
||||
workflow/engine/plugins/charts.php
|
||||
workflow/engine/plugins/charts/class.charts.php
|
||||
workflow/engine/plugins/charts/config/setup.conf
|
||||
workflow/engine/plugins/charts/genericCharts.php
|
||||
workflow/engine/plugins/charts/setupPage.xml
|
||||
workflow/engine/plugins/openFlash.php
|
||||
workflow/engine/plugins/openFlash/chart-data.php
|
||||
workflow/engine/plugins/openFlash/chart.php
|
||||
@@ -103,6 +108,8 @@ workflow/engine/plugins/pmosCommunity/open_flash_chart_object.php
|
||||
workflow/engine/plugins/pmosCommunity/public_html/open-flash-chart.swf
|
||||
workflow/engine/plugins/pmosCommunity/public_html/swfobject.js
|
||||
workflow/engine/plugins/pmosCommunity/setupPage.xml
|
||||
workflow/engine/plugins/processTemplate.php
|
||||
workflow/engine/plugins/processTemplate/class.processTemplate.php
|
||||
workflow/engine/skinEngine/base/images/updating/page_background.png
|
||||
workflow/engine/skinEngine/neoclassic/images/updating/page_background.png
|
||||
workflow/engine/src/ProcessMaker/Services/Api/Test2.php
|
||||
@@ -123,3 +130,4 @@ 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/tcpdf
|
||||
28
database/factories/AdditionalTablesFactory.php
Normal file
28
database/factories/AdditionalTablesFactory.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
|
||||
$factory->define(\ProcessMaker\Model\AdditionalTables::class, function(Faker $faker) {
|
||||
return [
|
||||
'ADD_TAB_UID' => G::generateUniqueID(),
|
||||
'ADD_TAB_NAME' => $faker->name,
|
||||
'ADD_TAB_CLASS_NAME' => $faker->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()
|
||||
];
|
||||
});
|
||||
50
database/factories/FieldsFactory.php
Normal file
50
database/factories/FieldsFactory.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
use ProcessMaker\Model\AdditionalTables;
|
||||
|
||||
$factory->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,
|
||||
];
|
||||
});
|
||||
|
||||
// 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,
|
||||
];
|
||||
});
|
||||
@@ -87,7 +87,9 @@ class CodeScanner
|
||||
|
||||
if (file_exists($fileDisabledCode)) {
|
||||
$arrayAux = array_filter(array_map("trim", file($fileDisabledCode, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES)));
|
||||
$arrayAux = array_filter($arrayAux, create_function("\$line", "return !preg_match(\"/^;.*\$/\", \$line);"));
|
||||
$arrayAux = array_filter($arrayAux, function ($line) {
|
||||
return !preg_match("/^;.*\$/", $line);
|
||||
});
|
||||
|
||||
$this->arrayDisabledCode = array_unique(array_merge($this->arrayDisabledCode, $arrayAux));
|
||||
}
|
||||
|
||||
@@ -77,12 +77,13 @@ class Controller
|
||||
*/
|
||||
public function __get($name)
|
||||
{
|
||||
$message = 'Undefined property via __get(): ' . $name . ' in ';
|
||||
if (array_key_exists($name, $this->__data__)) {
|
||||
return $this->__data__[$name];
|
||||
}
|
||||
|
||||
$trace = debug_backtrace();
|
||||
trigger_error('Undefined property via __get(): ' . $name . ' in ' . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_NOTICE);
|
||||
trigger_error($message . $trace[0]['file'] . ' on line ' . $trace[0]['line'], E_USER_NOTICE);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -177,8 +178,8 @@ class Controller
|
||||
$this->__request__ = new stdclass();
|
||||
}
|
||||
if (is_array($data)) {
|
||||
while ($var = each($data)) {
|
||||
$this->__request__->{$var['key']} = $var['value'];
|
||||
foreach ($data as $key => $value) {
|
||||
$this->__request__->{$key} = $value;
|
||||
}
|
||||
} else {
|
||||
$this->__request__ = $data;
|
||||
|
||||
@@ -360,7 +360,7 @@ class Form extends XmlForm
|
||||
|
||||
//Execute just if a query was set, it should be not empty
|
||||
if (trim($query) == "") {
|
||||
continue; //if it is empty string skip it
|
||||
break; //if it is empty string skip it
|
||||
}
|
||||
|
||||
//We do the query to the external connection and we've got the label
|
||||
@@ -438,7 +438,7 @@ class Form extends XmlForm
|
||||
|
||||
// execute just if a query was set, it should be not empty
|
||||
if (trim( $query ) == '') {
|
||||
continue; //if it is empty string skip it
|
||||
break; //if it is empty string skip it
|
||||
}
|
||||
|
||||
//we do the query to the external connection and we've got the label
|
||||
@@ -491,7 +491,7 @@ class Form extends XmlForm
|
||||
//Execute just if a query was set, it should be not empty
|
||||
if (trim( $query ) == "") {
|
||||
//if it is empty string skip it
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
|
||||
$rs = $stmt->executeQuery( ResultSet::FETCHMODE_NUM );
|
||||
|
||||
@@ -758,7 +758,7 @@ class headPublisher
|
||||
$sjson = $oServerConf->getProperty($keyState);
|
||||
if ($sjson !== "") {
|
||||
$json = G::json_decode($sjson);
|
||||
if ((is_array($json) || is_object($json)) && sizeof($json)){
|
||||
if (is_iterable($json)) {
|
||||
foreach ($json as $key => $value) {
|
||||
$views[$key] = $value;
|
||||
}
|
||||
|
||||
@@ -142,8 +142,8 @@ class HttpProxyController
|
||||
public function setHttpRequestData($data)
|
||||
{
|
||||
if (is_array($data)) {
|
||||
while ($var = each($data)) {
|
||||
$this->__request__->{$var['key']} = $var['value'];
|
||||
foreach ($data as $key => $value) {
|
||||
$this->__request__->{$key} = $value;
|
||||
}
|
||||
} else {
|
||||
$this->__request__ = $data;
|
||||
|
||||
@@ -48,7 +48,7 @@ class Menu
|
||||
{
|
||||
|
||||
public $Id = null;
|
||||
public $Options = null;
|
||||
public $Options = [];
|
||||
public $Labels = null;
|
||||
public $Icons = null;
|
||||
public $JS = null;
|
||||
|
||||
@@ -876,6 +876,8 @@ EOREGEX;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$shouldItContinue = false;
|
||||
switch ($upper) {
|
||||
case 'AS':
|
||||
$token_count ++;
|
||||
@@ -886,7 +888,7 @@ EOREGEX;
|
||||
++ $n;
|
||||
}
|
||||
|
||||
continue;
|
||||
$shouldItContinue = true;
|
||||
break;
|
||||
case 'INDEX':
|
||||
if ($token_category == 'CREATE') {
|
||||
@@ -908,12 +910,12 @@ EOREGEX;
|
||||
case 'OUTER':
|
||||
# $expression .= $token;
|
||||
$token_count ++;
|
||||
continue;
|
||||
$shouldItContinue = true;
|
||||
break;
|
||||
case 'FOR':
|
||||
$token_count ++;
|
||||
$skip_next = true;
|
||||
continue;
|
||||
$shouldItContinue = true;
|
||||
break;
|
||||
case 'LEFT':
|
||||
case 'RIGHT':
|
||||
@@ -969,7 +971,8 @@ EOREGEX;
|
||||
break;
|
||||
default:
|
||||
if ($token === false || empty( $token ) || $token === "") {
|
||||
continue;
|
||||
$shouldItContinue = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if ($token_count == 0) {
|
||||
@@ -982,6 +985,9 @@ EOREGEX;
|
||||
$token_count ++;
|
||||
break;
|
||||
}
|
||||
if ($shouldItContinue === true) {
|
||||
continue;
|
||||
}
|
||||
++ $i;
|
||||
}
|
||||
if (substr( trim( $table ), 0, 1 ) == '(') {
|
||||
|
||||
@@ -176,6 +176,24 @@ class RBAC
|
||||
'showDynaformListHistory' => ['PM_CASES'],
|
||||
'dynaformChangeLogViewHistory' => ['PM_CASES'],
|
||||
'historyDynaformGridPreview' => ['PM_CASES'],
|
||||
],
|
||||
'usersAjax.php' => [
|
||||
'countryList' => ['PM_LOGIN'],
|
||||
'stateList' => ['PM_LOGIN'],
|
||||
'locationList' => ['PM_LOGIN'],
|
||||
'usersList' => ['PM_USERS,PM_EDIT_USER_PROFILE_REPLACED_BY'],
|
||||
'availableCalendars' => ['PM_LOGIN'],
|
||||
'rolesList' => ['PM_LOGIN'],
|
||||
'getUserLogedRole' => ['PM_USERS,PM_EDIT_USER_PROFILE_PASSWORD'],
|
||||
'languagesList' => ['PM_LOGIN'],
|
||||
'saveUser' => [], // This action is validated with custom logic in the same page
|
||||
'savePersonalInfo' => [], // This action is validated with custom logic in the same page
|
||||
'userData' => [], // This action is validated with custom logic in the same page
|
||||
'defaultMainMenuOptionList' => ['PM_LOGIN'],
|
||||
'defaultCasesMenuOptionList' => ['PM_LOGIN'],
|
||||
'testPassword' => ['PM_USERS,PM_EDIT_USER_PROFILE_PASSWORD'],
|
||||
'testUsername' => ['PM_USERS,PM_EDIT_USER_PROFILE_USERNAME'],
|
||||
'passwordValidate' => ['PM_USERS,PM_EDIT_USER_PROFILE_PASSWORD'],
|
||||
]
|
||||
];
|
||||
$this->aliasPermissions['PM_CASES'] = [self::PM_GUEST_CASE];
|
||||
|
||||
@@ -11,7 +11,7 @@ INSERT INTO `RBAC_PERMISSIONS` VALUES
|
||||
('00000000000000000000000000000010','PM_SETUP_ADVANCE',NULL,NULL,1,'00000000000000000000000000000002'),
|
||||
('00000000000000000000000000000011','PM_DASHBOARD','2009-02-18 00:00:00','2009-02-18 00:00:00',1,'00000000000000000000000000000002'),
|
||||
('00000000000000000000000000000012','PM_WEBDAV','2009-08-21 00:00:00','2009-08-21 00:00:00',1,'00000000000000000000000000000002'),
|
||||
('00000000000000000000000000000013','PM_DELETECASE','2009-10-12 00:00:00',NULL,0,'00000000000000000000000000000002'),
|
||||
('00000000000000000000000000000013','PM_DELETECASE','2009-10-12 00:00:00',NULL,1,'00000000000000000000000000000002'),
|
||||
('00000000000000000000000000000014','PM_EDITPERSONALINFO','2009-10-12 00:00:00',NULL,1,'00000000000000000000000000000002'),
|
||||
('00000000000000000000000000000015','PM_FOLDERS_VIEW','2009-10-12 00:00:00',NULL,1,'00000000000000000000000000000002'),
|
||||
('00000000000000000000000000000016','PM_FOLDERS_ADD_FOLDER','2009-10-12 00:00:00',NULL,1,'00000000000000000000000000000002'),
|
||||
@@ -225,7 +225,7 @@ INSERT INTO `RBAC_SYSTEMS` VALUES
|
||||
('00000000000000000000000000000002','PROCESSMAKER','2007-07-31 19:10:22','2007-08-03 12:24:36',1);
|
||||
|
||||
INSERT INTO `RBAC_USERS` VALUES
|
||||
('00000000000000000000000000000001','admin','21232f297a57a5a743894a0e4a801fc3','Administrator','','admin@processmaker.com','2020-01-01','2007-08-03 12:24:36','2008-02-13 07:24:07',1,'MYSQL','00000000000000000000000000000000','',''),
|
||||
('00000000000000000000000000000001','admin','21232f297a57a5a743894a0e4a801fc3','Administrator','','admin@processmaker.com',DATE_ADD(curdate(), INTERVAL 1 YEAR),'2007-08-03 12:24:36','2008-02-13 07:24:07',1,'MYSQL','00000000000000000000000000000000','',''),
|
||||
('00000000000000000000000000000002','guest','$2y$10$rasFC.VNv9TLStNtFVJu6OjxhCi6FezdwkLrBzTFwmXsNnfW0/YZm','Guest','','guest@processmaker.com','2030-01-01','2009-02-01 12:24:36','2009-02-01 12:24:36',0,'MYSQL','00000000000000000000000000000000','','');
|
||||
|
||||
INSERT INTO `RBAC_USERS_ROLES` VALUES
|
||||
|
||||
@@ -32,6 +32,7 @@ define('PMTABLE_KEY', 'pmtable');
|
||||
define('DB_ADAPTER', 'mysql');
|
||||
// Path related some specific directories
|
||||
define('PATH_SEP', '/');
|
||||
define("PATH_PLUGINS", PATH_CORE . "plugins" . PATH_SEP);
|
||||
define('PATH_WORKSPACE', PATH_TRUNK . '/shared/sites/' . SYS_SYS . '/');
|
||||
define('PATH_METHODS', dirname(__DIR__) . '/workflow/engine/methods/');
|
||||
define('PATH_WORKFLOW_MYSQL_DATA', PATH_TRUNK . '/workflow/engine/data/mysql/');
|
||||
@@ -75,6 +76,7 @@ define("PATH_DATA_SITE", PATH_DATA . "sites/" . config("system.workspace") . "/"
|
||||
define("PATH_DYNAFORM", PATH_DATA_SITE . "xmlForms/");
|
||||
define("PATH_DATA_MAILTEMPLATES", PATH_DATA_SITE . "mailTemplates/");
|
||||
define("PATH_DATA_PUBLIC", PATH_DATA_SITE . "public/");
|
||||
define("PATH_CONTROLLERS", PATH_CORE . "controllers" . PATH_SEP);
|
||||
G::defineConstants();
|
||||
|
||||
/**
|
||||
|
||||
929
tests/resources/dynaformDataForRenewUids.json
Normal file
929
tests/resources/dynaformDataForRenewUids.json
Normal file
File diff suppressed because it is too large
Load Diff
120
tests/unit/thirdparty/propel-generator/classes/propel/engine/database/model/PhpNameGeneratorTest.php
vendored
Normal file
120
tests/unit/thirdparty/propel-generator/classes/propel/engine/database/model/PhpNameGeneratorTest.php
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
use Tests\TestCase;
|
||||
|
||||
class PhpNameGeneratorTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var PhpNameGenerator
|
||||
*/
|
||||
var $phpNameGenerator;
|
||||
|
||||
/**
|
||||
* Set up the test class
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
// Call the setUp parent method
|
||||
parent::setUp();
|
||||
|
||||
// Include class "PhpNameGenerator" from "thirdparty" folder, this class is not loaded with composer
|
||||
require_once PATH_THIRDPARTY . 'propel-generator/classes/propel/engine/database/model/PhpNameGenerator.php';
|
||||
|
||||
// Instance class PhpNameGenerator
|
||||
$this->phpNameGenerator = new PhpNameGenerator();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test "underscoreMethod" using texts with and without underscores
|
||||
*
|
||||
* @test
|
||||
* @covers PhpNameGenerator::underscoreMethod()
|
||||
*/
|
||||
public function it_should_test_underscore_method_through_generate_name()
|
||||
{
|
||||
// To force to use the protected method "underscoreMethod"
|
||||
$method = PhpNameGenerator::CONV_METHOD_UNDERSCORE;
|
||||
|
||||
// Assert for bug PMC-1341
|
||||
$string = 'q_10_0_0';
|
||||
$convertedString = $this->phpNameGenerator->generateName([$string, $method]);
|
||||
$this->assertEquals('Q1000', $convertedString);
|
||||
|
||||
// Assert for a text in lowercase without underscores
|
||||
$string = 'example';
|
||||
$convertedString = $this->phpNameGenerator->generateName([$string, $method]);
|
||||
$this->assertEquals('Example', $convertedString);
|
||||
|
||||
// Assert for a text in uppercase without underscores
|
||||
$string = 'EXAMPLE';
|
||||
$convertedString = $this->phpNameGenerator->generateName([$string, $method]);
|
||||
$this->assertEquals('Example', $convertedString);
|
||||
|
||||
// Assert for a capitalized text without underscores, should be return the same value
|
||||
$string = 'Example';
|
||||
$convertedString = $this->phpNameGenerator->generateName([$string, $method]);
|
||||
$this->assertEquals($string, $convertedString);
|
||||
|
||||
// Assert for a text in lowercase with underscore
|
||||
$string = 'first_name';
|
||||
$convertedString = $this->phpNameGenerator->generateName([$string, $method]);
|
||||
$this->assertEquals('FirstName', $convertedString);
|
||||
|
||||
// Assert for a text in lowercase with underscores
|
||||
$string = 'this_is_my_text';
|
||||
$convertedString = $this->phpNameGenerator->generateName([$string, $method]);
|
||||
$this->assertEquals('ThisIsMyText', $convertedString);
|
||||
|
||||
// Assert for a mixed text with underscores
|
||||
$string = 'this_Is_the_Number_1_to_check';
|
||||
$convertedString = $this->phpNameGenerator->generateName([$string, $method]);
|
||||
$this->assertEquals('ThisIsTheNumber1ToCheck', $convertedString);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test "phpnameMethod" using texts with and without underscores
|
||||
*
|
||||
* @test
|
||||
* @covers PhpNameGenerator::phpnameMethod()
|
||||
*/
|
||||
public function it_should_test_php_name_method_through_generate_name()
|
||||
{
|
||||
// To force to use the protected method "underscoreMethod"
|
||||
$method = PhpNameGenerator::CONV_METHOD_UNDERSCORE;
|
||||
|
||||
// Assert for bug PMC-1341
|
||||
$string = 'q_10_0_0';
|
||||
$convertedString = $this->phpNameGenerator->generateName([$string, $method]);
|
||||
$this->assertEquals('Q1000', $convertedString);
|
||||
|
||||
// Assert for a text in lowercase without underscores
|
||||
$string = 'example';
|
||||
$convertedString = $this->phpNameGenerator->generateName([$string, $method]);
|
||||
$this->assertEquals('Example', $convertedString);
|
||||
|
||||
// Assert for a text in uppercase without underscores
|
||||
$string = 'EXAMPLE';
|
||||
$convertedString = $this->phpNameGenerator->generateName([$string, $method]);
|
||||
$this->assertEquals('Example', $convertedString);
|
||||
|
||||
// Assert for a capitalized text without underscores, should be return the same value
|
||||
$string = 'Example';
|
||||
$convertedString = $this->phpNameGenerator->generateName([$string, $method]);
|
||||
$this->assertEquals($string, $convertedString);
|
||||
|
||||
// Assert for a text in lowercase with underscore
|
||||
$string = 'first_name';
|
||||
$convertedString = $this->phpNameGenerator->generateName([$string, $method]);
|
||||
$this->assertEquals('FirstName', $convertedString);
|
||||
|
||||
// Assert for a text in lowercase with underscores
|
||||
$string = 'this_is_my_text';
|
||||
$convertedString = $this->phpNameGenerator->generateName([$string, $method]);
|
||||
$this->assertEquals('ThisIsMyText', $convertedString);
|
||||
|
||||
// Assert for a mixed text with underscores
|
||||
$string = 'this_Is_the_Number_1_to_check';
|
||||
$convertedString = $this->phpNameGenerator->generateName([$string, $method]);
|
||||
$this->assertEquals('ThisIsTheNumber1ToCheck', $convertedString);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,17 @@
|
||||
|
||||
namespace Tests\unit\workflow\engine\classes;
|
||||
|
||||
use \Derivation;
|
||||
use Cases;
|
||||
use Derivation;
|
||||
use G;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use ProcessMaker\Model\Application;
|
||||
use ProcessMaker\Model\Delegation;
|
||||
use ProcessMaker\Model\Process;
|
||||
use ProcessMaker\Model\Route;
|
||||
use ProcessMaker\Model\Task;
|
||||
use ProcessMaker\Model\TaskUser;
|
||||
use ProcessMaker\Model\User;
|
||||
use Tests\TestCase;
|
||||
|
||||
class DerivationTest extends TestCase
|
||||
@@ -15,6 +25,41 @@ class DerivationTest extends TestCase
|
||||
{
|
||||
parent::setUp(); // TODO: Change the autogenerated stub
|
||||
|
||||
// Truncate the APP_SEQUENCE table
|
||||
DB::table('APP_SEQUENCE')->truncate();
|
||||
|
||||
config(["system.workspace" => "new_site"]);
|
||||
$workspace = config("system.workspace");
|
||||
|
||||
if (!file_exists(PATH_DB . $workspace)) {
|
||||
G::mk_dir(PATH_DB . $workspace);
|
||||
}
|
||||
|
||||
if (!file_exists(PATH_DB . $workspace . PATH_SEP . "db.php")) {
|
||||
$myfile = fopen(PATH_DB . $workspace . PATH_SEP . "db.php", "w");
|
||||
fwrite($myfile, "<?php
|
||||
define ('DB_ADAPTER', 'mysql' );
|
||||
define ('DB_HOST', '" . env('DB_HOST') . "' );
|
||||
define ('DB_NAME', '" . env('DB_DATABASE') . "' );
|
||||
define ('DB_USER', '" . env('DB_USERNAME') . "' );
|
||||
define ('DB_PASS', '" . env('DB_PASSWORD') . "' );
|
||||
define ('DB_RBAC_HOST', '" . env('DB_HOST') . "' );
|
||||
define ('DB_RBAC_NAME', '" . env('DB_DATABASE') . "' );
|
||||
define ('DB_RBAC_USER', '" . env('DB_USERNAME') . "' );
|
||||
define ('DB_RBAC_PASS', '" . env('DB_PASSWORD') . "' );
|
||||
define ('DB_REPORT_HOST', '" . env('DB_HOST') . "' );
|
||||
define ('DB_REPORT_NAME', '" . env('DB_DATABASE') . "' );
|
||||
define ('DB_REPORT_USER', '" . env('DB_USERNAME') . "' );
|
||||
define ('DB_REPORT_PASS', '" . env('DB_PASSWORD') . "' );");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Call the tearDown method
|
||||
*/
|
||||
public function tearDown()
|
||||
{
|
||||
parent::tearDown(); // TODO: Change the autogenerated stub
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,4 +125,139 @@ class DerivationTest extends TestCase
|
||||
$this->assertObjectHasAttribute('name', $res['var3_label']);
|
||||
$this->assertEquals($res['var3_label'], (object)['Street' => 'test', 'name' => 'Something']);
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the doDerivation method sending variables synchronously
|
||||
*
|
||||
* @covers Derivation::doDerivation()
|
||||
* @test
|
||||
*/
|
||||
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([
|
||||
'PRO_CREATE_USER' => $user->USR_UID
|
||||
]);
|
||||
$task = factory(Task::class)->create([
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
]);
|
||||
$application = factory(Application::class)->create();
|
||||
$appDelegation = factory(Delegation::class)->create();
|
||||
|
||||
// Create the parameters
|
||||
$currentDelegation = [
|
||||
'APP_UID' => $application->APP_UID,
|
||||
'DEL_INDEX' => $appDelegation->DEL_INDEX,
|
||||
'ROU_TYPE' => ''
|
||||
];
|
||||
$nextDel = [
|
||||
'TAS_UID' => $task->TAS_UID,
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'DEL_PRIORITY' => $appDelegation->DEL_PRIORITY,
|
||||
'TAS_ASSIGN_TYPE' => $task->TAS_ASSIGN_TYPE,
|
||||
'TAS_ID' => $task->TAS_ID
|
||||
];
|
||||
$appFields = [
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'DEL_THREAD' => $appDelegation->DEL_THREAD,
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'PRO_ID' => $process->PRO_ID,
|
||||
'APP_DATA' => [],
|
||||
'APP_TITLE' => $application->APP_TITLE,
|
||||
'APP_UID' => $application->APP_UID
|
||||
];
|
||||
$sp = [
|
||||
'SP_VARIABLES_OUT' => 'a:1:{s:6:"@&var1";s:6:"@&var2";}',
|
||||
'SP_VARIABLES_IN' => 'a:1:{s:6:"@&var2";s:6:"@&var3";}',
|
||||
'SP_SYNCHRONOUS' => '1',
|
||||
'SP_TYPE' => '',
|
||||
'TAS_UID' => $task->TAS_UID,
|
||||
'USR_UID' => $user->USR_UID,
|
||||
];
|
||||
|
||||
// Create the Derivation object
|
||||
$der = new Derivation();
|
||||
$der->case = new Cases;
|
||||
|
||||
// Call the doDerivation method
|
||||
$res = $der->doDerivation($currentDelegation, $nextDel, $appFields, $sp);
|
||||
|
||||
// Assert the new delegation index is 1
|
||||
$this->assertEquals(1, $res);
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the doDerivation method sending variables asynchronously
|
||||
*
|
||||
* @covers Derivation::doDerivation()
|
||||
* @test
|
||||
*/
|
||||
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([
|
||||
'PRO_CREATE_USER' => $user->USR_UID
|
||||
]);
|
||||
$task = factory(Task::class)->create([
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'TAS_USER' => $user->USR_UID
|
||||
]);
|
||||
factory(TaskUser::class)->create([
|
||||
'TAS_UID' => $task->TAS_UID,
|
||||
'USR_UID' => $user->USR_UID,
|
||||
]);
|
||||
$application = factory(Application::class)->create();
|
||||
$appDelegation = factory(Delegation::class)->create([
|
||||
'TAS_UID' => $task->TAS_UID
|
||||
]);
|
||||
factory(Route::class)->create([
|
||||
'TAS_UID' => $task->TAS_UID,
|
||||
'ROU_NEXT_TASK' => $task->TAS_UID,
|
||||
'PRO_UID' => $process->PRO_UID
|
||||
]);
|
||||
|
||||
// Create the parameters
|
||||
$currentDelegation = [
|
||||
'APP_UID' => $application->APP_UID,
|
||||
'DEL_INDEX' => $appDelegation->DEL_INDEX,
|
||||
'ROU_TYPE' => '',
|
||||
'TAS_UID' => $task->TAS_UID
|
||||
];
|
||||
$nextDel = [
|
||||
'TAS_UID' => $task->TAS_UID,
|
||||
'USR_UID' => $user->USR_UID,
|
||||
'DEL_PRIORITY' => $appDelegation->DEL_PRIORITY,
|
||||
'TAS_ASSIGN_TYPE' => $task->TAS_ASSIGN_TYPE,
|
||||
'TAS_ID' => $task->TAS_ID
|
||||
];
|
||||
$appFields = [
|
||||
'APP_NUMBER' => $application->APP_NUMBER,
|
||||
'DEL_THREAD' => $appDelegation->DEL_THREAD,
|
||||
'PRO_UID' => $process->PRO_UID,
|
||||
'PRO_ID' => $process->PRO_ID,
|
||||
'APP_DATA' => [],
|
||||
'APP_TITLE' => $application->APP_TITLE,
|
||||
'APP_UID' => $application->APP_UID
|
||||
];
|
||||
$sp = [
|
||||
'SP_VARIABLES_OUT' => 'a:1:{s:6:"@&var1";s:6:"@&var2";}',
|
||||
'SP_VARIABLES_IN' => 'a:1:{s:6:"@&var2";s:6:"@&var3";}',
|
||||
'SP_SYNCHRONOUS' => '0',
|
||||
'SP_TYPE' => '',
|
||||
'TAS_UID' => $task->TAS_UID,
|
||||
'USR_UID' => $user->USR_UID,
|
||||
];
|
||||
|
||||
// Create the Derivation object
|
||||
$der = new Derivation();
|
||||
$der->case = new Cases;
|
||||
|
||||
// Call the doDerivation method
|
||||
$res = $der->doDerivation($currentDelegation, $nextDel, $appFields, $sp);
|
||||
|
||||
// Assert the new delegation index is 1
|
||||
$this->assertEquals(1, $res);
|
||||
}
|
||||
}
|
||||
@@ -909,6 +909,8 @@ class PmDynaformTest extends TestCase
|
||||
|
||||
$sqlOriginal3 = 'DUMMY';
|
||||
|
||||
$sqlOriginal4 = 'SELECT U.USR_UID, U.USR_USERNAME FROM PMT_CODES C INNER JOIN USERS U ON U.USR_USERNAME = C.USR_USERNAME';
|
||||
|
||||
// Instance the class PmDynaform
|
||||
$pmDynaform = new PmDynaform([]);
|
||||
|
||||
@@ -924,6 +926,10 @@ class PmDynaformTest extends TestCase
|
||||
// Test another string, shoul be return the same value
|
||||
$sqlParsed3 = $pmDynaform->sqlParse($sqlOriginal3);
|
||||
$this->assertEquals($sqlOriginal3, $sqlParsed3);
|
||||
|
||||
// Test bug PMCORE-1049
|
||||
$sqlParsed4 = $pmDynaform->sqlParse($sqlOriginal4);
|
||||
$this->assertNotFalse(strpos($sqlParsed4, 'C.USR_USERNAME'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -65,7 +65,8 @@ class ExecuteQueryTest extends TestCase
|
||||
});
|
||||
$expected = $user->toArray();
|
||||
|
||||
$sql = "SELECT "
|
||||
foreach ($expected as $value) {
|
||||
$sql = "SELECT "
|
||||
. "USR_UID ,"
|
||||
. "USR_USERNAME ,"
|
||||
. "USR_PASSWORD ,"
|
||||
@@ -74,15 +75,16 @@ class ExecuteQueryTest extends TestCase
|
||||
. "USR_EMAIL "
|
||||
. "FROM USERS "
|
||||
. "WHERE "
|
||||
. "USR_UID NOT IN ("
|
||||
. " '00000000000000000000000000000001',"
|
||||
. " '00000000000000000000000000000002'"
|
||||
. ")"
|
||||
. "USR_UID = '" . $value['USR_UID'] . "'"
|
||||
. "ORDER BY USR_UID DESC";
|
||||
$actual = executeQuery($sql);
|
||||
$actual = array_values($actual);
|
||||
$actual = executeQuery($sql);
|
||||
|
||||
$actual = array_values($actual);
|
||||
|
||||
$this->assertEquals($value, head($actual));
|
||||
}
|
||||
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,6 +13,7 @@ use Tests\TestCase;
|
||||
|
||||
class ProcessesTest extends TestCase
|
||||
{
|
||||
private $processes;
|
||||
|
||||
/**
|
||||
* Constructor of the class.
|
||||
@@ -33,6 +34,7 @@ class ProcessesTest extends TestCase
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->processes = new Processes();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -154,7 +156,7 @@ class ProcessesTest extends TestCase
|
||||
* This checks fi the returned output documents are correct with the differect
|
||||
* parameters.
|
||||
* @test
|
||||
* @covers Processes::getOutputRows()
|
||||
* @covers \Processes::getOutputRows()
|
||||
*/
|
||||
public function it_should_return_output_documents()
|
||||
{
|
||||
@@ -205,7 +207,7 @@ class ProcessesTest extends TestCase
|
||||
/**
|
||||
* This checks if the dynaforms structure is saved with the different parameters.
|
||||
* @test
|
||||
* @covers Processes::createDynaformRows()
|
||||
* @covers \Processes::createDynaformRows()
|
||||
*/
|
||||
public function it_sholud_create_dynaform()
|
||||
{
|
||||
@@ -269,7 +271,7 @@ class ProcessesTest extends TestCase
|
||||
* This checks if the input documents structure is saved with the different
|
||||
* parameters.
|
||||
* @test
|
||||
* @covers Processes::createInputRows()
|
||||
* @covers \Processes::createInputRows()
|
||||
*/
|
||||
public function it_should_create_input_document()
|
||||
{
|
||||
@@ -339,7 +341,7 @@ class ProcessesTest extends TestCase
|
||||
* This checks if the output documents structure is saved with the different
|
||||
* parameters.
|
||||
* @test
|
||||
* @covers Processes::createOutputRows()
|
||||
* @covers \Processes::createOutputRows()
|
||||
*/
|
||||
public function it_should_create_output_document()
|
||||
{
|
||||
@@ -432,7 +434,7 @@ class ProcessesTest extends TestCase
|
||||
/**
|
||||
* This gets the data structure of a project.
|
||||
* @test
|
||||
* @covers Processes::getWorkflowData()
|
||||
* @covers \Processes::getWorkflowData()
|
||||
*/
|
||||
public function it_should_get_workflow_data()
|
||||
{
|
||||
@@ -459,4 +461,40 @@ class ProcessesTest extends TestCase
|
||||
$result = $processes->getWorkflowData($process->PRO_UID);
|
||||
$this->assertNotNull($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This test guarantees the replacement of new identifiers.
|
||||
* @test
|
||||
* @covers \Processes::renewAllDynaformGuid()
|
||||
*/
|
||||
public function it_should_renew_all_dynaform_guid()
|
||||
{
|
||||
$pathData = PATH_TRUNK . "/tests/resources/dynaformDataForRenewUids.json";
|
||||
$data = file_get_contents($pathData);
|
||||
$result = json_decode($data, JSON_OBJECT_AS_ARRAY);
|
||||
$result = (object) $result;
|
||||
$this->processes->renewAllDynaformGuid($result);
|
||||
foreach ($result as $key => $value) {
|
||||
$this->assertObjectHasAttribute($key, $result);
|
||||
}
|
||||
|
||||
//without PRO_DYNAFORMS
|
||||
$result = json_decode($data, JSON_OBJECT_AS_ARRAY);
|
||||
$result = (object) $result;
|
||||
unset($result->process['PRO_DYNAFORMS']);
|
||||
$this->processes->renewAllDynaformGuid($result);
|
||||
foreach ($result as $key => $value) {
|
||||
$this->assertObjectHasAttribute($key, $result);
|
||||
}
|
||||
|
||||
//for process inside PRO_DYNAFORMS
|
||||
$result = json_decode($data, JSON_OBJECT_AS_ARRAY);
|
||||
$result = (object) $result;
|
||||
$result->process['PRO_DYNAFORMS'] = [];
|
||||
$result->process['PRO_DYNAFORMS']['PROCESS'] = $result->dynaforms[0]['DYN_UID'];
|
||||
$this->processes->renewAllDynaformGuid($result);
|
||||
foreach ($result as $key => $value) {
|
||||
$this->assertObjectHasAttribute($key, $result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\classes\model;
|
||||
|
||||
use AdditionalTables;
|
||||
use Exception;
|
||||
use G;
|
||||
use ProcessMaker\Model\AdditionalTables as AdditionalTablesModel;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AdditionalTablesTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* This tests the creation of a PMTable.
|
||||
* @test
|
||||
* @covers \AdditionalTables::create()
|
||||
*/
|
||||
public function it_should_create()
|
||||
{
|
||||
$data = [
|
||||
"ADD_TAB_UID" => "",
|
||||
"ADD_TAB_NAME" => "PMT_TEST11",
|
||||
"ADD_TAB_CLASS_NAME" => "PmtTest11",
|
||||
"ADD_TAB_DESCRIPTION" => "",
|
||||
"ADD_TAB_PLG_UID" => "",
|
||||
"DBS_UID" => "workflow",
|
||||
"PRO_UID" => "",
|
||||
"ADD_TAB_TYPE" => "",
|
||||
"ADD_TAB_GRID" => "",
|
||||
"ADD_TAB_OFFLINE" => false,
|
||||
"ADD_TAB_UPDATE_DATE" => "2019-10-22 19:52:52"
|
||||
];
|
||||
|
||||
$additionalTables = new AdditionalTables();
|
||||
$result = $additionalTables->create($data);
|
||||
|
||||
$additionalTablesModel = AdditionalTablesModel::where('ADD_TAB_UID', '=', $result)
|
||||
->get()
|
||||
->first();
|
||||
$actual = $additionalTablesModel->toArray();
|
||||
unset($data["ADD_TAB_UID"]);
|
||||
|
||||
$this->assertArraySubset($data, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* This attempts to create a PMTable without correct data to cause an exception.
|
||||
* @test
|
||||
* @covers \AdditionalTables::create()
|
||||
*/
|
||||
public function it_should_create_without_data()
|
||||
{
|
||||
$data = [
|
||||
];
|
||||
$additionalTables = new AdditionalTables();
|
||||
$this->expectException(Exception::class);
|
||||
$additionalTables->create($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* This updates the data of a PMTable.
|
||||
* @test
|
||||
* @covers \AdditionalTables::update()
|
||||
*/
|
||||
public function it_should_update()
|
||||
{
|
||||
$additionalTables = factory(AdditionalTablesModel::class)->create();
|
||||
|
||||
$expected = [
|
||||
"ADD_TAB_UID" => $additionalTables->ADD_TAB_UID,
|
||||
"ADD_TAB_NAME" => "PMT_TEST11",
|
||||
"ADD_TAB_CLASS_NAME" => "PmtTest11",
|
||||
"DBS_UID" => "workflow",
|
||||
"ADD_TAB_OFFLINE" => false,
|
||||
"ADD_TAB_UPDATE_DATE" => "2019-10-22 19:53:11"
|
||||
];
|
||||
$additionalTables = new AdditionalTables();
|
||||
$additionalTables->update($expected);
|
||||
|
||||
$additionalTables = AdditionalTablesModel::where('ADD_TAB_UID', '=', $expected['ADD_TAB_UID'])
|
||||
->get()
|
||||
->first();
|
||||
|
||||
$this->assertEquals($expected["ADD_TAB_NAME"], $additionalTables->ADD_TAB_NAME);
|
||||
$this->assertEquals($expected["ADD_TAB_CLASS_NAME"], $additionalTables->ADD_TAB_CLASS_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* It tries to update the data of a non-existent "PMTable".
|
||||
* @test
|
||||
* @covers \AdditionalTables::update()
|
||||
*/
|
||||
public function it_should_update_if_registry_not_exist()
|
||||
{
|
||||
$expected = [
|
||||
"ADD_TAB_UID" => G::generateUniqueID(),
|
||||
"ADD_TAB_NAME" => "PMT_TEST11",
|
||||
"ADD_TAB_CLASS_NAME" => "PmtTest11",
|
||||
"DBS_UID" => "workflow",
|
||||
"ADD_TAB_OFFLINE" => false,
|
||||
"ADD_TAB_UPDATE_DATE" => "2019-10-22 19:53:11"
|
||||
];
|
||||
|
||||
$this->expectException(Exception::class);
|
||||
$additionalTables = new AdditionalTables();
|
||||
$additionalTables->update($expected);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\methods\cases;
|
||||
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use ProcessMaker\Model\User;
|
||||
use RBAC;
|
||||
use Tests\TestCase;
|
||||
|
||||
|
||||
class ProxyNewCasesListTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
/**
|
||||
* This sets the initial parameters for each test.
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp(); // TODO: Change the autogenerated stub
|
||||
$this->settingUserLogged();
|
||||
}
|
||||
|
||||
/**
|
||||
* This starts a valid user in session with the appropriate permissions.
|
||||
* @global object $RBAC
|
||||
*/
|
||||
private function settingUserLogged()
|
||||
{
|
||||
global $RBAC;
|
||||
|
||||
$user = User::where('USR_ID', '=', 1)
|
||||
->get()
|
||||
->first();
|
||||
|
||||
$_SESSION['USER_LOGGED'] = $user['USR_UID'];
|
||||
|
||||
$RBAC = RBAC::getSingleton(PATH_DATA, session_id());
|
||||
$RBAC->initRBAC();
|
||||
$RBAC->loadUserRolePermission('PROCESSMAKER', $_SESSION['USER_LOGGED']);
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the result contains an error
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_there_is_an_error_in_the_proxy_new_cases_list_file()
|
||||
{
|
||||
//Turn on output buffering
|
||||
ob_start();
|
||||
|
||||
//Call the tested file
|
||||
require_once PATH_METHODS . 'cases/proxyNewCasesList.php';
|
||||
|
||||
//Return the contents of the output buffer
|
||||
$outputBuffer = ob_get_contents();
|
||||
//Clean the output buffer and turn off output buffering
|
||||
ob_end_clean();
|
||||
|
||||
// This asserts there is an error in the output
|
||||
$this->assertEquals('{"error":"ID_ACCESS_DENIED"}', $outputBuffer);
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the result contains an empty "search" field
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_the_response_of_the_proxy_new_cases_list_file()
|
||||
{
|
||||
$_REQUEST["paged"] = '';
|
||||
$_REQUEST['count'] = '';
|
||||
$_REQUEST["category"] = '';
|
||||
$_REQUEST["process"] = '';
|
||||
$_REQUEST["search"] = 'fsfaefwa';
|
||||
$_REQUEST["filter"] = '';
|
||||
$_REQUEST["dateFrom"] = '';
|
||||
$_REQUEST["dateTo"] = '';
|
||||
$_REQUEST["start"] = '';
|
||||
$_REQUEST["limit"] = '';
|
||||
$_REQUEST['sort'] = 'ASC';
|
||||
$_REQUEST["dir"] = '';
|
||||
$_REQUEST["action"] = 'todo';
|
||||
$_REQUEST["user"] = '';
|
||||
$_REQUEST["list"] = 'inbox';
|
||||
$_REQUEST["filterStatus"] = '';
|
||||
$_REQUEST['openApplicationUid'] = '';
|
||||
|
||||
//Turn on output buffering
|
||||
ob_start();
|
||||
|
||||
//Call the tested file
|
||||
require_once PATH_METHODS . 'cases/proxyNewCasesList.php';
|
||||
|
||||
//Return the contents of the output buffer
|
||||
$outputBuffer = ob_get_contents();
|
||||
|
||||
//Clean the output buffer and turn off output buffering
|
||||
ob_end_clean();
|
||||
|
||||
$result = json_decode($outputBuffer, true);
|
||||
|
||||
//This asserts that the search parameter has an empty value
|
||||
$this->assertEmpty($result['filters']['search']);
|
||||
}
|
||||
}
|
||||
76
tests/unit/workflow/engine/methods/groups/GroupsAjaxTest.php
Normal file
76
tests/unit/workflow/engine/methods/groups/GroupsAjaxTest.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\methods\groups;
|
||||
|
||||
use Faker\Factory;
|
||||
use ProcessMaker\Model\Groupwf;
|
||||
use ProcessMaker\Model\User;
|
||||
use RBAC;
|
||||
use Tests\TestCase;
|
||||
|
||||
class GroupsAjaxTest extends TestCase
|
||||
{
|
||||
private $groups;
|
||||
|
||||
/**
|
||||
* Set up function
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->settingUserLogged();
|
||||
Groupwf::truncate();
|
||||
$this->createGroups();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create records in the GROUPSWF table
|
||||
*/
|
||||
private function createGroups()
|
||||
{
|
||||
$this->groups = factory(Groupwf::class, 10)->create();
|
||||
}
|
||||
|
||||
/**
|
||||
* This starts a valid user in session with the appropriate permissions.
|
||||
* @global object $RBAC
|
||||
*/
|
||||
private function settingUserLogged()
|
||||
{
|
||||
global $RBAC;
|
||||
|
||||
$user = User::where('USR_ID', '=', 1)
|
||||
->get()
|
||||
->first();
|
||||
|
||||
$_SESSION['USER_LOGGED'] = $user['USR_UID'];
|
||||
|
||||
$RBAC = RBAC::getSingleton(PATH_DATA, session_id());
|
||||
$RBAC->initRBAC();
|
||||
$RBAC->loadUserRolePermission('PROCESSMAKER', $_SESSION['USER_LOGGED']);
|
||||
}
|
||||
|
||||
/**
|
||||
* This tests the answer of the option groupsList.
|
||||
* @test
|
||||
*/
|
||||
public function it_should_return_option_groups_list()
|
||||
{
|
||||
global $RBAC;
|
||||
$_POST['action'] = 'groupsList';
|
||||
$_REQUEST["dir"] = "DESC";
|
||||
$_REQUEST["sort"] = "GRP_TITLE";
|
||||
|
||||
$fileName = PATH_METHODS . 'groups/groups_Ajax.php';
|
||||
|
||||
ob_start();
|
||||
require_once $fileName;
|
||||
$content = ob_get_clean();
|
||||
$content = json_decode($content, JSON_OBJECT_AS_ARRAY);
|
||||
|
||||
$this->assertArrayHasKey("success", $content);
|
||||
$this->assertArrayHasKey("groups", $content);
|
||||
$this->assertTrue($content["success"]);
|
||||
$this->assertTrue(is_array($content["groups"]));
|
||||
}
|
||||
}
|
||||
@@ -28,20 +28,21 @@ class UsersAjaxTest extends TestCase
|
||||
global $RBAC;
|
||||
//Creates the user factory
|
||||
$user = factory(User::class)->create();
|
||||
$usrUid = $user['USR_UID'];
|
||||
//Creates the configuration factory
|
||||
factory(Configuration::class)->create([
|
||||
'CFG_UID' => 'USER_PREFERENCES',
|
||||
'OBJ_UID' => '',
|
||||
'CFG_VALUE' => 'a:3:{s:12:"DEFAULT_LANG";s:0:"";s:12:"DEFAULT_MENU";s:8:"PM_SETUP";s:18:"DEFAULT_CASES_MENU";s:0:"";}',
|
||||
'PRO_UID' => '',
|
||||
'USR_UID' => $user['USR_UID'],
|
||||
'USR_UID' => $usrUid,
|
||||
'APP_UID' => '',
|
||||
]);
|
||||
|
||||
//Sets the needed variables
|
||||
$_SESSION['USER_LOGGED'] = $user['USR_UID'];
|
||||
$_SESSION['USER_LOGGED'] = $usrUid;
|
||||
$_POST['action'] = 'userData';
|
||||
$_POST['USR_UID'] = $user['USR_UID'];
|
||||
$_POST['USR_UID'] = $usrUid;
|
||||
$RBAC = RBAC::getSingleton(PATH_DATA, session_id());
|
||||
$RBAC->initRBAC();
|
||||
$RBAC->loadUserRolePermission('PROCESSMAKER', $_SESSION['USER_LOGGED']);
|
||||
@@ -63,7 +64,7 @@ class UsersAjaxTest extends TestCase
|
||||
//Assert the call was success
|
||||
$this->assertTrue($res->success);
|
||||
//Assert the result corresponds to the user logged
|
||||
$this->assertEquals($user['USR_UID'], $res->user->USR_UID);
|
||||
$this->assertEquals($usrUid, $res->user->USR_UID);
|
||||
//Assert the default menu is set
|
||||
$this->assertEquals('PM_EDIT_USER_PROFILE_DEFAULT_MAIN_MENU_OPTIONS',
|
||||
$res->permission->PREF_DEFAULT_MENUSELECTED);
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace ProcessMaker\BusinessModel;
|
||||
|
||||
use Exception;
|
||||
use G;
|
||||
use ProcessMaker\Model\Application;
|
||||
use RBAC;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
* Class DelegationTest
|
||||
*
|
||||
* @coversDefaultClass \ProcessMaker\BusinessModel\Cases
|
||||
*/
|
||||
class CasesTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* This checks the delete case
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::deleteCase()
|
||||
* @test
|
||||
* @expectedException Exception
|
||||
*/
|
||||
public function it_should_not_delete_case_without_permission()
|
||||
{
|
||||
// Set the RBAC
|
||||
global $RBAC;
|
||||
$_SESSION['USER_LOGGED'] = '00000000000000000000000000000002';
|
||||
$RBAC = RBAC::getSingleton(PATH_DATA, session_id());
|
||||
$RBAC->initRBAC();
|
||||
|
||||
$application = factory(Application::class)->create();
|
||||
// Tried to delete case
|
||||
$case = new Cases();
|
||||
$case->deleteCase($application->APP_UID, $_SESSION['USER_LOGGED']);
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks the delete case
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::deleteCase()
|
||||
* @test
|
||||
* @expectedException Exception
|
||||
*/
|
||||
public function it_should_not_delete_case_in_todo_status()
|
||||
{
|
||||
// Set the RBAC
|
||||
global $RBAC;
|
||||
$_SESSION['USER_LOGGED'] = '00000000000000000000000000000001';
|
||||
$RBAC = RBAC::getSingleton(PATH_DATA, session_id());
|
||||
$RBAC->initRBAC();
|
||||
|
||||
$application = factory(Application::class)->create(['APP_STATUS' => 'TO_DO']);
|
||||
// Tried to delete case
|
||||
$case = new Cases();
|
||||
$case->deleteCase($application->APP_UID, $_SESSION['USER_LOGGED']);
|
||||
}
|
||||
|
||||
/**
|
||||
* This checks the delete case
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::deleteCase()
|
||||
* @test
|
||||
* @expectedException Exception
|
||||
*/
|
||||
public function it_should_not_delete_case_when_is_not_owner()
|
||||
{
|
||||
// Set the RBAC
|
||||
global $RBAC;
|
||||
$_SESSION['USER_LOGGED'] = '00000000000000000000000000000001';
|
||||
$RBAC = RBAC::getSingleton(PATH_DATA, session_id());
|
||||
$RBAC->initRBAC();
|
||||
|
||||
$application = factory(Application::class)->create(['APP_INIT_USER' => '00000000000000000000000000000002']);
|
||||
// Tried to delete case
|
||||
$case = new Cases();
|
||||
$case->deleteCase($application->APP_UID, $_SESSION['USER_LOGGED']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\src\ProcessMaker\BusinessModel;
|
||||
|
||||
use Faker\Factory;
|
||||
use ProcessMaker\BusinessModel\Light;
|
||||
use Tests\TestCase;
|
||||
|
||||
class LightTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* This verifies that the mobile_offline_tables_download_interval parameter
|
||||
* is defined in the result returned by the getConfiguration() method.
|
||||
*
|
||||
* @test
|
||||
* @covers \ProcessMaker\BusinessModel\Light::getConfiguration
|
||||
*/
|
||||
public function it_should_return_mobile_offline_tables_download_interval_from_get_configuration_method()
|
||||
{
|
||||
$param = [
|
||||
'fileLimit' => true,
|
||||
'tz' => true,
|
||||
];
|
||||
$light = new Light();
|
||||
|
||||
/**
|
||||
* In the getConfiguration() method, the next section:
|
||||
*
|
||||
* $postMaxSize = $this->return_bytes(ini_get('post_max_size'));
|
||||
* $uploadMaxFileSize = $this->return_bytes(ini_get('upload_max_filesize'));
|
||||
* if ($postMaxSize < $uploadMaxFileSize) {
|
||||
* $uploadMaxFileSize = $postMaxSize;
|
||||
* }
|
||||
*
|
||||
* It can only be tested if you change the values of "post_max_size" and "upload_max_filesize"
|
||||
* in php.ini, you can't use the ini_set() function.
|
||||
* The mode change of these directives is "PHP_INI_PERDIR", where is entry can be
|
||||
* set in php.ini, .htaccess, httpd.conf or .user.ini, see here:
|
||||
* https://www.php.net/manual/es/ini.list.php
|
||||
* https://www.php.net/manual/en/configuration.changes.modes.php
|
||||
*/
|
||||
$result = $light->getConfiguration($param);
|
||||
|
||||
$this->assertArrayHasKey('mobile_offline_tables_download_interval', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This returns the value of mobile_offline_tables_download_interval
|
||||
* @test
|
||||
* @covers \ProcessMaker\BusinessModel\Light::getConfiguration
|
||||
*/
|
||||
public function this_should_return_mobile_offline_tables_download_interval_inside_env()
|
||||
{
|
||||
$oldContent = "";
|
||||
$path = PATH_CONFIG . "env.ini";
|
||||
if (file_exists($path)) {
|
||||
$oldContent = file_get_contents($path);
|
||||
}
|
||||
|
||||
$expected = 30;
|
||||
|
||||
$content = "mobile_offline_tables_download_interval = {$expected};";
|
||||
file_put_contents($path, $content);
|
||||
|
||||
$light = new Light();
|
||||
$result = $light->getConfiguration([]);
|
||||
$actual = $result['mobile_offline_tables_download_interval'];
|
||||
|
||||
file_put_contents($path, $oldContent);
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* This returns the default value of mobile_offline_tables_download_interval.
|
||||
* @test
|
||||
* @covers \ProcessMaker\BusinessModel\Light::getConfiguration
|
||||
*/
|
||||
public function this_should_return_default_value_if_mobile_offline_tables_download_interval_inside_env_is_not_an_integer()
|
||||
{
|
||||
$oldContent = "";
|
||||
$path = PATH_CONFIG . "env.ini";
|
||||
if (file_exists($path)) {
|
||||
$oldContent = file_get_contents($path);
|
||||
}
|
||||
|
||||
$faker = $faker = Factory::create();
|
||||
$alphanumeric = $faker->regexify('[A-Za-z0-9]{20}');
|
||||
$content = "mobile_offline_tables_download_interval = '{$alphanumeric}';";
|
||||
file_put_contents($path, $content);
|
||||
|
||||
$light = new Light();
|
||||
$result = $light->getConfiguration([]);
|
||||
$expected = (string) $result['mobile_offline_tables_download_interval'];
|
||||
|
||||
file_put_contents($path, $oldContent);
|
||||
|
||||
$this->assertTrue(ctype_digit($expected));
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user