Merged in release/3.4.4 (pull request #7197)

3.4.4: Update the feature with the last official build

Approved-by: Paula Quispe <paula.quispe@processmaker.com>
This commit is contained in:
Paula Quispe
2019-12-20 14:02:38 +00:00
47 changed files with 411 additions and 675 deletions

View File

@@ -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" => "test"]);
$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);
}
}