Files
luos/tests/unit/workflow/engine/src/ProcessMaker/Model/ProcessVariablesTest.php
Andrea Adamczyk c99216e41e PMC-910
2019-07-03 14:54:58 -04:00

51 lines
1.5 KiB
PHP

<?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']);
}
}