From d97c45a9b819986570a752c8b1b5cb2070675df7 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Thu, 1 May 2014 19:17:45 +0200
Subject: [PATCH] Add version of phpunit into travis script. Fix: strict mode.

---
 .travis.yml                                   |  2 +
 htdocs/compta/facture/class/facture.class.php |  4 +-
 htdocs/core/class/commonobject.class.php      |  5 +-
 htdocs/core/lib/functions2.lib.php            |  2 +-
 htdocs/core/lib/pdf.lib.php                   | 76 ++++++++++---------
 .../commande/doc/pdf_einstein.modules.php     |  2 +-
 .../expedition/doc/pdf_merou.modules.php      |  2 +-
 .../expedition/doc/pdf_rouget.modules.php     |  2 +-
 .../fichinter/doc/pdf_soleil.modules.php      |  2 +-
 htdocs/core/modules/modAdherent.class.php     |  4 +-
 htdocs/core/modules/modAgenda.class.php       |  3 +-
 htdocs/core/modules/modBanque.class.php       |  5 +-
 htdocs/core/modules/modBookmark.class.php     |  3 +-
 htdocs/core/modules/modCommande.class.php     |  2 +-
 htdocs/core/modules/modContrat.class.php      |  7 +-
 htdocs/core/modules/modFicheinter.class.php   |  5 +-
 htdocs/core/modules/modWorkflow.class.php     |  1 -
 .../project/pdf/pdf_baleine.modules.php       |  2 +-
 .../pdf/pdf_canelle.modules.php               |  7 +-
 ...terface_50_modAgenda_ActionsAuto.class.php | 16 ++--
 .../class/fournisseur.commande.class.php      |  6 +-
 htdocs/projet/class/project.class.php         | 13 ++--
 htdocs/projet/class/task.class.php            |  4 +-
 htdocs/societe/class/societe.class.php        |  9 ++-
 test/phpunit/AdherentTest.php                 |  2 +
 test/phpunit/ScriptsTest.php                  |  2 +-
 test/phpunit/SocieteTest.php                  |  2 +-
 27 files changed, 101 insertions(+), 89 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index a4f8ecd8270..4de657bbe31 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -31,6 +31,8 @@ before_script:
  - echo PHP version $PHPV 
 # - echo Update composer
 # - ~/.phpenv/versions/$(phpenv version-name)/bin/composer.phar self-update 
+ - echo PHPUnit version
+ - phpunit --version
  - echo Install phpcs then show installed rules
  - pyrus install pear/PHP_CodeSniffer
  - phpenv rehash
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index 44e4ce5032e..75ff6e18d5d 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -1270,7 +1270,7 @@ class Facture extends CommonInvoice
 			}
 			// Fin appel triggers
 		}
-		
+
 		// Removed extrafields
 		if (! $error) {
 			$result=$this->deleteExtraFields();
@@ -2654,7 +2654,7 @@ class Facture extends CommonInvoice
 		$num=count($this->lines);
 		for ($i = 0; $i < $num; $i++)
 		{
-			if ($this->lines[$i]->export_compta <> 0 && $this->lines[$i]->code_ventilation <> 0)
+			if (! empty($this->lines[$i]->export_compta) && ! empty($this->lines[$i]->code_ventilation))
 			{
 				$ventilExportCompta++;
 			}
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 3835f7cb07e..29bbbebaad9 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -79,7 +79,7 @@ abstract class CommonObject
         //print "lastname=".$this->lastname." name=".$this->name." nom=".$this->nom."<br>\n";
         $lastname=$this->lastname;
         $firstname=$this->firstname;
-        if (empty($lastname))  $lastname=($this->lastname?$this->lastname:($this->name?$this->name:$this->nom));
+        if (empty($lastname))  $lastname=(isset($this->lastname)?$this->lastname:(isset($this->name)?$this->name:(isset($this->nom)?$this->nom:'')));
         if (empty($firstname)) $firstname=$this->firstname;
 
         $ret='';
@@ -1590,6 +1590,9 @@ abstract class CommonObject
                 $this->total_localtax1 += $obj->total_localtax1;
                 $this->total_localtax2 += $obj->total_localtax2;
                 $this->total_ttc       += $obj->total_ttc;
+                if (! isset($total_ht_by_vats[$obj->vatrate]))  $total_ht_by_vats[$obj->vatrate]=0;
+                if (! isset($total_tva_by_vats[$obj->vatrate])) $total_tva_by_vats[$obj->vatrate]=0;
+                if (! isset($total_ttc_by_vats[$obj->vatrate])) $total_ttc_by_vats[$obj->vatrate]=0;
                 $total_ht_by_vats[$obj->vatrate]  += $obj->total_ht;
                 $total_tva_by_vats[$obj->vatrate] += $obj->total_tva;
                 $total_ttc_by_vats[$obj->vatrate] += $obj->total_ttc;
diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php
index 4ef5ad707b1..5d952c0a1c4 100644
--- a/htdocs/core/lib/functions2.lib.php
+++ b/htdocs/core/lib/functions2.lib.php
@@ -454,7 +454,7 @@ function clean_url($url,$http=1)
     {
         $proto=$regs[1];
         $domain=$regs[2];
-        $port=$regs[3];
+        $port=isset($regs[3])?$regs[3]:'';
         //print $url." -> ".$proto." - ".$domain." - ".$port;
         //$url = dol_string_nospecial(trim($url));
         $url = trim($url);
diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php
index f79eec5e403..f250c5511e7 100644
--- a/htdocs/core/lib/pdf.lib.php
+++ b/htdocs/core/lib/pdf.lib.php
@@ -80,38 +80,40 @@ function pdf_getInstance($format='',$metric='mm',$pagetype='P')
 	global $conf;
 
 	// Define constant for TCPDF
-	define('K_TCPDF_EXTERNAL_CONFIG',1);	// this avoid using tcpdf_config file
-	define('K_PATH_CACHE', DOL_DATA_ROOT.'/admin/temp/');
-	define('K_PATH_URL_CACHE', DOL_DATA_ROOT.'/admin/temp/');
-	dol_mkdir(K_PATH_CACHE);
-	define('K_BLANK_IMAGE', '_blank.png');
-	define('PDF_PAGE_FORMAT', 'A4');
-	define('PDF_PAGE_ORIENTATION', 'P');
-	define('PDF_CREATOR', 'TCPDF');
-	define('PDF_AUTHOR', 'TCPDF');
-	define('PDF_HEADER_TITLE', 'TCPDF Example');
-	define('PDF_HEADER_STRING', "by Dolibarr ERP CRM");
-	define('PDF_UNIT', 'mm');
-	define('PDF_MARGIN_HEADER', 5);
-	define('PDF_MARGIN_FOOTER', 10);
-	define('PDF_MARGIN_TOP', 27);
-	define('PDF_MARGIN_BOTTOM', 25);
-	define('PDF_MARGIN_LEFT', 15);
-	define('PDF_MARGIN_RIGHT', 15);
-	define('PDF_FONT_NAME_MAIN', 'helvetica');
-	define('PDF_FONT_SIZE_MAIN', 10);
-	define('PDF_FONT_NAME_DATA', 'helvetica');
-	define('PDF_FONT_SIZE_DATA', 8);
-	define('PDF_FONT_MONOSPACED', 'courier');
-	define('PDF_IMAGE_SCALE_RATIO', 1.25);
-	define('HEAD_MAGNIFICATION', 1.1);
-	define('K_CELL_HEIGHT_RATIO', 1.25);
-	define('K_TITLE_MAGNIFICATION', 1.3);
-	define('K_SMALL_RATIO', 2/3);
-	define('K_THAI_TOPCHARS', true);
-	define('K_TCPDF_CALLS_IN_HTML', true);
-	define('K_TCPDF_THROW_EXCEPTION_ERROR', false);
-
+	if (! defined('K_TCPDF_EXTERNAL_CONFIG'))
+	{
+		define('K_TCPDF_EXTERNAL_CONFIG',1);	// this avoid using tcpdf_config file
+		define('K_PATH_CACHE', DOL_DATA_ROOT.'/admin/temp/');
+		define('K_PATH_URL_CACHE', DOL_DATA_ROOT.'/admin/temp/');
+		dol_mkdir(K_PATH_CACHE);
+		define('K_BLANK_IMAGE', '_blank.png');
+		define('PDF_PAGE_FORMAT', 'A4');
+		define('PDF_PAGE_ORIENTATION', 'P');
+		define('PDF_CREATOR', 'TCPDF');
+		define('PDF_AUTHOR', 'TCPDF');
+		define('PDF_HEADER_TITLE', 'TCPDF Example');
+		define('PDF_HEADER_STRING', "by Dolibarr ERP CRM");
+		define('PDF_UNIT', 'mm');
+		define('PDF_MARGIN_HEADER', 5);
+		define('PDF_MARGIN_FOOTER', 10);
+		define('PDF_MARGIN_TOP', 27);
+		define('PDF_MARGIN_BOTTOM', 25);
+		define('PDF_MARGIN_LEFT', 15);
+		define('PDF_MARGIN_RIGHT', 15);
+		define('PDF_FONT_NAME_MAIN', 'helvetica');
+		define('PDF_FONT_SIZE_MAIN', 10);
+		define('PDF_FONT_NAME_DATA', 'helvetica');
+		define('PDF_FONT_SIZE_DATA', 8);
+		define('PDF_FONT_MONOSPACED', 'courier');
+		define('PDF_IMAGE_SCALE_RATIO', 1.25);
+		define('HEAD_MAGNIFICATION', 1.1);
+		define('K_CELL_HEIGHT_RATIO', 1.25);
+		define('K_TITLE_MAGNIFICATION', 1.3);
+		define('K_SMALL_RATIO', 2/3);
+		define('K_THAI_TOPCHARS', true);
+		define('K_TCPDF_CALLS_IN_HTML', true);
+		define('K_TCPDF_THROW_EXCEPTION_ERROR', false);
+	}
 
 	if (! empty($conf->global->MAIN_USE_FPDF) && ! empty($conf->global->MAIN_DISABLE_FPDI))
 		return "Error MAIN_USE_FPDF and MAIN_DISABLE_FPDI can't be set together";
@@ -129,7 +131,7 @@ function pdf_getInstance($format='',$metric='mm',$pagetype='P')
 
 	// Protection and encryption of pdf
 	if (empty($conf->global->MAIN_USE_FPDF) && ! empty($conf->global->PDF_SECURITY_ENCRYPTION))
-	{	
+	{
 		/* Permission supported by TCPDF
 		- print : Print the document;
 		- modify : Modify the contents of the document by operations other than those controlled by 'fill-forms', 'extract' and 'assemble';
@@ -161,7 +163,7 @@ function pdf_getInstance($format='',$metric='mm',$pagetype='P')
 	{
 		// Declare here a class to overwrite FPDI to add method writeHTMLCell
 		/**
-		 *	This class if a enhanced FPDI class that support method writeHTMLCell
+		 *	This class is an enhanced FPDI class that support method writeHTMLCell
 		 */
 		class FPDI_DolExtended extends FPDI
         {
@@ -910,7 +912,7 @@ function pdf_writelinedesc(&$pdf,$object,$i,$outputlangs,$w,$h,$posx,$posy,$hide
 	global $db, $conf, $langs, $hookmanager;
 
 	$reshook=0;
-	if (is_object($hookmanager) && ( ($object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code) ) || ! empty($object->lines[$i]->fk_parent_line) ) )
+	if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) )
 	{
 		$special_code = $object->lines[$i]->special_code;
 		if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);
@@ -959,7 +961,7 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl
 		if (! empty($conf->global->MAIN_MULTILANGS) && ($outputlangs->defaultlang != $langs->defaultlang))
 		{
 			if (! empty($prodser->multilangs[$outputlangs->defaultlang]["label"]) && $label == $prodser->label)     $label=$prodser->multilangs[$outputlangs->defaultlang]["label"];
-			
+
 			//Manage HTML entities description test
 			//Cause $prodser->description is store with htmlentities but $desc no
 			$needdesctranslation=false;
@@ -1081,7 +1083,7 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl
 		//print $libelleproduitservice;
 	}
 
-	if ($dbatch) 
+	if ($dbatch)
 	{
 		$format='day';
 		foreach ($dbatch as $detail)
diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php
index 2097ac0997f..e7b8f320ba9 100644
--- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php
+++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php
@@ -641,7 +641,7 @@ class pdf_einstein extends ModelePDFCommandes
 			$pdf->SetTextColor(0,0,0);
 			$pdf->SetFont('','', $default_font_size - 2);
 			$pdf->SetXY($posxval, $posy);
-			$lib_availability=$outputlangs->transnoentities("AvailabilityType".$object->availability_code)!=('AvailabilityType'.$object->availability_code)?$outputlangs->transnoentities("AvailabilityType".$object->availability_code):$outputlangs->convToOutputCharset($object->availability);
+			$lib_availability=$outputlangs->transnoentities("AvailabilityType".$object->availability_code)!=('AvailabilityType'.$object->availability_code)?$outputlangs->transnoentities("AvailabilityType".$object->availability_code):$outputlangs->convToOutputCharset(isset($object->availability)?$object->availability:'');
 			$lib_availability=str_replace('\n',"\n",$lib_availability);
 			$pdf->MultiCell(80, 4, $lib_availability, 0, 'L');
 
diff --git a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php
index 63ab48d8138..3de9a45f45d 100644
--- a/htdocs/core/modules/expedition/doc/pdf_merou.modules.php
+++ b/htdocs/core/modules/expedition/doc/pdf_merou.modules.php
@@ -602,7 +602,7 @@ class pdf_merou extends ModelePdfExpedition
 			$carac_client_name=$outputlangs->convToOutputCharset($object->client->nom);
 		}
 
-		$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,$object->contact,$usecontact,'target');
+		$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,((!empty($object->contact))?$object->contact:null),$usecontact,'target');
 
 
 		$blDestX=$blExpX+55;
diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
index d924da16785..caf6c69ceae 100644
--- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
+++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
@@ -612,7 +612,7 @@ class pdf_rouget extends ModelePdfExpedition
 				$carac_client_name=$outputlangs->convToOutputCharset($object->client->nom);
 			}
 
-			$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,$object->contact,$usecontact,'target');
+			$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,(!empty($object->contact)?$object->contact:null),$usecontact,'target');
 
 			// Show recipient
 			$widthrecbox=100;
diff --git a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php
index 0d28eda7b66..5e7c2141a0f 100644
--- a/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php
+++ b/htdocs/core/modules/fichinter/doc/pdf_soleil.modules.php
@@ -237,7 +237,7 @@ class pdf_soleil extends ModelePDFFicheinter
 				{
 					$objectligne = $object->lines[$i];
 
-					$valide = $objectligne->id ? $objectligne->fetch($objectligne->id) : 0;
+					$valide = empty($objectligne->id) ? 0 : $objectligne->fetch($objectligne->id);
 					if ($valide > 0 || $object->specimen)
 					{
 						$curX = $this->posxdesc-1;
diff --git a/htdocs/core/modules/modAdherent.class.php b/htdocs/core/modules/modAdherent.class.php
index 6dc8f90a803..1cfd593522b 100644
--- a/htdocs/core/modules/modAdherent.class.php
+++ b/htdocs/core/modules/modAdherent.class.php
@@ -92,9 +92,7 @@ class modAdherent extends DolibarrModules
 
         // Boxes
         //-------
-        $this->boxes = array();
-        $r=0;
-        $this->boxes[$r][1] = "box_members.php";
+        $this->boxes = array(0=>array('file'=>'box_members.php','enabledbydefaulton'=>'Home'));
 
         // Permissions
         //------------
diff --git a/htdocs/core/modules/modAgenda.class.php b/htdocs/core/modules/modAgenda.class.php
index 4e552d7cad7..6424bcb5194 100644
--- a/htdocs/core/modules/modAgenda.class.php
+++ b/htdocs/core/modules/modAgenda.class.php
@@ -97,8 +97,7 @@ class modAgenda extends DolibarrModules
 
 		// Boxes
 		//------
-		$this->boxes = array();
-		$this->boxes[0][1] = "box_actions.php";
+		$this->boxes = array(0=>array('file'=>'box_actions.php','enabledbydefaulton'=>'Home'));
 
 		// Permissions
 		//------------
diff --git a/htdocs/core/modules/modBanque.class.php b/htdocs/core/modules/modBanque.class.php
index 1d682edf9a2..04259aec337 100644
--- a/htdocs/core/modules/modBanque.class.php
+++ b/htdocs/core/modules/modBanque.class.php
@@ -77,8 +77,7 @@ class modBanque extends DolibarrModules
 		$this->const = array();
 
 		// Boites
-		$this->boxes = array();
-		$this->boxes[0][1] = "box_comptes.php";
+		$this->boxes = array(0=>array('file'=>'box_comptes.php','enabledbydefaulton'=>'Home'));
 
 		// Permissions
 		$this->rights = array();
@@ -160,7 +159,7 @@ class modBanque extends DolibarrModules
 		$this->export_sql_end[$r] .=' WHERE ba.rowid = b.fk_account';
 		$this->export_sql_end[$r] .=' AND ba.entity = '.$conf->entity;
 		$this->export_sql_order[$r] =' ORDER BY b.datev, b.num_releve';
-		
+
 		$r++;
 		$this->export_code[$r]=$this->rights_class.'_'.$r;
 		$this->export_label[$r]='Bordereaux remise Chq/Fact';
diff --git a/htdocs/core/modules/modBookmark.class.php b/htdocs/core/modules/modBookmark.class.php
index 7743ee79d57..3ae2f0eee12 100644
--- a/htdocs/core/modules/modBookmark.class.php
+++ b/htdocs/core/modules/modBookmark.class.php
@@ -70,8 +70,7 @@ class modBookmark extends DolibarrModules
 		$this->const = array();
 
 		// Boites
-		$this->boxes = array();
-		$this->boxes[0][1] = "box_bookmarks.php";
+		$this->boxes = array(0=>array('file'=>'box_bookmarks.php','enabledbydefaulton'=>'Home'));
 
 		// Permissions
 		$this->rights = array();
diff --git a/htdocs/core/modules/modCommande.class.php b/htdocs/core/modules/modCommande.class.php
index f9d552c286b..8a7a7789d3f 100644
--- a/htdocs/core/modules/modCommande.class.php
+++ b/htdocs/core/modules/modCommande.class.php
@@ -97,7 +97,7 @@ class modCommande extends DolibarrModules
 		$this->const[$r][3] = "";
 		$this->const[$r][4] = 0;
 
-		// Boites
+		// Boxes
 		$this->boxes = array();
 		$this->boxes = array(0=>array('file'=>'box_commandes.php','enabledbydefaulton'=>'Home'),2=>array('file'=>'box_graph_orders_permonth.php','enabledbydefaulton'=>'Home'));
 
diff --git a/htdocs/core/modules/modContrat.class.php b/htdocs/core/modules/modContrat.class.php
index 1ec212fb07b..48c94ff3ad3 100644
--- a/htdocs/core/modules/modContrat.class.php
+++ b/htdocs/core/modules/modContrat.class.php
@@ -75,9 +75,10 @@ class modContrat extends DolibarrModules
 		$this->const[0][4] = 0;
 
 		// Boxes
-		$this->boxes = array();
-		$this->boxes[0][1] = "box_contracts.php";
-		$this->boxes[1][1] = "box_services_expired.php";
+		$this->boxes = array(
+			0=>array('file'=>'box_contracts.php','enabledbydefaulton'=>'Home'),
+			1=>array('file'=>'box_services_expired.php','enabledbydefaulton'=>'Home')
+		);
 
 		// Permissions
 		$this->rights = array();
diff --git a/htdocs/core/modules/modFicheinter.class.php b/htdocs/core/modules/modFicheinter.class.php
index 52a90179b95..e2bfe2c4dfa 100644
--- a/htdocs/core/modules/modFicheinter.class.php
+++ b/htdocs/core/modules/modFicheinter.class.php
@@ -87,9 +87,8 @@ class modFicheinter extends DolibarrModules
         $this->const[$r][2] = "pacific";
         $r++;
 
-        // Boites
-        $this->boxes = array();
-        $this->boxes[0][1] = "box_ficheinter.php";
+        // Boxes
+        $this->boxes = array(0=>array('file'=>'box_ficheinter.php','enabledbydefaulton'=>'Home'));
 
         // Permissions
         $this->rights = array();
diff --git a/htdocs/core/modules/modWorkflow.class.php b/htdocs/core/modules/modWorkflow.class.php
index 7757f2a2548..71586902154 100644
--- a/htdocs/core/modules/modWorkflow.class.php
+++ b/htdocs/core/modules/modWorkflow.class.php
@@ -84,7 +84,6 @@ class modWorkflow extends DolibarrModules
 
         // Boxes
         $this->boxes = array();
-        //$this->boxes[0][1] = "box_workflow@workflow";
 
         // Permissions
         $this->rights = array();
diff --git a/htdocs/core/modules/project/pdf/pdf_baleine.modules.php b/htdocs/core/modules/project/pdf/pdf_baleine.modules.php
index 881b112688e..4ccbb35f180 100644
--- a/htdocs/core/modules/project/pdf/pdf_baleine.modules.php
+++ b/htdocs/core/modules/project/pdf/pdf_baleine.modules.php
@@ -106,7 +106,7 @@ class pdf_baleine extends ModelePDFProjects
 
 		if ($conf->projet->dir_output)
 		{
-			$nblignes = count($object->lines);
+			//$nblignes = count($object->lines);  // This is set later with array of tasks
 
 			$objectref = dol_sanitizeFileName($object->ref);
 			$dir = $conf->projet->dir_output;
diff --git a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php
index d45a63a0b9e..b75c89f5d39 100644
--- a/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php
+++ b/htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php
@@ -371,13 +371,16 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 					$localtax1ligne=$object->lines[$i]->total_localtax1;
 					$localtax2ligne=$object->lines[$i]->total_localtax2;
 
-					if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
+					if (! empty($object->remise_percent)) $tvaligne-=($tvaligne*$object->remise_percent)/100;
 
 					$vatrate=(string) $object->lines[$i]->tva_tx;
 					$localtax1rate=(string) $object->lines[$i]->localtax1_tx;
 					$localtax2rate=(string) $object->lines[$i]->localtax2_tx;
 
 					if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
+					if (empty($this->tva[$vatrate])) $this->tva[$vatrate]=0;
+					if (empty($this->localtax1[$localtax1rate])) $this->localtax1[$localtax1rate]=0;
+					if (empty($this->localtax2[$localtax2rate])) $this->localtax2[$localtax2rate]=0;
 					$this->tva[$vatrate] += $tvaligne;
 					$this->localtax1[$localtax1rate]+=$localtax1ligne;
 					$this->localtax2[$localtax2rate]+=$localtax2ligne;
@@ -1011,7 +1014,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 				$carac_client_name=$outputlangs->convToOutputCharset($mysoc->nom);
 			}
 
-			$carac_client=pdf_build_address($outputlangs,$this->emetteur,$mysoc,$object->contact,$usecontact,'target');
+			$carac_client=pdf_build_address($outputlangs,$this->emetteur,$mysoc,((!empty($object->contact))?$object->contact:null),$usecontact,'target');
 
 			// Show recipient
 			$widthrecbox=100;
diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php
index 3c2a61b1ec6..d882b8b8ab0 100644
--- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php
+++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php
@@ -131,7 +131,7 @@ class InterfaceActionsAuto
 			$object->actiontypecode='AC_OTH_AUTO';
             if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("NewCompanyToDolibarr",$object->nom);
             $object->actionmsg=$langs->transnoentities("NewCompanyToDolibarr",$object->nom);
-            if ($object->prefix) $object->actionmsg.=" (".$object->prefix.")";
+            if (! empty($object->prefix)) $object->actionmsg.=" (".$object->prefix.")";
             //$this->desc.="\n".$langs->transnoentities("Customer").': '.yn($object->client);
             //$this->desc.="\n".$langs->transnoentities("Supplier").': '.yn($object->fournisseur);
             $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
@@ -380,7 +380,7 @@ class InterfaceActionsAuto
         	$langs->load("other");
         	$langs->load("sendings");
         	$langs->load("agenda");
-        
+
         	$object->actiontypecode='AC_OTH_AUTO';
         	if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("ShippingValidated",$object->ref);
         	if (empty($object->actionmsg))
@@ -388,7 +388,7 @@ class InterfaceActionsAuto
         		$object->actionmsg=$langs->transnoentities("ShippingValidated",$object->ref);
         		$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
         	}
-        
+
         	// Parameters $object->sendtoid defined by caller
         	//$object->sendtoid=0;
         	$ok=1;
@@ -431,12 +431,12 @@ class InterfaceActionsAuto
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
 			$langs->load("orders");
 			$langs->load("agenda");
-		
+
 			$object->actiontypecode='AC_OTH_AUTO';
 			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderApprovedInDolibarr",$object->ref);
 			$object->actionmsg=$langs->transnoentities("OrderApprovedInDolibarr",$object->ref);
 			$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
-		
+
 			$object->sendtoid=0;
 			$ok=1;
 		}
@@ -445,12 +445,12 @@ class InterfaceActionsAuto
 			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
 			$langs->load("orders");
 			$langs->load("agenda");
-		
+
 			$object->actiontypecode='AC_OTH_AUTO';
 			if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("OrderRefusedInDolibarr",$object->ref);
 			$object->actionmsg=$langs->transnoentities("OrderRefusedInDolibarr",$object->ref);
 			$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
-		
+
 			$object->sendtoid=0;
 			$ok=1;
 		}
@@ -691,7 +691,7 @@ class InterfaceActionsAuto
         if ($ok)
         {
 			$now=dol_now();
-			
+
 			if(isset($_SESSION['listofnames']))
 			{
 				$attachs=$_SESSION['listofnames'];
diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php
index 0cb6fa2081f..c996c0e7ad8 100644
--- a/htdocs/fourn/class/fournisseur.commande.class.php
+++ b/htdocs/fourn/class/fournisseur.commande.class.php
@@ -46,7 +46,7 @@ class CommandeFournisseur extends CommonOrder
     protected $ismultientitymanaged = 1;	// 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
 
     var $id;
-    
+
     var $ref;		 // TODO deprecated
     var $product_ref;
     var $ref_supplier;
@@ -1834,7 +1834,7 @@ class CommandeFournisseur extends CommonOrder
 
         // Find first product
         $prodid=0;
-        $product=new ProductFournisseur($db);
+        $product=new ProductFournisseur($this->db);
         $sql = "SELECT rowid";
         $sql.= " FROM ".MAIN_DB_PREFIX."product";
         $sql.= " WHERE entity IN (".getEntity('product', 1).")";
@@ -1992,6 +1992,8 @@ class CommandeFournisseurLigne
     var $tva_tx;
     var $localtax1_tx;
     var $localtax2_tx;
+    var $localtax1_type;
+    var $localtax2_type;
     var $subprice;
     var $remise_percent;
     var $desc;          	// Description ligne
diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php
index 7196387b067..ca25a8bbfbe 100644
--- a/htdocs/projet/class/project.class.php
+++ b/htdocs/projet/class/project.class.php
@@ -765,7 +765,7 @@ class Project extends CommonObject
 
         $now=dol_now();
 
-        // Initialise parametres
+        // Initialise parameters
         $this->id = 0;
         $this->ref = 'SPECIMEN';
         $this->specimen = 1;
@@ -774,17 +774,20 @@ class Project extends CommonObject
         $this->date_m = $now;
         $this->date_start = $now;
         $this->note_public = 'SPECIMEN';
+        /*
         $nbp = rand(1, 9);
         $xnbp = 0;
         while ($xnbp < $nbp)
         {
             $line = new Task($this->db);
-            $line->desc = $langs->trans("Description") . " " . $xnbp;
-            $line->qty = 1;
-            $prodid = rand(1, $num_prods);
-            $line->fk_product = $prodids[$prodid];
+            $line->fk_project = 0;
+            $line->label = $langs->trans("Label") . " " . $xnbp;
+            $line->description = $langs->trans("Description") . " " . $xnbp;
+
+            $this->lines[]=$line;
             $xnbp++;
         }
+        */
     }
 
     /**
diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php
index 3345ce84b21..6b0b51005da 100644
--- a/htdocs/projet/class/task.class.php
+++ b/htdocs/projet/class/task.class.php
@@ -602,7 +602,7 @@ class Task extends CommonObject
 
                 if (! $error)
                 {
-					$tasks[$i] = new Task($db);
+					$tasks[$i] = new Task($this->db);
                     $tasks[$i]->id				= $obj->taskid;
 					$tasks[$i]->ref				= $obj->ref_task;
                     $tasks[$i]->fk_project		= $obj->projectid;
@@ -801,7 +801,7 @@ class Task extends CommonObject
                 $ret = -2;
             }
         }
-		
+
 		if ($ret >= 0)
         {
             $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task_time";
diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php
index 0c18dc3f1a8..dc7488c733f 100644
--- a/htdocs/societe/class/societe.class.php
+++ b/htdocs/societe/class/societe.class.php
@@ -525,11 +525,12 @@ class Societe extends CommonObject
 
         // Check name is required and codes are ok or unique.
         // If error, this->errors[] is filled
+        $result = 0;
         if ($action != 'add') $result = $this->verify();	// We don't check when update called during a create because verify was already done
 
         if ($result >= 0)
         {
-            dol_syslog(get_class($this)."::update verify ok");
+            dol_syslog(get_class($this)."::update verify ok or not done");
 
             $sql  = "UPDATE ".MAIN_DB_PREFIX."societe SET ";
             $sql .= "nom = '" . $this->db->escape($this->name) ."'"; // Required
@@ -604,7 +605,7 @@ class Societe extends CommonObject
             	unset($this->state_code);
             	unset($this->state);
 
-            	$nbrowsaffected+=$this->db->affected_rows($resql);
+            	$nbrowsaffected = $this->db->affected_rows($resql);
 
             	if (! $error && $nbrowsaffected)
             	{
@@ -679,13 +680,13 @@ class Societe extends CommonObject
                     return 1;
                 }
                 else
-                {
+				{
                     $this->db->rollback();
                     return -1;
                 }
             }
             else
-            {
+			{
                 if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
                 {
                     // Doublon
diff --git a/test/phpunit/AdherentTest.php b/test/phpunit/AdherentTest.php
index aebd54f45f6..bdb1784495b 100644
--- a/test/phpunit/AdherentTest.php
+++ b/test/phpunit/AdherentTest.php
@@ -80,6 +80,8 @@ class AdherentTest extends PHPUnit_Framework_TestCase
     	global $conf,$user,$langs,$db;
 		$db->begin();	// This is to have all actions inside a transaction even if test launched without suite.
 
+        if (! empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)) { print "\n".__METHOD__." Company must be setup to have name-firstname in order 'Firstname Lastname'\n"; die(); }
+
     	print __METHOD__."\n";
     }
     public static function tearDownAfterClass()
diff --git a/test/phpunit/ScriptsTest.php b/test/phpunit/ScriptsTest.php
index 19a10dc526b..6c7a79f75a4 100755
--- a/test/phpunit/ScriptsTest.php
+++ b/test/phpunit/ScriptsTest.php
@@ -175,7 +175,7 @@ class ScriptsTest extends PHPUnit_Framework_TestCase
 		$this->assertEquals($result,'Failed to find bank account with ref BANKDUMMY.');
 		$this->assertEquals($returnvar,255);
 		*/
-        return $result;
+        return '';
     }
 
     /**
diff --git a/test/phpunit/SocieteTest.php b/test/phpunit/SocieteTest.php
index 4c512279476..e9a1a51a4c9 100755
--- a/test/phpunit/SocieteTest.php
+++ b/test/phpunit/SocieteTest.php
@@ -333,7 +333,7 @@ class SocieteTest extends PHPUnit_Framework_TestCase
         $this->assertNotEquals($result, '');
 
         $result=$localobject->isInEEC();
-        print __METHOD__." id=".$localobject->id." country_code=".$this->country_code." result=".$result."\n";
+        print __METHOD__." id=".$localobject->id." country_code=".$localobject->country_code." result=".$result."\n";
         $this->assertTrue(true, $result);
 
         $localobject->info($localobject->id);
-- 
GitLab