mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-25 18:45:27 -06:00
Fixed ShortUrlServiceTest
This commit is contained in:
parent
cc1829f9ed
commit
30773c66d0
@ -2,10 +2,11 @@
|
|||||||
namespace AcelayaTest\UrlShortener\Service;
|
namespace AcelayaTest\UrlShortener\Service;
|
||||||
|
|
||||||
use Acelaya\UrlShortener\Entity\ShortUrl;
|
use Acelaya\UrlShortener\Entity\ShortUrl;
|
||||||
|
use Acelaya\UrlShortener\Repository\ShortUrlRepository;
|
||||||
use Acelaya\UrlShortener\Service\ShortUrlService;
|
use Acelaya\UrlShortener\Service\ShortUrlService;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Doctrine\ORM\EntityRepository;
|
|
||||||
use PHPUnit_Framework_TestCase as TestCase;
|
use PHPUnit_Framework_TestCase as TestCase;
|
||||||
|
use Prophecy\Argument;
|
||||||
use Prophecy\Prophecy\ObjectProphecy;
|
use Prophecy\Prophecy\ObjectProphecy;
|
||||||
|
|
||||||
class ShortUrlServiceTest extends TestCase
|
class ShortUrlServiceTest extends TestCase
|
||||||
@ -30,16 +31,19 @@ class ShortUrlServiceTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function listedUrlsAreReturnedFromEntityManager()
|
public function listedUrlsAreReturnedFromEntityManager()
|
||||||
{
|
{
|
||||||
$repo = $this->prophesize(EntityRepository::class);
|
$list = [
|
||||||
$repo->findAll()->willReturn([
|
|
||||||
new ShortUrl(),
|
new ShortUrl(),
|
||||||
new ShortUrl(),
|
new ShortUrl(),
|
||||||
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());
|
$this->em->getRepository(ShortUrl::class)->willReturn($repo->reveal());
|
||||||
|
|
||||||
$list = $this->service->listShortUrls();
|
$list = $this->service->listShortUrls();
|
||||||
$this->assertCount(4, $list);
|
$this->assertEquals(4, $list->getCurrentItemCount());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user