Skip to content

Commit

Permalink
🔨 #198
Browse files Browse the repository at this point in the history
  • Loading branch information
bjverde committed Oct 27, 2019
1 parent c94fe03 commit f0478d6
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 2 deletions.
2 changes: 1 addition & 1 deletion base/classes/constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
}


define('FORMDIN_VERSION', '4.7.8');
define('FORMDIN_VERSION', '4.7.9-alpha');

// --Data Base Management System
define('DBMS_ACCESS', 'ACCESS');
Expand Down
16 changes: 16 additions & 0 deletions base/classes/helpers/ArrayHelper.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,22 @@ static function convertArrayFormDin2Pdo($dataArray,$upperCase = false)
}
}
return $result;
}
//--------------------------------------------------------------------------------
/**
* Validade is array and not empty
* @param integer $id
* @param string $method
* @param string $line
* @throws InvalidArgumentException
* @return void
*/
public static function validateIsArray($array,$method,$line)
{
FormDinHelper::validateMethodLine($method, $line, __METHOD__);
if( empty($array) || !is_array($array) ){
throw new InvalidArgumentException(TMessage::ERROR_TYPE_NOT_ARRAY.'See the method: '.$method.' in the line: '.$line);
}
}
}
?>
1 change: 1 addition & 0 deletions base/classes/webform/TMessage.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class TMessage {

const ERROR_EMPTY_INPUT = 'O Parametro não pode ficar em branco';
const ERROR_TYPE_NOT_INT = 'Tipo não númerico! ';
const ERROR_TYPE_NOT_ARRAY = 'Tipo não é um array! ';

public function __construct() {
}
Expand Down
29 changes: 29 additions & 0 deletions base/test/classes/helpers/ArrayHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,33 @@ public function testConvertArrayFormDin2Pdo_Upcase() {
$retorno = ArrayHelper::convertArrayFormDin2Pdo($array,true);
$this->assertEquals($esperado, $retorno);
}
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------
/**
* @expectedException InvalidArgumentException
*/
public function testValidateIsArray_FailNull(){
ArrayHelper::validateIsArray(null,__METHOD__,__LINE__);
}
/**
* @expectedException InvalidArgumentException
*/
public function testValidateIsArray_FailArrayEmpty(){
$listArray = array();
$this->assertNull( ArrayHelper::validateIsArray($listArray,__METHOD__,__LINE__) );
}
/**
* @expectedException InvalidArgumentException
*/
public function testValidateIsArray_FailString(){
$listArray = 'xxx';
$this->assertNull( ArrayHelper::validateIsArray($listArray,__METHOD__,__LINE__) );
}
public function testValidateIdIsNumeric_OKArrayNotEmpty(){
$listArray = array();
$listArray[]=1;
$listArray[]=2;
$this->assertNull( ArrayHelper::validateIsArray($listArray,__METHOD__,__LINE__) );
}
}
2 changes: 1 addition & 1 deletion base/test/classes/helpers/FormDinHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class FormDinHelperTest extends TestCase
{

public function testVersion() {
$expected = '4.7.8';
$expected = '4.7.9-alpha';
$result = FormDinHelper::version();
$this->assertEquals( $expected , $result);
}
Expand Down

0 comments on commit f0478d6

Please sign in to comment.