mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-07 07:43:12 +08:00
Fixed query to count tags when a search term is present
This commit is contained in:
@@ -23,8 +23,13 @@ class TagsPaginatorAdapterTest extends DatabaseTestCase
|
||||
* @test
|
||||
* @dataProvider provideFilters
|
||||
*/
|
||||
public function expectedListOfTagsIsReturned(?string $searchTerm, int $offset, int $length, int $expected): void
|
||||
{
|
||||
public function expectedListOfTagsIsReturned(
|
||||
?string $searchTerm,
|
||||
int $offset,
|
||||
int $length,
|
||||
int $expectedSliceSize,
|
||||
int $expectedTotalCount,
|
||||
): void {
|
||||
$names = ['foo', 'bar', 'baz', 'another'];
|
||||
foreach ($names as $name) {
|
||||
$this->getEntityManager()->persist(new Tag($name));
|
||||
@@ -33,20 +38,20 @@ class TagsPaginatorAdapterTest extends DatabaseTestCase
|
||||
|
||||
$adapter = new TagsPaginatorAdapter($this->repo, TagsParams::fromRawData(['searchTerm' => $searchTerm]), null);
|
||||
|
||||
self::assertCount($expected, $adapter->getSlice($offset, $length));
|
||||
self::assertEquals(4, $adapter->getNbResults());
|
||||
self::assertCount($expectedSliceSize, $adapter->getSlice($offset, $length));
|
||||
self::assertEquals($expectedTotalCount, $adapter->getNbResults());
|
||||
}
|
||||
|
||||
public function provideFilters(): iterable
|
||||
{
|
||||
yield [null, 0, 10, 4];
|
||||
yield [null, 2, 10, 2];
|
||||
yield [null, 1, 3, 3];
|
||||
yield [null, 3, 3, 1];
|
||||
yield [null, 0, 2, 2];
|
||||
yield ['ba', 0, 10, 2];
|
||||
yield ['ba', 0, 1, 1];
|
||||
yield ['foo', 0, 10, 1];
|
||||
yield ['a', 0, 10, 3];
|
||||
yield [null, 0, 10, 4, 4];
|
||||
yield [null, 2, 10, 2, 4];
|
||||
yield [null, 1, 3, 3, 4];
|
||||
yield [null, 3, 3, 1, 4];
|
||||
yield [null, 0, 2, 2, 4];
|
||||
yield ['ba', 0, 10, 2, 2];
|
||||
yield ['ba', 0, 1, 1, 2];
|
||||
yield ['foo', 0, 10, 1, 1];
|
||||
yield ['a', 0, 10, 3, 3];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user