diff --git a/test/phpunit/AdherentTest.php b/test/phpunit/AdherentTest.php index f7a932250b2..d61b3fc6cf2 100644 --- a/test/phpunit/AdherentTest.php +++ b/test/phpunit/AdherentTest.php @@ -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)) { @@ -115,11 +116,39 @@ class AdherentTest extends PHPUnit_Framework_TestCase } /** - * testAdherentCreate + * testAdherentTypeCreate * * @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; $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); diff --git a/test/phpunit/CommandeFournisseurTest.php b/test/phpunit/CommandeFournisseurTest.php index 10435972924..ffc1776d559 100644 --- a/test/phpunit/CommandeFournisseurTest.php +++ b/test/phpunit/CommandeFournisseurTest.php @@ -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; diff --git a/test/phpunit/FunctionsTest.php b/test/phpunit/FunctionsTest.php index 34276ce5892..1fa41f0c460 100755 --- a/test/phpunit/FunctionsTest.php +++ b/test/phpunit/FunctionsTest.php @@ -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); diff --git a/test/phpunit/PdfDocTest.php b/test/phpunit/PdfDocTest.php index c119f1a4ec6..6823b60e314 100755 --- a/test/phpunit/PdfDocTest.php +++ b/test/phpunit/PdfDocTest.php @@ -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)";