-
Notifications
You must be signed in to change notification settings - Fork 72
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
Bring NullEngine back #317
Comments
Yeah I agree, the NullEngine is ❤️ It's probably going to come back before the final release. |
There is no engine in the new version, only
What do you think @chloelbn ? |
What bothers me with a NullSearchService is that all the logic regarding the manipulation of objects will have to be duplicated, while what we'd want is turn off the calls to Algolia and that's what the NullEngine was exactly doing. But that would imply reusing the Engine class again. I need to think about this a little bit more. |
With new design, (Void|Null)Client should be shipped instead. I have created following class class TestClient implements HttpClientInterface
{
/**
* @var RequestInterface[]
*/
private $requests = [];
/**
* {@inheritDoc}
*/
public function sendRequest(RequestInterface $request, $timeout, $connectTimeout)
{
$this->requests[] = $request;
return new Response(200, [], '{"objectIDs":[]}');
}
/**
* @return mixed[][]
*/
public function getRequestsForPath(string $path): array
{
$out = [];
foreach ($this->requests as $request) {
if (strstr($request->getUri()->getPath(), $path) === false) {
continue;
}
$body = $request->getBody();
$body->rewind();
$out[] = json_decode($body->getContents(), true)['requests'];
}
return $out;
}
} Which additionally has feature allowing to pull algolia requests out and assert expected ones were triggered in test cases. Serves as damage control for missing #297 |
@ostrolucky I like your solution! If you're okay with it, I'll add it to the doc and upgrade guide. Thanks for your help! |
Definitely, feel free. Although wiring of this is not easy, because there is no service for http client nor ApiWrapper defined, so consumer needs to replace whole |
I think the It's also useful when working offline. |
@julienbourdeau Could you tell me what would be the drawbacks of using @ostrolucky 's implementation instead of |
Drawback is that all users interested in this need to create class themselves and wire everything themselves. I think both me and @julienbourdeau would be interested to have NullClient in bundle/core, so it doesn't need to be copy pasted from documentation for all users interested in this feature. As a first step to help here I have created algolia/algoliasearch-client-php#596. |
@julienbourdeau is more in favor of a |
@ostrolucky I've opened a new issue to propose my solution, would you mind giving a look and share you thoughts? Thanks |
I'll follow what @nunomaduro originally suggested and create a I'm closing this issue. |
Description
We have difficulties to replace this functionality. Alternative you suggested requires writing implementation for interface with 11 (!!) methods. We can't use phpunit mocks, as we need to inject service into service container. We use algolia in multiple projects, this will slow down upgrade process a lot. Why was it removed?
The text was updated successfully, but these errors were encountered: