Merged in bugfix/PMCORE-530 (pull request #7480)
PMCORE-530 Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
committed by
Julio Cesar Laura Avendaño
commit
174fe46446
@@ -281,6 +281,34 @@ class AdditionalTablesTest extends TestCase
|
||||
Queue::assertPushed(GenerateReportTable::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* It tests the validateParameter method
|
||||
*
|
||||
* @covers \AdditionalTables::validateParameter()
|
||||
* @test
|
||||
*/
|
||||
public function it_should_test_the_validate_parameter_method()
|
||||
{
|
||||
//Create the AdditionalTables object
|
||||
$additionalTables = new AdditionalTables();
|
||||
//Call validateParameter method
|
||||
$result = $additionalTables->validateParameter(8, 1, 8, 4);
|
||||
//Assert the number is in the rage
|
||||
$this->assertEquals(8, $result);
|
||||
//Call validateParameter method
|
||||
$result = $additionalTables->validateParameter(9, 1, 5, 4);
|
||||
//Assert the number has exceeded the max value
|
||||
$this->assertEquals(5, $result);
|
||||
//Call validateParameter method
|
||||
$result = $additionalTables->validateParameter(-3, 1, 5, 4);
|
||||
//Assert the number has exceeded the min value
|
||||
$this->assertEquals(1, $result);
|
||||
//Call validateParameter method
|
||||
$result = $additionalTables->validateParameter("$%&(%&(DGS=UJHGE32598", 1, 5, 4);
|
||||
//Assert the number has extrange characters
|
||||
$this->assertEquals(4, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* This gets the content from template file.
|
||||
* @param string $pathData
|
||||
|
||||
@@ -396,6 +396,7 @@ class AdditionalTables extends BaseAdditionalTables
|
||||
|
||||
public function getAllData($sUID, $start = null, $limit = null, $keyOrderUppercase = true, $filter = '', $appUid = false, $search = '')
|
||||
{
|
||||
$conf = Bootstrap::getSystemConfiguration();
|
||||
$addTab = new AdditionalTables();
|
||||
$aData = $addTab->load($sUID, true);
|
||||
if (!isset($_SESSION['PROCESS'])) {
|
||||
@@ -429,7 +430,17 @@ class AdditionalTables extends BaseAdditionalTables
|
||||
foreach ($aData['FIELDS'] as $aField) {
|
||||
$field = '$oCriteria->addSelectColumn(' . $sClassPeerName . '::' . $aField['FLD_NAME'] . ');';
|
||||
if (in_array($aField['FLD_TYPE'], $types)) {
|
||||
$field = '$oCriteria->addAsColumn("' . $aField['FLD_NAME'] . '", "round(" . ' . $sClassPeerName . '::' . $aField['FLD_NAME'] . ' . ", ' . ($aField['FLD_TYPE'] == 'DOUBLE' ? '8' : '2') . ')");';
|
||||
|
||||
if ($aField['FLD_TYPE'] == 'DECIMAL' || $aField['FLD_TYPE'] == 'REAL') {
|
||||
$round = '", "" . ' . $sClassPeerName . '::' . $aField['FLD_NAME'] . ' . "");';
|
||||
|
||||
} else {
|
||||
$double = $this->validateParameter($conf['report_table_double_number'], 1, 8, 4);
|
||||
$float = $this->validateParameter($conf['report_table_floating_number'], 1, 5, 4);
|
||||
$round = '", "round(" . ' . $sClassPeerName . '::' . $aField['FLD_NAME'] . ' . ", ' . ($aField['FLD_TYPE'] == 'DOUBLE' ? $double : $float) . ')");';
|
||||
}
|
||||
|
||||
$field = '$oCriteria->addAsColumn("' . $aField['FLD_NAME'] . $round;
|
||||
}
|
||||
eval($field);
|
||||
}
|
||||
@@ -540,6 +551,29 @@ class AdditionalTables extends BaseAdditionalTables
|
||||
return array('rows' => $rows, 'count' => $count);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate report table double and float configuration values
|
||||
*
|
||||
* @param int $number
|
||||
* @param int $min
|
||||
* @param int $max
|
||||
* @param int $default
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function validateParameter($number, $min, $max, $default) {
|
||||
if (!is_numeric($number)) {
|
||||
$result = $default;
|
||||
} elseif ($number > $max) {
|
||||
$result = $max;
|
||||
} elseif ($number < $min) {
|
||||
$result = $min;
|
||||
} else {
|
||||
$result = $number;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function checkClassNotExist($sUID)
|
||||
{
|
||||
try {
|
||||
|
||||
@@ -79,7 +79,9 @@ class System
|
||||
'highlight_home_folder_scope' => 'unassigned', // For now only this list is supported
|
||||
'disable_advanced_search_case_title_fulltext' => 0,
|
||||
'pmftotalcalculation_floating_point_number' => 10,
|
||||
'report_table_batch_regeneration' => 1000
|
||||
'report_table_batch_regeneration' => 1000,
|
||||
'report_table_floating_number' => 4,
|
||||
'report_table_double_number' => 4
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user