mirror of
https://github.com/shlinkio/shlink.git
synced 2025-01-24 15:26:38 -06:00
Improved ShortUrlRepositoryTest covering listing case with filter by tag and search term at the same time
This commit is contained in:
parent
c7239aaca2
commit
080965e166
@ -5,15 +5,17 @@ namespace ShlinkioTest\Shlink\Core\Repository;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Shlinkio\Shlink\Core\Entity\ShortUrl;
|
||||
use Shlinkio\Shlink\Core\Entity\Tag;
|
||||
use Shlinkio\Shlink\Core\Entity\Visit;
|
||||
use Shlinkio\Shlink\Core\Repository\ShortUrlRepository;
|
||||
use ShlinkioTest\Shlink\Common\DbUnit\DatabaseTestCase;
|
||||
|
||||
class ShortUrlRepositoryTest extends DatabaseTestCase
|
||||
{
|
||||
const ENTITIES_TO_EMPTY = [
|
||||
protected const ENTITIES_TO_EMPTY = [
|
||||
ShortUrl::class,
|
||||
Visit::class,
|
||||
Tag::class,
|
||||
];
|
||||
|
||||
/**
|
||||
@ -79,4 +81,35 @@ class ShortUrlRepositoryTest extends DatabaseTestCase
|
||||
|
||||
$this->assertEquals($count, $this->repo->countList());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function findListProperlyFiltersByTagAndSearchTerm()
|
||||
{
|
||||
$tag = new Tag('bar');
|
||||
$this->getEntityManager()->persist($tag);
|
||||
|
||||
$foo = new ShortUrl();
|
||||
$foo->setOriginalUrl('foo')
|
||||
->setShortCode('foo')
|
||||
->setTags(new ArrayCollection([$tag]));
|
||||
$this->getEntityManager()->persist($foo);
|
||||
|
||||
$bar = new ShortUrl();
|
||||
$bar->setOriginalUrl('bar')
|
||||
->setShortCode('bar_very_long_text');
|
||||
$this->getEntityManager()->persist($bar);
|
||||
|
||||
$foo2 = new ShortUrl();
|
||||
$foo2->setOriginalUrl('foo_2')
|
||||
->setShortCode('foo_2');
|
||||
$this->getEntityManager()->persist($foo2);
|
||||
|
||||
$this->getEntityManager()->flush();
|
||||
|
||||
$result = $this->repo->findList(null, null, 'foo', ['bar']);
|
||||
$this->assertCount(1, $result);
|
||||
$this->assertSame($foo, $result[0]);
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ use ShlinkioTest\Shlink\Common\DbUnit\DatabaseTestCase;
|
||||
|
||||
class TagRepositoryTest extends DatabaseTestCase
|
||||
{
|
||||
const ENTITIES_TO_EMPTY = [
|
||||
protected const ENTITIES_TO_EMPTY = [
|
||||
Tag::class,
|
||||
];
|
||||
|
||||
|
@ -12,7 +12,7 @@ use ShlinkioTest\Shlink\Common\DbUnit\DatabaseTestCase;
|
||||
|
||||
class VisitRepositoryTest extends DatabaseTestCase
|
||||
{
|
||||
const ENTITIES_TO_EMPTY = [
|
||||
protected const ENTITIES_TO_EMPTY = [
|
||||
VisitLocation::class,
|
||||
Visit::class,
|
||||
ShortUrl::class,
|
||||
|
Loading…
Reference in New Issue
Block a user