[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.phpfile.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
phpunitoddly both tests fails (1 failure and 1 exception)Now if you run
phpunit --filter test_hello_says_hello_worldyou'll see that running only the working test works.What I have discovered is that
InteractsWithConsolewhen used withexpectsOutputis callingthis->fail()inside of itsbeforeApplicationDestroyedCallbackasthis->fails()throws it is breaking the execution flow of thetearDownmethod and preventing it from properly tearing down the test suite.Inside of the
tearDownmethod 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: