mirror of
https://github.com/shlinkio/shlink.git
synced 2024-11-28 00:38:46 +03:00
Extended VisitRepositoryTest with domain visits functions
This commit is contained in:
parent
e11bf6ac67
commit
984205e02c
1 changed files with 49 additions and 1 deletions
|
@ -52,7 +52,7 @@ class VisitRepositoryTest extends DatabaseTestCase
|
|||
{
|
||||
$shortUrl = ShortUrl::createEmpty();
|
||||
$this->getEntityManager()->persist($shortUrl);
|
||||
$countIterable = function (iterable $results): int {
|
||||
$countIterable = static function (iterable $results): int {
|
||||
$resultsCount = 0;
|
||||
foreach ($results as $value) {
|
||||
$resultsCount++;
|
||||
|
@ -256,6 +256,54 @@ class VisitRepositoryTest extends DatabaseTestCase
|
|||
)));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function findVisitsByDomainReturnsProperData(): void
|
||||
{
|
||||
$this->createShortUrlsAndVisits('doma.in');
|
||||
$this->getEntityManager()->flush();
|
||||
|
||||
self::assertCount(0, $this->repo->findVisitsByDomain('invalid', new VisitsListFiltering()));
|
||||
self::assertCount(6, $this->repo->findVisitsByDomain('DEFAULT', new VisitsListFiltering()));
|
||||
self::assertCount(3, $this->repo->findVisitsByDomain('doma.in', new VisitsListFiltering()));
|
||||
self::assertCount(1, $this->repo->findVisitsByDomain('doma.in', new VisitsListFiltering(null, true)));
|
||||
self::assertCount(2, $this->repo->findVisitsByDomain('doma.in', new VisitsListFiltering(
|
||||
DateRange::withStartAndEndDate(Chronos::parse('2016-01-02'), Chronos::parse('2016-01-03')),
|
||||
)));
|
||||
self::assertCount(1, $this->repo->findVisitsByDomain('doma.in', new VisitsListFiltering(
|
||||
DateRange::withStartDate(Chronos::parse('2016-01-03')),
|
||||
)));
|
||||
self::assertCount(2, $this->repo->findVisitsByDomain('DEFAULT', new VisitsListFiltering(
|
||||
DateRange::withStartAndEndDate(Chronos::parse('2016-01-02'), Chronos::parse('2016-01-03')),
|
||||
)));
|
||||
self::assertCount(4, $this->repo->findVisitsByDomain('DEFAULT', new VisitsListFiltering(
|
||||
DateRange::withStartDate(Chronos::parse('2016-01-03')),
|
||||
)));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function countVisitsByDomainReturnsProperData(): void
|
||||
{
|
||||
$this->createShortUrlsAndVisits('doma.in');
|
||||
$this->getEntityManager()->flush();
|
||||
|
||||
self::assertEquals(0, $this->repo->countVisitsByDomain('invalid', new VisitsListFiltering()));
|
||||
self::assertEquals(6, $this->repo->countVisitsByDomain('DEFAULT', new VisitsListFiltering()));
|
||||
self::assertEquals(3, $this->repo->countVisitsByDomain('doma.in', new VisitsListFiltering()));
|
||||
self::assertEquals(1, $this->repo->countVisitsByDomain('doma.in', new VisitsListFiltering(null, true)));
|
||||
self::assertEquals(2, $this->repo->countVisitsByDomain('doma.in', new VisitsListFiltering(
|
||||
DateRange::withStartAndEndDate(Chronos::parse('2016-01-02'), Chronos::parse('2016-01-03')),
|
||||
)));
|
||||
self::assertEquals(1, $this->repo->countVisitsByDomain('doma.in', new VisitsListFiltering(
|
||||
DateRange::withStartDate(Chronos::parse('2016-01-03')),
|
||||
)));
|
||||
self::assertEquals(2, $this->repo->countVisitsByDomain('DEFAULT', new VisitsListFiltering(
|
||||
DateRange::withStartAndEndDate(Chronos::parse('2016-01-02'), Chronos::parse('2016-01-03')),
|
||||
)));
|
||||
self::assertEquals(4, $this->repo->countVisitsByDomain('DEFAULT', new VisitsListFiltering(
|
||||
DateRange::withStartDate(Chronos::parse('2016-01-03')),
|
||||
)));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function countVisitsReturnsExpectedResultBasedOnApiKey(): void
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue