-
-
Notifications
You must be signed in to change notification settings - Fork 40
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
Fix expectsOutput bug #25
Conversation
I would only merge this if @taylorotwell accept the PR on |
Yeh. I think acceptance needs to be mutual, or not at all. :) |
$this->afterApplicationCreatedCallbacks = []; | ||
$this->beforeApplicationDestroyedCallbacks = []; | ||
|
||
Artisan::forgetBootstrappers(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The nested tries are from @GrahamCampbell he can correct me if I am wrong.
As far as I understand the idea is that if in the same tearDown
- a beforeApplicationDestroyed callback throws the app will still get flushed.
- an afterApplicationDestroyedCallback throws the variables will still get reset.
My initial fix had only the outter try/finally but it makes the assumption that beforeApplicationDestroyed callbacks won't throw.
While being a bit clunky the nested try/finally seems to really add value here. Or maybe there is another way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would just use rescue()
for this TBH.
if ($this->app) {
foreach ($this->beforeApplicationDestroyedCallbacks as $callback) {
\rescue($callback, null, false);
}
$this->app->flush();
$this->app = null;
foreach ($this->afterApplicationDestroyedCallbacks as $callback) {
\rescue($callback, null, false);
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I didn't know about this helper.
Well then I guess using rescue
is definitely a better option.
I'll make the changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh actually we can't use rescue
here.
calls to the this->fails()
method of phpunit throws. If we use rescue then phpunit won't be able to display these errors.
I guess we can call the beforeApplicationDestroyedCallbacks
with rescue and the afterApplicationDestroyedCallbacks
without it.
If a test trait needs to call $this->fail()
it will need to do so in an afterApplicationDestroyed
callback.
I'll check if laravel's provided test trait do so and update them accordingly if we go that route.
Maybe @GrahamCampbell as another idea?
Please resubmit PR with changes based on accepted PR to |
Yep I'll do that |
Hey there!
In order to fix this issue: laravel/framework#29246
I've made a PR on the laravel/framework repository: laravel/framework#29252
As it is changing code in the TestCase class I need to replicate the changes here as-well in order to make the tests pass.
So as requested by @GrahamCampbell I'am opening this PR.