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


PHP ObjectProphecy::persist方法代码示例

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


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

示例1: setUp

 public function setUp()
 {
     $this->em = $this->prophesize(EntityManagerInterface::class);
     $this->em->persist(Argument::any())->willReturn(null);
     $this->em->flush()->willReturn(null);
     $this->service = new ShortUrlService($this->em->reveal());
 }
开发者ID:shlinkio,项目名称:shlink,代码行数:7,代码来源:ShortUrlServiceTest.php

示例2: saveVisitsPersistsProvidedVisit

 /**
  * @test
  */
 public function saveVisitsPersistsProvidedVisit()
 {
     $visit = new Visit();
     $this->em->persist($visit)->shouldBeCalledTimes(1);
     $this->em->flush()->shouldBeCalledTimes(1);
     $this->visitService->saveVisit($visit);
 }
开发者ID:shlinkio,项目名称:shlink,代码行数:10,代码来源:VisitServiceTest.php

示例3: keyIsProperlyCreatedWithExpirationDate

 /**
  * @test
  */
 public function keyIsProperlyCreatedWithExpirationDate()
 {
     $this->em->flush()->shouldBeCalledTimes(1);
     $this->em->persist(Argument::type(ApiKey::class))->shouldBeCalledTimes(1);
     $date = new \DateTime('2030-01-01');
     $key = $this->service->create($date);
     $this->assertSame($date, $key->getExpirationDate());
 }
开发者ID:shlinkio,项目名称:shlink,代码行数:11,代码来源:ApiKeyServiceTest.php

示例4: trackUsesForwardedForHeaderIfPresent

 /**
  * @test
  */
 public function trackUsesForwardedForHeaderIfPresent()
 {
     $shortCode = '123ABC';
     $test = $this;
     $repo = $this->prophesize(EntityRepository::class);
     $repo->findOneBy(['shortCode' => $shortCode])->willReturn(new ShortUrl());
     $this->em->getRepository(ShortUrl::class)->willReturn($repo->reveal())->shouldBeCalledTimes(1);
     $this->em->persist(Argument::any())->will(function ($args) use($test) {
         /** @var Visit $visit */
         $visit = $args[0];
         $test->assertEquals('4.3.2.1', $visit->getRemoteAddr());
     })->shouldBeCalledTimes(1);
     $this->em->flush()->shouldBeCalledTimes(1);
     $this->visitsTracker->track($shortCode, ServerRequestFactory::fromGlobals(['REMOTE_ADDR' => '1.2.3.4'])->withHeader('X-Forwarded-For', '4.3.2.1,99.99.99.99'));
 }
开发者ID:shlinkio,项目名称:shlink,代码行数:18,代码来源:VisitsTrackerTest.php

示例5: setUp

 public function setUp()
 {
     $this->httpClient = $this->prophesize(ClientInterface::class);
     $this->em = $this->prophesize(EntityManagerInterface::class);
     $conn = $this->prophesize(Connection::class);
     $conn->isTransactionActive()->willReturn(false);
     $this->em->getConnection()->willReturn($conn->reveal());
     $this->em->flush()->willReturn(null);
     $this->em->commit()->willReturn(null);
     $this->em->beginTransaction()->willReturn(null);
     $this->em->persist(Argument::any())->will(function ($arguments) {
         /** @var ShortUrl $shortUrl */
         $shortUrl = $arguments[0];
         $shortUrl->setId(10);
     });
     $repo = $this->prophesize(ObjectRepository::class);
     $repo->findOneBy(Argument::any())->willReturn(null);
     $this->em->getRepository(ShortUrl::class)->willReturn($repo->reveal());
     $this->cache = new ArrayCache();
     $this->urlShortener = new UrlShortener($this->httpClient->reveal(), $this->em->reveal(), $this->cache);
 }
开发者ID:shlinkio,项目名称:shlink,代码行数:21,代码来源:UrlShortenerTest.php


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