From fb4173673ade1dd7b67ba9bf7409abd7795d1188 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@users.sourceforge.net>
Date: Wed, 14 Jul 2010 23:10:56 +0000
Subject: [PATCH] Fix: Fix on PHPUnit tests

---
 htdocs/compta/facture/class/facture.class.php | 13 ++++++++-----
 htdocs/core/class/notify.class.php            |  3 ++-
 test/AdherentTest.php                         |  1 +
 test/BuildDocTest.php                         |  1 +
 test/CommandeTest.php                         |  1 +
 test/CommonObjectTest.php                     |  1 +
 test/CompanyBankAccountTest.php               |  1 +
 test/ContratTest.php                          |  1 +
 test/DateLibTest.php                          |  3 ++-
 test/FactureTest.php                          |  1 +
 test/MyTestSuite.php                          |  1 +
 test/PropalTest.php                           |  1 +
 test/UserGroupTest.php                        |  1 +
 test/UserTest.php                             |  1 +
 14 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index 2046b785b52..ee5e01fd3a1 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -165,6 +165,7 @@ class Facture extends CommonObject
 			return -2;
 		}
 
+		$now=dol_now();
 
 		$this->db->begin();
 
@@ -226,7 +227,7 @@ class Facture extends CommonObject
 		$sql.= ", ".$conf->entity;
 		$sql.= ", '".$this->type."'";
 		$sql.= ", '".$socid."'";
-		$sql.= ", ".$this->db->idate(gmmktime());
+		$sql.= ", ".$this->db->idate($now);
 		$sql.= ", '".$totalht."'";
 		$sql.= ",".($this->remise_absolue>0?$this->remise_absolue:'NULL');
 		$sql.= ",".($this->remise_percent>0?$this->remise_percent:'NULL');
@@ -300,7 +301,7 @@ class Facture extends CommonObject
 					$tva_tx = get_default_tva($mysoc,$soc,($prod->tva_tx?$prod->tva_tx:0));
 					$localtax1_tx=get_localtax($tva_tx,1,$soc);
 					$localtax2_tx=get_localtax($tva_tx,2,$soc);
-					
+
 					$result_insert = $this->addline(
 					$this->id,
 					$_facrec->lignes[$i]->desc,
@@ -1611,7 +1612,7 @@ class Facture extends CommonObject
 			$txtva=price2num($txtva);
 			$txlocaltax1=price2num($txlocaltax1);
 			$txlocaltax2=price2num($txlocaltax2);
-			
+
 			if ($price_base_type=='HT')
 			{
 				$pu=$pu_ht;
@@ -2814,6 +2815,8 @@ class Facture extends CommonObject
 			$ligne->subprice=100;
 			$ligne->price=100;
 			$ligne->tva_tx=19.6;
+			$ligne->localtax1_tx=0;
+			$ligne->localtax2_tx=0;
 			$ligne->remise_percent=10;
 			$ligne->total_ht=90;
 			$ligne->total_ttc=107.64;	// 90 * 1.196
@@ -2910,8 +2913,8 @@ class FactureLigne
 	var $total_ht;
 	//! Total TVA  de la ligne toute quantite et incluant la remise ligne
 	var $total_tva;
-	var $total_localtax1; //Total Local tax 1 de la ligne
-	var $total_localtax2; //Total Local tax 2 de la ligne
+	var $total_localtax1=0; //Total Local tax 1 de la ligne
+	var $total_localtax2=0; //Total Local tax 2 de la ligne
 	//! Total TTC de la ligne toute quantite et incluant la remise ligne
 	var $total_ttc;
 
diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php
index aac03d10a47..41d497260db 100644
--- a/htdocs/core/class/notify.class.php
+++ b/htdocs/core/class/notify.class.php
@@ -87,7 +87,7 @@ class Notify
 	{
         $num=-1;
 
-        $sql = "SELECT n.rowid, c.email, c.rowid, c.name, c.firstname, a.titre, s.nom";
+        $sql = "SELECT n.rowid, c.email, c.rowid, c.name, c.firstname, a.code, a.titre, s.nom";
         $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as c, ".MAIN_DB_PREFIX."action_def as a, ".MAIN_DB_PREFIX."notify_def as n, ".MAIN_DB_PREFIX."societe as s";
         $sql.= " WHERE n.fk_contact = c.rowid AND a.rowid = n.fk_action";
         $sql.= " AND n.fk_soc = s.rowid";
@@ -218,6 +218,7 @@ class Notify
                     else
                     {
                         $this->error=$mailfile->error;
+                        //dol_syslog("Notify::send ".$this->error, LOG_ERR);
                     }
                 }
                 $i++;
diff --git a/test/AdherentTest.php b/test/AdherentTest.php
index 8b82eb0f73d..3257a397d48 100644
--- a/test/AdherentTest.php
+++ b/test/AdherentTest.php
@@ -36,6 +36,7 @@ if (empty($user->id))
 	$user->fetch(1);
 	$user->getrights();
 }
+$conf->global->MAIN_DISABLE_ALL_MAILS=1;
 
 
 /**
diff --git a/test/BuildDocTest.php b/test/BuildDocTest.php
index 8d209d29e13..0c0e787e37d 100644
--- a/test/BuildDocTest.php
+++ b/test/BuildDocTest.php
@@ -36,6 +36,7 @@ if (empty($user->id))
 	$user->fetch(1);
 	$user->getrights();
 }
+$conf->global->MAIN_DISABLE_ALL_MAILS=1;
 
 
 /**
diff --git a/test/CommandeTest.php b/test/CommandeTest.php
index 4c0b6a48577..b3e6b0ce299 100644
--- a/test/CommandeTest.php
+++ b/test/CommandeTest.php
@@ -36,6 +36,7 @@ if (empty($user->id))
 	$user->fetch(1);
 	$user->getrights();
 }
+$conf->global->MAIN_DISABLE_ALL_MAILS=1;
 
 
 /**
diff --git a/test/CommonObjectTest.php b/test/CommonObjectTest.php
index 27fb80e491f..e3e9840603d 100644
--- a/test/CommonObjectTest.php
+++ b/test/CommonObjectTest.php
@@ -37,6 +37,7 @@ if (empty($user->id))
 	$user->fetch(1);
 	$user->getrights();
 }
+$conf->global->MAIN_DISABLE_ALL_MAILS=1;
 
 
 /**
diff --git a/test/CompanyBankAccountTest.php b/test/CompanyBankAccountTest.php
index b0c2be044f3..bdec9452a56 100644
--- a/test/CompanyBankAccountTest.php
+++ b/test/CompanyBankAccountTest.php
@@ -36,6 +36,7 @@ if (empty($user->id))
 	$user->fetch(1);
 	$user->getrights();
 }
+$conf->global->MAIN_DISABLE_ALL_MAILS=1;
 
 
 /**
diff --git a/test/ContratTest.php b/test/ContratTest.php
index a1da26ea4cc..61d1118262b 100644
--- a/test/ContratTest.php
+++ b/test/ContratTest.php
@@ -36,6 +36,7 @@ if (empty($user->id))
 	$user->fetch(1);
 	$user->getrights();
 }
+$conf->global->MAIN_DISABLE_ALL_MAILS=1;
 
 
 /**
diff --git a/test/DateLibTest.php b/test/DateLibTest.php
index d1db7c3311c..592cf8af8d1 100644
--- a/test/DateLibTest.php
+++ b/test/DateLibTest.php
@@ -36,6 +36,7 @@ if (empty($user->id))
 	$user->fetch(1);
 	$user->getrights();
 }
+$conf->global->MAIN_DISABLE_ALL_MAILS=1;
 
 
 /**
@@ -134,7 +135,7 @@ class DateLibTest extends PHPUnit_Framework_TestCase
 
 		$result=ConvertSecondToTime(0,'all',86400);
     	print __METHOD__." result=".$result."\n";
-		$this->assertEquals('00:00',$result);
+		$this->assertEquals('0',$result);
 
 		$result=ConvertSecondToTime(86400,'all',86400);
     	print __METHOD__." result=".$result."\n";
diff --git a/test/FactureTest.php b/test/FactureTest.php
index 87858e8e3f1..3b79653de28 100644
--- a/test/FactureTest.php
+++ b/test/FactureTest.php
@@ -36,6 +36,7 @@ if (empty($user->id))
 	$user->fetch(1);
 	$user->getrights();
 }
+$conf->global->MAIN_DISABLE_ALL_MAILS=1;
 
 
 /**
diff --git a/test/MyTestSuite.php b/test/MyTestSuite.php
index e667e777c37..13fb364ad87 100644
--- a/test/MyTestSuite.php
+++ b/test/MyTestSuite.php
@@ -37,6 +37,7 @@ if (empty($user->id))
 	$user->fetch(1);
 	$user->getrights();
 }
+$conf->global->MAIN_DISABLE_ALL_MAILS=1;
 
 
 /**
diff --git a/test/PropalTest.php b/test/PropalTest.php
index 3bcaa2edd8b..7beed32501e 100644
--- a/test/PropalTest.php
+++ b/test/PropalTest.php
@@ -36,6 +36,7 @@ if (empty($user->id))
 	$user->fetch(1);
 	$user->getrights();
 }
+$conf->global->MAIN_DISABLE_ALL_MAILS=1;
 
 
 /**
diff --git a/test/UserGroupTest.php b/test/UserGroupTest.php
index 5ee3a241fd5..93791088d9d 100644
--- a/test/UserGroupTest.php
+++ b/test/UserGroupTest.php
@@ -36,6 +36,7 @@ if (empty($user->id))
 	$user->fetch(1);
 	$user->getrights();
 }
+$conf->global->MAIN_DISABLE_ALL_MAILS=1;
 
 
 /**
diff --git a/test/UserTest.php b/test/UserTest.php
index 91c2d4b03f4..1ffd9c707db 100644
--- a/test/UserTest.php
+++ b/test/UserTest.php
@@ -36,6 +36,7 @@ if (empty($user->id))
 	$user->fetch(1);
 	$user->getrights();
 }
+$conf->global->MAIN_DISABLE_ALL_MAILS=1;
 
 
 /**
-- 
GitLab