Support filtering orphan visits by type in VisitRepository

This commit is contained in:
Alejandro Celaya
2024-02-10 13:57:16 +01:00
parent 17792a1603
commit 46acf4de1c
13 changed files with 154 additions and 61 deletions

View File

@@ -26,6 +26,8 @@ use Shlinkio\Shlink\Core\Visit\Entity\Visit;
use Shlinkio\Shlink\Core\Visit\Model\Visitor;
use Shlinkio\Shlink\Core\Visit\Model\VisitsParams;
use Shlinkio\Shlink\Core\Visit\Model\VisitsStats;
use Shlinkio\Shlink\Core\Visit\Persistence\OrphanVisitsCountFiltering;
use Shlinkio\Shlink\Core\Visit\Persistence\OrphanVisitsListFiltering;
use Shlinkio\Shlink\Core\Visit\Persistence\VisitsCountFiltering;
use Shlinkio\Shlink\Core\Visit\Persistence\VisitsListFiltering;
use Shlinkio\Shlink\Core\Visit\Repository\VisitRepository;
@@ -251,10 +253,10 @@ class VisitsStatsHelperTest extends TestCase
$list = array_map(static fn () => Visit::forBasePath(Visitor::emptyInstance()), range(0, 3));
$repo = $this->createMock(VisitRepository::class);
$repo->expects($this->once())->method('countOrphanVisits')->with(
$this->isInstanceOf(VisitsCountFiltering::class),
$this->isInstanceOf(OrphanVisitsCountFiltering::class),
)->willReturn(count($list));
$repo->expects($this->once())->method('findOrphanVisits')->with(
$this->isInstanceOf(VisitsListFiltering::class),
$this->isInstanceOf(OrphanVisitsListFiltering::class),
)->willReturn($list);
$this->em->expects($this->once())->method('getRepository')->with(Visit::class)->willReturn($repo);