diff --git a/module/Core/test/Crawling/CrawlingHelperTest.php b/module/Core/test/Crawling/CrawlingHelperTest.php index 92901efc..7667fb93 100644 --- a/module/Core/test/Crawling/CrawlingHelperTest.php +++ b/module/Core/test/Crawling/CrawlingHelperTest.php @@ -5,39 +5,35 @@ declare(strict_types=1); namespace ShlinkioTest\Shlink\Core\Crawling; use Doctrine\ORM\EntityManagerInterface; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -use Prophecy\PhpUnit\ProphecyTrait; -use Prophecy\Prophecy\ObjectProphecy; use Shlinkio\Shlink\Core\Crawling\CrawlingHelper; use Shlinkio\Shlink\Core\ShortUrl\Entity\ShortUrl; use Shlinkio\Shlink\Core\ShortUrl\Repository\ShortUrlRepositoryInterface; class CrawlingHelperTest extends TestCase { - use ProphecyTrait; - private CrawlingHelper $helper; - private ObjectProphecy $em; + private MockObject $em; protected function setUp(): void { - $this->em = $this->prophesize(EntityManagerInterface::class); - $this->helper = new CrawlingHelper($this->em->reveal()); + $this->em = $this->createMock(EntityManagerInterface::class); + $this->helper = new CrawlingHelper($this->em); } /** @test */ public function listCrawlableShortCodesDelegatesIntoRepository(): void { - $repo = $this->prophesize(ShortUrlRepositoryInterface::class); - $findCrawlableShortCodes = $repo->findCrawlableShortCodes()->willReturn([]); - $getRepo = $this->em->getRepository(ShortUrl::class)->willReturn($repo->reveal()); + $repo = $this->createMock(ShortUrlRepositoryInterface::class); + $repo->expects($this->once())->method('findCrawlableShortCodes')->willReturn([]); + $this->em->expects($this->once())->method('getRepository')->with($this->equalTo(ShortUrl::class))->willReturn( + $repo, + ); $result = $this->helper->listCrawlableShortCodes(); foreach ($result as $shortCode) { - // Result is a generator and therefore, it needs to be iterated + // $result is a generator and therefore, it needs to be iterated } - - $findCrawlableShortCodes->shouldHaveBeenCalledOnce(); - $getRepo->shouldHaveBeenCalledOnce(); } }