-
Notifications
You must be signed in to change notification settings - Fork 11k
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
Using DatabaseMigrations trait prevents overriding console command dependencies #15455
Comments
I believe this is because This is a good guess as to what is happening, but I don't have a solution by any means, just what I learned from a similar nightmare of an experience yesterday chasing a similar problem down. |
When you use the DatabaseMigrations trait in tests, a call to Inside any test if you try to swap any console command dependency using The problem is that we build |
Thanks @themsaid and @taylorotwell. Nice work! That was LIGHTNING fast! |
Thanks you! |
Description:
It seems as though you can't swap out the IoC bindings for console commands when you're using the
DatabaseMigrations
trait in your tests.For example, I've set up an default binding for and interface in
AppServiceProvider
. I also, have a console command which typehints the interface. During my test, I'm trying to swap out that dependency for a dummy one, but using$this->artisan('command')
still uses the default binding. This is because I'm usingDatabaseMigrations
. Removing it allows me to swap out the binding like expected.Steps To Reproduce:
Here's a example that demonstrates this behavior. You can also run the tests for this example repository: https://github.com/davidhemphill/console-bindings
In
AppServiceProvider
I've set up a binding like this.And this is a test for a console command that uses GatewayInterface as a dependency.
The text was updated successfully, but these errors were encountered: