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

[11.x] Container shares fixed values/initialized instances instead of singleton closure resolutions #51804

Merged
merged 2 commits into from
Jun 14, 2024

Conversation

seriquynh
Copy link
Contributor

Inside tests, there are a few fixed values/initialized instances that can be shared instead of being resolved via callbacks. Eg:

$this->container->singleton(Registrar::class, function () {
    return $this->router;
});

// container->make() will return same instance like the code above.
$this->container->instance(Registrar::class, $this->router);

@@ -318,14 +316,8 @@ public function testModelInstanceAsParameter()

$request = m::mock(Request::class);

$nextParam = null;

$next = function ($param) use (&$nextParam) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

$nextParam and $next are useless because they do nothing and don't have any assertions. This test is to ensure if right parameters are passed to Authorize::handle() methods.

@taylorotwell taylorotwell merged commit 1a473f8 into laravel:11.x Jun 14, 2024
28 checks passed
@seriquynh seriquynh deleted the container-instance branch June 20, 2024 02:15
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.

2 participants