diff --git a/dev/codesniffer/ruleset.xml b/dev/codesniffer/ruleset.xml
index b5b3d90d4b2..b31cd2b3bef 100755
--- a/dev/codesniffer/ruleset.xml
+++ b/dev/codesniffer/ruleset.xml
@@ -135,6 +135,13 @@
0
-->
+
+ 0
+
+
+
+ 5
+
diff --git a/test/phpunit/AdherentTest.php b/test/phpunit/AdherentTest.php
index 8aaf1905434..8e3d33b7450 100644
--- a/test/phpunit/AdherentTest.php
+++ b/test/phpunit/AdherentTest.php
@@ -39,6 +39,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
/**
+ *
* @xcovers DoliDb
* @xcovers Translate
* @xcovers Conf
diff --git a/test/phpunit/AllTests.php b/test/phpunit/AllTests.php
index 2358c4f83ce..a550f6811aa 100644
--- a/test/phpunit/AllTests.php
+++ b/test/phpunit/AllTests.php
@@ -95,8 +95,12 @@ class AllTests
require_once dirname(__FILE__).'/CategorieTest.php';
$suite->addTestSuite('CategorieTest');
- require_once dirname(__FILE__).'/WebservicesTest.php'; // At end because it's the longer
+ require_once dirname(__FILE__).'/WebservicesTest.php';
$suite->addTestSuite('WebservicesTest');
+ require_once dirname(__FILE__).'/ExportTest.php';
+ $suite->addTestSuite('ExportTest');
+ require_once dirname(__FILE__).'/ImportTest.php';
+ $suite->addTestSuite('ImportTest');
require_once dirname(__FILE__).'/ModulesTest.php'; // At end because it's the longer
$suite->addTestSuite('ModulesTest');
diff --git a/test/phpunit/BuildDocTest.php b/test/phpunit/BuildDocTest.php
index 930d7bbce1c..fea6e603450 100644
--- a/test/phpunit/BuildDocTest.php
+++ b/test/phpunit/BuildDocTest.php
@@ -63,6 +63,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
/**
+ *
* @xcovers DoliDb
* @xcovers User
* @xcovers Translate
diff --git a/test/phpunit/CMailFileTest.php b/test/phpunit/CMailFileTest.php
index eef53b19bc5..6a2dea77fc3 100755
--- a/test/phpunit/CMailFileTest.php
+++ b/test/phpunit/CMailFileTest.php
@@ -39,6 +39,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
/**
+ *
* @xcovers DoliDb
* @xcovers Translate
* @xcovers Conf
diff --git a/test/phpunit/CategorieTest.php b/test/phpunit/CategorieTest.php
index 92ba8c26158..511b8adcd46 100755
--- a/test/phpunit/CategorieTest.php
+++ b/test/phpunit/CategorieTest.php
@@ -39,6 +39,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
/**
+ *
* @xcovers DoliDb
* @xcovers Translate
* @xcovers Conf
diff --git a/test/phpunit/ChargeSocialesTest.php b/test/phpunit/ChargeSocialesTest.php
index e4c4ecf9fd8..d725984f797 100755
--- a/test/phpunit/ChargeSocialesTest.php
+++ b/test/phpunit/ChargeSocialesTest.php
@@ -39,6 +39,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
/**
+ *
* @xcovers DoliDb
* @xcovers Translate
* @xcovers Conf
diff --git a/test/phpunit/CommandeFournisseurTest.php b/test/phpunit/CommandeFournisseurTest.php
index 6bc7e47ef57..b1bcfe0982f 100644
--- a/test/phpunit/CommandeFournisseurTest.php
+++ b/test/phpunit/CommandeFournisseurTest.php
@@ -40,6 +40,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
/**
+ *
* @xcovers CommandeFournisseur
* @xcovers CommandeFournisseurLigne
*
diff --git a/test/phpunit/CommandeTest.php b/test/phpunit/CommandeTest.php
index aff3471550c..03bbb024f80 100644
--- a/test/phpunit/CommandeTest.php
+++ b/test/phpunit/CommandeTest.php
@@ -39,6 +39,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
/**
+ *
* @xcovers Commande
* @xcovers OrderLine
*
diff --git a/test/phpunit/CommonObjectTest.php b/test/phpunit/CommonObjectTest.php
index b802cd8cd6d..ba0d3e25d88 100644
--- a/test/phpunit/CommonObjectTest.php
+++ b/test/phpunit/CommonObjectTest.php
@@ -40,6 +40,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
/**
+ *
* @xcovers DoliDb
* @xcovers User
* @xcovers Translate
diff --git a/test/phpunit/CompanyBankAccountTest.php b/test/phpunit/CompanyBankAccountTest.php
index 380706fce9a..bd726353f4e 100644
--- a/test/phpunit/CompanyBankAccountTest.php
+++ b/test/phpunit/CompanyBankAccountTest.php
@@ -39,6 +39,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
/**
+ *
* @xcovers CompanyBankAccount
*
* @backupGlobals disabled
diff --git a/test/phpunit/ContratTest.php b/test/phpunit/ContratTest.php
index fadaf67fa0f..552d31bc219 100644
--- a/test/phpunit/ContratTest.php
+++ b/test/phpunit/ContratTest.php
@@ -39,6 +39,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
/**
+ *
* @xcovers DoliDb
* @xcovers Translate
* @xcovers Conf
diff --git a/test/phpunit/CoreTest.php b/test/phpunit/CoreTest.php
index 1e9cc93c68d..435082a35f6 100755
--- a/test/phpunit/CoreTest.php
+++ b/test/phpunit/CoreTest.php
@@ -17,7 +17,7 @@
*/
/**
- * \file test/phpunit/SecurityTest.php
+ * \file test/phpunit/CoreTest.php
* \ingroup test
* \brief PHPUnit test
* \remarks To run this script as CLI: phpunit filename.php
diff --git a/test/phpunit/Example_import_company_1.csv b/test/phpunit/Example_import_company_1.csv
new file mode 100755
index 00000000000..a5bbe397f16
--- /dev/null
+++ b/test/phpunit/Example_import_company_1.csv
@@ -0,0 +1,2 @@
+"Name* (s.nom)";"Status (s.status)";"Customer* (s.client)";"Supplier* (s.fournisseur)";"DateCreation (s.datec)";"CustomerCode (s.code_client)";"SupplierCode (s.code_fournisseur)";"Address (s.address)";"Zip (s.cp)";"Town (s.ville)";"Phone (s.tel)";"Fax (s.fax)";"Url (s.url)";"Email (s.email)";"IdProf1 (s.siret)";"IdProf2 (s.siren)";"IdProf3 (s.ape)";"IdProf4 (s.idprof4)";"VATIntraShort (s.tva_intra)";"Capital (s.capital)";"Note (s.note)";"ThirdPartyType (s.fk_typent)";"Effectif (s.fk_effectif)";"JuridicalStatus (s.fk_forme_juridique)";"ProspectLevel (s.fk_prospectlevel)";"ProspectStatus (s.fk_stcomm)";"DefaultLanguage (s.default_lang)";"BarCode (s.gencod)"
+"MyBigCompanyImport1";1;3;1;01/01/00;"CU01-0001";"SU01-0001";"61 jump street";123456;"Big town";101010101;101010102;"http://mycompany.com";"test@mycompany.com";;;;;"FR0123456789";10000;"This is an example of note for record";2;3;1;"PL_MEDIUM";1;"en_US";123456789
diff --git a/test/phpunit/ExportTest.php b/test/phpunit/ExportTest.php
new file mode 100755
index 00000000000..a29a397aaea
--- /dev/null
+++ b/test/phpunit/ExportTest.php
@@ -0,0 +1,167 @@
+
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+/**
+ * \file test/phpunit/ImportTest.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/Framework.php';
+require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
+require_once dirname(__FILE__).'/../../htdocs/exports/class/export.class.php';
+
+if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1');
+if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1');
+if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
+if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
+if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1');
+if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1');
+if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show
+if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php
+if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
+if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session)
+
+
+/**
+ * When no cover is provided. We use everything.
+ *
+ * @backupGlobals disabled
+ * @backupStaticAttributes enabled
+ * @remarks backupGlobals must be disabled to have db,conf,user and lang not erased.
+ */
+class ExportTest extends PHPUnit_Framework_TestCase
+{
+ protected $savconf;
+ protected $savuser;
+ protected $savlangs;
+ protected $savdb;
+
+ /**
+ * Constructor
+ * We save global variables into local variables
+ *
+ * @return ExportTest
+ */
+ function ExportTest()
+ {
+ //$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";
+ }
+
+ /**
+ * Ran on start
+ *
+ * @return void
+ */
+ protected function setUp()
+ {
+ global $conf,$user,$langs,$db;
+ $conf=$this->savconf;
+ $user=$this->savuser;
+ $langs=$this->savlangs;
+ $db=$this->savdb;
+
+ print __METHOD__."\n";
+ }
+ /**
+ * Ran on start
+ *
+ * @return void
+ */
+ protected function tearDown()
+ {
+ print __METHOD__."\n";
+ }
+
+
+ /**
+ * Test export function
+ *
+ * @return void
+ */
+ public function testExportPersonalizedExport()
+ {
+ global $conf,$user,$langs,$db;
+
+ $sql = "SELECT f.facnumber as f_facnumber, f.amount as f_amount, f.total as f_total, f.tva as f_tva FROM ".MAIN_DB_PREFIX."facture f";
+
+ $objexport=new Export($db);
+ //$objexport->load_arrays($user,$datatoexport);
+
+ // Define properties
+ $datatoexport='test';
+ $array_selected = array("f.facnumber"=>1, "f.amount"=>2, "f.total"=>3, "f.tva"=>4);
+ $array_export_fields = array("f.facnumber"=>"FacNumber", "f.amount"=>"FacAmount", "f.total"=>"FacTotal", "f.tva"=>"FacVat");
+ $array_alias = array("f_facnumber"=>"facnumber", "f_amount"=>"amount", "f_total"=>"total", "f_tva"=>"tva");
+ $objexport->array_export_fields[0]=$array_export_fields;
+ $objexport->array_export_alias[0]=$array_alias;
+
+ $model='csv';
+
+ // Build export file
+ $result=$objexport->build_file($user, $model, $datatoexport, $array_selected, $sql);
+ $expectedresult=1;
+ $this->assertEquals($result,$expectedresult);
+
+ $model='tsv';
+
+ // Build export file
+ $result=$objexport->build_file($user, $model, $datatoexport, $array_selected, $sql);
+ $expectedresult=1;
+ $this->assertEquals($result,$expectedresult);
+
+ $model='excel';
+
+ // Build export file
+ $result=$objexport->build_file($user, $model, $datatoexport, $array_selected, $sql);
+ $expectedresult=1;
+ $this->assertEquals($result,$expectedresult);
+
+ return true;
+ }
+
+}
+?>
\ No newline at end of file
diff --git a/test/phpunit/FactureFournisseurTest.php b/test/phpunit/FactureFournisseurTest.php
index dfc5e49ef7f..2b7a7b67aaa 100644
--- a/test/phpunit/FactureFournisseurTest.php
+++ b/test/phpunit/FactureFournisseurTest.php
@@ -39,6 +39,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
/**
+ *
* @xcovers DoliDb
* @xcovers User
* @xcovers Translate
diff --git a/test/phpunit/FactureTest.php b/test/phpunit/FactureTest.php
index 674d851e643..48c88e4299f 100644
--- a/test/phpunit/FactureTest.php
+++ b/test/phpunit/FactureTest.php
@@ -39,6 +39,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
/**
+ *
* @xcovers DoliDb
* @xcovers User
* @xcovers Translate
diff --git a/test/phpunit/FunctionsTest.php b/test/phpunit/FunctionsTest.php
index 2cef6cbcfa6..b2ec54f0d89 100755
--- a/test/phpunit/FunctionsTest.php
+++ b/test/phpunit/FunctionsTest.php
@@ -41,6 +41,7 @@ if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is
/**
+ *
* @backupGlobals disabled
* @backupStaticAttributes enabled
* @remarks backupGlobals must be disabled to have db,conf,user and lang not erased.
diff --git a/test/phpunit/ImportTest.php b/test/phpunit/ImportTest.php
new file mode 100755
index 00000000000..301f56c8700
--- /dev/null
+++ b/test/phpunit/ImportTest.php
@@ -0,0 +1,124 @@
+
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+/**
+ * \file test/phpunit/ImportTest.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/Framework.php';
+require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
+
+if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1');
+if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1');
+if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
+if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
+if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1');
+if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1');
+if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show
+if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php
+if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
+if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session)
+
+
+/**
+ * When no cover is provided. We use everything.
+ *
+ * @backupGlobals disabled
+ * @backupStaticAttributes enabled
+ * @remarks backupGlobals must be disabled to have db,conf,user and lang not erased.
+ */
+class ImportTest extends PHPUnit_Framework_TestCase
+{
+ protected $savconf;
+ protected $savuser;
+ protected $savlangs;
+ protected $savdb;
+
+ /**
+ * Constructor
+ * We save global variables into local variables
+ *
+ * @return ImportTest
+ */
+ function ImportTest()
+ {
+ //$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 testImportSample1()
+ {
+
+
+
+ return true;
+ }
+
+}
+?>
\ No newline at end of file
diff --git a/test/phpunit/ModulesTest.php b/test/phpunit/ModulesTest.php
index f319f74d6e1..4e02d9b2885 100755
--- a/test/phpunit/ModulesTest.php
+++ b/test/phpunit/ModulesTest.php
@@ -38,6 +38,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
/**
+ *
* @xcovers DolibarrModules
* @xcovers modAccounting
* @xcovers modAdherent
diff --git a/test/phpunit/PropalTest.php b/test/phpunit/PropalTest.php
index 2cb10af4d6e..045fbd2d7e2 100644
--- a/test/phpunit/PropalTest.php
+++ b/test/phpunit/PropalTest.php
@@ -39,6 +39,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
/**
+ *
* @xcovers Propal
* @xcovers PropaleLigne
*
diff --git a/test/phpunit/SecurityTest.php b/test/phpunit/SecurityTest.php
index 347d94cbc04..c83eb81fa0b 100755
--- a/test/phpunit/SecurityTest.php
+++ b/test/phpunit/SecurityTest.php
@@ -42,6 +42,7 @@ if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is
/**
+ *
* @xcovers DoliDb
* @xcovers Translate
* @xcovers Conf
diff --git a/test/phpunit/SocieteTest.php b/test/phpunit/SocieteTest.php
index 7d6aa47a6db..a5f761677f9 100755
--- a/test/phpunit/SocieteTest.php
+++ b/test/phpunit/SocieteTest.php
@@ -39,6 +39,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
/**
+ *
* @xcovers DoliDb
* @xcovers Conf
* @xcovers Societe
diff --git a/test/phpunit/UserGroupTest.php b/test/phpunit/UserGroupTest.php
index 26b706090c8..c98fd59501d 100644
--- a/test/phpunit/UserGroupTest.php
+++ b/test/phpunit/UserGroupTest.php
@@ -39,6 +39,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
/**
+ *
* @xcovers DoliDb
* @xcovers Translate
* @xcovers Conf
diff --git a/test/phpunit/UserTest.php b/test/phpunit/UserTest.php
index 7347905c3fe..a166834b977 100644
--- a/test/phpunit/UserTest.php
+++ b/test/phpunit/UserTest.php
@@ -39,6 +39,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
/**
+ *
* @xcovers DoliDb
* @xcovers Translate
* @xcovers Conf
diff --git a/test/phpunit/WebservicesTest.php b/test/phpunit/WebservicesTest.php
index 250bf687578..a5d8acb74b2 100755
--- a/test/phpunit/WebservicesTest.php
+++ b/test/phpunit/WebservicesTest.php
@@ -41,7 +41,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
/**
- * When not cover is provided. We use everything.
+ * When no cover is provided. We use everything.
*
* @backupGlobals disabled
* @backupStaticAttributes enabled