Skip to content
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

DatabaseTransactions trait does not function correctly when Mockery is used. #360

Closed
36degrees opened this Issue Feb 11, 2016 · 3 comments

Comments

Projects
None yet
3 participants
@36degrees
Copy link

36degrees commented Feb 11, 2016

The DatabaseTransactions trait does not roll back correctly if Mockery::close throws an exception, as the loop over beforeApplicationDestroyedCallbacks is never executed (the exception takes us out of that context).

This results in queries in tests run after taking a very long time, before finally failing with

Illuminate\Database\QueryException: SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction (SQL: [...]))

Moving Mockery::close to the last call in the tearDown function (i.e. after the callbacks) appears to fix this, but I'm not sure if this could have any other negative impact.

To recreate this, assert something 'invalid' with Mockery and add debug statements to the tearDown method in src/Testing/TestCase.php – they will never get run for the test with the failed Mockery assertion in.

I imagine this will also be happening with the DatabaseMigrations trait, but haven't tested this.

@36degrees 36degrees changed the title DatabaseMigrations trait does not function correctly when Mockery is used. DatabaseTransactions trait does not function correctly when Mockery is used. Feb 11, 2016

@GrahamCampbell

This comment has been minimized.

Copy link
Member

GrahamCampbell commented Jun 18, 2018

Closing due to inactivity.

@mikefrancis

This comment has been minimized.

Copy link

mikefrancis commented Jul 10, 2018

@36degrees Hey there, did you get anywhere with this? Having the same problem in Laravel 5.4

Only way to get our test suite not to error is to remove the trait, but this randomly breaks a bunch of tests 😢

@36degrees

This comment has been minimized.

Copy link
Author

36degrees commented Jul 10, 2018

Afraid I've changed job and haven't worked with Laravel in a couple of years, and no longer have access to the source code, so I can't tell you what we did! Sorry!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.