PMCORE-3709

This commit is contained in:
Paula.Quispe
2022-04-08 12:51:19 -04:00
parent 4d262146bd
commit 9fd71632a2
10 changed files with 197 additions and 16 deletions

View File

@@ -5,8 +5,10 @@ namespace ProcessMaker\BusinessModel;
use Exception;
use G;
use ProcessMaker\BusinessModel\Variable;
use ProcessMaker\Model\AdditionalTables;
use ProcessMaker\Model\Application;
use ProcessMaker\Model\Dynaform;
use ProcessMaker\Model\Fields;
use ProcessMaker\Model\Process;
use ProcessMaker\Model\ProcessVariables;
use Tests\TestCase;
@@ -16,7 +18,6 @@ use Tests\TestCase;
*/
class VariableTest extends TestCase
{
/**
* Test it create variables related to the process
*
@@ -272,4 +273,30 @@ class VariableTest extends TestCase
$variable = new Variable();
$result = $variable->executeSqlControl(null, []);
}
/**
* This verify the exception
* @test
* @covers \ProcessMaker\BusinessModel\Variable::throwExceptionIfVariableIsAssociatedAditionalTable()
*/
public function it_should_test_exception_when_a_variable_is_related_table()
{
//assert
$this->expectException(Exception::class);
// Create process variable
$variable = factory(ProcessVariables::class)->create();
$result = ProcessVariables::getVariable($variable->VAR_UID);
$this->assertNotEmpty($result);
// Create tables
$table = factory(AdditionalTables::class)->create([
'PRO_UID' => $variable->PRO_UID,
]);
// Create fields
$fields = factory(Fields::class)->create([
'ADD_TAB_UID' => $table->ADD_TAB_UID,
'FLD_NAME' => $variable->VAR_NAME,
]);
$variable = new Variable();
$res = $variable->throwExceptionIfVariableIsAssociatedAditionalTable($variable->VAR_UID);
}
}

View File

@@ -44,6 +44,31 @@ class AdditionalTablesTest extends TestCase
$this->assertCount(1, $table->offline([$table->ADD_TAB_OFFLINE])->get());
}
/**
* Test scope query to get the offline tables
*
* @covers \ProcessMaker\Model\AdditionalTables::scopeProcess()
* @test
*/
public function it_filter_process()
{
$table = factory(AdditionalTables::class)->create();
$this->assertCount(1, $table->process($table->PRO_UID)->get());
}
/**
* Test scope query to get tables related to the process
*
* @covers \ProcessMaker\Model\AdditionalTables::getTables()
* @test
*/
public function it_get_tables_related_to_process()
{
$table = factory(AdditionalTables::class)->create();
$result = AdditionalTables::getTables($table->PRO_UID);
$this->assertNotEmpty($result);
}
/**
* Test get the structure of offline tables
*

View File

@@ -42,4 +42,19 @@ class FieldsTest extends TestCase
$result = Fields::getFields($fields->ADD_TAB_UID);
$this->assertNotEmpty($result);
}
/**
* Test scope and search a field related to the specific ADD_TAB_UID
*
* @covers \ProcessMaker\Model\Fields::scopeField()
* @covers \ProcessMaker\Model\Fields::scopeFieldOrLabel()
* @covers \ProcessMaker\Model\Fields::searchVariable()
* @test
*/
public function it_search_field()
{
$fields = factory(Fields::class)->create();
$result = Fields::searchVariable($fields->ADD_TAB_UID, $fields->FLD_NAME);
$this->assertNotEmpty($result);
}
}

View File

@@ -54,6 +54,19 @@ class ProcessVariablesTest extends TestCase
$this->assertEquals($process[0]['PRO_UID'], $result[1]['PRJ_UID']);
}
/**
* Test it return a variable related to the VAR_UID
*
* @covers \ProcessMaker\Model\ProcessVariables::getVariable()
* @test
*/
public function it_get_variable()
{
$table = factory(ProcessVariables::class)->create();
$result = ProcessVariables::getVariable($table->VAR_UID);
$this->assertNotEmpty($result);
}
/**
* Test it return the variables related to the PRO_ID
*
@@ -76,6 +89,8 @@ class ProcessVariablesTest extends TestCase
/**
* Test it return the variables by type related to the PRO_ID
*
* @covers \ProcessMaker\Model\ProcessVariables::scopeProcessId()
* @covers \ProcessMaker\Model\ProcessVariables::scopeTypeId()
* @covers \ProcessMaker\Model\ProcessVariables::getVariablesByType()
* @test
*/