-
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
[5.9] Fix expects output bug #29252
[5.9] Fix expects output bug #29252
Conversation
Here's a link to the orchestral/testbench-core pr: orchestral/testbench-core#25 |
@GrahamCampbell I've replicated your commit in orchestral/testbench-core#25 😉 |
Check #29267 ... it works for me, do you see any reason why my PR wouldn't work? |
@themsaid This can’t work it really is missing the When using If the callback is not executed the transaction is never rolled back thus locking the db. Whatever happens we need to let every beforeApplicationDestroy perform its tear down. I can remove the |
@paulhenri-l database transaction callback run before any other callbacks, can you show me a test where this lock happens for you? |
@paulhenri-l I'm closing this since the other approach won't require changes in orchestral/testbench, the less changes the better. However, I'd like to fix the issue so can you please help me replicate the databases test? |
@themsaid Yes sure thing, the bug only happened at work though. I'll do my best to replicate it I'll keep you updated in the other pr. |
As discussed in #29248
Here's the PR targeting Laravel 5.9 instead of 5.8
This PR is fixing #29246
I'm also going to open a pr on orchestral/testbench in order to make the tests pass.
Steps to reproduce
The simplest way to reproduce it is to add this test into a brand new laravel application
Paste this inside of the
tests/Feature/ExposeBugCommand.php
file.Explanations
By simply looking at this test you can see that the first test method should fail and the second one pass.
But if you run
phpunit
oddly both tests fails (1 failure and 1 exception)Now if you run
phpunit --filter test_hello_says_hello_world
you'll see that running only the working test works.What I have discovered is that
InteractsWithConsole
when used withexpectsOutput
is callingthis->fail()
inside of itsbeforeApplicationDestroyedCallback
asthis->fails()
throws it is breaking the execution flow of thetearDown
method and preventing it from properly tearing down the test suite.Inside of the
tearDown
method there is a call toMockery::close()
but because of thethis->fail()
exception this line is never reached.On subsequent tests
Mockery::close()
gets called and throws an error related to the previous test.Notifications
If there are other test traits using
this->fail()
in their callbacks then they are also preventing the test suite from properly tearing down and should be fixed. I can do that.PRs
We've been discussing the fix with @GrahamCampbell and @crynobone inside of these pr: