From 6f26f35529ef09391714d8d690f745c9b51a8b2f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur <eldy@users.sourceforge.net> Date: Wed, 13 Oct 2010 19:01:22 +0000 Subject: [PATCH] Add more phpunit tests --- test/phpunit/AdherentTest.php | 53 +++-- test/phpunit/CommandeFournisseurTest.php | 29 ++- test/phpunit/CommandeTest.php | 28 ++- test/phpunit/CompanyBankAccountTest.php | 27 ++- test/phpunit/ContratTest.php | 30 ++- test/phpunit/FactureFournisseurTest.php | 30 ++- test/phpunit/FactureTest.php | 30 ++- test/phpunit/ModulesTest.php | 147 ++++++++++++ test/phpunit/MyTestSuite.php | 8 +- test/phpunit/PropalTest.php | 28 ++- test/phpunit/README | 2 +- test/phpunit/SocieteTest.php | 282 +++++++++++++++++++++++ test/phpunit/UserGroupTest.php | 30 ++- test/phpunit/UserTest.php | 30 ++- test/phpunit/phpunittest.xml | 61 ++--- 15 files changed, 744 insertions(+), 71 deletions(-) create mode 100755 test/phpunit/ModulesTest.php create mode 100755 test/phpunit/SocieteTest.php diff --git a/test/phpunit/AdherentTest.php b/test/phpunit/AdherentTest.php index ac0939a54be..6fb709f97c0 100644 --- a/test/phpunit/AdherentTest.php +++ b/test/phpunit/AdherentTest.php @@ -124,10 +124,11 @@ class AdherentTest extends PHPUnit_Framework_TestCase $localobject=new Adherent($this->savdb); $localobject->initAsSpecimen(); - $result=$localobject->create($user); + $result=$localobject->create($user); + print __METHOD__." result=".$result."\n"; $this->assertLessThan($result, 0); - print __METHOD__." result=".$result."\n"; + return $result; } @@ -145,10 +146,10 @@ class AdherentTest extends PHPUnit_Framework_TestCase $localobject=new Adherent($this->savdb); $result=$localobject->fetch($id); - - $this->assertLessThan($result, 0); print __METHOD__." id=".$id." result=".$result."\n"; - return $localobject; + $this->assertLessThan($result, 0); + + return $localobject; } /** @@ -165,9 +166,9 @@ class AdherentTest extends PHPUnit_Framework_TestCase $localobject->note='New note after update'; $result=$localobject->update($user); - print __METHOD__." id=".$localobject->id." result=".$result."\n"; $this->assertLessThan($result, 0); + return $localobject; } @@ -185,13 +186,37 @@ class AdherentTest extends PHPUnit_Framework_TestCase $result=$localobject->validate($user); print __METHOD__." id=".$localobject->id." result=".$result."\n"; - $this->assertLessThan($result, 0); - return $localobject->id; + + return $localobject; } - /** - * @depends testAdherentValid + /** + * @depends testAdherentValid + * The depends says test is run only if previous is ok + */ + public function testAdherentOther($localobject) + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + /*$result=$localobject->setstatus(0); + print __METHOD__." id=".$localobject->id." result=".$result."\n"; + $this->assertLessThan($result, 0); + */ + + $localobject->info($localobject->id); + print __METHOD__." localobject->date_creation=".$localobject->date_creation."\n"; + $this->assertNotEquals($localobject->date_creation, ''); + + return $localobject->id; + } + + /** + * @depends testAdherentOther * The depends says test is run only if previous is ok */ public function testAdherentDelete($id) @@ -205,10 +230,10 @@ class AdherentTest extends PHPUnit_Framework_TestCase $localobject=new Adherent($this->savdb); $result=$localobject->fetch($id); $result=$localobject->delete($id); - print __METHOD__." id=".$id." result=".$result."\n"; - $this->assertLessThan($result, 0); - return $result; + $this->assertLessThan($result, 0); + + return $result; } /** @@ -225,9 +250,9 @@ class AdherentTest extends PHPUnit_Framework_TestCase $localobject=new Adherent($this->savdb); $result=$localobject->ref='refthatdoesnotexists'; $result=$localobject->VerifyNumRef(); - print __METHOD__." result=".$result."\n"; $this->assertEquals($result, 0); + return $result; }*/ } diff --git a/test/phpunit/CommandeFournisseurTest.php b/test/phpunit/CommandeFournisseurTest.php index 80a709e03b4..f78bdd40b05 100644 --- a/test/phpunit/CommandeFournisseurTest.php +++ b/test/phpunit/CommandeFournisseurTest.php @@ -204,11 +204,36 @@ class CommandeFournisseurTest extends PHPUnit_Framework_TestCase print __METHOD__." id=".$localobject->id." result=".$result."\n"; $this->assertLessThan($result, 0); - return $localobject->id; + return $localobject; + } + + /** + * @depends testCommandeFournisseurCancel + * The depends says test is run only if previous is ok + */ + public function testCommandeFournisseurOther($localobject) + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + /*$result=$localobject->setstatus(0); + print __METHOD__." id=".$localobject->id." result=".$result."\n"; + $this->assertLessThan($result, 0); + */ + + /*$localobject->info($localobject->id); + print __METHOD__." localobject->date_creation=".$localobject->date_creation."\n"; + $this->assertNotEquals($localobject->date_creation, ''); + */ + + return $localobject->id; } /** - * @depends testCommandeFournisseurCancel + * @depends testCommandeFournisseurOther * The depends says test is run only if previous is ok */ public function testCommandeFournisseurDelete($id) diff --git a/test/phpunit/CommandeTest.php b/test/phpunit/CommandeTest.php index 9867fd450c4..9c5950b93c1 100644 --- a/test/phpunit/CommandeTest.php +++ b/test/phpunit/CommandeTest.php @@ -203,11 +203,35 @@ class CommandeTest extends PHPUnit_Framework_TestCase print __METHOD__." id=".$localobject->id." result=".$result."\n"; $this->assertLessThan($result, 0); - return $localobject->id; + return $localobject; + } + + /** + * @depends testCommandeCancel + * The depends says test is run only if previous is ok + */ + public function testCommandeOther($localobject) + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + /*$result=$localobject->setstatus(0); + print __METHOD__." id=".$localobject->id." result=".$result."\n"; + $this->assertLessThan($result, 0); + */ + + $localobject->info($localobject->id); + print __METHOD__." localobject->date_creation=".$localobject->date_creation."\n"; + $this->assertNotEquals($localobject->date_creation, ''); + + return $localobject->id; } /** - * @depends testCommandeCancel + * @depends testCommandeOther * The depends says test is run only if previous is ok */ public function testCommandeDelete($id) diff --git a/test/phpunit/CompanyBankAccountTest.php b/test/phpunit/CompanyBankAccountTest.php index 16bd3e9dee4..ac5141679ce 100644 --- a/test/phpunit/CompanyBankAccountTest.php +++ b/test/phpunit/CompanyBankAccountTest.php @@ -42,8 +42,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1; /** * @backupGlobals disabled * @backupStaticAttributes enabled - * @covers Commande - * @covers OrderLine + * @covers CompanyBankAccount * @remarks backupGlobals must be disabled to have db,conf,user and lang not erased. */ class CompanyBankAccountTest extends PHPUnit_Framework_TestCase @@ -165,11 +164,31 @@ class CompanyBankAccountTest extends PHPUnit_Framework_TestCase print __METHOD__." id=".$localobject->id." result=".$result."\n"; $this->assertLessThan($result, 0); - return $localobject->id; + return $localobject; + } + + /** + * @depends testCompanyBankAccountFetch + * The depends says test is run only if previous is ok + */ + public function testCompanyBankAccountOther($localobject) + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + $localobject->owner='New owner'; + $result=$localobject->update($user); + + print __METHOD__." id=".$localobject->id." result=".$result."\n"; + $this->assertLessThan($result, 0); + return $localobject->id; } /** - * @depends testCompanyBankAccountUpdate + * @depends testCompanyBankAccountOther * The depends says test is run only if previous is ok */ /* public function testCompanyBankAccountDelete($id) diff --git a/test/phpunit/ContratTest.php b/test/phpunit/ContratTest.php index 1e2d77eb591..247366038eb 100644 --- a/test/phpunit/ContratTest.php +++ b/test/phpunit/ContratTest.php @@ -189,11 +189,35 @@ class ContratTest extends PHPUnit_Framework_TestCase print __METHOD__." id=".$localobject->id." result=".$result."\n"; $this->assertLessThan($result, 0); - return $localobject->id; + return $localobject; } - /** - * @depends testContratValid + /** + * @depends testContratValid + * The depends says test is run only if previous is ok + */ + public function testContratOther($localobject) + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + /*$result=$localobject->setstatus(0); + print __METHOD__." id=".$localobject->id." result=".$result."\n"; + $this->assertLessThan($result, 0); + */ + + $localobject->info($localobject->id); + print __METHOD__." localobject->date_creation=".$localobject->date_creation."\n"; + $this->assertNotEquals($localobject->date_creation, ''); + + return $localobject->id; + } + + /** + * @depends testContratOther * The depends says test is run only if previous is ok */ public function testContratDelete($id) diff --git a/test/phpunit/FactureFournisseurTest.php b/test/phpunit/FactureFournisseurTest.php index f6e3190b3b2..89225e40e34 100644 --- a/test/phpunit/FactureFournisseurTest.php +++ b/test/phpunit/FactureFournisseurTest.php @@ -188,11 +188,35 @@ class FactureFournisseurTest extends PHPUnit_Framework_TestCase print __METHOD__." id=".$localobject->id." result=".$result."\n"; $this->assertLessThan($result, 0); - return $localobject->id; + return $localobject; } - /** - * @depends testFactureFournisseurValid + /** + * @depends testFactureFournisseurValid + * The depends says test is run only if previous is ok + */ + public function testFactureFournisseurOther($localobject) + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + /*$result=$localobject->setstatus(0); + print __METHOD__." id=".$localobject->id." result=".$result."\n"; + $this->assertLessThan($result, 0); + */ + + $localobject->info($localobject->id); + print __METHOD__." localobject->date_creation=".$localobject->date_creation."\n"; + $this->assertNotEquals($localobject->date_creation, ''); + + return $localobject->id; + } + + /** + * @depends testFactureFournisseurOther * The depends says test is run only if previous is ok */ public function testFactureFournisseurDelete($id) diff --git a/test/phpunit/FactureTest.php b/test/phpunit/FactureTest.php index d6cf4527c61..e9204ef1ce7 100644 --- a/test/phpunit/FactureTest.php +++ b/test/phpunit/FactureTest.php @@ -190,11 +190,35 @@ class FactureTest extends PHPUnit_Framework_TestCase print __METHOD__." id=".$localobject->id." result=".$result."\n"; $this->assertLessThan($result, 0); - return $localobject->id; + return $localobject; } - /** - * @depends testFactureValid + /** + * @depends testFactureValid + * The depends says test is run only if previous is ok + */ + public function testFactureOther($localobject) + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + /*$result=$localobject->setstatus(0); + print __METHOD__." id=".$localobject->id." result=".$result."\n"; + $this->assertLessThan($result, 0); + */ + + $localobject->info($localobject->id); + print __METHOD__." localobject->date_creation=".$localobject->date_creation."\n"; + $this->assertNotEquals($localobject->date_creation, ''); + + return $localobject->id; + } + + /** + * @depends testFactureOther * The depends says test is run only if previous is ok */ public function testFactureDelete($id) diff --git a/test/phpunit/ModulesTest.php b/test/phpunit/ModulesTest.php new file mode 100755 index 00000000000..6a3b1422fac --- /dev/null +++ b/test/phpunit/ModulesTest.php @@ -0,0 +1,147 @@ +<?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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/** + * \file test/phpunit/ModulesTest.php + * \ingroup test + * \brief PHPUnit test + * \version $Id$ + * \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 (empty($user->id)) +{ + print "Load permissions for admin user nb 1\n"; + $user->fetch(1); + $user->getrights(); +} +$conf->global->MAIN_DISABLE_ALL_MAILS=1; + + +/** + * @backupGlobals disabled + * @backupStaticAttributes enabled + * @covers DolibarrModules + * @covers modAccounting + * @covers modAdherent + * @covers modAgenda + * @covers modBanque + * @covers modBarcode + * @covers modBookmark + * @covers modBoutique + * @remarks backupGlobals must be disabled to have db,conf,user and lang not erased. + */ +class ModulesTest extends PHPUnit_Framework_TestCase +{ + protected $savconf; + protected $savuser; + protected $savlangs; + protected $savdb; + + /** + * Constructor + * We save global variables into local variables + * + * @return BuildDocTest + */ + function ModulesTest() + { + //$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 testModulesInit() + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + $modulelist=array('Accounting','Adherent','Agenda','Banque','Barcode','Bookmark','Boutique', + 'CashDesk','Categorie','ClickToDial','Commande','Comptabilite','Contrat','Deplacement','Document','Domain','Don', + 'ECM','Expedition','Export','ExternalRss','ExternalSite','FTP','Facture', + 'Fckeditor','Ficheinter','Fournisseur','GeoIPMaxmind','Gravatar','Import','Label','Ldap','Mailing', + 'Mantis','Notification','Paybox','Paypal','Phenix','Prelevement','Product','Projet','Propale', + 'Service','Societe','Stock','Syslog','Tax','User','WebServices','Webcalendar'); + foreach($modulelist as $modlabel) + { + require_once(DOL_DOCUMENT_ROOT.'/includes/modules/mod'.$modlabel.'.class.php'); + $class='mod'.$modlabel; + $mod=new $class($db); + $result=$mod->remove(); + $result=$mod->init(); + $this->assertLessThan($result, 0); + print __METHOD__." result=".$result."\n"; + } + + return 0; + } + +} +?> \ No newline at end of file diff --git a/test/phpunit/MyTestSuite.php b/test/phpunit/MyTestSuite.php index aab4bba0da6..37ddb7de717 100644 --- a/test/phpunit/MyTestSuite.php +++ b/test/phpunit/MyTestSuite.php @@ -58,9 +58,12 @@ class MyTestSuite require_once dirname(__FILE__).'/CommonObjectTest.php'; $suite->addTestSuite('CommonObjectTest'); + require_once dirname(__FILE__).'/SocieteTest.php'; + $suite->addTestSuite('SocieteTest'); require_once dirname(__FILE__).'/AdherentTest.php'; $suite->addTestSuite('AdherentTest'); - require_once dirname(__FILE__).'/CommandeTest.php'; + + require_once dirname(__FILE__).'/CommandeTest.php'; $suite->addTestSuite('CommandeTest'); require_once dirname(__FILE__).'/CommandeFournisseurTest.php'; $suite->addTestSuite('CommandeFournisseurTest'); @@ -81,6 +84,9 @@ class MyTestSuite require_once dirname(__FILE__).'/ChargeSocialesTest.php'; $suite->addTestSuite('ChargeSocialesTest'); + require_once dirname(__FILE__).'/ModulesTest.php'; + $suite->addTestSuite('ModulesTest'); + return $suite; } } diff --git a/test/phpunit/PropalTest.php b/test/phpunit/PropalTest.php index d0285186280..ed63b867400 100644 --- a/test/phpunit/PropalTest.php +++ b/test/phpunit/PropalTest.php @@ -184,11 +184,35 @@ class PropalTest extends PHPUnit_Framework_TestCase print __METHOD__." id=".$localobject->id." result=".$result."\n"; $this->assertLessThan($result, 0); - return $localobject->id; + return $localobject; + } + + /** + * @depends testPropalValid + * The depends says test is run only if previous is ok + */ + public function testPropalOther($localobject) + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + /*$result=$localobject->setstatus(0); + print __METHOD__." id=".$localobject->id." result=".$result."\n"; + $this->assertLessThan($result, 0); + */ + + $localobject->info($localobject->id); + print __METHOD__." localobject->date_creation=".$localobject->date_creation."\n"; + $this->assertNotEquals($localobject->date_creation, ''); + + return $localobject->id; } /** - * @depends testPropalValid + * @depends testPropalOther * The depends says test is run only if previous is ok */ public function testPropalDelete($id) diff --git a/test/phpunit/README b/test/phpunit/README index 86964d48efe..9df6b76a4f7 100644 --- a/test/phpunit/README +++ b/test/phpunit/README @@ -28,7 +28,7 @@ Run > phpunit --coverage-html ./report MyTestSuite.php Note that xdebug must be installed for this feature to work. * Generate a report of Unit tests code coverage among all Dolibarr classes: -Increase your PHP memory (memory_limit in php.ini) to 528MB. +Increase your PHP memory (memory_limit in php.ini) to 512MB. Check that you use the "mysqli" driver in your conf.php file (otherwise edit the file phpunittest.xml). Run > phpunit --configuration ./phpunittest.xml --coverage-html ./report MyTestSuite.php diff --git a/test/phpunit/SocieteTest.php b/test/phpunit/SocieteTest.php new file mode 100755 index 00000000000..38dc57dac8a --- /dev/null +++ b/test/phpunit/SocieteTest.php @@ -0,0 +1,282 @@ +<?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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/** + * \file test/phpunit/SocieteTest.php + * \ingroup test + * \brief PHPUnit test + * \version $Id$ + * \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/societe/class/societe.class.php'; + +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; + + +/** + * @backupGlobals disabled + * @backupStaticAttributes enabled + * @covers DoliDb + * @covers Conf + * @covers Societe + * @remarks backupGlobals must be disabled to have db,conf,user and lang not erased. + */ +class SocieteTest extends PHPUnit_Framework_TestCase +{ + protected $savconf; + protected $savuser; + protected $savlangs; + protected $savdb; + + /** + * Constructor + * We save global variables into local variables + * + * @return SocieteTest + */ + function SocieteTest() + { + //$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 testSocieteCreate() + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + $localobject=new Societe($this->savdb); + $localobject->initAsSpecimen(); + $result=$localobject->create($user); + + print __METHOD__." result=".$result."\n"; + $this->assertLessThanOrEqual($result, 0); + + return $result; + } + + /** + * @depends testSocieteCreate + * The depends says test is run only if previous is ok + */ + public function testSocieteFetch($id) + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + $localobject=new Societe($this->savdb); + $result=$localobject->fetch($id); + print __METHOD__." id=".$id." result=".$result."\n"; + $this->assertLessThan($result, 0); + + $result=$localobject->verify(); + print __METHOD__." id=".$id." result=".$result."\n"; + $this->assertEquals($result, 0); + + return $localobject; + } + + /** + * @depends testSocieteFetch + * The depends says test is run only if previous is ok + */ + public function testSocieteUpdate($localobject) + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + $localobject->note='New note after update'; + $result=$localobject->update($localobject->id,$user); + print __METHOD__." id=".$localobject->id." result=".$result."\n"; + $this->assertLessThan($result, 0); + + return $localobject; + } + + /** + * @depends testSocieteUpdate + * The depends says test is run only if previous is ok + */ + public function testSocieteOther($localobject) + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + $result=$localobject->factures_impayes(); + print __METHOD__." id=".$localobject->id." result=".join(',',$result)."\n"; + //$this->assertLessThan($result, 0); + + $result=$localobject->set_as_client(); + print __METHOD__." id=".$localobject->id." result=".$result."\n"; + $this->assertLessThan($result, 0); + + $result=$localobject->set_price_level(1,$user); + print __METHOD__." id=".$localobject->id." result=".$result."\n"; + $this->assertLessThan($result, 0); + + $result=$localobject->set_remise_client(10,'Gift',$user); + print __METHOD__." id=".$localobject->id." result=".$result."\n"; + $this->assertLessThan($result, 0); + + $result=$localobject->getNomUrl(1); + print __METHOD__." id=".$localobject->id." result=".$result."\n"; + $this->assertNotEquals($result, ''); + + $result=$localobject->getFullAddress(); + print __METHOD__." id=".$localobject->id." result=".$result."\n"; + $this->assertContains('MyTown', $result); + + $result=$localobject->isInEEC(); + print __METHOD__." id=".$localobject->id." pays_code=".$this->pays_code." result=".$result."\n"; + $this->assertTrue(true, $result); + + $localobject->info($localobject->id); + print __METHOD__." localobject->date_creation=".$localobject->date_creation."\n"; + $this->assertNotEquals($localobject->date_creation, ''); + + return $localobject->id; + } + + /** + * @depends testSocieteOther + * The depends says test is run only if previous is ok + */ + public function testSocieteDelete($id) + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + $localobject=new Societe($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 testVerifyNumRef() + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + $localobject=new Adherent($this->savdb); + $result=$localobject->ref='refthatdoesnotexists'; + $result=$localobject->VerifyNumRef(); + + print __METHOD__." result=".$result."\n"; + $this->assertEquals($result, 0); + return $result; + }*/ + + + /** + */ + public function testSocieteStatic() + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + $localobject=new Societe($db); + + + return; + } +} +?> \ No newline at end of file diff --git a/test/phpunit/UserGroupTest.php b/test/phpunit/UserGroupTest.php index 68ef0014862..a45798b8198 100644 --- a/test/phpunit/UserGroupTest.php +++ b/test/phpunit/UserGroupTest.php @@ -206,11 +206,35 @@ class UserGroupTest extends PHPUnit_Framework_TestCase print __METHOD__." id=".$localobject->id." result=".$result."\n"; $this->assertLessThan($result, 0); - return $localobject->id; + return $localobject; } - /** - * @depends testUserGroupDelRight + /** + * @depends testUserGroupDelRight + * The depends says test is run only if previous is ok + */ + public function testUserGroupOther($localobject) + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + /*$result=$localobject->setstatus(0); + print __METHOD__." id=".$localobject->id." result=".$result."\n"; + $this->assertLessThan($result, 0); + */ + + /*$localobject->info($localobject->id); + print __METHOD__." localobject->date_creation=".$localobject->date_creation."\n"; + $this->assertNotEquals($localobject->date_creation, ''); + */ + return $localobject->id; + } + + /** + * @depends testUserOther * The depends says test is run only if previous is ok */ public function testUserGroupDelete($id) diff --git a/test/phpunit/UserTest.php b/test/phpunit/UserTest.php index 61340970065..147636bdade 100644 --- a/test/phpunit/UserTest.php +++ b/test/phpunit/UserTest.php @@ -187,11 +187,35 @@ class UserTest extends PHPUnit_Framework_TestCase print __METHOD__." id=".$localobject->id." result=".$result."\n"; $this->assertLessThan($result, 0); - return $localobject->id; + return $localobject; } - /** - * @depends testUserDisable + /** + * @depends testUserDisable + * The depends says test is run only if previous is ok + */ + public function testUserOther($localobject) + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + /*$result=$localobject->setstatus(0); + print __METHOD__." id=".$localobject->id." result=".$result."\n"; + $this->assertLessThan($result, 0); + */ + + $localobject->info($localobject->id); + print __METHOD__." localobject->date_creation=".$localobject->date_creation."\n"; + $this->assertNotEquals($localobject->date_creation, ''); + + return $localobject->id; + } + + /** + * @depends testUserOther * The depends says test is run only if previous is ok */ public function testUserDelete($id) diff --git a/test/phpunit/phpunittest.xml b/test/phpunit/phpunittest.xml index e0dde6ebece..73ce7a07d78 100644 --- a/test/phpunit/phpunittest.xml +++ b/test/phpunit/phpunittest.xml @@ -2,38 +2,39 @@ <filter> <blacklist> <directory>../CVS/</directory> - <directory>../test/</directory> - <directory>../htdocs/includes/adodbtime/</directory> - <directory>../htdocs/includes/artichow/</directory> - <directory>../htdocs/includes/barcode/php-barcode/</directory> - <directory>../htdocs/includes/efc_xfss/</directory> - <directory>../htdocs/includes/fckeditor/</directory> - <directory>../htdocs/includes/fpdf/</directory> - <directory>../htdocs/includes/geoip/</directory> - <directory>../htdocs/includes/iui/</directory> - <directory>../htdocs/includes/iwebkit/</directory> - <directory>../htdocs/includes/jcrop/</directory> - <directory>../htdocs/includes/jquery/</directory> - <directory>../htdocs/includes/jsgantt/</directory> - <directory>../htdocs/includes/magpierss/</directory> - <directory>../htdocs/includes/nusoap/</directory> - <directory>../htdocs/includes/odtphp/</directory> - <directory>../htdocs/includes/php_excelreader/</directory> - <directory>../htdocs/includes/php_writeexcel/</directory> - <directory>../htdocs/includes/smarty/</directory> - <directory>../htdocs/includes/smtps/</directory> - <directory>../htdocs/includes/tcpdf/</directory> - <directory>../htdocs/includes/vcard/</directory> - <file>../htdocs/lib/databases/mssql.lib.php</file> - <file>../htdocs/lib/databases/pgsql.lib.php</file> - <file>../htdocs/lib/databases/mysql.lib.php</file> - <!-- <file>../htdocs/lib/databases/mysqli.lib.php</file> --> + <directory>../../test/</directory> + <directory>../../htdocs/includes/adodbtime/</directory> + <directory>../../htdocs/includes/artichow/</directory> + <directory>../../htdocs/includes/barcode/php-barcode/</directory> + <directory>../../htdocs/includes/efc_xfss/</directory> + <directory>../../htdocs/includes/fckeditor/</directory> + <directory>../../htdocs/includes/fpdf/</directory> + <directory>../../htdocs/includes/geoip/</directory> + <directory>../../htdocs/includes/iui/</directory> + <directory>../../htdocs/includes/iwebkit/</directory> + <directory>../../htdocs/includes/jcrop/</directory> + <directory>../../htdocs/includes/jquery/</directory> + <directory>../../htdocs/includes/jsgantt/</directory> + <directory>../../htdocs/includes/magpierss/</directory> + <directory>../../htdocs/includes/nusoap/</directory> + <directory>../../htdocs/includes/odtphp/</directory> + <directory>../../htdocs/includes/php_excelreader/</directory> + <directory>../../htdocs/includes/php_writeexcel/</directory> + <directory>../../htdocs/includes/smarty/</directory> + <directory>../../htdocs/includes/smtps/</directory> + <directory>../../htdocs/includes/tcpdf/</directory> + <directory>../../htdocs/includes/vcard/</directory> + <directory>../../htdocs/includes/menus/smartphone/</directory> + <file>../../htdocs/lib/databases/mssql.lib.php</file> + <file>../../htdocs/lib/databases/pgsql.lib.php</file> + <file>../../htdocs/lib/databases/mysql.lib.php</file> + <!-- <file>../../htdocs/lib/databases/mysqli.lib.php</file> --> </blacklist> <whitelist> - <directory suffix=".class.php">../htdocs/</directory> - <directory suffix=".lib.php">../htdocs/</directory> - <directory suffix=".modules.php">../htdocs/</directory> - <file>../htdocs/includes/modules/facture/modules_facture.php</file> + <directory suffix=".class.php">../../htdocs/</directory> + <directory suffix=".lib.php">../../htdocs/</directory> + <directory suffix=".modules.php">../../htdocs/</directory> + <file>../../htdocs/includes/modules/facture/modules_facture.php</file> </whitelist> </filter> </phpunit> \ No newline at end of file -- GitLab