Skip to content
This repository has been archived by the owner on May 13, 2021. It is now read-only.

Add tests for search() method #81

Closed
curquiza opened this issue Jan 27, 2021 · 4 comments
Closed

Add tests for search() method #81

curquiza opened this issue Jan 27, 2021 · 4 comments

Comments

@curquiza
Copy link
Member

If I understand well, we don't have tests for the search() method:

/**
* Perform the given search on the engine.
*
* @return mixed
*/
public function search(Builder $builder)
{
return $this->performSearch($builder, array_filter([
'filters' => $this->filters($builder),
'limit' => $builder->limit,
]));
}

We should add tests for this.

Tell me if I'm wrong 🙂

@curquiza curquiza added this to Open issues in SDKs & Integrations via automation Jan 27, 2021
@shokme
Copy link
Collaborator

shokme commented Jan 29, 2021

/** @test */
public function searchSendsCorrectParametersToMeilisearch()
{
$client = m::mock(Client::class);
$client->shouldReceive('index')->with('table')->andReturn($index = m::mock(Indexes::class));
$index->shouldReceive('search')->with('mustang', [
'filters' => 'foo=1',
]);
$engine = new MeilisearchEngine($client);
$builder = new Builder(new SearchableModel(), 'mustang', function ($meilisearch, $query, $options) {
$options['filters'] = 'foo=1';
return $meilisearch->search($query, $options);
});
$engine->search($builder);
}

not sure to understand, this one is not enough?

@curquiza
Copy link
Member Author

curquiza commented Feb 1, 2021

Maybe I badly understand I was surprised the tests (PHP ...) job did not break in this PR (#70) before I changed the search into rawSearch.
For me, there was a lack of test, but again, maybe I missed something.

@mmachatschek mmachatschek mentioned this issue Feb 17, 2021
3 tasks
bors bot added a commit that referenced this issue Mar 2, 2021
102: Add feature tests r=curquiza a=mmachatschek

WIP

This adds feature tests to the repo and solves #90 and #81

~~TODOS:~~

- [x] ~~Add documentation how to run feature tests locally~~
- [x] Add more tests (based on https://github.com/meilisearch/meilisearch-symfony/)
- [x] Update the cleanup method and add a `SCOUT_PREFIX` config with a test key and only remove indexes with that prefix to avoid deleting documents from a local meilisearch instance


~~I added a matrix for the meilisearch containers to also test the library against older versions. If this should be removed, just tell me @shokme or @curquiza.~~

Co-authored-by: Markus Machatschek <mmachatschek@yahoo.com>
@mmachatschek
Copy link
Collaborator

@curquiza I think this should be solved or at least be covered by #102

@curquiza
Copy link
Member Author

Yes! :)
If anyone thinks there are missing tests, feel free to open a new issue!

SDKs & Integrations automation moved this from Open issues to Done Mar 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
No open projects
Development

No branches or pull requests

3 participants