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

Fix getTotalCount() method #80

Merged
merged 1 commit into from
Jan 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Engines/MeilisearchEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public function map(Builder $builder, $results, $model)
*/
public function getTotalCount($results)
{
return $results['nbHits'];
return count($results['hits']);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions tests/MeilisearchEngineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function mapIdsReturnsEmptyCollectionIfNoHits()
$engine = new MeilisearchEngine($client);

$results = $engine->mapIds([
'nbHits' => 0, 'hits' => [],
'hits' => [],
]);

$this->assertEquals(0, count($results));
Expand All @@ -87,7 +87,7 @@ public function mapCorrectlyMapsResultsToModels()
$builder = m::mock(Builder::class);

$results = $engine->map($builder, [
'nbHits' => 1, 'hits' => [
'hits' => [
['id' => 1],
],
], $model);
Expand All @@ -113,7 +113,7 @@ public function mapMethodRespectsOrder()
$builder = m::mock(Builder::class);

$results = $engine->map($builder, [
'nbHits' => 4, 'hits' => [
'hits' => [
['id' => 1],
['id' => 2],
['id' => 4],
Expand Down