Fix test on verifCond for value 0
This commit is contained in:
parent
0c9fb16a36
commit
e609622f2b
@ -8082,7 +8082,7 @@ function verifCond($strRights)
|
|||||||
|
|
||||||
//print $strRights."<br>\n";
|
//print $strRights."<br>\n";
|
||||||
$rights = true;
|
$rights = true;
|
||||||
if ($strRights != '') {
|
if ($strRights !== '') {
|
||||||
$str = 'if(!('.$strRights.')) { $rights = false; }';
|
$str = 'if(!('.$strRights.')) { $rights = false; }';
|
||||||
dol_eval($str); // The dol_eval must contains all the global $xxx used into a condition
|
dol_eval($str); // The dol_eval must contains all the global $xxx used into a condition
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1048,13 +1048,19 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase
|
|||||||
$this->assertFalse($verifcond, 'Test a false comparison');
|
$this->assertFalse($verifcond, 'Test a false comparison');
|
||||||
|
|
||||||
$verifcond=verifCond('$conf->facture->enabled');
|
$verifcond=verifCond('$conf->facture->enabled');
|
||||||
$this->assertTrue($verifcond, 'Test that conf property of a module report true when enabled');
|
$this->assertTrue($verifcond, 'Test that the conf property of a module reports true when enabled');
|
||||||
|
|
||||||
$verifcond=verifCond('$conf->moduledummy->enabled');
|
$verifcond=verifCond('$conf->moduledummy->enabled');
|
||||||
$this->assertFalse($verifcond, 'Test that conf property of a module report false when disabled');
|
$this->assertFalse($verifcond, 'Test that the conf property of a module reports false when disabled');
|
||||||
|
|
||||||
|
$verifcond=verifCond(0);
|
||||||
|
$this->assertFalse($verifcond, 'Test that verifConf(0) return False');
|
||||||
|
|
||||||
|
$verifcond=verifCond("0");
|
||||||
|
$this->assertFalse($verifcond, 'Test that verifConf("0") return False');
|
||||||
|
|
||||||
$verifcond=verifCond('');
|
$verifcond=verifCond('');
|
||||||
$this->assertTrue($verifcond);
|
$this->assertTrue($verifcond, 'Test that verifConf("") return False (special case)');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user