-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
app helper doesn't return mocked instance when parameters are present #19450
Comments
In the original PR #18271 - Taylor says:
I'm wondering if this is a side effect of that... ...but it does seem slightly broken - because it means it is not fullable testable. |
I wonder then how I can mock a job that accepts parameters, because I currently cannot due to this issue. |
I have this problem too. The current behaviour seems like a bug to me. This issue helped me understand it. So only way now in my project is to introduce a conditional for Please reconsider this one :-) |
I had to do a dirty trick to test this too. Would love to see this changed someway. |
Are there any news? It is really exhausting writing tests with this behavior. I'm using version 5.5. |
It appears that passing
Simply deleting |
See also #25041 for recent discussions. |
In case someone else is looking for this. You can mock it like this in your tests.
And it will use the Mock. |
@mikepmtl even when you call $this->json('POST',....) ?! Example: `$request = [.....];
|
Hello, it seems that i have the same issue in 5.8.16, App::offsetSet(Class::class, $this->mock(Class::class, function ($mock) {
// do whatever you want
$mock;
})); until this issue is resolved (if it's resolved at all) |
I have kind of similar problem here, https://stackoverflow.com/q/59853235, but none of the solutions here works. Any idea? |
This worked just perfectly. Just don't forget to instantiate object via |
|
Hello, i'm having this issue again in 2023, the |
This solved my issue. |
When binding a mock instance to a class, resolving that class acts differently depending on whether parameters are passed in:
get_class(app(SomeClass::class))
yieldsMockery_0_SomeClass
which is the mockery instancewhen parameters are passed in:
get_class(app(SomeClass::class, ['param' => 'fakeparam']));
this yieldsSomeClass
instead of the mockery instance.This seems like an unfortunate inconsistency, but maybe this functionality is intentional?
The text was updated successfully, but these errors were encountered: