Allow tags, orphan and non-orphan visits to be provided a domain filter param

This commit is contained in:
Alejandro Celaya
2025-10-28 10:55:06 +01:00
parent 10dab5be20
commit 14a7e3bb05
26 changed files with 189 additions and 98 deletions

View File

@@ -29,10 +29,12 @@ use Shlinkio\Shlink\Core\Visit\Model\OrphanVisitsParams;
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\Model\WithDomainVisitsParams;
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\Persistence\WithDomainVisitsCountFiltering;
use Shlinkio\Shlink\Core\Visit\Persistence\WithDomainVisitsListFiltering;
use Shlinkio\Shlink\Core\Visit\Repository\OrphanVisitsCountRepository;
use Shlinkio\Shlink\Core\Visit\Repository\ShortUrlVisitsCountRepository;
use Shlinkio\Shlink\Core\Visit\Repository\VisitRepository;
@@ -147,7 +149,7 @@ class VisitsStatsHelperTest extends TestCase
$this->expectException(TagNotFoundException::class);
$this->helper->visitsForTag($tag, new VisitsParams(), $apiKey);
$this->helper->visitsForTag($tag, new WithDomainVisitsParams(), $apiKey);
}
#[Test, DataProviderExternal(ApiKeyDataProviders::class, 'adminApiKeysProvider')]
@@ -170,7 +172,7 @@ class VisitsStatsHelperTest extends TestCase
[Visit::class, $repo2],
]);
$paginator = $this->helper->visitsForTag($tag, new VisitsParams(), $apiKey);
$paginator = $this->helper->visitsForTag($tag, new WithDomainVisitsParams(), $apiKey);
self::assertEquals($list, ArrayUtils::iteratorToArray($paginator->getCurrentPageResults()));
}
@@ -265,14 +267,14 @@ class VisitsStatsHelperTest extends TestCase
);
$repo = $this->createMock(VisitRepository::class);
$repo->expects($this->once())->method('countNonOrphanVisits')->with(
$this->isInstanceOf(VisitsCountFiltering::class),
$this->isInstanceOf(WithDOmainVisitsCountFiltering::class),
)->willReturn(count($list));
$repo->expects($this->once())->method('findNonOrphanVisits')->with(
$this->isInstanceOf(VisitsListFiltering::class),
$this->isInstanceOf(WithDOmainVisitsListFiltering::class),
)->willReturn($list);
$this->em->expects($this->once())->method('getRepository')->with(Visit::class)->willReturn($repo);
$paginator = $this->helper->nonOrphanVisits(new VisitsParams());
$paginator = $this->helper->nonOrphanVisits(new WithDomainVisitsParams());
self::assertEquals($list, ArrayUtils::iteratorToArray($paginator->getCurrentPageResults()));
}