mirror of
https://github.com/shlinkio/shlink.git
synced 2024-12-27 15:08:24 +03:00
37 lines
1.2 KiB
PHP
37 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace ShlinkioTest\Shlink\Core\Crawling;
|
|
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
use PHPUnit\Framework\MockObject\MockObject;
|
|
use PHPUnit\Framework\TestCase;
|
|
use Shlinkio\Shlink\Core\Crawling\CrawlingHelper;
|
|
use Shlinkio\Shlink\Core\ShortUrl\Entity\ShortUrl;
|
|
use Shlinkio\Shlink\Core\ShortUrl\Repository\ShortUrlRepositoryInterface;
|
|
|
|
class CrawlingHelperTest extends TestCase
|
|
{
|
|
private CrawlingHelper $helper;
|
|
private MockObject $em;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
$this->em = $this->createMock(EntityManagerInterface::class);
|
|
$this->helper = new CrawlingHelper($this->em);
|
|
}
|
|
|
|
/** @test */
|
|
public function listCrawlableShortCodesDelegatesIntoRepository(): void
|
|
{
|
|
$repo = $this->createMock(ShortUrlRepositoryInterface::class);
|
|
$repo->expects($this->once())->method('findCrawlableShortCodes')->willReturn([]);
|
|
$this->em->expects($this->once())->method('getRepository')->with(ShortUrl::class)->willReturn($repo);
|
|
|
|
$result = $this->helper->listCrawlableShortCodes();
|
|
foreach ($result as $shortCode) {
|
|
// $result is a generator and therefore, it needs to be iterated
|
|
}
|
|
}
|
|
}
|