I have an issue when I run tests using DatabaseTransactions.
In my products table, I have all the products with stock_count = -99
Here is my code
TestCase.php (all the tests extend this class)
use DatabaseTransactions;
protected $connectionsToTransact = ["mysql"];
public function setUp()
{
parent::setUp();
MimProduct::query()->update(['stock_count'=>100]);
...
}
Then in one of my test, I dd the same query, one using DB Facade the other one using the actual model.
dd(DB::table("mim.products")->first(),MimProduct::all()->first());
and the output is
My conclusions so far are:
- Using the DB facade doesn’t work with the DB Transaction trait; it cannot use the “in-memory” transactions, and so it will work off the “live” DB.
- Whereas a model has access to memory.
Am I correct or there is a way to overcome this issue?
Thanks in advance.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire