Fix test on $resql

This commit is contained in:
Laurent Destailleur 2023-03-17 18:05:45 +01:00
parent 17807ea00c
commit 3961fa7a97
3 changed files with 13 additions and 4 deletions

View File

@ -3930,8 +3930,8 @@ class CommandeFournisseurLigne extends CommonOrderLine
$sql .= " WHERE rowid = ".((int) $this->id);
dol_syslog(get_class($this)."::updateline", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result) {
$resql = $this->db->query($sql);
if ($resql) {
if (!$error) {
$result = $this->insertExtraFields();
if ($result < 0) {
@ -3940,7 +3940,6 @@ class CommandeFournisseurLigne extends CommonOrderLine
}
if (!$error && !$notrigger) {
global $user;
// Call trigger
$result = $this->call_trigger('LINEORDER_SUPPLIER_MODIFY', $user);
if ($result < 0) {

View File

@ -4240,7 +4240,7 @@ class Product extends CommonObject
$sql = "SELECT MAX(rang) as max_rank FROM ".$this->db->prefix()."product_association";
$sql .= " WHERE fk_product_pere = ".((int) $id_pere);
$resql = $this->db->query($sql);
if ($resql > 0) {
if ($resql) {
$obj = $this->db->fetch_object($resql);
$rank = $obj->max_rank + 1;
//Addition of a product with the highest rank +1

View File

@ -544,6 +544,16 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase
$this->assertTrue($ok, 'Found a preg_grep with a param that is a $var but without preg_quote in file '.$file['relativename'].'.');
// Test we don't have "if ($resql >"
$ok=true;
$matches=array();
preg_match_all('/if \(\$resql >/', $filecontent, $matches, PREG_SET_ORDER);
foreach ($matches as $key => $val) {
$ok=false;
break;
}
$this->assertTrue($ok, 'Found a if $resql with a > operator (when $resql is a boolean or resource) in file '.$file['relativename'].'. Please remove the > ... part.');
// Test we don't have empty($user->hasRight
$ok=true;
$matches=array();