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 $savlangs;
protected $savdb;
protected $savmysoc;
/**
* Constructor
@@ -92,11 +93,12 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase
parent::__construct();
//$this->sharedFixture
global $conf,$user,$langs,$db;
global $conf,$user,$langs,$db,$mysoc;
$this->savconf=$conf;
$this->savuser=$user;
$this->savlangs=$langs;
$this->savdb=$db;
$this->savmysoc=$mysoc;
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
//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
*/
protected function setUp(): void
{
global $conf,$user,$langs,$db;
global $conf,$user,$langs,$db,$mysoc;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
$mysoc=$this->savmysoc;
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.
$conf->global->SERVICE_ARE_ECOMMERCE_200238EC = 1;
// Test RULE 1 (FR-US)
$vat=get_default_tva($companyfr, $companyus, 0);
$this->assertEquals(0, $vat, 'RULE 1 ECOMMERCE_200238EC');