forked from Wavyzz/dolibarr
FIX Better test on validity of compute field syntax with parenthesis
This commit is contained in:
@@ -1061,6 +1061,10 @@ class SecurityTest extends PHPUnit\Framework\TestCase
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
// Declare classes found into string to evaluate
|
||||
include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
include_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
|
||||
|
||||
$result=dol_eval('1==1', 1, 0);
|
||||
print "result1 = ".$result."\n";
|
||||
$this->assertTrue($result);
|
||||
@@ -1069,8 +1073,15 @@ class SecurityTest extends PHPUnit\Framework\TestCase
|
||||
print "result2 = ".$result."\n";
|
||||
$this->assertFalse($result);
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
include_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
|
||||
$s = '((($reloadedobj = new ClassThatDoesNotExists($db)) && ($reloadedobj->fetchNoCompute($objectoffield->fk_product) > 0)) ? \'1\' : \'0\')';
|
||||
$result3a = dol_eval($s, 1, 1, '2');
|
||||
print "result3a = ".$result."\n";
|
||||
$this->assertTrue(is_null($result3a));
|
||||
|
||||
$s = '((($reloadedobj = new Project($db)) && ($reloadedobj->fetchNoCompute($objectoffield->fk_product) > 0)) ? \'1\' : \'0\')';
|
||||
$result3b = dol_eval($s, 1, 1, '2');
|
||||
print "result3b = ".$result."\n";
|
||||
$this->assertEquals('0', $result3b);
|
||||
|
||||
$s = '(($reloadedobj = new Task($db)) && ($reloadedobj->fetchNoCompute($object->id) > 0) && ($secondloadedobj = new Project($db)) && ($secondloadedobj->fetchNoCompute($reloadedobj->fk_project) > 0)) ? $secondloadedobj->ref : "Parent project not found"';
|
||||
$result=dol_eval($s, 1, 1, '2');
|
||||
|
||||
Reference in New Issue
Block a user