Fix more robust phpunit test

This commit is contained in:
Laurent Destailleur
2023-03-20 12:05:44 +01:00
parent 9ddb7b6198
commit 1151a8e65e

View File

@@ -80,6 +80,7 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase
protected $savuser; protected $savuser;
protected $savlangs; protected $savlangs;
protected $savdb; protected $savdb;
protected $savmysoc;
/** /**
* Constructor * Constructor
@@ -92,11 +93,12 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase
parent::__construct(); parent::__construct();
//$this->sharedFixture //$this->sharedFixture
global $conf,$user,$langs,$db; global $conf,$user,$langs,$db,$mysoc;
$this->savconf=$conf; $this->savconf=$conf;
$this->savuser=$user; $this->savuser=$user;
$this->savlangs=$langs; $this->savlangs=$langs;
$this->savdb=$db; $this->savdb=$db;
$this->savmysoc=$mysoc;
print __METHOD__." db->type=".$db->type." user->id=".$user->id; print __METHOD__." db->type=".$db->type." user->id=".$user->id;
//print " - db ".$db->db; //print " - db ".$db->db;
@@ -142,17 +144,18 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase
} }
/** /**
* Init phpunit tests * Init phpunit tests. Restore variables before each test.
* *
* @return void * @return void
*/ */
protected function setUp(): void protected function setUp(): void
{ {
global $conf,$user,$langs,$db; global $conf,$user,$langs,$db,$mysoc;
$conf=$this->savconf; $conf=$this->savconf;
$user=$this->savuser; $user=$this->savuser;
$langs=$this->savlangs; $langs=$this->savlangs;
$db=$this->savdb; $db=$this->savdb;
$mysoc=$this->savmysoc;
print __METHOD__."\n"; print __METHOD__."\n";
} }
@@ -1225,7 +1228,6 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase
// We do same tests but with option SERVICE_ARE_ECOMMERCE_200238EC on. // We do same tests but with option SERVICE_ARE_ECOMMERCE_200238EC on.
$conf->global->SERVICE_ARE_ECOMMERCE_200238EC = 1; $conf->global->SERVICE_ARE_ECOMMERCE_200238EC = 1;
// Test RULE 1 (FR-US) // Test RULE 1 (FR-US)
$vat=get_default_tva($companyfr, $companyus, 0); $vat=get_default_tva($companyfr, $companyus, 0);
$this->assertEquals(0, $vat, 'RULE 1 ECOMMERCE_200238EC'); $this->assertEquals(0, $vat, 'RULE 1 ECOMMERCE_200238EC');