From 30773c66d05716a9c64c0a895158d9efd6f9f7ad Mon Sep 17 00:00:00 2001 From: Alejandro Celaya <alejandro@alejandrocelaya.com> Date: Mon, 4 Jul 2016 09:18:10 +0200 Subject: [PATCH] Fixed ShortUrlServiceTest --- tests/Service/ShortUrlServiceTest.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/Service/ShortUrlServiceTest.php b/tests/Service/ShortUrlServiceTest.php index 6d325d17..3b77ee6a 100644 --- a/tests/Service/ShortUrlServiceTest.php +++ b/tests/Service/ShortUrlServiceTest.php @@ -2,10 +2,11 @@ namespace AcelayaTest\UrlShortener\Service; use Acelaya\UrlShortener\Entity\ShortUrl; +use Acelaya\UrlShortener\Repository\ShortUrlRepository; use Acelaya\UrlShortener\Service\ShortUrlService; use Doctrine\ORM\EntityManagerInterface; -use Doctrine\ORM\EntityRepository; use PHPUnit_Framework_TestCase as TestCase; +use Prophecy\Argument; use Prophecy\Prophecy\ObjectProphecy; class ShortUrlServiceTest extends TestCase @@ -30,16 +31,19 @@ class ShortUrlServiceTest extends TestCase */ public function listedUrlsAreReturnedFromEntityManager() { - $repo = $this->prophesize(EntityRepository::class); - $repo->findAll()->willReturn([ + $list = [ new ShortUrl(), new ShortUrl(), new ShortUrl(), new ShortUrl(), - ])->shouldBeCalledTimes(1); + ]; + + $repo = $this->prophesize(ShortUrlRepository::class); + $repo->findList(Argument::cetera())->willReturn($list)->shouldBeCalledTimes(1); + $repo->countList(Argument::cetera())->willReturn(count($list))->shouldBeCalledTimes(1); $this->em->getRepository(ShortUrl::class)->willReturn($repo->reveal()); $list = $this->service->listShortUrls(); - $this->assertCount(4, $list); + $this->assertEquals(4, $list->getCurrentItemCount()); } }