當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ObjectProphecy::flush方法代碼示例

本文整理匯總了PHP中Prophecy\Prophecy\ObjectProphecy::flush方法的典型用法代碼示例。如果您正苦於以下問題:PHP ObjectProphecy::flush方法的具體用法?PHP ObjectProphecy::flush怎麽用?PHP ObjectProphecy::flush使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Prophecy\Prophecy\ObjectProphecy的用法示例。


在下文中一共展示了ObjectProphecy::flush方法的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: exceptionIsThrownWhenOrmThrowsException

 /**
  * @test
  * @expectedException \Shlinkio\Shlink\Common\Exception\RuntimeException
  */
 public function exceptionIsThrownWhenOrmThrowsException()
 {
     $conn = $this->prophesize(Connection::class);
     $conn->isTransactionActive()->willReturn(true);
     $this->em->getConnection()->willReturn($conn->reveal());
     $this->em->rollback()->shouldBeCalledTimes(1);
     $this->em->close()->shouldBeCalledTimes(1);
     $this->em->flush()->willThrow(new ORMException());
     $this->urlShortener->urlToShortCode(new Uri('http://foobar.com/12345/hello?foo=bar'));
 }
開發者ID:shlinkio,項目名稱:shlink,代碼行數:14,代碼來源:UrlShortenerTest.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: disableReturnsDisabledKeyWhenFOund

 /**
  * @test
  */
 public function disableReturnsDisabledKeyWhenFOund()
 {
     $key = new ApiKey();
     $repo = $this->prophesize(EntityRepository::class);
     $repo->findOneBy(['key' => '12345'])->willReturn($key)->shouldBeCalledTimes(1);
     $this->em->getRepository(ApiKey::class)->willReturn($repo->reveal());
     $this->em->flush()->shouldBeCalledTimes(1);
     $this->assertTrue($key->isEnabled());
     $returnedKey = $this->service->disable('12345');
     $this->assertFalse($key->isEnabled());
     $this->assertSame($key, $returnedKey);
 }
開發者ID:shlinkio,項目名稱:shlink,代碼行數:15,代碼來源:ApiKeyServiceTest.php


注:本文中的Prophecy\Prophecy\ObjectProphecy::flush方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。