Conflicts

This commit is contained in:
Paula Quispe
2020-06-12 19:04:53 -04:00
33 changed files with 2799 additions and 620 deletions

View File

@@ -188,4 +188,43 @@ class VariableTest extends TestCase
$this->assertArrayHasKey('var_accepted_values', $res, "The result does not contains 'var_accepted_values' as key");
$this->assertArrayHasKey('inp_doc_uid', $res, "The result does not contains 'inp_doc_uid' as key");
}
/**
* Test it return the variables by type related to the PRO_UID
*
* @covers \ProcessMaker\BusinessModel\Variable::getVariablesByType()
* @test
*/
public function it_list_variables_by_type_related_a_process()
{
$process = factory(Process::class)->create();
$varType = 'integer';
$varTypeId = 2;
for ($x = 1; $x <= 5; $x++) {
$processVar = factory(ProcessVariables::class)->states('foreign_keys')->create([
'PRO_ID' => $process->PRO_ID,
'PRJ_UID' => $process->PRO_UID,
'VAR_FIELD_TYPE' => $varType,
'VAR_FIELD_TYPE_ID' => $varTypeId,
'VAR_NAME' => 'varTestName' . $x,
]);
}
$variable = new Variable();
// Get all results
$res = $variable->getVariablesByType($process->PRO_UID, 2);
$this->assertEquals(5, count($res));
$res = head($res);
$this->assertArrayHasKey('value', $res, "The result does not contains 'value' as key");
// Get a specific start and limit
$res = $variable->getVariablesByType($process->PRO_UID, 2, 0, 2);
$this->assertNotEmpty($res);
$this->assertEquals(2, count($res));
// Get a specific search
$res = $variable->getVariablesByType($process->PRO_UID, 2, 0, 4, 'varTest');
$this->assertNotEmpty($res);
$this->assertEquals(4, count($res));
// When the search does not match
$res = $variable->getVariablesByType($process->PRO_UID, 2, null, null, 'other');
$this->assertEmpty($res);
}
}

View File

@@ -2,6 +2,7 @@
namespace ProcessMaker\Core;
use App\Jobs\Email;
use Tests\TestCase;
class JobsManagerTest extends TestCase

View File

@@ -70,4 +70,41 @@ class ProcessVariablesTest extends TestCase
$result = ProcessVariables::getVariables($process->PRO_ID);
$this->assertNotEmpty($result);
}
/**
* Test it return the variables by type related to the PRO_ID
*
* @covers \ProcessMaker\Model\ProcessVariables::getVariablesByType()
* @test
*/
public function it_list_variables_type_by_process()
{
$process = factory(Process::class)->create();
$varType = 'integer';
$varTypeId = 2;
for ($x = 1; $x <= 5; $x++) {
$processVar = factory(ProcessVariables::class)->states('foreign_keys')->create([
'PRO_ID' => $process->PRO_ID,
'PRJ_UID' => $process->PRO_UID,
'VAR_FIELD_TYPE' => $varType,
'VAR_FIELD_TYPE_ID' => $varTypeId,
'VAR_NAME' => 'varTestName' . $x,
]);
}
$res = ProcessVariables::getVariablesByType($processVar->PRO_ID, 2, null, null, null);
$this->assertNotEmpty($res);
$this->assertEquals(5, count($res));
// Get a specific start and limit
$res = ProcessVariables::getVariablesByType($process->PRO_ID, 2, 0, 2);
$this->assertNotEmpty($res);
$this->assertEquals(2, count($res));
// Get a specific search
$res = ProcessVariables::getVariablesByType($process->PRO_ID, 2, 0, 4, 'varTest');
$this->assertNotEmpty($res);
$this->assertEquals(4, count($res));
// When the search does not match
$res = ProcessVariables::getVariablesByType($process->PRO_ID, 2, null, null, 'other');
$this->assertEmpty($res);
}
}