forked from Wavyzz/dolibarr
Add more phpunit tests
This commit is contained in:
@@ -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;
|
||||
}*/
|
||||
}
|
||||
|
||||
@@ -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
|
||||
* @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 testCommandeFournisseurOther
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testCommandeFournisseurDelete($id)
|
||||
|
||||
@@ -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
|
||||
* @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 testCommandeOther
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testCommandeDelete($id)
|
||||
|
||||
@@ -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 testCompanyBankAccountUpdate
|
||||
* @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 testCompanyBankAccountOther
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
/* public function testCompanyBankAccountDelete($id)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
147
test/phpunit/ModulesTest.php
Executable file
147
test/phpunit/ModulesTest.php
Executable file
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
282
test/phpunit/SocieteTest.php
Executable file
282
test/phpunit/SocieteTest.php
Executable file
@@ -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;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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>
|
||||
Reference in New Issue
Block a user