em = $this->prophesize(EntityManagerInterface::class); $this->service = new ShortUrlService($this->em->reveal()); } /** * @test */ public function listedUrlsAreReturnedFromEntityManager() { $list = [ new ShortUrl(), new ShortUrl(), new ShortUrl(), new ShortUrl(), ]; $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->assertEquals(4, $list->getCurrentItemCount()); } }