Fix: PHPUnit tests
This commit is contained in:
parent
3cb6e196b6
commit
67758c963b
@ -29,6 +29,7 @@ global $conf,$user,$langs,$db;
|
|||||||
require_once 'PHPUnit/Autoload.php';
|
require_once 'PHPUnit/Autoload.php';
|
||||||
require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
|
require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
|
||||||
require_once dirname(__FILE__).'/../../htdocs/adherents/class/adherent.class.php';
|
require_once dirname(__FILE__).'/../../htdocs/adherents/class/adherent.class.php';
|
||||||
|
require_once dirname(__FILE__).'/../../htdocs/adherents/class/adherent_type.class.php';
|
||||||
|
|
||||||
if (empty($user->id))
|
if (empty($user->id))
|
||||||
{
|
{
|
||||||
@ -115,11 +116,39 @@ class AdherentTest extends PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testAdherentCreate
|
* testAdherentTypeCreate
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testAdherentCreate()
|
public function testAdherentTypeCreate()
|
||||||
|
{
|
||||||
|
global $conf,$user,$langs,$db;
|
||||||
|
$conf=$this->savconf;
|
||||||
|
$user=$this->savuser;
|
||||||
|
$langs=$this->savlangs;
|
||||||
|
$db=$this->savdb;
|
||||||
|
|
||||||
|
$localobject=new AdherentType($this->savdb);
|
||||||
|
$localobject->statut=1;
|
||||||
|
$localobject->libelle='Adherent type test';
|
||||||
|
$localobject->cotisation=1;
|
||||||
|
$localobject->vote=1;
|
||||||
|
$result=$localobject->create($user);
|
||||||
|
print __METHOD__." result=".$result."\n";
|
||||||
|
$this->assertLessThan($result, 0);
|
||||||
|
|
||||||
|
return $localobject->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* testAdherentCreate
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @depends testAdherentTypeCreate
|
||||||
|
* The depends says test is run only if previous is ok
|
||||||
|
*/
|
||||||
|
public function testAdherentCreate($fk_adherent_type)
|
||||||
{
|
{
|
||||||
global $conf,$user,$langs,$db;
|
global $conf,$user,$langs,$db;
|
||||||
$conf=$this->savconf;
|
$conf=$this->savconf;
|
||||||
@ -129,6 +158,7 @@ class AdherentTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$localobject=new Adherent($this->savdb);
|
$localobject=new Adherent($this->savdb);
|
||||||
$localobject->initAsSpecimen();
|
$localobject->initAsSpecimen();
|
||||||
|
$localobject->typeid=$fk_adherent_type;
|
||||||
$result=$localobject->create($user);
|
$result=$localobject->create($user);
|
||||||
print __METHOD__." result=".$result."\n";
|
print __METHOD__." result=".$result."\n";
|
||||||
$this->assertLessThan($result, 0);
|
$this->assertLessThan($result, 0);
|
||||||
|
|||||||
@ -131,12 +131,12 @@ class CommandeFournisseurTest extends PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
// Set supplier and product to use
|
// Set supplier and product to use
|
||||||
$socid=1;
|
$socid=1;
|
||||||
$prodid=1;
|
|
||||||
$societe=new Societe($db);
|
$societe=new Societe($db);
|
||||||
$societe->fetch($socid);
|
$societe->fetch($socid);
|
||||||
$product=new ProductFournisseur($db);
|
$product=new ProductFournisseur($db);
|
||||||
$product->fetch($prodid);
|
$product->fetch(0,'PIDRESS');
|
||||||
|
if ($product->id <= 0) { print "\n".__METHOD__." A product with ref PIDRESS must exists into database"; die(); }
|
||||||
|
|
||||||
$quantity=10;
|
$quantity=10;
|
||||||
$ref_fourn='SUPPLIER_REF_PHPUNIT';
|
$ref_fourn='SUPPLIER_REF_PHPUNIT';
|
||||||
$tva_tx=19.6;
|
$tva_tx=19.6;
|
||||||
|
|||||||
@ -613,7 +613,7 @@ class FunctionsTest extends PHPUnit_Framework_TestCase
|
|||||||
$vat1=get_default_localtax($companyes,$companyes,1,0);
|
$vat1=get_default_localtax($companyes,$companyes,1,0);
|
||||||
$vat2=get_default_localtax($companyes,$companyes,2,0);
|
$vat2=get_default_localtax($companyes,$companyes,2,0);
|
||||||
$this->assertEquals(5.2,$vat1);
|
$this->assertEquals(5.2,$vat1);
|
||||||
$this->assertEquals(-15,$vat2);
|
$this->assertEquals(-21,$vat2);
|
||||||
|
|
||||||
// Test RULE ES-IT
|
// Test RULE ES-IT
|
||||||
$vat1=get_default_localtax($companyes,$companyit,1,0);
|
$vat1=get_default_localtax($companyes,$companyit,1,0);
|
||||||
|
|||||||
@ -129,11 +129,16 @@ class PdfDocTest extends PHPUnit_Framework_TestCase
|
|||||||
$langs=$this->savlangs;
|
$langs=$this->savlangs;
|
||||||
$db=$this->savdb;
|
$db=$this->savdb;
|
||||||
|
|
||||||
|
$localproduct=new Product($this->savdb);
|
||||||
|
$localproduct->fetch(0,'PIDRESS');
|
||||||
|
$product_id=$localproduct->id;
|
||||||
|
if ($product_id <= 0) { print "\n".__METHOD__." A product with ref PIDRESS must exists into database"; die(); }
|
||||||
|
|
||||||
$localobject=new Facture($this->savdb);
|
$localobject=new Facture($this->savdb);
|
||||||
$localobject->initAsSpecimen();
|
$localobject->initAsSpecimen();
|
||||||
$localobject->lines=array();
|
$localobject->lines=array();
|
||||||
$localobject->lines[0]=new FactureLigne($this->savdb);
|
$localobject->lines[0]=new FactureLigne($this->savdb);
|
||||||
$localobject->lines[0]->fk_product=1;
|
$localobject->lines[0]->fk_product=$product_id;
|
||||||
$localobject->lines[0]->label='Label 1';
|
$localobject->lines[0]->label='Label 1';
|
||||||
$localobject->lines[0]->desc="This is a description with a é accent\n(Country of origin: France)";
|
$localobject->lines[0]->desc="This is a description with a é accent\n(Country of origin: France)";
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user