mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-06 01:28: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:
@@ -139,7 +139,7 @@ class CommonObjectTest extends PHPUnit\Framework\TestCase
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobject=new Commande($this->savdb);
|
||||
$localobject=new Commande($db);
|
||||
$localobject->fetch(1);
|
||||
|
||||
$result=$localobject->fetch_user(1);
|
||||
@@ -162,7 +162,7 @@ class CommonObjectTest extends PHPUnit\Framework\TestCase
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobject=new Commande($this->savdb);
|
||||
$localobject=new Commande($db);
|
||||
$localobject->fetch(1);
|
||||
$result=$localobject->fetch_projet();
|
||||
|
||||
@@ -184,7 +184,7 @@ class CommonObjectTest extends PHPUnit\Framework\TestCase
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$localobject=new Commande($this->savdb);
|
||||
$localobject=new Commande($db);
|
||||
$localobject->fetch(1);
|
||||
|
||||
$result=$localobject->fetch_thirdparty();
|
||||
|
||||
Reference in New Issue
Block a user