mirror of
https://github.com/shlinkio/shlink.git
synced 2025-03-27 12:01:49 +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();
|
$shortUrl = ShortUrl::createEmpty();
|
||||||
$this->getEntityManager()->persist($shortUrl);
|
$this->getEntityManager()->persist($shortUrl);
|
||||||
$countIterable = function (iterable $results): int {
|
$countIterable = static function (iterable $results): int {
|
||||||
$resultsCount = 0;
|
$resultsCount = 0;
|
||||||
foreach ($results as $value) {
|
foreach ($results as $value) {
|
||||||
$resultsCount++;
|
$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 */
|
/** @test */
|
||||||
public function countVisitsReturnsExpectedResultBasedOnApiKey(): void
|
public function countVisitsReturnsExpectedResultBasedOnApiKey(): void
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue