From 124e7f9b8823e4c509b7d11bd69b9e9294a119f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 24 Nov 2021 23:07:06 +0100 Subject: [PATCH] enable societe.class.php in coding test --- htdocs/societe/class/societe.class.php | 12 ++++++------ test/phpunit/CodingPhpTest.php | 5 ++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 22276cc7bee..84f551bbd93 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -4752,12 +4752,12 @@ class Societe extends CommonObject * Function used to replace a thirdparty id with another one. * It must be used within a transaction to avoid trouble * - * @param DoliDB $db Database handler + * @param DoliDB $dbs Database handler, because function is static we name it $dbs not $db to avoid breaking coding test * @param int $origin_id Old thirdparty id (will be removed) * @param int $dest_id New thirdparty id * @return bool True if success, False if error */ - public static function replaceThirdparty(DoliDB $db, $origin_id, $dest_id) + public static function replaceThirdparty(DoliDB $dbs, $origin_id, $dest_id) { if ($origin_id == $dest_id) { dol_syslog('Error: Try to merge a thirdparty into itself'); @@ -4774,9 +4774,9 @@ class Societe extends CommonObject $sql .= ' FROM '.MAIN_DB_PREFIX.'societe_commerciaux '; $sql .= ' WHERE fk_soc = '.(int) $origin_id.') '; - $resql = $db->query($sql); - while ($obj = $db->fetch_object($resql)) { - $db->query('DELETE FROM '.MAIN_DB_PREFIX.'societe_commerciaux WHERE rowid = '.((int) $obj->rowid)); + $resql = $dbs->query($sql); + while ($obj = $dbs->fetch_object($resql)) { + $dbs->query('DELETE FROM '.MAIN_DB_PREFIX.'societe_commerciaux WHERE rowid = '.((int) $obj->rowid)); } /** @@ -4792,7 +4792,7 @@ class Societe extends CommonObject 'societe_rib' ); - return CommonObject::commonReplaceThirdparty($db, $origin_id, $dest_id, $tables); + return CommonObject::commonReplaceThirdparty($dbs, $origin_id, $dest_id, $tables); } /** diff --git a/test/phpunit/CodingPhpTest.php b/test/phpunit/CodingPhpTest.php index 383c37e95e5..b069140f420 100644 --- a/test/phpunit/CodingPhpTest.php +++ b/test/phpunit/CodingPhpTest.php @@ -213,12 +213,11 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase 'multicurrency.class.php', 'productbatch.class.php', 'reception.class.php', - 'societe.class.php' ))) { - // Must not found $db-> + // Must not find $db-> $ok=true; $matches=array(); - // Check string $db-> inside a class.php file (it should be $this->db-> insto such classes) + // Check string $db-> inside a class.php file (it should be $this->db-> into such classes) preg_match_all('/'.preg_quote('$db->', '/').'/', $filecontent, $matches, PREG_SET_ORDER); foreach ($matches as $key => $val) { $ok=false;