Skip to content
Snippets Groups Projects
Commit 67758c96 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Fix: PHPUnit tests

parent 3cb6e196
No related branches found
No related tags found
No related merge requests found
......@@ -29,6 +29,7 @@ global $conf,$user,$langs,$db;
require_once 'PHPUnit/Autoload.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_type.class.php';
if (empty($user->id))
{
......@@ -114,12 +115,40 @@ class AdherentTest extends PHPUnit_Framework_TestCase
print __METHOD__."\n";
}
/**
* testAdherentTypeCreate
*
* @return void
*/
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()
public function testAdherentCreate($fk_adherent_type)
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
......@@ -129,6 +158,7 @@ class AdherentTest extends PHPUnit_Framework_TestCase
$localobject=new Adherent($this->savdb);
$localobject->initAsSpecimen();
$localobject->typeid=$fk_adherent_type;
$result=$localobject->create($user);
print __METHOD__." result=".$result."\n";
$this->assertLessThan($result, 0);
......
......@@ -131,12 +131,12 @@ class CommandeFournisseurTest extends PHPUnit_Framework_TestCase
// Set supplier and product to use
$socid=1;
$prodid=1;
$societe=new Societe($db);
$societe->fetch($socid);
$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;
$ref_fourn='SUPPLIER_REF_PHPUNIT';
$tva_tx=19.6;
......
......@@ -613,7 +613,7 @@ class FunctionsTest extends PHPUnit_Framework_TestCase
$vat1=get_default_localtax($companyes,$companyes,1,0);
$vat2=get_default_localtax($companyes,$companyes,2,0);
$this->assertEquals(5.2,$vat1);
$this->assertEquals(-15,$vat2);
$this->assertEquals(-21,$vat2);
// Test RULE ES-IT
$vat1=get_default_localtax($companyes,$companyit,1,0);
......
......@@ -129,11 +129,16 @@ class PdfDocTest extends PHPUnit_Framework_TestCase
$langs=$this->savlangs;
$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->initAsSpecimen();
$localobject->lines=array();
$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]->desc="This is a description with a é accent\n(Country of origin: France)";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment