PMCORE-3880 PhpUnit: Error: Call to undefined function factory
This commit is contained in:
@@ -7,11 +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;
|
||||
use CreateTestSite;
|
||||
|
||||
/**
|
||||
* Test that the deprecated files are removed successfully
|
||||
@@ -21,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';
|
||||
@@ -79,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'));
|
||||
}
|
||||
@@ -150,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;
|
||||
@@ -203,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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user