-
Notifications
You must be signed in to change notification settings - Fork 11.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[11.x] Re-refresh the database if the RefreshDatabase
transaction was committed
#53997
[11.x] Re-refresh the database if the RefreshDatabase
transaction was committed
#53997
Conversation
0c024bf
to
f19b479
Compare
RefreshDatabase
's transaction was committed
RefreshDatabase
's transaction was committedRefreshDatabase
transaction was committed
Is it possible to add a test for this in some way? |
I think there might be an issue introduced here. Post upgrade I am seeing the following error:
|
Which database are you using for your tests? |
@SjorsO MySQL Docker Image 8.0.32-1.2.11-server |
Could you manually edit the
If it does, I'll open up a PR to get this breaking change fixed (although I have no clue why |
That does indeed fix the issue. |
I can't share a ton of code, but our base "Feature" test case uses the
|
I've opened a PR to fix the breaking change: #54075 You mentioned that you're using |
@SjorsO All of our feature tests use a base class that includes |
@chrisnetonline I had the same issue, our system uses https://github.com/archtechx/tenancy. It might be because |
Woops I actually meant @SjorsO ! ;) |
We are using sqlite in our test cases and have the same |
The
RefreshDatabase
trait:migrate:fresh
before the first testThe issue is that it is possible to accidentally commit the transaction started by
RefreshDatabase
. For example, truncating a table automatically commits any active transactions. If a test commits the transaction, all database records created by that test won't be rolled back, causing each subsequent test to have a dirty database.This is especially frustrating to debug because the test that commits the transaction passes, but tests after that fail unpredictably depending on the type of assertions they do. The logical place to start debugging the issue is with the failing tests, but those have nothing to do with the problem.
This PR solves this issue by refreshing the database if you (accidentally) commit the database transaction started by the
RefreshDatabase
trait.To reproduce this issue, use MySQL, then run the following tests: