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
Closed

Comments

@36degrees
Copy link

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
Copy link
Member

Closing due to inactivity.

@mikefrancis
Copy link

@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
Copy link
Author

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants