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

Return the bound instance when using Container::instance #19442

Merged
merged 1 commit into from
Jun 1, 2017
Merged

Return the bound instance when using Container::instance #19442

merged 1 commit into from
Jun 1, 2017

Conversation

adamwathan
Copy link
Contributor

In many of my feature tests I need to replace something in the container with a test double, but keep a reference to the test double to use in my assertions.

Currently I'm declaring the variable at the same time I pass it into the container:

$this->app->instance(CreditCardGateway::class, $creditCardGateway = new FakeCreditCardGateway);
$this->app->instance(WebhookDispatcher::class, $webhookDispatcher = new FakeWebhookDispatcher);

I think this is sort of grim, so this PR lets me rewrite that like this:

$creditCardGateway = $this->app->instance(CreditCardGateway::class, new FakeCreditCardGateway);
$webhookDispatcher = $this->app->instance(WebhookDispatcher::class, new FakeWebhookDispatcher);

I think it makes it a lot easier to see where the variable is coming from at a glance 👍

@taylorotwell taylorotwell merged commit 1ca7c23 into laravel:master Jun 1, 2017
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