Enhance PHPUnits

This commit is contained in:
Laurent Destailleur 2011-12-30 14:18:19 +01:00
parent ce8f97e4aa
commit 55156edd0d
8 changed files with 484 additions and 109 deletions

View File

@ -80,7 +80,7 @@ class Adherent extends CommonObject
var $morphy; var $morphy;
var $public; var $public;
var $note; // Note var $note; // Private note
var $statut; // -1:brouillon, 0:resilie, >=1:valide,paye var $statut; // -1:brouillon, 0:resilie, >=1:valide,paye
var $photo; var $photo;
@ -115,11 +115,11 @@ class Adherent extends CommonObject
/** /**
* Constructor * Constructor
* *
* @param DoliDB $DB Database handler * @param DoliDB $db Database handler
*/ */
function Adherent($DB) function Adherent($db)
{ {
$this->db = $DB ; $this->db = $db;
$this->statut = -1; $this->statut = -1;
// l'adherent n'est pas public par defaut // l'adherent n'est pas public par defaut
$this->public = 0; $this->public = 0;
@ -388,8 +388,15 @@ class Adherent extends CommonObject
dol_syslog(get_class($this)."::update notrigger=".$notrigger.", nosyncuser=".$nosyncuser.", nosyncuserpass=".$nosyncuserpass.", email=".$this->email); dol_syslog(get_class($this)."::update notrigger=".$notrigger.", nosyncuser=".$nosyncuser.", nosyncuserpass=".$nosyncuserpass.", email=".$this->email);
// Clean parameters // Clean parameters
if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->nom=ucwords(trim($this->nom)); $this->lastname=trim($this->lastname)?trim($this->lastname):trim($this->nom);
if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->prenom=ucwords(trim($this->prenom)); $this->firstname=trim($this->firstname)?trim($this->firstname):trim($this->prenom);
$this->address=($this->address?$this->address:$this->adresse);
$this->zip=($this->zip?$this->zip:$this->cp);
$this->town=($this->town?$this->town:$this->ville);
$this->country_id=($this->country_id > 0?$this->country_id:$this->fk_pays);
$this->state_id=($this->state_id > 0?$this->state_id:$this->fk_departement);
if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname=ucwords(trim($this->lastname));
if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname=ucwords(trim($this->firstname));
// Check parameters // Check parameters
if (! empty($conf->global->ADHERENT_MAIL_REQUIRED) && ! isValidEMail($this->email)) if (! empty($conf->global->ADHERENT_MAIL_REQUIRED) && ! isValidEMail($this->email))
@ -403,16 +410,16 @@ class Adherent extends CommonObject
$sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET"; $sql = "UPDATE ".MAIN_DB_PREFIX."adherent SET";
$sql.= " civilite = ".($this->civilite_id?"'".$this->civilite_id."'":"null"); $sql.= " civilite = ".($this->civilite_id?"'".$this->civilite_id."'":"null");
$sql.= ", prenom = ".($this->prenom?"'".$this->db->escape($this->prenom)."'":"null"); $sql.= ", prenom = ".($this->firstname?"'".$this->db->escape($this->firstname)."'":"null");
$sql.= ", nom=" .($this->nom?"'".$this->db->escape($this->nom)."'":"null"); $sql.= ", nom=" .($this->lastname?"'".$this->db->escape($this->lastname)."'":"null");
$sql.= ", login=" .($this->login?"'".$this->db->escape($this->login)."'":"null"); $sql.= ", login=" .($this->login?"'".$this->db->escape($this->login)."'":"null");
$sql.= ", societe=" .($this->societe?"'".$this->db->escape($this->societe)."'":"null"); $sql.= ", societe=" .($this->societe?"'".$this->db->escape($this->societe)."'":"null");
$sql.= ", fk_soc=" .($this->fk_soc > 0?"'".$this->fk_soc."'":"null"); $sql.= ", fk_soc=" .($this->fk_soc > 0?"'".$this->fk_soc."'":"null");
$sql.= ", adresse=" .($this->adresse?"'".$this->db->escape($this->adresse)."'":"null"); $sql.= ", adresse=" .($this->address?"'".$this->db->escape($this->address)."'":"null");
$sql.= ", cp=" .($this->cp?"'".$this->db->escape($this->cp)."'":"null"); $sql.= ", cp=" .($this->zip?"'".$this->db->escape($this->zip)."'":"null");
$sql.= ", ville=" .($this->ville?"'".$this->db->escape($this->ville)."'":"null"); $sql.= ", ville=" .($this->town?"'".$this->db->escape($this->town)."'":"null");
$sql.= ", pays=" .($this->country_id>0?"'".$this->country_id."'":"null"); $sql.= ", pays=" .($this->country_id>0?"'".$this->country_id."'":"null");
$sql.= ", fk_departement=".($this->fk_departement>0?"'".$this->fk_departement."'":"null"); $sql.= ", fk_departement=".($this->state_id>0?"'".$this->state_id."'":"null");
$sql.= ", email='".$this->email."'"; $sql.= ", email='".$this->email."'";
$sql.= ", phone=" .($this->phone?"'".$this->db->escape($this->phone)."'":"null"); $sql.= ", phone=" .($this->phone?"'".$this->db->escape($this->phone)."'":"null");
$sql.= ", phone_perso=" .($this->phone_perso?"'".$this->db->escape($this->phone_perso)."'":"null"); $sql.= ", phone_perso=" .($this->phone_perso?"'".$this->db->escape($this->phone_perso)."'":"null");
@ -433,7 +440,12 @@ class Adherent extends CommonObject
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
$nbrowsaffected+=$this->db->affected_rows($resql); unset($this->country_code);
unset($this->country);
unset($this->state_code);
unset($this->state);
$nbrowsaffected+=$this->db->affected_rows($resql);
// Actions on extra fields (by external module) // Actions on extra fields (by external module)
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
@ -953,7 +965,7 @@ class Adherent extends CommonObject
{ {
global $conf, $langs; global $conf, $langs;
$sql = "SELECT d.rowid, d.civilite, d.prenom as firstname, d.nom as name, d.societe, d.fk_soc, d.statut, d.public, d.adresse as address, d.cp as zip, d.ville as town, d.note,"; $sql = "SELECT d.rowid, d.civilite, d.prenom as firstname, d.nom as lastname, d.societe, d.fk_soc, d.statut, d.public, d.adresse as address, d.cp as zip, d.ville as town, d.note,";
$sql.= " d.email, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass,"; $sql.= " d.email, d.phone, d.phone_perso, d.phone_mobile, d.login, d.pass,";
$sql.= " d.photo, d.fk_adherent_type, d.morphy,"; $sql.= " d.photo, d.fk_adherent_type, d.morphy,";
$sql.= " d.datec as datec,"; $sql.= " d.datec as datec,";
@ -990,8 +1002,8 @@ class Adherent extends CommonObject
$this->civilite_id = $obj->civilite; $this->civilite_id = $obj->civilite;
$this->prenom = $obj->firstname; $this->prenom = $obj->firstname;
$this->firstname = $obj->firstname; $this->firstname = $obj->firstname;
$this->nom = $obj->name; $this->nom = $obj->lastname;
$this->lastname = $obj->name; $this->lastname = $obj->lastname;
$this->login = $obj->login; $this->login = $obj->login;
$this->pass = $obj->pass; $this->pass = $obj->pass;
$this->societe = $obj->societe; $this->societe = $obj->societe;
@ -1755,14 +1767,23 @@ class Adherent extends CommonObject
/** /**
* Return full address of member * Return full address of member
* *
* @param int $withcountry 1=Add country into address string *
* @param string $sep Separator to use to build string * @param int $withcountry 1=Add country into address string
* @return string Full address string * @param string $sep Separator to use to build string
* @return string Full address string
*/ */
function getFullAddress($withcountry=0,$sep="\n") function getFullAddress($withcountry=0,$sep="\n")
{ {
$ret=''; $ret='';
if (in_array($this->country,array('us'))) if ($withcountry && $this->country_id && (empty($this->country_code) || empty($this->country)))
{
require_once(DOL_DOCUMENT_ROOT ."/core/lib/company.lib.php");
$tmparray=getCountry($this->country_id,'all');
$this->country_code=$tmparray['code'];
$this->country =$tmparray['label'];
}
if (in_array($this->country_code,array('US')))
{ {
$ret.=($this->address?$this->address.$sep:''); $ret.=($this->address?$this->address.$sep:'');
$ret.=trim($this->zip.' '.$this->town); $ret.=trim($this->zip.' '.$this->town);
@ -1777,7 +1798,6 @@ class Adherent extends CommonObject
return trim($ret); return trim($ret);
} }
/** /**
* Retourne le libelle du statut d'un adherent (brouillon, valide, resilie) * Retourne le libelle du statut d'un adherent (brouillon, valide, resilie)
* *

View File

@ -53,6 +53,9 @@ class Contact extends CommonObject
var $fk_departement; // Id of department var $fk_departement; // Id of department
var $departement_code; // Code of department var $departement_code; // Code of department
var $departement; // Label of department var $departement; // Label of department
var $state_id; // Id of department
var $state_code; // Code of department
var $state; // Label of department
var $fk_pays; // Id of country var $fk_pays; // Id of country
var $pays_code; // Code of country var $pays_code; // Code of country
@ -68,6 +71,7 @@ class Contact extends CommonObject
var $email; var $email;
var $birthday; var $birthday;
var $default_lang; var $default_lang;
var $note; // Private note
var $ref_facturation; // Nb de reference facture pour lequel il est contact var $ref_facturation; // Nb de reference facture pour lequel il est contact
var $ref_contrat; // Nb de reference contrat pour lequel il est contact var $ref_contrat; // Nb de reference contrat pour lequel il est contact
@ -83,11 +87,11 @@ class Contact extends CommonObject
/** /**
* Constructor * Constructor
* *
* @param DoliDB $DB Database handler * @param DoliDB $db Database handler
*/ */
function Contact($DB) function Contact($db)
{ {
$this->db = $DB; $this->db = $db;
} }
/** /**
@ -106,9 +110,9 @@ class Contact extends CommonObject
$this->db->begin(); $this->db->begin();
// Clean parameters // Clean parameters
$this->name=trim($this->name); $this->lastname=$this->lastname?trim($this->lastname):$this->name;
$this->firstname=trim($this->firstname); $this->firstname=trim($this->firstname);
if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->name=ucwords($this->name); if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->lastname=ucwords($this->lastname);
if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname=ucwords($this->firstname); if (! empty($conf->global->MAIN_FIRST_TO_UPPER)) $this->firstname=ucwords($this->firstname);
if (! $this->socid) $this->socid = 0; if (! $this->socid) $this->socid = 0;
if (! $this->priv) $this->priv = 0; if (! $this->priv) $this->priv = 0;
@ -134,7 +138,7 @@ class Contact extends CommonObject
$sql.= " ".$conf->entity; $sql.= " ".$conf->entity;
$sql.= ")"; $sql.= ")";
dol_syslog("Contact::create sql=".$sql); dol_syslog(get_class($this)."::create sql=".$sql);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
@ -178,7 +182,7 @@ class Contact extends CommonObject
else else
{ {
$this->db->rollback(); $this->db->rollback();
dol_syslog("Contact::create ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
return -2; return -2;
} }
} }
@ -187,7 +191,7 @@ class Contact extends CommonObject
$this->error=$this->db->lasterror(); $this->error=$this->db->lasterror();
$this->db->rollback(); $this->db->rollback();
dol_syslog("Contact::create ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::create ".$this->error, LOG_ERR);
return -1; return -1;
} }
} }
@ -208,16 +212,18 @@ class Contact extends CommonObject
$this->id = $id; $this->id = $id;
// Nettoyage parametres // Clean parameters
$this->name=trim($this->name); $this->lastname=trim($this->lastname)?trim($this->lastname):trim($this->name);
$this->firstname=trim($this->firstname); $this->firstname=trim($this->firstname);
$this->email=trim($this->email); $this->email=trim($this->email);
$this->phone_pro=trim($this->phone_pro); $this->phone_pro=trim($this->phone_pro);
$this->phone_perso=trim($this->phone_perso); $this->phone_perso=trim($this->phone_perso);
$this->phone_mobile=trim($this->phone_mobile); $this->phone_mobile=trim($this->phone_mobile);
$this->fax=trim($this->fax); $this->fax=trim($this->fax);
$this->zip=($this->zip?$this->zip:$this->cp);
$this->town=($this->town?$this->town:$this->ville);
$this->country_id=($this->country_id > 0?$this->country_id:$this->fk_pays); $this->country_id=($this->country_id > 0?$this->country_id:$this->fk_pays);
$this->state_id=($this->state_id > 0?$this->state_id:$this->fk_departement);
$this->db->begin(); $this->db->begin();
@ -225,13 +231,13 @@ class Contact extends CommonObject
if ($this->socid > 0) $sql .= " fk_soc='".$this->db->escape($this->socid)."',"; if ($this->socid > 0) $sql .= " fk_soc='".$this->db->escape($this->socid)."',";
if ($this->socid == -1) $sql .= " fk_soc=null,"; if ($this->socid == -1) $sql .= " fk_soc=null,";
$sql .= " civilite='".$this->db->escape($this->civilite_id)."'"; $sql .= " civilite='".$this->db->escape($this->civilite_id)."'";
$sql .= ", name='".$this->db->escape($this->name)."'"; $sql .= ", name='".$this->db->escape($this->lastname)."'";
$sql .= ", firstname='".$this->db->escape($this->firstname)."'"; $sql .= ", firstname='".$this->db->escape($this->firstname)."'";
$sql .= ", address='".$this->db->escape($this->address)."'"; $sql .= ", address='".$this->db->escape($this->address)."'";
$sql .= ", cp='".$this->db->escape($this->zip)."'"; $sql .= ", cp='".$this->db->escape($this->zip)."'";
$sql .= ", ville='".$this->db->escape($this->town)."'"; $sql .= ", ville='".$this->db->escape($this->town)."'";
$sql .= ", fk_pays=".($this->country_id>0?$this->country_id:'NULL'); $sql .= ", fk_pays=".($this->country_id>0?$this->country_id:'NULL');
$sql .= ", fk_departement=".($this->fk_departement>0?$this->fk_departement:'NULL'); $sql .= ", fk_departement=".($this->state_id>0?$this->state_id:'NULL');
$sql .= ", poste='".$this->db->escape($this->poste)."'"; $sql .= ", poste='".$this->db->escape($this->poste)."'";
$sql .= ", fax='".$this->db->escape($this->fax)."'"; $sql .= ", fax='".$this->db->escape($this->fax)."'";
$sql .= ", email='".$this->db->escape($this->email)."'"; $sql .= ", email='".$this->db->escape($this->email)."'";
@ -245,10 +251,15 @@ class Contact extends CommonObject
$sql .= ", default_lang=".($this->default_lang?"'".$this->default_lang."'":"null"); $sql .= ", default_lang=".($this->default_lang?"'".$this->default_lang."'":"null");
$sql .= " WHERE rowid=".$id; $sql .= " WHERE rowid=".$id;
dol_syslog("Contact::update sql=".$sql,LOG_DEBUG); dol_syslog(get_class($this)."::update sql=".$sql,LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{ {
unset($this->country_code);
unset($this->country);
unset($this->state_code);
unset($this->state);
if (! $error && ! $notrigger) if (! $error && ! $notrigger)
{ {
// Appel des triggers // Appel des triggers
@ -267,7 +278,7 @@ class Contact extends CommonObject
else else
{ {
$this->error=join(',',$this->errors); $this->error=join(',',$this->errors);
dol_syslog("Contact::update Error ".$this->error,LOG_ERR); dol_syslog(get_class($this)."::update Error ".$this->error,LOG_ERR);
$this->db->rollback(); $this->db->rollback();
return -$error; return -$error;
} }
@ -275,7 +286,7 @@ class Contact extends CommonObject
else else
{ {
$this->error=$this->db->lasterror().' sql='.$sql; $this->error=$this->db->lasterror().' sql='.$sql;
dol_syslog("Contact::update Error ".$this->error,LOG_ERR); dol_syslog(get_class($this)."::update Error ".$this->error,LOG_ERR);
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }
@ -390,7 +401,7 @@ class Contact extends CommonObject
if ($user) $sql .= ", fk_user_modif=".$user->id; if ($user) $sql .= ", fk_user_modif=".$user->id;
$sql .= " WHERE rowid=".$id; $sql .= " WHERE rowid=".$id;
//print "update_perso: ".$this->birthday.'-'.$this->db->idate($this->birthday); //print "update_perso: ".$this->birthday.'-'.$this->db->idate($this->birthday);
dol_syslog("Contact::update_perso this->birthday=".$this->birthday." - sql=".$sql); dol_syslog(get_class($this)."::update_perso this->birthday=".$this->birthday." - sql=".$sql);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (! $resql) if (! $resql)
{ {
@ -450,14 +461,14 @@ class Contact extends CommonObject
$langs->load("companies"); $langs->load("companies");
$sql = "SELECT c.rowid, c.fk_soc, c.civilite as civilite_id, c.name, c.firstname,"; $sql = "SELECT c.rowid, c.fk_soc, c.civilite as civilite_id, c.name as lastname, c.firstname,";
$sql.= " c.address, c.cp, c.ville,"; $sql.= " c.address, c.cp as zip, c.ville as town,";
$sql.= " c.fk_pays,"; $sql.= " c.fk_pays as country_id,";
$sql.= " c.fk_departement,"; $sql.= " c.fk_departement,";
$sql.= " c.birthday,"; $sql.= " c.birthday,";
$sql.= " c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email, c.jabberid,"; $sql.= " c.poste, c.phone, c.phone_perso, c.phone_mobile, c.fax, c.email, c.jabberid,";
$sql.= " c.priv, c.note, c.default_lang, c.canvas,"; $sql.= " c.priv, c.note, c.default_lang, c.canvas,";
$sql.= " p.libelle as pays, p.code as pays_code,"; $sql.= " p.libelle as country, p.code as country_code,";
$sql.= " d.nom as departement, d.code_departement as departement_code,"; $sql.= " d.nom as departement, d.code_departement as departement_code,";
$sql.= " u.rowid as user_id, u.login as user_login,"; $sql.= " u.rowid as user_id, u.login as user_login,";
$sql.= " s.nom as socname, s.address as socaddress, s.cp as soccp, s.ville as soccity, s.default_lang as socdefault_lang"; $sql.= " s.nom as socname, s.address as socaddress, s.cp as soccp, s.ville as soccity, s.default_lang as socdefault_lang";
@ -468,7 +479,7 @@ class Contact extends CommonObject
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON c.fk_soc = s.rowid";
$sql.= " WHERE c.rowid = ". $id; $sql.= " WHERE c.rowid = ". $id;
dol_syslog("Contact::fetch sql=".$sql); dol_syslog(get_class($this)."::fetch sql=".$sql);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
@ -479,31 +490,32 @@ class Contact extends CommonObject
$this->id = $obj->rowid; $this->id = $obj->rowid;
$this->ref = $obj->rowid; $this->ref = $obj->rowid;
$this->civilite_id = $obj->civilite_id; $this->civilite_id = $obj->civilite_id;
$this->name = $obj->name; $this->lastname = $obj->lastname;
$this->name = $obj->lastname; // TODO deprecated
$this->firstname = $obj->firstname; $this->firstname = $obj->firstname;
$this->nom = $obj->name; // TODO deprecated $this->nom = $obj->lastname; // TODO deprecated
$this->prenom = $obj->firstname; // TODO deprecated $this->prenom = $obj->firstname; // TODO deprecated
$this->address = $obj->address; $this->address = $obj->address;
$this->adresse = $obj->address; // TODO deprecated $this->adresse = $obj->address; // TODO deprecated
$this->cp = $obj->cp; // TODO deprecated $this->cp = $obj->zip; // TODO deprecated
$this->zip = $obj->cp; $this->zip = $obj->zip;
$this->ville = $obj->ville; // TODO deprecated $this->ville = $obj->town; // TODO deprecated
$this->town = $obj->ville; $this->town = $obj->town;
$this->fk_departement = $obj->fk_departement; $this->fk_departement = $obj->fk_departement;
$this->state_id = $obj->fk_departement; $this->state_id = $obj->fk_departement;
$this->departement_code = $obj->departement_code; // TODO deprecated $this->departement_code = $obj->departement_code; // TODO deprecated
$this->state_code = $obj->departement_code; $this->state_code = $obj->departement_code;
$this->departement = $obj->departement; // TODO deprecated $this->departement = $obj->departement; // TODO deprecated
$this->state = $obj->departement; $this->state = $obj->departement;
$this->fk_pays = $obj->fk_pays; $this->fk_pays = $obj->country_id;
$this->country_id = $obj->fk_pays; $this->country_id = $obj->country_id;
$this->pays_code = $obj->fk_pays?$obj->pays_code:''; $this->pays_code = $obj->country_id?$obj->country_code:'';
$this->country_code = $obj->fk_pays?$obj->pays_code:''; $this->country_code = $obj->country_id?$obj->country_code:'';
$this->pays = ($obj->fk_pays > 0)?$langs->transnoentitiesnoconv("Country".$obj->pays_code):''; $this->pays = ($obj->country_id > 0)?$langs->transnoentitiesnoconv("Country".$obj->country_code):'';
$this->country = ($obj->fk_pays > 0)?$langs->transnoentitiesnoconv("Country".$obj->pays_code):''; $this->country = ($obj->country_id > 0)?$langs->transnoentitiesnoconv("Country".$obj->country_code):'';
$this->socid = $obj->fk_soc; $this->socid = $obj->fk_soc;
$this->socname = $obj->socname; $this->socname = $obj->socname;
@ -547,7 +559,7 @@ class Contact extends CommonObject
else else
{ {
$this->error=$this->db->error(); $this->error=$this->db->error();
dol_syslog("Contact::fetch ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR);
return -1; return -1;
} }
@ -572,7 +584,7 @@ class Contact extends CommonObject
else else
{ {
$this->error=$this->db->error(); $this->error=$this->db->error();
dol_syslog("Contact::fetch ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR);
return -1; return -1;
} }
} }
@ -588,7 +600,7 @@ class Contact extends CommonObject
else else
{ {
$this->error=$this->db->error(); $this->error=$this->db->error();
dol_syslog("Contact::fetch ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR);
return -1; return -1;
} }
} }
@ -612,7 +624,7 @@ class Contact extends CommonObject
$sql.=" AND fk_socpeople = ". $this->id; $sql.=" AND fk_socpeople = ". $this->id;
$sql.=" GROUP BY tc.element"; $sql.=" GROUP BY tc.element";
dol_syslog("Contact::load_ref_elements sql=".$sql); dol_syslog(get_class($this)."::load_ref_elements sql=".$sql);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
@ -633,7 +645,7 @@ class Contact extends CommonObject
else else
{ {
$this->error=$this->db->error()." - ".$sql; $this->error=$this->db->error()." - ".$sql;
dol_syslog("Contact::load_ref_elements Error ".$this->error, LOG_ERR); dol_syslog(get_class($this)."::load_ref_elements Error ".$this->error, LOG_ERR);
return -1; return -1;
} }
} }
@ -664,7 +676,7 @@ class Contact extends CommonObject
$sql.= " WHERE ec.fk_socpeople=".$this->id; $sql.= " WHERE ec.fk_socpeople=".$this->id;
$sql.= " AND ec.fk_c_type_contact=tc.rowid"; $sql.= " AND ec.fk_c_type_contact=tc.rowid";
$sql.= " AND tc.source='external'"; $sql.= " AND tc.source='external'";
dol_syslog("Contact::delete sql=".$sql); dol_syslog(get_class($this)."::delete sql=".$sql);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
@ -677,7 +689,7 @@ class Contact extends CommonObject
$sqldel = "DELETE FROM ".MAIN_DB_PREFIX."element_contact"; $sqldel = "DELETE FROM ".MAIN_DB_PREFIX."element_contact";
$sqldel.=" WHERE rowid = ".$obj->rowid; $sqldel.=" WHERE rowid = ".$obj->rowid;
dol_syslog("Contact::delete sql=".$sqldel); dol_syslog(get_class($this)."::delete sql=".$sqldel);
$result = $this->db->query($sqldel); $result = $this->db->query($sqldel);
if (! $result) if (! $result)
{ {
@ -699,7 +711,7 @@ class Contact extends CommonObject
{ {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."socpeople"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."socpeople";
$sql .= " WHERE rowid=".$this->id; $sql .= " WHERE rowid=".$this->id;
dol_syslog("Contact::delete sql=".$sql); dol_syslog(get_class($this)."::delete sql=".$sql);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if (! $result) if (! $result)
{ {
@ -847,7 +859,15 @@ class Contact extends CommonObject
function getFullAddress($withcountry=0,$sep="\n") function getFullAddress($withcountry=0,$sep="\n")
{ {
$ret=''; $ret='';
if (in_array($this->country,array('us'))) if ($withcountry && $this->country_id && (empty($this->country_code) || empty($this->country)))
{
require_once(DOL_DOCUMENT_ROOT ."/core/lib/company.lib.php");
$tmparray=getCountry($this->country_id,'all');
$this->country_code=$tmparray['code'];
$this->country =$tmparray['label'];
}
if (in_array($this->country_code,array('US')))
{ {
$ret.=($this->address?$this->address.$sep:''); $ret.=($this->address?$this->address.$sep:'');
$ret.=trim($this->zip.' '.$this->town); $ret.=trim($this->zip.' '.$this->town);
@ -875,13 +895,6 @@ class Contact extends CommonObject
$code=$this->civilite_id; $code=$this->civilite_id;
return $langs->trans("Civility".$code)!="Civility".$code ? $langs->trans("Civility".$code) : ''; return $langs->trans("Civility".$code)!="Civility".$code ? $langs->trans("Civility".$code) : '';
/*if (empty($ret))
{
$ret=$code;
$langs->getLabelFromKey($this->db,$reg[1],'c_civilite','code','civilite');
//$ret=dol_getIdFromCode($this->db,$code,'c_civilite',
}
return $ret;*/
} }
@ -1035,16 +1048,14 @@ class Contact extends CommonObject
// Initialise parameters // Initialise parameters
$this->id=0; $this->id=0;
$this->specimen=1; $this->specimen=1;
$this->nom = 'DOLIBARR'; $this->name = 'DOLIBARR';
$this->name = $this->nom; $this->firstname = 'SPECIMEN';
$this->prenom = 'SPECIMEN';
$this->firstname = $this->prenom;
$this->address = '61 jump street'; $this->address = '61 jump street';
$this->cp = '75000'; $this->zip = '75000';
$this->ville = 'Paris'; $this->town = 'Paris';
$this->fk_pays = 1; $this->country_id = 1;
$this->pays_code = 'FR'; $this->country_code = 'FR';
$this->pays = 'France'; $this->country = 'France';
$this->email = 'specimen@specimen.com'; $this->email = 'specimen@specimen.com';
$socid = rand(1, $num_socs); $socid = rand(1, $num_socs);
$this->socid = $socids[$socid]; $this->socid = $socids[$socid];

View File

@ -377,7 +377,7 @@ class Societe extends CommonObject
$error=0; $error=0;
dol_syslog("Societe::Update id=".$id." call_trigger=".$call_trigger." allowmodcodeclient=".$allowmodcodeclient." allowmodcodefournisseur=".$allowmodcodefournisseur); dol_syslog(get_class($this)."::Update id=".$id." call_trigger=".$call_trigger." allowmodcodeclient=".$allowmodcodeclient." allowmodcodefournisseur=".$allowmodcodefournisseur);
// For triggers // For triggers
if ($call_trigger) if ($call_trigger)
@ -401,7 +401,7 @@ class Societe extends CommonObject
$this->ville=$this->town; // TODO obsolete $this->ville=$this->town; // TODO obsolete
$this->state_id=trim($this->state_id); $this->state_id=trim($this->state_id);
$this->country_id = ($this->country_id > 0)?$this->country_id:$this->pays_id; $this->country_id = ($this->country_id > 0)?$this->country_id:$this->pays_id;
$this->pays_id = $this->country_id; $this->pays_id = $this->country_id;
$this->tel = trim($this->tel); $this->tel = trim($this->tel);
$this->fax = trim($this->fax); $this->fax = trim($this->fax);
$this->tel = preg_replace("/\s/","",$this->tel); $this->tel = preg_replace("/\s/","",$this->tel);
@ -456,7 +456,7 @@ class Societe extends CommonObject
if ($result >= 0) if ($result >= 0)
{ {
dol_syslog("Societe::Update verify ok"); dol_syslog(get_class($this)."::Update verify ok");
$sql = "UPDATE ".MAIN_DB_PREFIX."societe"; $sql = "UPDATE ".MAIN_DB_PREFIX."societe";
$sql.= " SET nom = '" . $this->db->escape($this->name) ."'"; // Champ obligatoire $sql.= " SET nom = '" . $this->db->escape($this->name) ."'"; // Champ obligatoire
@ -534,6 +534,11 @@ class Societe extends CommonObject
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
unset($this->country_code);
unset($this->country);
unset($this->state_code);
unset($this->state);
// Si le fournisseur est classe on l'ajoute // Si le fournisseur est classe on l'ajoute
$this->AddFournisseurInCategory($this->fournisseur_categorie); $this->AddFournisseurInCategory($this->fournisseur_categorie);
@ -698,7 +703,7 @@ class Societe extends CommonObject
$this->country_code = $obj->country_id?$obj->country_code:''; $this->country_code = $obj->country_id?$obj->country_code:'';
$this->pays = $obj->country_id?($langs->trans('Country'.$obj->country_code)!='Country'.$obj->country_code?$langs->trans('Country'.$obj->country_code):$obj->country):''; // TODO obsolete $this->pays = $obj->country_id?($langs->trans('Country'.$obj->country_code)!='Country'.$obj->country_code?$langs->trans('Country'.$obj->country_code):$obj->country):''; // TODO obsolete
$this->country = $obj->country_id?($langs->trans('Country'.$obj->country_code)!='Country'.$obj->country_code?$langs->trans('Country'.$obj->country_code):$obj->country):''; $this->country = $obj->country_id?($langs->trans('Country'.$obj->country_code)!='Country'.$obj->country_code?$langs->trans('Country'.$obj->country_code):$obj->country):'';
$this->state_id = $obj->fk_departement; $this->state_id = $obj->fk_departement;
$this->state_code = $obj->departement_code; $this->state_code = $obj->departement_code;
$this->state = $obj->departement; $this->state = $obj->departement;
@ -1426,24 +1431,33 @@ class Societe extends CommonObject
/** /**
* Return full address of third party * Return full address of third party
* @param withcountry 1=Add country into address string *
* @param sep Separator to use to build string * @param int $withcountry 1=Add country into address string
* @return string Full address string * @param string $sep Separator to use to build string
* @return string Full address string
*/ */
function getFullAddress($withcountry=0,$sep="\n") function getFullAddress($withcountry=0,$sep="\n")
{ {
$ret=''; $ret='';
if (in_array($this->country,array('us'))) if ($withcountry && $this->country_id && (empty($this->country_code) || empty($this->country)))
{ {
$ret.=($this->address?$this->address.$sep:''); require_once(DOL_DOCUMENT_ROOT ."/core/lib/company.lib.php");
$ret.=trim($this->zip.' '.$this->town); $tmparray=getCountry($this->country_id,'all');
if ($withcountry) $ret.=($this->country?$sep.$this->country:''); $this->country_code=$tmparray['code'];
$this->country =$tmparray['label'];
}
if (in_array($this->country_code,array('US')))
{
$ret.=($this->address?$this->address.$sep:'');
$ret.=trim($this->zip.' '.$this->town);
if ($withcountry) $ret.=($this->country?$sep.$this->country:'');
} }
else else
{ {
$ret.=($this->address?$this->address.$sep:''); $ret.=($this->address?$this->address.$sep:'');
$ret.=trim($this->zip.' '.$this->town); $ret.=trim($this->zip.' '.$this->town);
if ($withcountry) $ret.=($this->country?$sep.$this->country:''); if ($withcountry) $ret.=($this->country?$sep.$this->country:'');
} }
return trim($ret); return trim($ret);
} }
@ -1913,10 +1927,11 @@ class Societe extends CommonObject
/** /**
* Verify if a profid exists into database for others thirds * Verify if a profid exists into database for others thirds
* @param idprof 1,2,3,4 (Exemple: 1=siren,2=siret,3=naf,4=rcs/rm) *
* @param value value of profid * @param int $idprof 1,2,3,4 (Example: 1=siren,2=siret,3=naf,4=rcs/rm)
* @param socid id of society if update * @param string $value Value of profid
* @return boolean true if exists, false if not * @param int $socid Id of society if update
* @return boolean true if exists, false if not
*/ */
function id_prof_exists($idprof,$value,$socid=0) function id_prof_exists($idprof,$value,$socid=0)
{ {

View File

@ -234,11 +234,9 @@ if (empty($reshook))
$contact->firstname = $object->firstname; $contact->firstname = $object->firstname;
$contact->address = $object->address; $contact->address = $object->address;
$contact->zip = $object->zip; $contact->zip = $object->zip;
$contact->cp = $object->cp; // TODO obsolete
$contact->town = $object->town; $contact->town = $object->town;
$contact->ville = $object->ville; // TODO obsolete $contact->state_id = $object->state_id;
$contact->fk_departement = $object->state_id; $contact->country_id = $object->country_id;
$contact->fk_pays = $object->country_id;
$contact->socid = $object->id; // fk_soc $contact->socid = $object->id; // fk_soc
$contact->status = 1; $contact->status = 1;
$contact->email = $object->email; $contact->email = $object->email;

View File

@ -158,10 +158,52 @@ class AdherentTest extends PHPUnit_Framework_TestCase
$langs=$this->savlangs; $langs=$this->savlangs;
$db=$this->savdb; $db=$this->savdb;
$localobject->login='newlogin';
$localobject->societe='New company';
$localobject->note='New note after update'; $localobject->note='New note after update';
$result=$localobject->update($user); //$localobject->note_public='New note public after update';
print __METHOD__." id=".$localobject->id." result=".$result."\n"; $localobject->lastname='New name';
$this->assertLessThan($result, 0); $localobject->firstname='New firstname';
$localobject->address='New address';
$localobject->zip='New zip';
$localobject->town='New town';
$localobject->country_id=2;
$localobject->statut=0;
$localobject->phone='New tel pro';
$localobject->phone_perso='New tel perso';
$localobject->phone_mobile='New tel mobile';
$localobject->email='newemail@newemail.com';
$result=$localobject->update($user);
print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0);
$result=$localobject->update_note($localobject->note);
print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0);
//$result=$localobject->update_note_public($localobject->note_public);
//print __METHOD__." id=".$localobject->id." result=".$result."\n";
//$this->assertLessThan($result, 0);
$newobject=new Adherent($this->savdb);
$result=$newobject->fetch($localobject->id);
print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0);
$this->assertEquals($localobject->login, $newobject->login);
$this->assertEquals($localobject->societe, $newobject->societe);
$this->assertEquals($localobject->note, $newobject->note);
//$this->assertEquals($localobject->note_public, $newobject->note_public);
$this->assertEquals($localobject->lastname, $newobject->lastname);
$this->assertEquals($localobject->firstname, $newobject->firstname);
$this->assertEquals($localobject->address, $newobject->address);
$this->assertEquals($localobject->zip, $newobject->zip);
$this->assertEquals($localobject->town, $newobject->town);
$this->assertEquals($localobject->country_id, $newobject->country_id);
$this->assertEquals('BE', $newobject->country_code);
$this->assertEquals($localobject->statut, $newobject->statut);
$this->assertEquals($localobject->phone, $newobject->phone);
$this->assertEquals($localobject->phone_perso, $newobject->phone_perso);
$this->assertEquals($localobject->phone_mobile, $newobject->phone_mobile);
$this->assertEquals($localobject->email, $newobject->email);
return $localobject; return $localobject;
} }

View File

@ -74,6 +74,8 @@ class AllTests
require_once dirname(__FILE__).'/SocieteTest.php'; require_once dirname(__FILE__).'/SocieteTest.php';
$suite->addTestSuite('SocieteTest'); $suite->addTestSuite('SocieteTest');
require_once dirname(__FILE__).'/ContactTest.php';
$suite->addTestSuite('ContactTest');
require_once dirname(__FILE__).'/AdherentTest.php'; require_once dirname(__FILE__).'/AdherentTest.php';
$suite->addTestSuite('AdherentTest'); $suite->addTestSuite('AdherentTest');

283
test/phpunit/ContactTest.php Executable file
View File

@ -0,0 +1,283 @@
<?php
/* Copyright (C) 2010 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* or see http://www.gnu.org/
*/
/**
* \file test/phpunit/ContactTest.php
* \ingroup test
* \brief PHPUnit test
* \remarks To run this script as CLI: phpunit filename.php
*/
global $conf,$user,$langs,$db;
//define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver
require_once 'PHPUnit/Autoload.php';
require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
require_once dirname(__FILE__).'/../../htdocs/contact/class/contact.class.php';
$langs->load("dict");
if (empty($user->id))
{
print "Load permissions for admin user nb 1\n";
$user->fetch(1);
$user->getrights();
}
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
/**
* Class for PHPUnit tests
*
* @backupGlobals disabled
* @backupStaticAttributes enabled
* @remarks backupGlobals must be disabled to have db,conf,user and lang not erased.
*/
class ContactTest extends PHPUnit_Framework_TestCase
{
protected $savconf;
protected $savuser;
protected $savlangs;
protected $savdb;
/**
* Constructor
* We save global variables into local variables
*
* @return ContactTest
*/
function ContactTest()
{
//$this->sharedFixture
global $conf,$user,$langs,$db;
$this->savconf=$conf;
$this->savuser=$user;
$this->savlangs=$langs;
$this->savdb=$db;
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
//print " - db ".$db->db;
print "\n";
}
// Static methods
public static function setUpBeforeClass()
{
global $conf,$user,$langs,$db;
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
print __METHOD__."\n";
}
public static function tearDownAfterClass()
{
global $conf,$user,$langs,$db;
$db->rollback();
print __METHOD__."\n";
}
/**
*/
protected function setUp()
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
print __METHOD__."\n";
}
/**
*/
protected function tearDown()
{
print __METHOD__."\n";
}
/**
*/
public function testContactCreate()
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
$localobject=new Contact($this->savdb);
$localobject->initAsSpecimen();
$result=$localobject->create($user);
print __METHOD__." result=".$result."\n";
$this->assertLessThanOrEqual($result, 0);
return $result;
}
/**
* @depends testContactCreate
* The depends says test is run only if previous is ok
*/
public function testContactFetch($id)
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
$localobject=new Contact($this->savdb);
$result=$localobject->fetch($id);
print __METHOD__." id=".$id." result=".$result."\n";
$this->assertLessThan($result, 0);
return $localobject;
}
/**
* @depends testContactFetch
* The depends says test is run only if previous is ok
*/
public function testContactUpdate($localobject)
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
$localobject->note='New note after update';
//$localobject->note_public='New note public after update';
$localobject->lastname='New name';
$localobject->firstname='New firstname';
$localobject->address='New address';
$localobject->zip='New zip';
$localobject->town='New town';
$localobject->country_id=2;
$localobject->status=0;
$localobject->phone_pro='New tel pro';
$localobject->phone_perso='New tel perso';
$localobject->phone_mobile='New tel mobile';
$localobject->fax='New fax';
$localobject->email='newemail@newemail.com';
$localobject->jabberid='New im id';
$localobject->default_lang='es_ES';
$result=$localobject->update($localobject->id,$user);
print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0);
$result=$localobject->update_note($localobject->note);
print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0);
//$result=$localobject->update_note_public($localobject->note_public);
//print __METHOD__." id=".$localobject->id." result=".$result."\n";
//$this->assertLessThan($result, 0);
$newobject=new Contact($this->savdb);
$result=$newobject->fetch($localobject->id);
print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0);
$this->assertEquals($localobject->note, $newobject->note);
//$this->assertEquals($localobject->note_public, $newobject->note_public);
$this->assertEquals($localobject->lastname, $newobject->lastname);
$this->assertEquals($localobject->firstname, $newobject->firstname);
$this->assertEquals($localobject->address, $newobject->address);
$this->assertEquals($localobject->zip, $newobject->zip);
$this->assertEquals($localobject->town, $newobject->town);
$this->assertEquals($localobject->country_id, $newobject->country_id);
$this->assertEquals('BE', $newobject->country_code);
$this->assertEquals($localobject->status, $newobject->status);
$this->assertEquals($localobject->phone_pro, $newobject->phone_pro);
$this->assertEquals($localobject->phone_perso, $newobject->phone_perso);
$this->assertEquals($localobject->phone_mobile, $newobject->phone_mobile);
$this->assertEquals($localobject->fax, $newobject->fax);
$this->assertEquals($localobject->email, $newobject->email);
$this->assertEquals($localobject->jabberid, $newobject->jabberid);
$this->assertEquals($localobject->default_lang, $newobject->default_lang);
return $localobject;
}
/**
* @depends testContactUpdate
* The depends says test is run only if previous is ok
*/
public function testContactOther($localobject)
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
//$localobject->fetch($localobject->id);
$result=$localobject->getNomUrl(1);
print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertNotEquals($result, '');
$result=$localobject->getFullAddress(1);
print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertContains("New address\nNew zip New town\nBelgium", $result);
$localobject->info($localobject->id);
print __METHOD__." localobject->date_creation=".$localobject->date_creation."\n";
$this->assertNotEquals($localobject->date_creation, '');
return $localobject->id;
}
/**
* @depends testContactOther
* The depends says test is run only if previous is ok
*/
public function testContactDelete($id)
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
$localobject=new Contact($this->savdb);
$result=$localobject->fetch($id);
$result=$localobject->delete($id);
print __METHOD__." id=".$id." result=".$result."\n";
$this->assertLessThan($result, 0);
return $result;
}
/**
*/
public function testContactStatic()
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
$localobject=new Contact($db);
return;
}
}
?>

View File

@ -28,6 +28,7 @@ global $conf,$user,$langs,$db;
require_once 'PHPUnit/Autoload.php'; require_once 'PHPUnit/Autoload.php';
require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
require_once dirname(__FILE__).'/../../htdocs/societe/class/societe.class.php'; require_once dirname(__FILE__).'/../../htdocs/societe/class/societe.class.php';
$langs->load("dict");
if (empty($user->id)) if (empty($user->id))
{ {
@ -172,10 +173,11 @@ class SocieteTest extends PHPUnit_Framework_TestCase
$localobject->address='New address'; $localobject->address='New address';
$localobject->zip='New zip'; $localobject->zip='New zip';
$localobject->town='New town'; $localobject->town='New town';
$localobject->country_id=2;
$localobject->status=0; $localobject->status=0;
$localobject->tel='New tel'; $localobject->tel='New tel';
$localobject->fax='New fax'; $localobject->fax='New fax';
$localobject->email='New email'; $localobject->email='newemail@newemail.com';
$localobject->url='New url'; $localobject->url='New url';
$localobject->idprof1='new idprof1'; $localobject->idprof1='new idprof1';
$localobject->idprof2='new idprof2'; $localobject->idprof2='new idprof2';
@ -202,6 +204,8 @@ class SocieteTest extends PHPUnit_Framework_TestCase
$this->assertEquals($localobject->address, $newobject->address); $this->assertEquals($localobject->address, $newobject->address);
$this->assertEquals($localobject->zip, $newobject->zip); $this->assertEquals($localobject->zip, $newobject->zip);
$this->assertEquals($localobject->town, $newobject->town); $this->assertEquals($localobject->town, $newobject->town);
$this->assertEquals($localobject->country_id, $newobject->country_id);
$this->assertEquals('BE', $newobject->country_code);
$this->assertEquals($localobject->status, $newobject->status); $this->assertEquals($localobject->status, $newobject->status);
$this->assertEquals($localobject->tel, $newobject->tel); $this->assertEquals($localobject->tel, $newobject->tel);
$this->assertEquals($localobject->fax, $newobject->fax); $this->assertEquals($localobject->fax, $newobject->fax);
@ -243,9 +247,9 @@ class SocieteTest extends PHPUnit_Framework_TestCase
print __METHOD__." id=".$localobject->id." result=".$result."\n"; print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertNotEquals($result, ''); $this->assertNotEquals($result, '');
$result=$localobject->getFullAddress(); $result=$localobject->getFullAddress(1);
print __METHOD__." id=".$localobject->id." result=".$result."\n"; print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertContains("New address\nNew zip New town", $result); $this->assertContains("New address\nNew zip New town\nBelgium", $result);
$result=$localobject->isInEEC(); $result=$localobject->isInEEC();
print __METHOD__." id=".$localobject->id." country_code=".$this->country_code." result=".$result."\n"; print __METHOD__." id=".$localobject->id." country_code=".$this->country_code." result=".$result."\n";