mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-06 23:33:13 +08:00
Improved repository tests
This commit is contained in:
@@ -76,6 +76,7 @@ class ShortUrlRepositoryTest extends DatabaseTestCase
|
||||
$this->getEntityManager()->flush();
|
||||
|
||||
$this->assertEquals($count, $this->repo->countList());
|
||||
$this->assertEquals($count, $this->repo->countList());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,7 +93,10 @@ class ShortUrlRepositoryTest extends DatabaseTestCase
|
||||
$this->getEntityManager()->persist($foo);
|
||||
|
||||
$bar = new ShortUrl('bar');
|
||||
$bar->setShortCode('bar_very_long_text');
|
||||
$visit = new Visit($bar, Visitor::emptyInstance());
|
||||
$this->getEntityManager()->persist($visit);
|
||||
$bar->setShortCode('bar_very_long_text')
|
||||
->setVisits(new ArrayCollection([$visit]));
|
||||
$this->getEntityManager()->persist($bar);
|
||||
|
||||
$foo2 = new ShortUrl('foo_2');
|
||||
@@ -104,6 +108,22 @@ class ShortUrlRepositoryTest extends DatabaseTestCase
|
||||
$result = $this->repo->findList(null, null, 'foo', ['bar']);
|
||||
$this->assertCount(1, $result);
|
||||
$this->assertSame($foo, $result[0]);
|
||||
|
||||
$result = $this->repo->findList();
|
||||
$this->assertCount(3, $result);
|
||||
|
||||
$result = $this->repo->findList(2);
|
||||
$this->assertCount(2, $result);
|
||||
|
||||
$result = $this->repo->findList(2, 1);
|
||||
$this->assertCount(2, $result);
|
||||
|
||||
$result = $this->repo->findList(2, 2);
|
||||
$this->assertCount(1, $result);
|
||||
|
||||
$result = $this->repo->findList(null, null, null, [], ['visits' => 'DESC']);
|
||||
$this->assertCount(3, $result);
|
||||
$this->assertSame($bar, $result[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -82,6 +82,8 @@ class VisitRepositoryTest extends DatabaseTestCase
|
||||
$this->assertCount(4, $this->repo->findVisitsByShortCode($shortUrl->getShortCode(), new DateRange(
|
||||
Chronos::parse('2016-01-03')
|
||||
)));
|
||||
$this->assertCount(3, $this->repo->findVisitsByShortCode($shortUrl->getShortCode(), null, 3, 2));
|
||||
$this->assertCount(2, $this->repo->findVisitsByShortCode($shortUrl->getShortCode(), null, 5, 4));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user