當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。