Integrated icon indicating copy to clipboard operation
Integrated copied to clipboard

Db transactions

Open gerardZf2Comments opened this issue 9 years ago • 1 comments

Sorry to open an issue without running any code but i think i have enough info to ask what others may be wondering.

Mysql seems to commit open transactions when a new one is open. http://stackoverflow.com/questions/1490846/mysql-transactions-within-transactions

So how does the transaction trait in this package work if the code called in the test starts a new transaction and commits it. In this case could a rollback work?

If not does that mean this trait can only be used to test code that doesn't use transactions?

gerardZf2Comments avatar Jan 04 '16 11:01 gerardZf2Comments

I don't think you should be using multiple transactions at all when running integration tests! You are testing a single feature of an application and this can mean multiple database calls. However you only want to start the transaction before the test and rollback when the test is done (if it succeeds or not).

It's a trait which you use in your code. If you already use transactions in your code, you simply don't use the trait. I don't think there is a way to get around this, since it's MySQL that's doing this. Not the package or in this case the database provider in Laravel

bobbybouwmann avatar Feb 08 '16 08:02 bobbybouwmann