2
0
forked from Wavyzz/dolibarr

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:
Alexandre Janniaux
2023-04-13 20:25:07 +02:00
parent 2635ec9c19
commit b6235c29d0
46 changed files with 198 additions and 194 deletions

View File

@@ -138,7 +138,7 @@ class FormAdminTest extends PHPUnit\Framework\TestCase
$langs=$this->savlangs;
$db=$this->savdb;
$localobject=new FormAdmin($this->savdb);
$localobject=new FormAdmin($db);
$result=$localobject->select_paper_format('', 'paperformat_id', 'A4', 0, 1);
$this->assertEquals($result, '<select class="flat" id="paperformat_id" name="paperformat_id"><option value="EUA4">Format A4 - 210x297 mm</option></select>');