Skip to content

Commit

Permalink
:base: #289 correções
Browse files Browse the repository at this point in the history
  • Loading branch information
bjverde committed Jan 22, 2024
1 parent 84af0dc commit 526a0f3
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 28 deletions.
28 changes: 12 additions & 16 deletions FormDin5/lib/widget/FormDin5/helpers/FormDinHelper.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,20 @@ public static function version()
return self::FORMDIN_VERSION;
}
/***
* Returns if the current formDin version meets the minimum requirements
* Returns whether the reported version of formDin is greater than or equal to the reference version.
*
* Retorna se a versão atual do formDin atende aos requisitos mínimos
* @param string $version - versão de referencia
* Retorna true se a versão informada do formDin é maior ou igual a versão de referencia.
* @param string $version - versão informada
* @param string $versionRef - versão de referencia
* @return boolean
*/
public static function versionMinimum($version,$versionRef=null)
{
if(empty($versionRef)){
$formVersion = explode("-", self::version());
$formVersion = $formVersion[0];
}else{
$formVersion = $versionRef;
$versionRef = $formVersion[0];
}
return version_compare($formVersion,$version,'>=');
return version_compare($versionRef,$version,'>=');
}
public static function validateFormat($version)
{
Expand All @@ -119,6 +117,7 @@ public static function verifyFormDinMinimumVersion($minimumVersion) {
$msg = TFormDinMessage::FORM_MIN_YOU_VERSION.self::version().TFormDinMessage::FORM_MIN_VERSION_NOT.$minimumVersion;
throw new DomainException($msg);
}
self::verifyMinimumVersionAdiantiFrameWorkToFormDin();
}
}
/***
Expand All @@ -127,15 +126,12 @@ public static function verifyFormDinMinimumVersion($minimumVersion) {
* Verifica se a versão do AdiantiFrameWork atendene o requisito minimo para o FormDin funcionar
* @param string $minimumVersion
*/
public static function verifyMinimumVersionAdiantiFrameWorkToFormDin($minimumVersion) {
if ( empty($minimumVersion) ) {
throw new DomainException(TFormDinMessage::ADIANTI_VERSION_BLANK);
} else {
if( !FormDinHelper::versionMinimum($minimumVersion,self::ADIANTI_MIN_FORMDIN) ){
$msg = TFormDinMessage::ADIANTI_MIN_YOU_VERSION.self::ADIANTI_MIN_FORMDIN.'.'.TFormDinMessage::FORM_MIN_VERSION_ADIANTI.$minimumVersion;
throw new DomainException($msg);
}
}
public static function verifyMinimumVersionAdiantiFrameWorkToFormDin() {
$adiantiVersion = self::getAdiantiFrameWorkVersion();
if( !FormDinHelper::versionMinimum(self::ADIANTI_MIN_FORMDIN,$adiantiVersion) ){
$msg = TFormDinMessage::ADIANTI_MIN_YOU_VERSION.$adiantiVersion.'.'.TFormDinMessage::FORM_MIN_VERSION_ADIANTI.self::ADIANTI_MIN_FORMDIN;
throw new DomainException($msg);
}
}
/***
* Checks if the version of Adianti FrameWork meets the minimum requirement for System to work
Expand Down
44 changes: 37 additions & 7 deletions FormDin5/tests/lib/widget/FormDin5/helpers/FormDinHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
class FormDinHelperTest extends TestCase
{
public $formDinVersion = '5.1.1';
public $adiantiVersion = '7.5.1b2';
public $adiantiVersion = '7.6.0.1';

public function testVersion() {
$expected = $this->formDinVersion;
Expand All @@ -73,25 +73,55 @@ public function testVersionMinimum_equal() {
$result = FormDinHelper::versionMinimum('5.0.0');
$this->assertEquals( $expected , $result);
}
public function testVersionMinimum_Ref1Menor() {
$expected = true;
$result = FormDinHelper::versionMinimum('5.0.0','6.0.0');
$this->assertEquals( $expected , $result);
}
public function testVersionMinimum_Ref1equal() {
$expected = true;
$result = FormDinHelper::versionMinimum('6.0.0','6.0.0');
$this->assertEquals( $expected , $result);
}
public function testVersionMinimum_Ref1Maior() {
$expected = false;
$result = FormDinHelper::versionMinimum('6.0.0','5.0.0');
$this->assertEquals( $expected , $result);
}

/**
* @doesNotPerformAssertions
*/
public function testAdianti_verifyFormDinMinimumVersion_okOlder() {
FormDinHelper::verifyFormDinMinimumVersion('1.0.0');
}
/**
* @doesNotPerformAssertions
*/
public function testAdianti_verifyFormDinMinimumVersion_ok() {
FormDinHelper::verifyFormDinMinimumVersion($this->formDinVersion);
}
}
public function testAdianti_verifyFormDinMinimumVersion_Exception() {
$this->expectException(DomainException::class);
FormDinHelper::verifyFormDinMinimumVersion('99.99.99');
}
public function testAdianti_verifyFormDinMinimumVersion_ExceptionWrongFormat1() {
$this->expectException(DomainException::class);
FormDinHelper::verifyFormDinMinimumVersion('99');
}
public function testAdianti_verifyFormDinMinimumVersion_ExceptionWrongFormat2() {
$this->expectException(DomainException::class);
FormDinHelper::verifyFormDinMinimumVersion('99.99');
}
public function testAdianti_verifyFormDinMinimumVersion_ExceptionWrongFormat5() {
$this->expectException(DomainException::class);
FormDinHelper::verifyFormDinMinimumVersion('99.99.99.99.99');
}
/**
* @doesNotPerformAssertions
*/
public function testAdianti_verifyMinimumVersionAdiantiFrameWorkToFormDin_ok() {
FormDinHelper::verifyMinimumVersionAdiantiFrameWorkToFormDin($this->formDinVersion);
}
public function testAdianti_verifyMinimumVersionAdiantiFrameWorkToFormDin_Exception() {
$this->expectException(DomainException::class);
FormDinHelper::verifyMinimumVersionAdiantiFrameWorkToFormDin('99.99.99');
FormDinHelper::verifyMinimumVersionAdiantiFrameWorkToFormDin();
}
/**
* @doesNotPerformAssertions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function testAddFilter_like() {
$data->nome = 'Maria';

$expected = array();
$expected[] = new TFilter('nome','like',$data);
$expected[] = new TFilter('nome','like',$data->nome);

$filters= array();
$result = OrmAdiantiHelper::addFilter($filters,'nome','like',$data->nome,null);
Expand All @@ -119,7 +119,7 @@ public function testAddFilter_equal() {
$data->nome = 'Maria';

$expected = array();
$expected[] = new TFilter('nome','=',$data);
$expected[] = new TFilter('nome','=',$data->nome);

$filters= array();
$result = OrmAdiantiHelper::addFilter($filters,'nome','=',$data->nome,null);
Expand All @@ -130,7 +130,7 @@ public function testAddFilter_notEqual() {
$data->nome = 'Maria';

$expected = array();
$expected[] = new TFilter('nome','!=',$data);
$expected[] = new TFilter('nome','!=',$data->nome);

$filters= array();
$result = OrmAdiantiHelper::addFilter($filters,'nome','!=',$data->nome,null);
Expand All @@ -141,7 +141,7 @@ public function testAddFilter_In() {
$data->nome = 'Maria';

$expected = array();
$expected[] = new TFilter('nome','in',$data);
$expected[] = new TFilter('nome','in',$data->nome);

$filters= array();
$result = OrmAdiantiHelper::addFilter($filters,'nome','in',$data->nome,null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@ class TFormDinGridColumnFormatDateTest extends TestCase
{

private $classTest;
private $objForm;

/**
* Prepares the environment before running a test.
*/
protected function setUp(): void {
parent::setUp();
$this->classTest = new TFormDinGridColumnFormatDate('TEST', 'TEST');
$this->objForm = new mockFormDinComAdianti();
$this->classTest = new TFormDinGridColumnFormatDate($this->objForm,'TEST', 'TEST');
}

/**
Expand Down

0 comments on commit 526a0f3

Please sign in to comment.