Added DB test for TagsPaginator

This commit is contained in:
Alejandro Celaya
2022-01-06 10:35:01 +01:00
parent b38b8a3365
commit 0cf33c6119
2 changed files with 61 additions and 2 deletions

View File

@@ -11,11 +11,18 @@ class TagsPaginatorAdapter extends AbstractTagsPaginatorAdapter
{
public function getSlice(int $offset, int $length): iterable
{
return $this->repo->match(Spec::andX(
$conditions = [
new WithApiKeySpecsEnsuringJoin($this->apiKey),
Spec::orderBy('name'),
Spec::limit($length),
Spec::offset($offset),
));
];
$searchTerm = $this->params->searchTerm();
if ($searchTerm !== null) {
$conditions[] = Spec::like('name', $searchTerm);
}
return $this->repo->match(Spec::andX(...$conditions));
}
}