mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-08 00:52:01 +01:00
phpunit: use $db instead of $this->savdb
The global variables are stored in $this, and in particular $db is used through this mean. But $this->savdb is supposed to be the immutable global state that is stored at the test class instantiation and restored at the beginning of each test. For $this->savdb, I don't think any consequences are created by this, since the object is saved by each test anyway and the $db object is mostly a query object within a transaction, but future change could use this to inject a different stateful $db object to trace some behaviour in the test for instance, so make sure the correct one is used.
This commit is contained in:
@@ -324,14 +324,14 @@ class PricesTest extends PHPUnit\Framework\TestCase
|
||||
$conf->global->MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND=0;
|
||||
|
||||
// Two lines of 1.24 give 2.48 HT and 2.72 TTC with standard vat rounding mode
|
||||
$localobject=new Facture($this->savdb);
|
||||
$localobject=new Facture($db);
|
||||
$localobject->initAsSpecimen('nolines');
|
||||
$invoiceid=$localobject->create($user);
|
||||
|
||||
$localobject->addline('Desc', 1.24, 1, 10, 0, 0, 0, 0, '', '', 0, 0, 0, 'HT');
|
||||
$localobject->addline('Desc', 1.24, 1, 10, 0, 0, 0, 0, '', '', 0, 0, 0, 'HT');
|
||||
|
||||
$newlocalobject=new Facture($this->savdb);
|
||||
$newlocalobject=new Facture($db);
|
||||
$newlocalobject->fetch($invoiceid);
|
||||
|
||||
$this->assertEquals(2.48, $newlocalobject->total_ht, "testUpdatePrice test1");
|
||||
@@ -340,14 +340,14 @@ class PricesTest extends PHPUnit\Framework\TestCase
|
||||
|
||||
|
||||
// Two lines of 1.24 give 2.48 HT and 2.73 TTC with global vat rounding mode
|
||||
$localobject=new Facture($this->savdb);
|
||||
$localobject=new Facture($db);
|
||||
$localobject->initAsSpecimen('nolines');
|
||||
$invoiceid=$localobject->create($user);
|
||||
|
||||
$localobject->addline('Desc', 1.24, 1, 10, 0, 0, 0, 0, '', '', 0, 0, 0, 'HT');
|
||||
$localobject->addline('Desc', 1.24, 1, 10, 0, 0, 0, 0, '', '', 0, 0, 0, 'HT');
|
||||
|
||||
$newlocalobject=new Facture($this->savdb);
|
||||
$newlocalobject=new Facture($db);
|
||||
$newlocalobject->fetch($invoiceid);
|
||||
|
||||
$this->assertEquals(2.48, $newlocalobject->total_ht, "testUpdatePrice test4");
|
||||
|
||||
Reference in New Issue
Block a user