当前位置: 首页>>代码示例>>PHP>>正文


PHP ObjectProphecy::getRepository方法代码示例

本文整理汇总了PHP中Prophecy\Prophecy\ObjectProphecy::getRepository方法的典型用法代码示例。如果您正苦于以下问题:PHP ObjectProphecy::getRepository方法的具体用法?PHP ObjectProphecy::getRepository怎么用?PHP ObjectProphecy::getRepository使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Prophecy\Prophecy\ObjectProphecy的用法示例。


在下文中一共展示了ObjectProphecy::getRepository方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getUnlocatedVisitsFallbacksToRepository

 /**
  * @test
  */
 public function getUnlocatedVisitsFallbacksToRepository()
 {
     $repo = $this->prophesize(VisitRepository::class);
     $repo->findUnlocatedVisits()->shouldBeCalledTimes(1);
     $this->em->getRepository(Visit::class)->willReturn($repo->reveal())->shouldBeCalledTimes(1);
     $this->visitService->getUnlocatedVisits();
 }
开发者ID:shlinkio,项目名称:shlink,代码行数:10,代码来源:VisitServiceTest.php

示例2: infoReturnsVisistForCertainShortCode

 /**
  * @test
  */
 public function infoReturnsVisistForCertainShortCode()
 {
     $shortCode = '123ABC';
     $shortUrl = (new ShortUrl())->setOriginalUrl('http://domain.com/foo/bar');
     $repo = $this->prophesize(EntityRepository::class);
     $repo->findOneBy(['shortCode' => $shortCode])->willReturn($shortUrl);
     $this->em->getRepository(ShortUrl::class)->willReturn($repo->reveal())->shouldBeCalledTimes(1);
     $list = [new Visit(), new Visit()];
     $repo2 = $this->prophesize(VisitRepository::class);
     $repo2->findVisitsByShortUrl($shortUrl, null)->willReturn($list);
     $this->em->getRepository(Visit::class)->willReturn($repo2->reveal())->shouldBeCalledTimes(1);
     $this->assertEquals($list, $this->visitsTracker->info($shortCode));
 }
开发者ID:shlinkio,项目名称:shlink,代码行数:16,代码来源:VisitsTrackerTest.php

示例3: providedTagsAreGetFromRepoAndSetToTheShortUrl

 /**
  * @test
  */
 public function providedTagsAreGetFromRepoAndSetToTheShortUrl()
 {
     $shortUrl = $this->prophesize(ShortUrl::class);
     $shortUrl->setTags(Argument::any())->shouldBeCalledTimes(1);
     $shortCode = 'abc123';
     $repo = $this->prophesize(ShortUrlRepository::class);
     $repo->findOneBy(['shortCode' => $shortCode])->willReturn($shortUrl->reveal())->shouldBeCalledTimes(1);
     $this->em->getRepository(ShortUrl::class)->willReturn($repo->reveal());
     $tagRepo = $this->prophesize(EntityRepository::class);
     $tagRepo->findOneBy(['name' => 'foo'])->willReturn(new Tag())->shouldbeCalledTimes(1);
     $tagRepo->findOneBy(['name' => 'bar'])->willReturn(null)->shouldbeCalledTimes(1);
     $this->em->getRepository(Tag::class)->willReturn($tagRepo->reveal());
     $this->service->setTagsByShortCode($shortCode, ['foo', 'bar']);
 }
开发者ID:shlinkio,项目名称:shlink,代码行数:17,代码来源:ShortUrlServiceTest.php

示例4: listEnabledFindsOnlyEnabledApiKeys

 /**
  * @test
  */
 public function listEnabledFindsOnlyEnabledApiKeys()
 {
     $repo = $this->prophesize(EntityRepository::class);
     $repo->findBy(['enabled' => true])->willReturn([])->shouldBeCalledTimes(1);
     $this->em->getRepository(ApiKey::class)->willReturn($repo->reveal());
     $this->service->listKeys(true);
 }
开发者ID:shlinkio,项目名称:shlink,代码行数:10,代码来源:ApiKeyServiceTest.php

示例5: cachedShortCodeDoesNotHitDatabase

 /**
  * @test
  */
 public function cachedShortCodeDoesNotHitDatabase()
 {
     $shortCode = '12C1c';
     $expectedUrl = 'expected_url';
     $this->cache->save($shortCode . '_longUrl', $expectedUrl);
     $this->em->getRepository(ShortUrl::class)->willReturn(null)->shouldBeCalledTimes(0);
     $url = $this->urlShortener->shortCodeToUrl($shortCode);
     $this->assertEquals($expectedUrl, $url);
 }
开发者ID:shlinkio,项目名称:shlink,代码行数:12,代码来源:UrlShortenerTest.php


注:本文中的Prophecy\Prophecy\ObjectProphecy::getRepository方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。