-
-
Notifications
You must be signed in to change notification settings - Fork 10
Add an ability to fake search response data #22
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
base: master
Are you sure you want to change the base?
Conversation
lets say you have some that fetches from two diffrent scout models? Would you be able to fake both responses. So you would get one fake response for the User and the another for the company? Search::fakeResponseData([ Search::fakeResponseData([ // code in some class |
@christian-nielsen yes, we have Search::fakeResponseData([
'foo' => 'bar'
])->within('users');
Search::fakeResponseData([
'foo' => 'baz'
])->within('posts'); // or $post->searchableAs() If you don't call I'm not sure if it would be possible to use |
What about also allowing class model name:
if you give it a class model name, it will do this underlaying: (new $className)->searchableAs() |
@christian-nielsen it might be fine for models which returns a static value, but in theory it might depend on some database fields. I think it would be nice to support all combinations: string, model instance, model class name. |
I tried the branch, If I set the hits-key, it not being set as the items. Search::fakeResponseData([ |
@christian-nielsen you can already mock model records with
|
I understand. The reason why it did not work, is because I did not understand that it needed to match on all params:
A way to just force use an index and ignore other params would be nice |
It is still work in progress and there might be API changes.
Usage:
It is possible to provide filters (supports all Laravel\Scout\Builder methods) to fake response data for a specific search:
TODO: