em = $this->prophesize(EntityManagerInterface::class); $this->service = new ShortUrlService($this->em->reveal()); } /** * @test */ public function listedUrlsAreReturnedFromEntityManager() { $repo = $this->prophesize(EntityRepository::class); $repo->findAll()->willReturn([ new ShortUrl(), new ShortUrl(), new ShortUrl(), new ShortUrl(), ])->shouldBeCalledTimes(1); $this->em->getRepository(ShortUrl::class)->willReturn($repo->reveal()); $list = $this->service->listShortUrls(); $this->assertCount(4, $list); } }