2
0
forked from Wavyzz/dolibarr

Add more phpunit tests

This commit is contained in:
Laurent Destailleur
2010-10-13 19:01:22 +00:00
parent 2dadffa9b4
commit 6f26f35529
15 changed files with 744 additions and 71 deletions

View File

@@ -124,10 +124,11 @@ class AdherentTest extends PHPUnit_Framework_TestCase
$localobject=new Adherent($this->savdb); $localobject=new Adherent($this->savdb);
$localobject->initAsSpecimen(); $localobject->initAsSpecimen();
$result=$localobject->create($user);
$this->assertLessThan($result, 0); $result=$localobject->create($user);
print __METHOD__." result=".$result."\n"; print __METHOD__." result=".$result."\n";
$this->assertLessThan($result, 0);
return $result; return $result;
} }
@@ -145,9 +146,9 @@ class AdherentTest extends PHPUnit_Framework_TestCase
$localobject=new Adherent($this->savdb); $localobject=new Adherent($this->savdb);
$result=$localobject->fetch($id); $result=$localobject->fetch($id);
$this->assertLessThan($result, 0);
print __METHOD__." id=".$id." result=".$result."\n"; print __METHOD__." id=".$id." result=".$result."\n";
$this->assertLessThan($result, 0);
return $localobject; return $localobject;
} }
@@ -165,9 +166,9 @@ class AdherentTest extends PHPUnit_Framework_TestCase
$localobject->note='New note after update'; $localobject->note='New note after update';
$result=$localobject->update($user); $result=$localobject->update($user);
print __METHOD__." id=".$localobject->id." result=".$result."\n"; print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0); $this->assertLessThan($result, 0);
return $localobject; return $localobject;
} }
@@ -185,15 +186,39 @@ class AdherentTest extends PHPUnit_Framework_TestCase
$result=$localobject->validate($user); $result=$localobject->validate($user);
print __METHOD__." id=".$localobject->id." result=".$result."\n"; print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0); $this->assertLessThan($result, 0);
return $localobject->id;
return $localobject;
} }
/** /**
* @depends testAdherentValid * @depends testAdherentValid
* The depends says test is run only if previous is ok * 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) public function testAdherentDelete($id)
{ {
global $conf,$user,$langs,$db; global $conf,$user,$langs,$db;
@@ -205,9 +230,9 @@ class AdherentTest extends PHPUnit_Framework_TestCase
$localobject=new Adherent($this->savdb); $localobject=new Adherent($this->savdb);
$result=$localobject->fetch($id); $result=$localobject->fetch($id);
$result=$localobject->delete($id); $result=$localobject->delete($id);
print __METHOD__." id=".$id." result=".$result."\n"; print __METHOD__." id=".$id." result=".$result."\n";
$this->assertLessThan($result, 0); $this->assertLessThan($result, 0);
return $result; return $result;
} }
@@ -225,9 +250,9 @@ class AdherentTest extends PHPUnit_Framework_TestCase
$localobject=new Adherent($this->savdb); $localobject=new Adherent($this->savdb);
$result=$localobject->ref='refthatdoesnotexists'; $result=$localobject->ref='refthatdoesnotexists';
$result=$localobject->VerifyNumRef(); $result=$localobject->VerifyNumRef();
print __METHOD__." result=".$result."\n"; print __METHOD__." result=".$result."\n";
$this->assertEquals($result, 0); $this->assertEquals($result, 0);
return $result; return $result;
}*/ }*/
} }

View File

@@ -204,13 +204,38 @@ class CommandeFournisseurTest extends PHPUnit_Framework_TestCase
print __METHOD__." id=".$localobject->id." result=".$result."\n"; print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0); $this->assertLessThan($result, 0);
return $localobject->id; return $localobject;
} }
/** /**
* @depends testCommandeFournisseurCancel * @depends testCommandeFournisseurCancel
* The depends says test is run only if previous is ok * 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) public function testCommandeFournisseurDelete($id)
{ {
global $conf,$user,$langs,$db; global $conf,$user,$langs,$db;

View File

@@ -203,13 +203,37 @@ class CommandeTest extends PHPUnit_Framework_TestCase
print __METHOD__." id=".$localobject->id." result=".$result."\n"; print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0); $this->assertLessThan($result, 0);
return $localobject->id; return $localobject;
} }
/** /**
* @depends testCommandeCancel * @depends testCommandeCancel
* The depends says test is run only if previous is ok * 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) public function testCommandeDelete($id)
{ {
global $conf,$user,$langs,$db; global $conf,$user,$langs,$db;

View File

@@ -42,8 +42,7 @@ $conf->global->MAIN_DISABLE_ALL_MAILS=1;
/** /**
* @backupGlobals disabled * @backupGlobals disabled
* @backupStaticAttributes enabled * @backupStaticAttributes enabled
* @covers Commande * @covers CompanyBankAccount
* @covers OrderLine
* @remarks backupGlobals must be disabled to have db,conf,user and lang not erased. * @remarks backupGlobals must be disabled to have db,conf,user and lang not erased.
*/ */
class CompanyBankAccountTest extends PHPUnit_Framework_TestCase class CompanyBankAccountTest extends PHPUnit_Framework_TestCase
@@ -165,11 +164,31 @@ class CompanyBankAccountTest extends PHPUnit_Framework_TestCase
print __METHOD__." id=".$localobject->id." result=".$result."\n"; print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0); $this->assertLessThan($result, 0);
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; return $localobject->id;
} }
/** /**
* @depends testCompanyBankAccountUpdate * @depends testCompanyBankAccountOther
* The depends says test is run only if previous is ok * The depends says test is run only if previous is ok
*/ */
/* public function testCompanyBankAccountDelete($id) /* public function testCompanyBankAccountDelete($id)

View File

@@ -189,13 +189,37 @@ class ContratTest extends PHPUnit_Framework_TestCase
print __METHOD__." id=".$localobject->id." result=".$result."\n"; print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0); $this->assertLessThan($result, 0);
return $localobject->id; return $localobject;
} }
/** /**
* @depends testContratValid * @depends testContratValid
* The depends says test is run only if previous is ok * 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) public function testContratDelete($id)
{ {
global $conf,$user,$langs,$db; global $conf,$user,$langs,$db;

View File

@@ -188,13 +188,37 @@ class FactureFournisseurTest extends PHPUnit_Framework_TestCase
print __METHOD__." id=".$localobject->id." result=".$result."\n"; print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0); $this->assertLessThan($result, 0);
return $localobject->id; return $localobject;
} }
/** /**
* @depends testFactureFournisseurValid * @depends testFactureFournisseurValid
* The depends says test is run only if previous is ok * 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) public function testFactureFournisseurDelete($id)
{ {
global $conf,$user,$langs,$db; global $conf,$user,$langs,$db;

View File

@@ -190,13 +190,37 @@ class FactureTest extends PHPUnit_Framework_TestCase
print __METHOD__." id=".$localobject->id." result=".$result."\n"; print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0); $this->assertLessThan($result, 0);
return $localobject->id; return $localobject;
} }
/** /**
* @depends testFactureValid * @depends testFactureValid
* The depends says test is run only if previous is ok * 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) public function testFactureDelete($id)
{ {
global $conf,$user,$langs,$db; global $conf,$user,$langs,$db;

147
test/phpunit/ModulesTest.php Executable file
View 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;
}
}
?>

View File

@@ -58,8 +58,11 @@ class MyTestSuite
require_once dirname(__FILE__).'/CommonObjectTest.php'; require_once dirname(__FILE__).'/CommonObjectTest.php';
$suite->addTestSuite('CommonObjectTest'); $suite->addTestSuite('CommonObjectTest');
require_once dirname(__FILE__).'/SocieteTest.php';
$suite->addTestSuite('SocieteTest');
require_once dirname(__FILE__).'/AdherentTest.php'; require_once dirname(__FILE__).'/AdherentTest.php';
$suite->addTestSuite('AdherentTest'); $suite->addTestSuite('AdherentTest');
require_once dirname(__FILE__).'/CommandeTest.php'; require_once dirname(__FILE__).'/CommandeTest.php';
$suite->addTestSuite('CommandeTest'); $suite->addTestSuite('CommandeTest');
require_once dirname(__FILE__).'/CommandeFournisseurTest.php'; require_once dirname(__FILE__).'/CommandeFournisseurTest.php';
@@ -81,6 +84,9 @@ class MyTestSuite
require_once dirname(__FILE__).'/ChargeSocialesTest.php'; require_once dirname(__FILE__).'/ChargeSocialesTest.php';
$suite->addTestSuite('ChargeSocialesTest'); $suite->addTestSuite('ChargeSocialesTest');
require_once dirname(__FILE__).'/ModulesTest.php';
$suite->addTestSuite('ModulesTest');
return $suite; return $suite;
} }
} }

View File

@@ -184,13 +184,37 @@ class PropalTest extends PHPUnit_Framework_TestCase
print __METHOD__." id=".$localobject->id." result=".$result."\n"; print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0); $this->assertLessThan($result, 0);
return $localobject->id; return $localobject;
} }
/** /**
* @depends testPropalValid * @depends testPropalValid
* The depends says test is run only if previous is ok * 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 testPropalOther
* The depends says test is run only if previous is ok
*/
public function testPropalDelete($id) public function testPropalDelete($id)
{ {
global $conf,$user,$langs,$db; global $conf,$user,$langs,$db;

View File

@@ -28,7 +28,7 @@ Run > phpunit --coverage-html ./report MyTestSuite.php
Note that xdebug must be installed for this feature to work. Note that xdebug must be installed for this feature to work.
* Generate a report of Unit tests code coverage among all Dolibarr classes: * 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 Check that you use the "mysqli" driver in your conf.php file (otherwise
edit the file phpunittest.xml). edit the file phpunittest.xml).
Run > phpunit --configuration ./phpunittest.xml --coverage-html ./report MyTestSuite.php Run > phpunit --configuration ./phpunittest.xml --coverage-html ./report MyTestSuite.php

282
test/phpunit/SocieteTest.php Executable file
View 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;
}
}
?>

View File

@@ -206,13 +206,37 @@ class UserGroupTest extends PHPUnit_Framework_TestCase
print __METHOD__." id=".$localobject->id." result=".$result."\n"; print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0); $this->assertLessThan($result, 0);
return $localobject->id; return $localobject;
} }
/** /**
* @depends testUserGroupDelRight * @depends testUserGroupDelRight
* The depends says test is run only if previous is ok * 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) public function testUserGroupDelete($id)
{ {
global $conf,$user,$langs,$db; global $conf,$user,$langs,$db;

View File

@@ -187,13 +187,37 @@ class UserTest extends PHPUnit_Framework_TestCase
print __METHOD__." id=".$localobject->id." result=".$result."\n"; print __METHOD__." id=".$localobject->id." result=".$result."\n";
$this->assertLessThan($result, 0); $this->assertLessThan($result, 0);
return $localobject->id; return $localobject;
} }
/** /**
* @depends testUserDisable * @depends testUserDisable
* The depends says test is run only if previous is ok * 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) public function testUserDelete($id)
{ {
global $conf,$user,$langs,$db; global $conf,$user,$langs,$db;

View File

@@ -2,38 +2,39 @@
<filter> <filter>
<blacklist> <blacklist>
<directory>../CVS/</directory> <directory>../CVS/</directory>
<directory>../test/</directory> <directory>../../test/</directory>
<directory>../htdocs/includes/adodbtime/</directory> <directory>../../htdocs/includes/adodbtime/</directory>
<directory>../htdocs/includes/artichow/</directory> <directory>../../htdocs/includes/artichow/</directory>
<directory>../htdocs/includes/barcode/php-barcode/</directory> <directory>../../htdocs/includes/barcode/php-barcode/</directory>
<directory>../htdocs/includes/efc_xfss/</directory> <directory>../../htdocs/includes/efc_xfss/</directory>
<directory>../htdocs/includes/fckeditor/</directory> <directory>../../htdocs/includes/fckeditor/</directory>
<directory>../htdocs/includes/fpdf/</directory> <directory>../../htdocs/includes/fpdf/</directory>
<directory>../htdocs/includes/geoip/</directory> <directory>../../htdocs/includes/geoip/</directory>
<directory>../htdocs/includes/iui/</directory> <directory>../../htdocs/includes/iui/</directory>
<directory>../htdocs/includes/iwebkit/</directory> <directory>../../htdocs/includes/iwebkit/</directory>
<directory>../htdocs/includes/jcrop/</directory> <directory>../../htdocs/includes/jcrop/</directory>
<directory>../htdocs/includes/jquery/</directory> <directory>../../htdocs/includes/jquery/</directory>
<directory>../htdocs/includes/jsgantt/</directory> <directory>../../htdocs/includes/jsgantt/</directory>
<directory>../htdocs/includes/magpierss/</directory> <directory>../../htdocs/includes/magpierss/</directory>
<directory>../htdocs/includes/nusoap/</directory> <directory>../../htdocs/includes/nusoap/</directory>
<directory>../htdocs/includes/odtphp/</directory> <directory>../../htdocs/includes/odtphp/</directory>
<directory>../htdocs/includes/php_excelreader/</directory> <directory>../../htdocs/includes/php_excelreader/</directory>
<directory>../htdocs/includes/php_writeexcel/</directory> <directory>../../htdocs/includes/php_writeexcel/</directory>
<directory>../htdocs/includes/smarty/</directory> <directory>../../htdocs/includes/smarty/</directory>
<directory>../htdocs/includes/smtps/</directory> <directory>../../htdocs/includes/smtps/</directory>
<directory>../htdocs/includes/tcpdf/</directory> <directory>../../htdocs/includes/tcpdf/</directory>
<directory>../htdocs/includes/vcard/</directory> <directory>../../htdocs/includes/vcard/</directory>
<file>../htdocs/lib/databases/mssql.lib.php</file> <directory>../../htdocs/includes/menus/smartphone/</directory>
<file>../htdocs/lib/databases/pgsql.lib.php</file> <file>../../htdocs/lib/databases/mssql.lib.php</file>
<file>../htdocs/lib/databases/mysql.lib.php</file> <file>../../htdocs/lib/databases/pgsql.lib.php</file>
<!-- <file>../htdocs/lib/databases/mysqli.lib.php</file> --> <file>../../htdocs/lib/databases/mysql.lib.php</file>
<!-- <file>../../htdocs/lib/databases/mysqli.lib.php</file> -->
</blacklist> </blacklist>
<whitelist> <whitelist>
<directory suffix=".class.php">../htdocs/</directory> <directory suffix=".class.php">../../htdocs/</directory>
<directory suffix=".lib.php">../htdocs/</directory> <directory suffix=".lib.php">../../htdocs/</directory>
<directory suffix=".modules.php">../htdocs/</directory> <directory suffix=".modules.php">../../htdocs/</directory>
<file>../htdocs/includes/modules/facture/modules_facture.php</file> <file>../../htdocs/includes/modules/facture/modules_facture.php</file>
</whitelist> </whitelist>
</filter> </filter>
</phpunit> </phpunit>