diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index 144b3d02ca4..36efb483c94 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -334,11 +334,11 @@ print '
'; /* - * Modeles de documents + * Document templates generators */ print_titre($langs->trans("OrdersModelModule")); -// Defini tableau def de modele +// Load array def with activated templates $type='order'; $def = array(); $sql = "SELECT nom"; @@ -365,12 +365,11 @@ else print "\n"; print "\n"; -print ' \n"; -print " \n"; -print '\n"; -print '\n"; -print ''; -print ''; +print ''; +print ''; +print '\n"; +print '\n"; +print ''; print "\n"; clearstatcache(); @@ -387,11 +386,13 @@ foreach ($conf->file->dol_document_root as $dirroot) $handle=opendir($dir); if (is_resource($handle)) { + while (($file = readdir($handle))!==false) { $filelist[]=$file; } closedir($handle); + arsort($filelist); foreach($filelist as $file) { diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index 40b7cef01c4..bd145f32ae4 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -439,10 +439,11 @@ print '
'; print_titre($langs->trans("BillsPDFModules")); // Load array def with activated templates +$type='invoice'; $def = array(); $sql = "SELECT nom"; $sql.= " FROM ".MAIN_DB_PREFIX."document_model"; -$sql.= " WHERE type = 'invoice'"; +$sql.= " WHERE type = '".$type."'"; $sql.= " AND entity = ".$conf->entity; $resql=$db->query($sql); if ($resql) @@ -472,7 +473,6 @@ print "\n"; clearstatcache(); - $var=true; foreach ($conf->file->dol_document_root as $dirroot) { @@ -490,6 +490,7 @@ foreach ($conf->file->dol_document_root as $dirroot) $filelist[]=$file; } closedir($handle); + arsort($filelist); foreach($filelist as $file) { diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php index 57ee3b7e395..cd56a0f032a 100644 --- a/htdocs/admin/modules.php +++ b/htdocs/admin/modules.php @@ -472,7 +472,7 @@ dol_fiche_end(); print '
'; print '
'; -$db->close(); - llxFooter(); + +$db->close(); ?> diff --git a/htdocs/admin/propale.php b/htdocs/admin/propale.php index 7e57e60d2f6..1689a406f88 100644 --- a/htdocs/admin/propale.php +++ b/htdocs/admin/propale.php @@ -422,6 +422,7 @@ foreach ($conf->file->dol_document_root as $dirroot) $filelist[]=$file; } closedir($handle); + arsort($filelist); foreach($filelist as $file) { diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index b9cf7b68241..0decdf402f7 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -422,33 +422,48 @@ function dol_filemtime($pathoffile) } /** - * Copy a file to another file + * Copy a file to another file. * * @param string $srcfile Source file (can't be a directory) * @param string $destfile Destination file (can't be a directory) * @param int $newmask Mask for new file (0 by default means $conf->global->MAIN_UMASK) * @param int $overwriteifexists Overwrite file if exists (1 by default) - * @return boolean True if OK, false if KO + * @return int <0 if error, 0 if nothing done (dest file already exists and overwriteifexists=0), >0 if OK */ function dol_copy($srcfile, $destfile, $newmask=0, $overwriteifexists=1) { global $conf; - $result=false; dol_syslog("files.lib.php::dol_copy srcfile=".$srcfile." destfile=".$destfile." newmask=".$newmask." overwritifexists=".$overwriteifexists); - if ($overwriteifexists || ! dol_is_file($destfile)) + $destexists=dol_is_file($destfile); + if (! $overwriteifexists && $destexists) return 0; + + $newpathofsrcfile=dol_osencode($srcfile); + $newpathofdestfile=dol_osencode($destfile); + $newdirdestfile=dirname($newpathofdestfile); + + if ($destexists && ! is_writable($newpathofdestfile)) + { + dol_syslog("files.lib.php::dol_copy failed Permission denied to overwrite target file", LOG_WARNING); + return -1; + } + if (! is_writable($newdirdestfile)) + { + dol_syslog("files.lib.php::dol_copy failed Permission denied to write into target directory ".$newdirdestfile, LOG_WARNING); + return -2; + } + // Copy with overwriting if exists + $result=@copy($newpathofsrcfile, $newpathofdestfile); + //$result=copy($newpathofsrcfile, $newpathofdestfile); // To see errors, remove @ + if (! $result) { - $newpathofsrcfile=dol_osencode($srcfile); - $newpathofdestfile=dol_osencode($destfile); - - $result=@copy($newpathofsrcfile, $newpathofdestfile); - //$result=copy($srcfile, $destfile); // To see errors, remove @ - if (! $result) dol_syslog("files.lib.php::dol_copy failed", LOG_WARNING); - if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK; - @chmod($newpathofdestfile, octdec($newmask)); + dol_syslog("files.lib.php::dol_copy failed to copy", LOG_WARNING); + return -3; } + if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK; + @chmod($newpathofdestfile, octdec($newmask)); - return $result; + return 1; } /** diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 216fd0aa43b..435d26ab08a 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -98,41 +98,38 @@ abstract class DolibarrModules // Create module's directories if (! $err) $err+=$this->create_dirs(); - // Execute les requetes sql complementaires - if (! $err) + // Execute addons requests + $num=count($array_sql); + for ($i = 0; $i < $num; $i++) { - $num=count($array_sql); - for ($i = 0; $i < $num; $i++) + if (! $err) { - if (! $err) + $val=$array_sql[$i]; + $sql=''; + $ignoreerror=0; + if (is_array($val)) { - $val=$array_sql[$i]; - $sql=''; - $ignoreerror=0; - if (is_array($val)) + $sql=$val['sql']; + $ignoreerror=$val['ignoreerror']; + } + else + { + $sql=$val; + } + + dol_syslog(get_class($this)."::_init ignoreerror=".$ignoreerror." sql=".$sql, LOG_DEBUG); + $result=$this->db->query($sql); + if (! $result) + { + if (! $ignoreerror) { - $sql=$val['sql']; - $ignoreerror=$val['ignoreerror']; + $this->error=$this->db->lasterror(); + dol_syslog(get_class($this)."::_init Error ".$this->error, LOG_ERR); + $err++; } else { - $sql=$val; - } - - dol_syslog(get_class($this)."::_init ignoreerror=".$ignoreerror." sql=".$sql, LOG_DEBUG); - $result=$this->db->query($sql); - if (! $result) - { - if (! $ignoreerror) - { - $this->error=$this->db->lasterror(); - dol_syslog(get_class($this)."::_init Error ".$this->error, LOG_ERR); - $err++; - } - else - { - dol_syslog(get_class($this)."::_init Warning ".$this->db->lasterror(), LOG_WARNING); - } + dol_syslog(get_class($this)."::_init Warning ".$this->db->lasterror(), LOG_WARNING); } } } diff --git a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php index 66824db4005..190e603f74b 100644 --- a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php +++ b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php @@ -1,7 +1,7 @@ +/* Copyright (C) 2010-2012 Laurent Destailleur * Copyright (C) 2012 Juanjo Menent - * + * * 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 @@ -39,13 +39,13 @@ class doc_generic_order_odt extends ModelePDFCommandes var $emetteur; // Objet societe qui emet var $phpmin = array(5,2,0); // Minimum version of PHP required by module - var $version = 'development'; + var $version = 'dolibarr'; /** * Constructor * - * @param DoliDB $DB Database handler + * @param DoliDB $db Database handler */ function doc_generic_order_odt($db) { @@ -107,7 +107,7 @@ class doc_generic_order_odt extends ModelePDFCommandes 'object_date_modification'=>dol_print_date($object->date_modification,'day'), 'object_date_validation'=>dol_print_date($object->date_validation,'dayhour'), 'object_date_close'=>dol_print_date($object->date_cloture,'dayhour'), - 'object_payment_mode'=>$object->mode_reglement, + 'object_payment_mode'=>($object->mode_reglement!='-'?$object->mode_reglement:''), 'object_payment_term'=>$object->cond_reglement, 'object_total_ht'=>price($object->total_ht,0,$outputlangs), 'object_total_vat'=>price($object->total_tva,0,$outputlangs), @@ -144,7 +144,7 @@ class doc_generic_order_odt extends ModelePDFCommandes ); } - /** + /** * Return description of a module * @param langs Lang object to use for output * @return string Description diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index faea0a306c8..4435a867f1c 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2010-2012 Laurent Destailleur * 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 @@ -45,7 +45,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures /** * Constructor * - * @param DoliDB $DB Database handler + * @param DoliDB $db Database handler */ function doc_generic_invoice_odt($db) { @@ -115,7 +115,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures 'object_date_creation'=>dol_print_date($object->date_creation,'day'), 'object_date_modification'=>dol_print_date($object->date_modification,'day'), 'object_date_validation'=>dol_print_date($object->date_validation,'dayhour'), - 'object_payment_mode'=>$object->mode_reglement, + 'object_payment_mode'=>($object->mode_reglement!='-'?$object->mode_reglement:''), 'object_payment_term'=>$object->cond_reglement, 'object_total_ht'=>price($object->total_ht,0,$outputlangs), 'object_total_vat'=>price($object->total_tva,0,$outputlangs), diff --git a/htdocs/core/modules/modCommande.class.php b/htdocs/core/modules/modCommande.class.php index 9e4cea75084..4a3267f1976 100644 --- a/htdocs/core/modules/modCommande.class.php +++ b/htdocs/core/modules/modCommande.class.php @@ -90,7 +90,7 @@ class modCommande extends DolibarrModules $this->const[$r][2] = "mod_commande_marbre"; $this->const[$r][3] = 'Nom du gestionnaire de numerotation des commandes'; $this->const[$r][4] = 0; - + $r++; $this->const[$r][0] = "COMMANDE_ADDON_PDF_ODT_PATH"; $this->const[$r][1] = "chaine"; @@ -195,7 +195,7 @@ class modCommande extends DolibarrModules */ function init($options='') { - global $conf; + global $conf,$langs; // Permissions $this->remove(); @@ -204,11 +204,18 @@ class modCommande extends DolibarrModules require_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'); $dirodt=DOL_DATA_ROOT.'/doctemplates/orders'; create_exdir($dirodt); - dol_copy(DOL_DOCUMENT_ROOT.'/install/doctemplates/orders/template_order.odt',$dirodt.'/template_order.odt',0,0); - + $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/orders/template_order.odt'; $dest=$dirodt.'/template_order.odt'; + $result=dol_copy($src,$dest,0,0); + if ($result < 0) + { + $langs->load("errors"); + $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest); + return 0; + } + $sql = array( - "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->const[0][2]."'", - "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom,type) VALUES('".$this->const[0][2]."','order')" + "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->const[0][2]."' AND entity = ".$conf->entity, + "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->const[0][2]."','order',".$conf->entity.")" ); return $this->_init($sql,$options); @@ -216,8 +223,12 @@ class modCommande extends DolibarrModules /** - * \brief Fonction appelee lors de la desactivation d'un module. - * Supprime de la base les constantes, boites et permissions du module. + * Function called when module is disabled. + * Remove from database constants, boxes and permissions from Dolibarr database. + * Data directories are not deleted + * + * @param string $options Options when enabling module ('', 'noboxes') + * @return int 1 if OK, 0 if KO */ function remove() { diff --git a/htdocs/core/modules/modFacture.class.php b/htdocs/core/modules/modFacture.class.php index e06da8453f9..3c2c68b09cc 100644 --- a/htdocs/core/modules/modFacture.class.php +++ b/htdocs/core/modules/modFacture.class.php @@ -212,7 +212,7 @@ class modFacture extends DolibarrModules */ function init($options='') { - global $conf; + global $conf,$langs; // Remove permissions and default values $this->remove($options); @@ -220,11 +220,18 @@ class modFacture extends DolibarrModules require_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'); $dirodt=DOL_DATA_ROOT.'/doctemplates/invoices'; create_exdir($dirodt); - dol_copy(DOL_DOCUMENT_ROOT.'/install/doctemplates/invoices/template_invoice.odt',$dirodt.'/template_invoice.odt',0,0); + $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/invoices/template_invoice.odt'; $dest=$dirodt.'/template_invoice.odt'; + $result=dol_copy($src,$dest,0,0); + if ($result < 0) + { + $langs->load("errors"); + $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest); + return 0; + } $sql = array( "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->const[0][2]."' AND entity = ".$conf->entity, - "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->const[0][2]."','invoice',".$conf->entity.")", + "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->const[0][2]."','invoice',".$conf->entity.")" ); return $this->_init($sql,$options); diff --git a/htdocs/core/modules/modPropale.class.php b/htdocs/core/modules/modPropale.class.php index 6a0eabe0c6f..d7770bb61fa 100644 --- a/htdocs/core/modules/modPropale.class.php +++ b/htdocs/core/modules/modPropale.class.php @@ -190,7 +190,7 @@ class modPropale extends DolibarrModules */ function init($options='') { - global $conf; + global $conf,$langs; // Remove permissions and default values $this->remove(); @@ -199,7 +199,14 @@ class modPropale extends DolibarrModules require_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'); $dirodt=DOL_DATA_ROOT.'/doctemplates/proposals'; create_exdir($dirodt); - dol_copy(DOL_DOCUMENT_ROOT.'/install/doctemplates/proposals/template_proposal.odt',$dirodt.'/template_proposal.odt',0,0); + $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/proposals/template_proposal.odt'; $dest=$dirodt.'/template_proposal.odt'; + $result=dol_copy($src,$dest,0,0); + if ($result < 0) + { + $langs->load("errors"); + $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest); + return 0; + } $sql = array( "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->const[0][2]."' AND entity = ".$conf->entity, diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index ab20a588b15..224e23d67f1 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -316,7 +316,14 @@ class modSociete extends DolibarrModules require_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'); $dirodt=DOL_DATA_ROOT.'/doctemplates/thirdparties'; create_exdir($dirodt); - dol_copy(DOL_DOCUMENT_ROOT.'/install/doctemplates/thirdparties/template_thirdparty.odt',$dirodt.'/template_thirdparty.odt',0,0); + $src=DOL_DOCUMENT_ROOT.'/install/doctemplates/thirdparties/template_thirdparty.odt'; $dest=$dirodt.'/template_thirdparty.odt'; + $result=dol_copy($src,$dest,0,0); + if ($result < 0) + { + $langs->load("errors"); + $this->error=$langs->trans('ErrorFailToCopyFile',$src,$dest); + return 0; + } $sql = array(); diff --git a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php index 63a0cef81c5..92af7983233 100644 --- a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php +++ b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php @@ -1,7 +1,7 @@ +/* Copyright (C) 2010-2012 Laurent Destailleur * Copyright (C) 2012 Juanjo Menent - * + * * 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 @@ -39,13 +39,13 @@ class doc_generic_proposal_odt extends ModelePDFPropales var $emetteur; // Objet societe qui emet var $phpmin = array(5,2,0); // Minimum version of PHP required by module - var $version = 'development'; + var $version = 'dolibarr'; /** * Constructor * - * @param DoliDB $DB Database handler + * @param DoliDB $db Database handler */ function doc_generic_proposal_odt($db) { @@ -102,11 +102,11 @@ class doc_generic_proposal_odt extends ModelePDFPropales 'object_ref_ext'=>$object->ref_ext, 'object_ref_customer'=>$object->ref_client, 'object_date'=>dol_print_date($object->date,'day'), - 'object_fin_validite'=>dol_print_date($object->fin_validite,'dayhour'), + 'object_date_end'=>dol_print_date($object->fin_validite,'day'), 'object_date_creation'=>dol_print_date($object->date_creation,'day'), 'object_date_modification'=>dol_print_date($object->date_modification,'day'), 'object_date_validation'=>dol_print_date($object->date_validation,'dayhour'), - 'object_payment_mode'=>$object->mode_reglement, + 'object_payment_mode'=>($object->mode_reglement!='-'?$object->mode_reglement:''), 'object_payment_term'=>$object->cond_reglement, 'object_total_ht'=>price($object->total_ht,0,$outputlangs), 'object_total_vat'=>price($object->total_tva,0,$outputlangs), @@ -143,7 +143,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales ); } - /** + /** * Return description of a module * @param langs Lang object to use for output * @return string Description diff --git a/htdocs/install/doctemplates/proposals/template_proposal.odt b/htdocs/install/doctemplates/proposals/template_proposal.odt index d3779f546d4..e163fef7665 100644 Binary files a/htdocs/install/doctemplates/proposals/template_proposal.odt and b/htdocs/install/doctemplates/proposals/template_proposal.odt differ diff --git a/htdocs/install/etape1.php b/htdocs/install/etape1.php index bdc9868e3ee..80568b6ddf5 100644 --- a/htdocs/install/etape1.php +++ b/htdocs/install/etape1.php @@ -392,7 +392,7 @@ if (! $error && $db->connected && $action == "set") { // We must ignore errors as an existing old file may already exists and not be replacable or // the installer (like for ubuntu) may not have permission to create another file than conf.php. - // Also no other process must be able to read file or we expose the new file so content with password. + // Also no other process must be able to read file or we expose the new file, so content with password. @dol_copy($conffile, $conffile.'.old', '0400'); } diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 0817785acce..65a342bf83a 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -10,6 +10,7 @@ ErrorBadUrl=Url %s is wrong ErrorLoginAlreadyExists=Login %s already exists. ErrorGroupAlreadyExists=Group %s already exists. ErrorRecordNotFound=Record not found. +ErrorFailToCopyFile=Failed to copy file '%s' into '%s'. ErrorFailToRenameFile=Failed to rename file '%s' into '%s'. ErrorFailToDeleteFile=Failed to remove file '%s'. ErrorFailToCreateFile=Failed to create file '%s'. diff --git a/htdocs/langs/fr_FR/errors.lang b/htdocs/langs/fr_FR/errors.lang index b708c2aba1a..870589c8322 100644 --- a/htdocs/langs/fr_FR/errors.lang +++ b/htdocs/langs/fr_FR/errors.lang @@ -11,6 +11,7 @@ ErrorLoginAlreadyExists=Le login %s existe déjà. ErrorGroupAlreadyExists=Le groupe %s existe déjà. ErrorRecordNotFound=Enregistrement non trouvé. ErrorDuplicateTrigger=Un fichier trigger de classe '%s' est présent plusieurs fois. Supprimer le doublon du répertoire '%s'. +ErrorFailToCopyFile=Echec de la copie du fichier '%s' en '%s'. ErrorFailToRenameFile=Echec du renommage du fichier '%s' en '%s'. ErrorFailToCreateFile=Echec de la création du fichier '%s'. ErrorFailToDeleteFile=Echec de l'effacement du fichier '%s'. diff --git a/test/phpunit/AdherentTest.php b/test/phpunit/AdherentTest.php index d0e68c1ba7e..286be96a8fc 100644 --- a/test/phpunit/AdherentTest.php +++ b/test/phpunit/AdherentTest.php @@ -89,6 +89,9 @@ class AdherentTest extends PHPUnit_Framework_TestCase } /** + * Init phpunit tests + * + * @return void */ protected function setUp() { @@ -101,6 +104,9 @@ class AdherentTest extends PHPUnit_Framework_TestCase print __METHOD__."\n"; } /** + * End phpunit tests + * + * @return void */ protected function tearDown() { diff --git a/test/phpunit/BuildDocTest.php b/test/phpunit/BuildDocTest.php index 238ddd48351..c3c490ef4e1 100644 --- a/test/phpunit/BuildDocTest.php +++ b/test/phpunit/BuildDocTest.php @@ -121,6 +121,9 @@ class BuildDocTest extends PHPUnit_Framework_TestCase } /** + * Init phpunit tests + * + * @return void */ protected function setUp() { @@ -133,6 +136,9 @@ class BuildDocTest extends PHPUnit_Framework_TestCase print __METHOD__."\n"; } /** + * End phpunit tests + * + * @return void */ protected function tearDown() { diff --git a/test/phpunit/CMailFileTest.php b/test/phpunit/CMailFileTest.php index fccf9e2a3cb..f7bf4791f7a 100755 --- a/test/phpunit/CMailFileTest.php +++ b/test/phpunit/CMailFileTest.php @@ -89,6 +89,9 @@ class CMailFileTest extends PHPUnit_Framework_TestCase } /** + * Init phpunit tests + * + * @return void */ protected function setUp() { @@ -101,6 +104,9 @@ class CMailFileTest extends PHPUnit_Framework_TestCase print __METHOD__."\n"; } /** + * End phpunit tests + * + * @return void */ protected function tearDown() { diff --git a/test/phpunit/CategorieTest.php b/test/phpunit/CategorieTest.php index d254b81ba0e..a5634084c85 100755 --- a/test/phpunit/CategorieTest.php +++ b/test/phpunit/CategorieTest.php @@ -90,6 +90,9 @@ class CategorieTest extends PHPUnit_Framework_TestCase } /** + * Init phpunit tests + * + * @return void */ protected function setUp() { @@ -102,6 +105,9 @@ class CategorieTest extends PHPUnit_Framework_TestCase print __METHOD__."\n"; } /** + * End phpunit tests + * + * @return void */ protected function tearDown() { diff --git a/test/phpunit/ChargeSocialesTest.php b/test/phpunit/ChargeSocialesTest.php index bb9f36b3601..829efe78693 100755 --- a/test/phpunit/ChargeSocialesTest.php +++ b/test/phpunit/ChargeSocialesTest.php @@ -89,6 +89,9 @@ class ChargeSocialesTest extends PHPUnit_Framework_TestCase } /** + * Init phpunit tests + * + * @return void */ protected function setUp() { @@ -101,6 +104,9 @@ class ChargeSocialesTest extends PHPUnit_Framework_TestCase print __METHOD__."\n"; } /** + * End phpunit tests + * + * @return void */ protected function tearDown() { diff --git a/test/phpunit/CommandeFournisseurTest.php b/test/phpunit/CommandeFournisseurTest.php index f4a30a78f7f..da459471dd4 100644 --- a/test/phpunit/CommandeFournisseurTest.php +++ b/test/phpunit/CommandeFournisseurTest.php @@ -90,6 +90,9 @@ class CommandeFournisseurTest extends PHPUnit_Framework_TestCase } /** + * Init phpunit tests + * + * @return void */ protected function setUp() { @@ -103,6 +106,9 @@ class CommandeFournisseurTest extends PHPUnit_Framework_TestCase //print $db->getVersion()."\n"; } /** + * End phpunit tests + * + * @return void */ protected function tearDown() { diff --git a/test/phpunit/CommandeTest.php b/test/phpunit/CommandeTest.php index ab92568f43d..6541d13f9d2 100644 --- a/test/phpunit/CommandeTest.php +++ b/test/phpunit/CommandeTest.php @@ -89,6 +89,9 @@ class CommandeTest extends PHPUnit_Framework_TestCase } /** + * Init phpunit tests + * + * @return void */ protected function setUp() { @@ -102,6 +105,9 @@ class CommandeTest extends PHPUnit_Framework_TestCase //print $db->getVersion()."\n"; } /** + * End phpunit tests + * + * @return void */ protected function tearDown() { diff --git a/test/phpunit/CommonObjectTest.php b/test/phpunit/CommonObjectTest.php index 34a01173b22..cae50abe534 100644 --- a/test/phpunit/CommonObjectTest.php +++ b/test/phpunit/CommonObjectTest.php @@ -90,6 +90,9 @@ class CommonObjectTest extends PHPUnit_Framework_TestCase } /** + * Init phpunit tests + * + * @return void */ protected function setUp() { @@ -102,6 +105,9 @@ class CommonObjectTest extends PHPUnit_Framework_TestCase print __METHOD__."\n"; } /** + * End phpunit tests + * + * @return void */ protected function tearDown() { diff --git a/test/phpunit/CompanyBankAccountTest.php b/test/phpunit/CompanyBankAccountTest.php index 70fc38eea54..2c5b95c4e89 100644 --- a/test/phpunit/CompanyBankAccountTest.php +++ b/test/phpunit/CompanyBankAccountTest.php @@ -89,6 +89,9 @@ class CompanyBankAccountTest extends PHPUnit_Framework_TestCase } /** + * Init phpunit tests + * + * @return void */ protected function setUp() { @@ -102,6 +105,9 @@ class CompanyBankAccountTest extends PHPUnit_Framework_TestCase //print $db->getVersion()."\n"; } /** + * End phpunit tests + * + * @return void */ protected function tearDown() { diff --git a/test/phpunit/ContactTest.php b/test/phpunit/ContactTest.php index d57ed5154a5..f4ea66f0324 100755 --- a/test/phpunit/ContactTest.php +++ b/test/phpunit/ContactTest.php @@ -91,6 +91,9 @@ class ContactTest extends PHPUnit_Framework_TestCase } /** + * Init phpunit tests + * + * @return void */ protected function setUp() { @@ -103,6 +106,9 @@ class ContactTest extends PHPUnit_Framework_TestCase print __METHOD__."\n"; } /** + * End phpunit tests + * + * @return void */ protected function tearDown() { @@ -143,7 +149,7 @@ class ContactTest extends PHPUnit_Framework_TestCase $localobject=new Contact($this->savdb); $result=$localobject->fetch($id); - + print __METHOD__." id=".$id." result=".$result."\n"; $this->assertLessThan($result, 0); diff --git a/test/phpunit/ContratTest.php b/test/phpunit/ContratTest.php index 0d71f2850a1..fbf20f0deaf 100644 --- a/test/phpunit/ContratTest.php +++ b/test/phpunit/ContratTest.php @@ -89,6 +89,9 @@ class ContratTest extends PHPUnit_Framework_TestCase } /** + * Init phpunit tests + * + * @return void */ protected function setUp() { @@ -101,6 +104,9 @@ class ContratTest extends PHPUnit_Framework_TestCase print __METHOD__."\n"; } /** + * End phpunit tests + * + * @return void */ protected function tearDown() { @@ -120,10 +126,10 @@ class ContratTest extends PHPUnit_Framework_TestCase $localobject=new Contrat($this->savdb); $localobject->initAsSpecimen(); $result=$localobject->create($user); - + print __METHOD__." result=".$result."\n"; $this->assertLessThan($result, 0); - + return $result; } @@ -141,10 +147,10 @@ class ContratTest extends PHPUnit_Framework_TestCase $localobject=new Contrat($this->savdb); $result=$localobject->fetch($id); - + print __METHOD__." id=".$id." result=".$result."\n"; $this->assertLessThan($result, 0); - + return $localobject; } diff --git a/test/phpunit/CoreTest.php b/test/phpunit/CoreTest.php index 4ec3b477f31..a0eeb7404cc 100755 --- a/test/phpunit/CoreTest.php +++ b/test/phpunit/CoreTest.php @@ -88,6 +88,9 @@ class CoreTest extends PHPUnit_Framework_TestCase } /** + * Init phpunit tests + * + * @return void */ protected function setUp() { @@ -100,6 +103,9 @@ class CoreTest extends PHPUnit_Framework_TestCase print __METHOD__."\n"; } /** + * End phpunit tests + * + * @return void */ protected function tearDown() { diff --git a/test/phpunit/DateLibTest.php b/test/phpunit/DateLibTest.php index 601f81354a3..33c2eddefd2 100644 --- a/test/phpunit/DateLibTest.php +++ b/test/phpunit/DateLibTest.php @@ -89,6 +89,9 @@ class DateLibTest extends PHPUnit_Framework_TestCase } /** + * Init phpunit tests + * + * @return void */ protected function setUp() { @@ -101,6 +104,9 @@ class DateLibTest extends PHPUnit_Framework_TestCase print __METHOD__."\n"; } /** + * End phpunit tests + * + * @return void */ protected function tearDown() { diff --git a/test/phpunit/DiscountTest.php b/test/phpunit/DiscountTest.php index 1b44aeb09f5..556acdcec13 100755 --- a/test/phpunit/DiscountTest.php +++ b/test/phpunit/DiscountTest.php @@ -89,6 +89,9 @@ class DiscountTest extends PHPUnit_Framework_TestCase } /** + * Init phpunit tests + * + * @return void */ protected function setUp() { @@ -102,6 +105,9 @@ class DiscountTest extends PHPUnit_Framework_TestCase //print $db->getVersion()."\n"; } /** + * End phpunit tests + * + * @return void */ protected function tearDown() { diff --git a/test/phpunit/ExportTest.php b/test/phpunit/ExportTest.php index 0e60171790b..d7ba76dae2b 100755 --- a/test/phpunit/ExportTest.php +++ b/test/phpunit/ExportTest.php @@ -92,9 +92,9 @@ class ExportTest extends PHPUnit_Framework_TestCase } /** - * Ran on start + * Init phpunit tests * - * @return void + * @return void */ protected function setUp() { @@ -107,9 +107,9 @@ class ExportTest extends PHPUnit_Framework_TestCase print __METHOD__."\n"; } /** - * Ran on start + * End phpunit tests * - * @return void + * @return void */ protected function tearDown() { diff --git a/test/phpunit/FactureFournisseurTest.php b/test/phpunit/FactureFournisseurTest.php index c162ec47d6e..470fa6c49d6 100644 --- a/test/phpunit/FactureFournisseurTest.php +++ b/test/phpunit/FactureFournisseurTest.php @@ -89,6 +89,9 @@ class FactureFournisseurTest extends PHPUnit_Framework_TestCase } /** + * Init phpunit tests + * + * @return void */ protected function setUp() { @@ -101,6 +104,9 @@ class FactureFournisseurTest extends PHPUnit_Framework_TestCase print __METHOD__."\n"; } /** + * End phpunit tests + * + * @return void */ protected function tearDown() { diff --git a/test/phpunit/FilesLibTest.php b/test/phpunit/FilesLibTest.php index 5a896452c3a..3a608ce2bbd 100644 --- a/test/phpunit/FilesLibTest.php +++ b/test/phpunit/FilesLibTest.php @@ -90,6 +90,9 @@ class FilesLibTest extends PHPUnit_Framework_TestCase } /** + * Init phpunit tests + * + * @return void */ protected function setUp() { @@ -102,6 +105,9 @@ class FilesLibTest extends PHPUnit_Framework_TestCase print __METHOD__."\n"; } /** + * End phpunit tests + * + * @return void */ protected function tearDown() { @@ -109,7 +115,10 @@ class FilesLibTest extends PHPUnit_Framework_TestCase } /** - */ + * testDolCountNbOfLine + * + * @return int + */ public function testDolCountNbOfLine() { global $conf,$user,$langs,$db; @@ -127,7 +136,10 @@ class FilesLibTest extends PHPUnit_Framework_TestCase } /** - */ + * testDolIsFileDir + * + * @return int + */ public function testDolIsFileDir() { global $conf,$user,$langs,$db; @@ -150,6 +162,9 @@ class FilesLibTest extends PHPUnit_Framework_TestCase } /** + * testDolOther + * + * @return boolean */ public function testDolOther() { @@ -176,5 +191,53 @@ class FilesLibTest extends PHPUnit_Framework_TestCase return $result; } + + /** + * testDolCopyMove + * + * @return int + */ + public function testDolCopyMove() + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + $file=dirname(__FILE__).'/Example_import_company_1.csv'; + + $result=dol_copy($file, '/adir/that/does/not/exists/file.csv'); + print __METHOD__." result=".$result."\n"; + $this->assertLessThan(0,$result); // We should have error + + $result=dol_copy($file, $conf->admin->dir_temp.'/file.csv',0,1); + print __METHOD__." result=".$result."\n"; + $this->assertGreaterThanOrEqual(1,$result); // Should be 1 + + // Again to test with overwriting=0 + $result=dol_copy($file, $conf->admin->dir_temp.'/file.csv',0,0); + print __METHOD__." result=".$result."\n"; + $this->assertEquals(0,$result); // Should be 0 + + // Again to test with overwriting=1 + $result=dol_copy($file, $conf->admin->dir_temp.'/file.csv',0,1); + print __METHOD__." result=".$result."\n"; + $this->assertGreaterThanOrEqual(1,$result); // Should be 1 + + // Again to test with overwriting=1 + $result=dol_move($conf->admin->dir_temp.'/file.csv',$conf->admin->dir_temp.'/file2.csv',0,1); + print __METHOD__." result=".$result."\n"; + $this->assertTrue($result); + + $result=dol_delete_file($conf->admin->dir_temp.'/file2.csv'); + print __METHOD__." result=".$result."\n"; + $this->assertTrue($result); + + // Again to test no erreor when deleteing a non existing file + $result=dol_delete_file($conf->admin->dir_temp.'/file2.csv'); + print __METHOD__." result=".$result."\n"; + $this->assertTrue($result); + } } ?> \ No newline at end of file diff --git a/test/phpunit/ImportTest.php b/test/phpunit/ImportTest.php index 407818c2d21..e650a8adb46 100755 --- a/test/phpunit/ImportTest.php +++ b/test/phpunit/ImportTest.php @@ -91,6 +91,9 @@ class ImportTest extends PHPUnit_Framework_TestCase } /** + * Init phpunit tests + * + * @return void */ protected function setUp() { @@ -103,6 +106,9 @@ class ImportTest extends PHPUnit_Framework_TestCase print __METHOD__."\n"; } /** + * End phpunit tests + * + * @return void */ protected function tearDown() { diff --git a/test/phpunit/ModulesTest.php b/test/phpunit/ModulesTest.php index df27f147dc4..6df87dde2f2 100755 --- a/test/phpunit/ModulesTest.php +++ b/test/phpunit/ModulesTest.php @@ -88,6 +88,9 @@ class ModulesTest extends PHPUnit_Framework_TestCase } /** + * Init phpunit tests + * + * @return void */ protected function setUp() { @@ -100,6 +103,9 @@ class ModulesTest extends PHPUnit_Framework_TestCase print __METHOD__."\n"; } /** + * End phpunit tests + * + * @return void */ protected function tearDown() {
'.$langs->trans("Name")."".$langs->trans("Description")."'.$langs->trans("Status")."'.$langs->trans("Default")."'.$langs->trans("Infos").''.$langs->trans("Preview").''.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Status")."'.$langs->trans("Default")."'.$langs->trans("Infos").'