mirror of
https://github.com/shlinkio/shlink.git
synced 2024-11-28 00:38:46 +03:00
Added tests for findCrawlableShortCodes
This commit is contained in:
parent
3ef02d46c0
commit
36e4a0dd32
1 changed files with 33 additions and 0 deletions
|
@ -436,4 +436,37 @@ class ShortUrlRepositoryTest extends DatabaseTestCase
|
|||
self::assertNull($this->repo->findOneByImportedUrl($buildImported('my-cool-slug', 'doma.in')));
|
||||
self::assertNull($this->repo->findOneByImportedUrl($buildImported('another-slug')));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function findCrawlableShortCodesReturnsExpectedResult(): void
|
||||
{
|
||||
$createShortUrl = fn (bool $crawlable) => ShortUrl::fromMeta(
|
||||
ShortUrlMeta::fromRawData(['crawlable' => $crawlable, 'longUrl' => 'foo.com']),
|
||||
);
|
||||
|
||||
$shortUrl1 = $createShortUrl(true);
|
||||
$this->getEntityManager()->persist($shortUrl1);
|
||||
$shortUrl2 = $createShortUrl(false);
|
||||
$this->getEntityManager()->persist($shortUrl2);
|
||||
$shortUrl3 = $createShortUrl(true);
|
||||
$this->getEntityManager()->persist($shortUrl3);
|
||||
$shortUrl4 = $createShortUrl(true);
|
||||
$this->getEntityManager()->persist($shortUrl4);
|
||||
$shortUrl5 = $createShortUrl(false);
|
||||
$this->getEntityManager()->persist($shortUrl5);
|
||||
$this->getEntityManager()->flush();
|
||||
|
||||
$iterable = $this->repo->findCrawlableShortCodes();
|
||||
$results = [];
|
||||
foreach ($iterable as $shortCode) {
|
||||
$results[] = $shortCode;
|
||||
}
|
||||
|
||||
self::assertCount(3, $results);
|
||||
self::assertContains($shortUrl1->getShortCode(), $results);
|
||||
self::assertContains($shortUrl3->getShortCode(), $results);
|
||||
self::assertContains($shortUrl4->getShortCode(), $results);
|
||||
self::assertNotContains($shortUrl2->getShortCode(), $results);
|
||||
self::assertNotContains($shortUrl5->getShortCode(), $results);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue