Merged in bugfix/PMC-910 (pull request #6955)
PMC-910 Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
committed by
Julio Cesar Laura Avendaño
commit
c2b740fdff
21
database/factories/ProcessVariablesFactory.php
Normal file
21
database/factories/ProcessVariablesFactory.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
use ProcessMaker\Model\ProcessVariables;
|
||||
|
||||
$factory->define(ProcessVariables::class, function (Faker $faker) {
|
||||
return [
|
||||
'VAR_UID' => G::generateUniqueID(),
|
||||
'PRJ_UID' => G::generateUniqueID(),
|
||||
'VAR_NAME' => $faker->word,
|
||||
'VAR_FIELD_TYPE' => G::generateUniqueID(),
|
||||
'VAR_FIELD_SIZE' => 10,
|
||||
'VAR_LABEL' => 'string',
|
||||
'VAR_DBCONNECTION' => 'workflow',
|
||||
'VAR_SQL' => '',
|
||||
'VAR_NULL' => 0,
|
||||
'VAR_DEFAULT' => '',
|
||||
'VAR_ACCEPTED_VALUES' => '',
|
||||
'INP_DOC_UID' => ''
|
||||
];
|
||||
});
|
||||
16
database/factories/TriggerFactory.php
Normal file
16
database/factories/TriggerFactory.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
use Faker\Generator as Faker;
|
||||
use ProcessMaker\Model\Triggers;
|
||||
|
||||
$factory->define(Triggers::class, function (Faker $faker) {
|
||||
return [
|
||||
'TRI_UID' => G::generateUniqueID(),
|
||||
'TRI_TITLE' => $faker->sentence(5),
|
||||
'TRI_DESCRIPTION' => $faker->text,
|
||||
'PRO_UID' => G::generateUniqueID(),
|
||||
'TRI_TYPE' => 'SCRIPT',
|
||||
'TRI_WEBBOT' => $faker->text,
|
||||
'TRI_PARAM' => '',
|
||||
];
|
||||
});
|
||||
353
tests/unit/gulliver/system/gTest.php
Executable file
353
tests/unit/gulliver/system/gTest.php
Executable file
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\src\ProcessMaker\Core;
|
||||
|
||||
use ProcessMaker\Core\System;
|
||||
use Tests\TestCase;
|
||||
|
||||
class SystemTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Define the required variables
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
$config = config('database.connections.testexternal');
|
||||
define('DB_HOST', $config['host']);
|
||||
define('DB_NAME', $config['database']);
|
||||
define('DB_USER', $config['username']);
|
||||
define('DB_PASS', $config['password']);
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the initLaravel method
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function it_should_init_laravel_configurations()
|
||||
{
|
||||
$object = new System();
|
||||
$object->initLaravel();
|
||||
|
||||
// Assert that the configurations were set successfully
|
||||
$this->assertEquals(DB_HOST, config('database.connections.workflow.host'));
|
||||
$this->assertEquals(DB_NAME, config('database.connections.workflow.database'));
|
||||
$this->assertEquals(DB_USER, config('database.connections.workflow.username'));
|
||||
$this->assertEquals(DB_PASS, config('database.connections.workflow.password'));
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
|
||||
|
||||
use ProcessMaker\Model\Process;
|
||||
use ProcessMaker\Model\ProcessVariables;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ProcessVariablesTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* It tests the process scope in the ProcessVariables model
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_process_scope_in_process_variables_model()
|
||||
{
|
||||
$process = factory(Process::class, 2)->create();
|
||||
|
||||
factory(ProcessVariables::class)->create(
|
||||
[
|
||||
'PRJ_UID' => $process[0]['PRO_UID'],
|
||||
'VAR_SQL' => 'SELECT * FROM USERS WHERE USR_UID="213" UNION SELECT * from PROCESS'
|
||||
]
|
||||
);
|
||||
|
||||
factory(ProcessVariables::class)->create(
|
||||
[
|
||||
'PRJ_UID' => $process[1]['PRO_UID'],
|
||||
'VAR_SQL' => ''
|
||||
]
|
||||
);
|
||||
|
||||
factory(ProcessVariables::class)->create(
|
||||
[
|
||||
'PRJ_UID' => $process[0]['PRO_UID'],
|
||||
'VAR_SQL' => ''
|
||||
]
|
||||
);
|
||||
|
||||
$variablesQuery = ProcessVariables::query()->select();
|
||||
$variablesQuery->process($process[0]['PRO_UID']);
|
||||
$result = $variablesQuery->get()->values()->toArray();
|
||||
|
||||
// Assert there are two process variables for the specific process
|
||||
$this->assertCount(2, $result);
|
||||
|
||||
// Assert that the result has the correct filtered process
|
||||
$this->assertEquals($process[0]['PRO_UID'], $result[0]['PRJ_UID']);
|
||||
$this->assertEquals($process[0]['PRO_UID'], $result[1]['PRJ_UID']);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\unit\workflow\engine\src\ProcessMaker\Model;
|
||||
|
||||
use ProcessMaker\Model\Process;
|
||||
use ProcessMaker\Model\Triggers;
|
||||
use Tests\TestCase;
|
||||
|
||||
class TriggersTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* It tests the process scope in the trigger model
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_process_scope_in_trigger_model()
|
||||
{
|
||||
$process = factory(Process::class, 3)->create();
|
||||
factory(Triggers::class)->create(
|
||||
[
|
||||
'PRO_UID' => $process[0]['PRO_UID'],
|
||||
'TRI_WEBBOT' => '$text=222;
|
||||
$var1= executeQuery("SELECT *
|
||||
FROM USERS WHERE
|
||||
USR_UID=\'$UID\' UNION SELECT * from PROCESS");
|
||||
|
||||
$var1= executeQuery("SELECT *
|
||||
FROM USERS WHERE
|
||||
USR_UID=\'$UID\' UNION SELECT * from PROCESS");
|
||||
|
||||
$query = "SELECT * FROM USERS UNION
|
||||
|
||||
SELECT * FROM TASKS";
|
||||
|
||||
$QUERY2 = "select * from USERS union SELECT * from GROUPS";
|
||||
|
||||
$s1 = "select * from USER";
|
||||
$s2 = "select * from TASK";
|
||||
|
||||
$query3 = $s1. " UNION " . $s2;
|
||||
|
||||
executeQuery($query3);'
|
||||
]
|
||||
);
|
||||
|
||||
factory(Triggers::class)->create(
|
||||
[
|
||||
'PRO_UID' => $process[1]['PRO_UID'],
|
||||
'TRI_WEBBOT' => 'die();'
|
||||
]
|
||||
);
|
||||
|
||||
factory(Triggers::class)->create(
|
||||
[
|
||||
'PRO_UID' => $process[2]['PRO_UID'],
|
||||
'TRI_WEBBOT' => 'executeQuery("select * from USERS");'
|
||||
]
|
||||
);
|
||||
|
||||
factory(Triggers::class)->create(
|
||||
[
|
||||
'PRO_UID' => $process[2]['PRO_UID'],
|
||||
'TRI_WEBBOT' => 'executeQuery();'
|
||||
]
|
||||
);
|
||||
|
||||
$triggerQuery = Triggers::query()->select();
|
||||
$triggerQuery->process($process[2]['PRO_UID']);
|
||||
$result = $triggerQuery->get()->values()->toArray();
|
||||
|
||||
// Assert there are two triggers for the specific process
|
||||
$this->assertCount(2, $result);
|
||||
|
||||
// Assert that the result has the correct filtered process
|
||||
$this->assertEquals($process[2]['PRO_UID'], $result[0]['PRO_UID']);
|
||||
$this->assertEquals($process[2]['PRO_UID'], $result[1]['PRO_UID']);
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user