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

[5.3] Reset artisan application after running migrations in tests #15531

Merged
merged 2 commits into from
Sep 20, 2016
Merged

[5.3] Reset artisan application after running migrations in tests #15531

merged 2 commits into from
Sep 20, 2016

Conversation

themsaid
Copy link
Member

When you use the DatabaseMigrations trait in tests, a call to $this->artisan('migrate') is made for every test, this call creates an instance of Illuminate\Console\Application and resolves all commands.

Inside any test if you try to swap any console command dependency using $this->app->bind() and then call the command via $this->artisan('command') the old concrete implementation will be called instead of the swapped dummy one.

This PR fixes that by resetting the artisan application instance so that it gets rebuilt inside the actual tests allowing the swapping of bindings.

@@ -2,6 +2,8 @@

namespace Illuminate\Foundation\Testing;

use Illuminate\Foundation\Console\Kernel;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to use Illuminate\Contracts\Console\Kernel here... I think that is what is bound to the container when the app is bootstrapped.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes correct, IDE's fault. Fixing.

@taylorotwell taylorotwell merged commit 164223c into laravel:5.3 Sep 20, 2016
@themsaid themsaid deleted the resetArtisan branch September 20, 2016 22:23
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

Successfully merging this pull request may close these issues.

None yet

2 participants