mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-21 17:01:19 +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:
@@ -140,7 +140,7 @@ class PdfDocTest extends PHPUnit\Framework\TestCase
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localproduct=new Product($this->savdb);
|
||||
$localproduct=new Product($db);
|
||||
$result = $localproduct->fetch(0, 'PINKDRESS');
|
||||
if ($result < 0) {
|
||||
print "\n".__METHOD__." Failed to make the fetch of product PINKDRESS. ".$localproduct->error; die(1);
|
||||
@@ -150,10 +150,10 @@ class PdfDocTest extends PHPUnit\Framework\TestCase
|
||||
print "\n".__METHOD__." A product with ref PINKDRESS must exists into database. Create it manually before running the test"; die(1);
|
||||
}
|
||||
|
||||
$localobject=new Facture($this->savdb);
|
||||
$localobject=new Facture($db);
|
||||
$localobject->initAsSpecimen();
|
||||
$localobject->lines=array();
|
||||
$localobject->lines[0]=new FactureLigne($this->savdb);
|
||||
$localobject->lines[0]=new FactureLigne($db);
|
||||
$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)";
|
||||
|
||||
Reference in New Issue
Block a user