2
0
forked from Wavyzz/dolibarr

Add version of phpunit into travis script.

Fix: strict mode.
This commit is contained in:
Laurent Destailleur
2014-05-01 19:17:45 +02:00
parent 7bb23086b8
commit d97c45a9b8
27 changed files with 101 additions and 89 deletions

View File

@@ -31,6 +31,8 @@ before_script:
- echo PHP version $PHPV - echo PHP version $PHPV
# - echo Update composer # - echo Update composer
# - ~/.phpenv/versions/$(phpenv version-name)/bin/composer.phar self-update # - ~/.phpenv/versions/$(phpenv version-name)/bin/composer.phar self-update
- echo PHPUnit version
- phpunit --version
- echo Install phpcs then show installed rules - echo Install phpcs then show installed rules
- pyrus install pear/PHP_CodeSniffer - pyrus install pear/PHP_CodeSniffer
- phpenv rehash - phpenv rehash

View File

@@ -2654,7 +2654,7 @@ class Facture extends CommonInvoice
$num=count($this->lines); $num=count($this->lines);
for ($i = 0; $i < $num; $i++) 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++; $ventilExportCompta++;
} }

View File

@@ -79,7 +79,7 @@ abstract class CommonObject
//print "lastname=".$this->lastname." name=".$this->name." nom=".$this->nom."<br>\n"; //print "lastname=".$this->lastname." name=".$this->name." nom=".$this->nom."<br>\n";
$lastname=$this->lastname; $lastname=$this->lastname;
$firstname=$this->firstname; $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; if (empty($firstname)) $firstname=$this->firstname;
$ret=''; $ret='';
@@ -1590,6 +1590,9 @@ abstract class CommonObject
$this->total_localtax1 += $obj->total_localtax1; $this->total_localtax1 += $obj->total_localtax1;
$this->total_localtax2 += $obj->total_localtax2; $this->total_localtax2 += $obj->total_localtax2;
$this->total_ttc += $obj->total_ttc; $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_ht_by_vats[$obj->vatrate] += $obj->total_ht;
$total_tva_by_vats[$obj->vatrate] += $obj->total_tva; $total_tva_by_vats[$obj->vatrate] += $obj->total_tva;
$total_ttc_by_vats[$obj->vatrate] += $obj->total_ttc; $total_ttc_by_vats[$obj->vatrate] += $obj->total_ttc;

View File

@@ -454,7 +454,7 @@ function clean_url($url,$http=1)
{ {
$proto=$regs[1]; $proto=$regs[1];
$domain=$regs[2]; $domain=$regs[2];
$port=$regs[3]; $port=isset($regs[3])?$regs[3]:'';
//print $url." -> ".$proto." - ".$domain." - ".$port; //print $url." -> ".$proto." - ".$domain." - ".$port;
//$url = dol_string_nospecial(trim($url)); //$url = dol_string_nospecial(trim($url));
$url = trim($url); $url = trim($url);

View File

@@ -80,6 +80,8 @@ function pdf_getInstance($format='',$metric='mm',$pagetype='P')
global $conf; global $conf;
// Define constant for TCPDF // Define constant for TCPDF
if (! defined('K_TCPDF_EXTERNAL_CONFIG'))
{
define('K_TCPDF_EXTERNAL_CONFIG',1); // this avoid using tcpdf_config file define('K_TCPDF_EXTERNAL_CONFIG',1); // this avoid using tcpdf_config file
define('K_PATH_CACHE', DOL_DATA_ROOT.'/admin/temp/'); define('K_PATH_CACHE', DOL_DATA_ROOT.'/admin/temp/');
define('K_PATH_URL_CACHE', DOL_DATA_ROOT.'/admin/temp/'); define('K_PATH_URL_CACHE', DOL_DATA_ROOT.'/admin/temp/');
@@ -111,7 +113,7 @@ function pdf_getInstance($format='',$metric='mm',$pagetype='P')
define('K_THAI_TOPCHARS', true); define('K_THAI_TOPCHARS', true);
define('K_TCPDF_CALLS_IN_HTML', true); define('K_TCPDF_CALLS_IN_HTML', true);
define('K_TCPDF_THROW_EXCEPTION_ERROR', false); define('K_TCPDF_THROW_EXCEPTION_ERROR', false);
}
if (! empty($conf->global->MAIN_USE_FPDF) && ! empty($conf->global->MAIN_DISABLE_FPDI)) 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"; return "Error MAIN_USE_FPDF and MAIN_DISABLE_FPDI can't be set together";
@@ -161,7 +163,7 @@ function pdf_getInstance($format='',$metric='mm',$pagetype='P')
{ {
// Declare here a class to overwrite FPDI to add method writeHTMLCell // 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 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; global $db, $conf, $langs, $hookmanager;
$reshook=0; $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; $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); if (! empty($object->lines[$i]->fk_parent_line)) $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line);

View File

@@ -641,7 +641,7 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
$pdf->SetFont('','', $default_font_size - 2); $pdf->SetFont('','', $default_font_size - 2);
$pdf->SetXY($posxval, $posy); $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); $lib_availability=str_replace('\n',"\n",$lib_availability);
$pdf->MultiCell(80, 4, $lib_availability, 0, 'L'); $pdf->MultiCell(80, 4, $lib_availability, 0, 'L');

View File

@@ -602,7 +602,7 @@ class pdf_merou extends ModelePdfExpedition
$carac_client_name=$outputlangs->convToOutputCharset($object->client->nom); $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; $blDestX=$blExpX+55;

View File

@@ -612,7 +612,7 @@ class pdf_rouget extends ModelePdfExpedition
$carac_client_name=$outputlangs->convToOutputCharset($object->client->nom); $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 // Show recipient
$widthrecbox=100; $widthrecbox=100;

View File

@@ -237,7 +237,7 @@ class pdf_soleil extends ModelePDFFicheinter
{ {
$objectligne = $object->lines[$i]; $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) if ($valide > 0 || $object->specimen)
{ {
$curX = $this->posxdesc-1; $curX = $this->posxdesc-1;

View File

@@ -92,9 +92,7 @@ class modAdherent extends DolibarrModules
// Boxes // Boxes
//------- //-------
$this->boxes = array(); $this->boxes = array(0=>array('file'=>'box_members.php','enabledbydefaulton'=>'Home'));
$r=0;
$this->boxes[$r][1] = "box_members.php";
// Permissions // Permissions
//------------ //------------

View File

@@ -97,8 +97,7 @@ class modAgenda extends DolibarrModules
// Boxes // Boxes
//------ //------
$this->boxes = array(); $this->boxes = array(0=>array('file'=>'box_actions.php','enabledbydefaulton'=>'Home'));
$this->boxes[0][1] = "box_actions.php";
// Permissions // Permissions
//------------ //------------

View File

@@ -77,8 +77,7 @@ class modBanque extends DolibarrModules
$this->const = array(); $this->const = array();
// Boites // Boites
$this->boxes = array(); $this->boxes = array(0=>array('file'=>'box_comptes.php','enabledbydefaulton'=>'Home'));
$this->boxes[0][1] = "box_comptes.php";
// Permissions // Permissions
$this->rights = array(); $this->rights = array();

View File

@@ -70,8 +70,7 @@ class modBookmark extends DolibarrModules
$this->const = array(); $this->const = array();
// Boites // Boites
$this->boxes = array(); $this->boxes = array(0=>array('file'=>'box_bookmarks.php','enabledbydefaulton'=>'Home'));
$this->boxes[0][1] = "box_bookmarks.php";
// Permissions // Permissions
$this->rights = array(); $this->rights = array();

View File

@@ -97,7 +97,7 @@ class modCommande extends DolibarrModules
$this->const[$r][3] = ""; $this->const[$r][3] = "";
$this->const[$r][4] = 0; $this->const[$r][4] = 0;
// Boites // Boxes
$this->boxes = array(); $this->boxes = array();
$this->boxes = array(0=>array('file'=>'box_commandes.php','enabledbydefaulton'=>'Home'),2=>array('file'=>'box_graph_orders_permonth.php','enabledbydefaulton'=>'Home')); $this->boxes = array(0=>array('file'=>'box_commandes.php','enabledbydefaulton'=>'Home'),2=>array('file'=>'box_graph_orders_permonth.php','enabledbydefaulton'=>'Home'));

View File

@@ -75,9 +75,10 @@ class modContrat extends DolibarrModules
$this->const[0][4] = 0; $this->const[0][4] = 0;
// Boxes // Boxes
$this->boxes = array(); $this->boxes = array(
$this->boxes[0][1] = "box_contracts.php"; 0=>array('file'=>'box_contracts.php','enabledbydefaulton'=>'Home'),
$this->boxes[1][1] = "box_services_expired.php"; 1=>array('file'=>'box_services_expired.php','enabledbydefaulton'=>'Home')
);
// Permissions // Permissions
$this->rights = array(); $this->rights = array();

View File

@@ -87,9 +87,8 @@ class modFicheinter extends DolibarrModules
$this->const[$r][2] = "pacific"; $this->const[$r][2] = "pacific";
$r++; $r++;
// Boites // Boxes
$this->boxes = array(); $this->boxes = array(0=>array('file'=>'box_ficheinter.php','enabledbydefaulton'=>'Home'));
$this->boxes[0][1] = "box_ficheinter.php";
// Permissions // Permissions
$this->rights = array(); $this->rights = array();

View File

@@ -84,7 +84,6 @@ class modWorkflow extends DolibarrModules
// Boxes // Boxes
$this->boxes = array(); $this->boxes = array();
//$this->boxes[0][1] = "box_workflow@workflow";
// Permissions // Permissions
$this->rights = array(); $this->rights = array();

View File

@@ -106,7 +106,7 @@ class pdf_baleine extends ModelePDFProjects
if ($conf->projet->dir_output) 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); $objectref = dol_sanitizeFileName($object->ref);
$dir = $conf->projet->dir_output; $dir = $conf->projet->dir_output;

View File

@@ -371,13 +371,16 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$localtax1ligne=$object->lines[$i]->total_localtax1; $localtax1ligne=$object->lines[$i]->total_localtax1;
$localtax2ligne=$object->lines[$i]->total_localtax2; $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; $vatrate=(string) $object->lines[$i]->tva_tx;
$localtax1rate=(string) $object->lines[$i]->localtax1_tx; $localtax1rate=(string) $object->lines[$i]->localtax1_tx;
$localtax2rate=(string) $object->lines[$i]->localtax2_tx; $localtax2rate=(string) $object->lines[$i]->localtax2_tx;
if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; 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->tva[$vatrate] += $tvaligne;
$this->localtax1[$localtax1rate]+=$localtax1ligne; $this->localtax1[$localtax1rate]+=$localtax1ligne;
$this->localtax2[$localtax2rate]+=$localtax2ligne; $this->localtax2[$localtax2rate]+=$localtax2ligne;
@@ -1011,7 +1014,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$carac_client_name=$outputlangs->convToOutputCharset($mysoc->nom); $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 // Show recipient
$widthrecbox=100; $widthrecbox=100;

View File

@@ -131,7 +131,7 @@ class InterfaceActionsAuto
$object->actiontypecode='AC_OTH_AUTO'; $object->actiontypecode='AC_OTH_AUTO';
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("NewCompanyToDolibarr",$object->nom); if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("NewCompanyToDolibarr",$object->nom);
$object->actionmsg=$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("Customer").': '.yn($object->client);
//$this->desc.="\n".$langs->transnoentities("Supplier").': '.yn($object->fournisseur); //$this->desc.="\n".$langs->transnoentities("Supplier").': '.yn($object->fournisseur);
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;

View File

@@ -1834,7 +1834,7 @@ class CommandeFournisseur extends CommonOrder
// Find first product // Find first product
$prodid=0; $prodid=0;
$product=new ProductFournisseur($db); $product=new ProductFournisseur($this->db);
$sql = "SELECT rowid"; $sql = "SELECT rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."product"; $sql.= " FROM ".MAIN_DB_PREFIX."product";
$sql.= " WHERE entity IN (".getEntity('product', 1).")"; $sql.= " WHERE entity IN (".getEntity('product', 1).")";
@@ -1992,6 +1992,8 @@ class CommandeFournisseurLigne
var $tva_tx; var $tva_tx;
var $localtax1_tx; var $localtax1_tx;
var $localtax2_tx; var $localtax2_tx;
var $localtax1_type;
var $localtax2_type;
var $subprice; var $subprice;
var $remise_percent; var $remise_percent;
var $desc; // Description ligne var $desc; // Description ligne

View File

@@ -765,7 +765,7 @@ class Project extends CommonObject
$now=dol_now(); $now=dol_now();
// Initialise parametres // Initialise parameters
$this->id = 0; $this->id = 0;
$this->ref = 'SPECIMEN'; $this->ref = 'SPECIMEN';
$this->specimen = 1; $this->specimen = 1;
@@ -774,17 +774,20 @@ class Project extends CommonObject
$this->date_m = $now; $this->date_m = $now;
$this->date_start = $now; $this->date_start = $now;
$this->note_public = 'SPECIMEN'; $this->note_public = 'SPECIMEN';
/*
$nbp = rand(1, 9); $nbp = rand(1, 9);
$xnbp = 0; $xnbp = 0;
while ($xnbp < $nbp) while ($xnbp < $nbp)
{ {
$line = new Task($this->db); $line = new Task($this->db);
$line->desc = $langs->trans("Description") . " " . $xnbp; $line->fk_project = 0;
$line->qty = 1; $line->label = $langs->trans("Label") . " " . $xnbp;
$prodid = rand(1, $num_prods); $line->description = $langs->trans("Description") . " " . $xnbp;
$line->fk_product = $prodids[$prodid];
$this->lines[]=$line;
$xnbp++; $xnbp++;
} }
*/
} }
/** /**

View File

@@ -602,7 +602,7 @@ class Task extends CommonObject
if (! $error) if (! $error)
{ {
$tasks[$i] = new Task($db); $tasks[$i] = new Task($this->db);
$tasks[$i]->id = $obj->taskid; $tasks[$i]->id = $obj->taskid;
$tasks[$i]->ref = $obj->ref_task; $tasks[$i]->ref = $obj->ref_task;
$tasks[$i]->fk_project = $obj->projectid; $tasks[$i]->fk_project = $obj->projectid;

View File

@@ -525,11 +525,12 @@ class Societe extends CommonObject
// Check name is required and codes are ok or unique. // Check name is required and codes are ok or unique.
// If error, this->errors[] is filled // 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 ($action != 'add') $result = $this->verify(); // We don't check when update called during a create because verify was already done
if ($result >= 0) 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 = "UPDATE ".MAIN_DB_PREFIX."societe SET ";
$sql .= "nom = '" . $this->db->escape($this->name) ."'"; // Required $sql .= "nom = '" . $this->db->escape($this->name) ."'"; // Required
@@ -604,7 +605,7 @@ class Societe extends CommonObject
unset($this->state_code); unset($this->state_code);
unset($this->state); unset($this->state);
$nbrowsaffected+=$this->db->affected_rows($resql); $nbrowsaffected = $this->db->affected_rows($resql);
if (! $error && $nbrowsaffected) if (! $error && $nbrowsaffected)
{ {

View File

@@ -80,6 +80,8 @@ class AdherentTest extends PHPUnit_Framework_TestCase
global $conf,$user,$langs,$db; global $conf,$user,$langs,$db;
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite. $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"; print __METHOD__."\n";
} }
public static function tearDownAfterClass() public static function tearDownAfterClass()

View File

@@ -175,7 +175,7 @@ class ScriptsTest extends PHPUnit_Framework_TestCase
$this->assertEquals($result,'Failed to find bank account with ref BANKDUMMY.'); $this->assertEquals($result,'Failed to find bank account with ref BANKDUMMY.');
$this->assertEquals($returnvar,255); $this->assertEquals($returnvar,255);
*/ */
return $result; return '';
} }
/** /**

View File

@@ -333,7 +333,7 @@ class SocieteTest extends PHPUnit_Framework_TestCase
$this->assertNotEquals($result, ''); $this->assertNotEquals($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=".$localobject->country_code." result=".$result."\n";
$this->assertTrue(true, $result); $this->assertTrue(true, $result);
$localobject->info($localobject->id); $localobject->info($localobject->id);