Merge branch '17.0' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur
2023-03-20 15:53:06 +01:00
12 changed files with 174 additions and 46 deletions

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";
}
@@ -1233,7 +1236,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');
@@ -1256,7 +1258,7 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase
}
/**
* testGetDefaultTva
* testGetDefaultLocalTax
*
* @return void
*/
@@ -1343,6 +1345,27 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase
}
/**
* testGetLocalTaxByThird
*
* @return void
*/
public function testGetLocalTaxByThird()
{
global $mysoc;
$mysoc->country_code = 'ES';
$result = get_localtax_by_third(1);
print __METHOD__." result=".$result."\n";
$this->assertEquals('5.2', $result);
$result = get_localtax_by_third(2);
print __METHOD__." result=".$result."\n";
$this->assertEquals('-19:-15:-9', $result);
}
/**
* testDolExplodeIntoArray
*