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


PHP PHPUnit_Framework_TestCase::once方法代码示例

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


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

示例1: getReadMock

 /**
  * @param TblCronTask[] $cronTasks
  * @return \Trovit\CronManagerBundle\Repository\TblCronTaskRepository|\PHPUnit_Framework_MockObject_MockObject
  */
 public function getReadMock(array $cronTasks)
 {
     $mock = $this->getBasicMock();
     $mock->expects($this->_testCase->once())->method('findAll')->willReturn($cronTasks);
     $mock->expects($this->_testCase->once())->method('getActiveCronTasks')->willReturn($cronTasks);
     return $mock;
 }
开发者ID:viscat,项目名称:PCCronManagerBundle,代码行数:11,代码来源:TblCronTaskRepositoryMocks.php

示例2: mockQuoteIdMask

 /**
  * Return mocks with expected invokes
  *
  * First element is quoteIdMaskFactoryMock, second one is quoteIdMaskMock
  *
  * @param $maskedCartId
  * @param $cartId
  * @return array
  */
 public function mockQuoteIdMask($maskedCartId, $cartId)
 {
     $quoteIdMaskMock = $this->testCase->getMock('Magento\\Quote\\Model\\QuoteIdMask', ['load', 'getQuoteId', 'getMaskedId'], [], '', false);
     $quoteIdMaskFactoryMock = $this->testCase->getMockBuilder('Magento\\Quote\\Model\\QuoteIdMaskFactory')->setMethods(['create'])->disableOriginalConstructor()->getMock();
     $quoteIdMaskFactoryMock->expects($this->testCase->once())->method('create')->willReturn($quoteIdMaskMock);
     $quoteIdMaskMock->expects($this->testCase->once())->method('load')->with($maskedCartId)->willReturnSelf();
     $quoteIdMaskMock->expects($this->testCase->once())->method('getQuoteId')->willReturn($cartId);
     return [$quoteIdMaskFactoryMock, $quoteIdMaskMock];
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:18,代码来源:GuestCartTestHelper.php

示例3: create

 /**
  * Create a new mock of the curlbuilder and return
  * the given filename as content
  *
  * @access public
  * @param  PHPUnit_Framework_TestCase   $instance
  * @return mock
  */
 public static function create($instance)
 {
     $reflection = new \ReflectionMethod($instance, $instance->getName());
     $doc_block = $reflection->getDocComment();
     $responsefile = self::parseDocBlock($doc_block, '@responsefile');
     $responsecode = self::parseDocBlock($doc_block, '@responsecode');
     $defaultheaders = array("X-Ratelimit-Limit" => "1000", "X-Ratelimit-Remaining" => "998", "X-Varnish" => "4059929980");
     $skipmock = self::parseDocBlock($doc_block, '@skipmock');
     if (empty($responsecode)) {
         $responsecode = [201];
     }
     if (empty($responsefile)) {
         $responsefile = [$instance->getName()];
     }
     // Setup Curlbuilder mock
     $curlbuilder = $instance->getMockBuilder("\\DirkGroenen\\Pinterest\\Utils\\CurlBuilder")->getMock();
     $curlbuilder->expects($instance->any())->method('create')->will($instance->returnSelf());
     // Build response file path
     $responseFilePath = __DIR__ . '/../responses/' . (new \ReflectionClass($instance))->getShortName() . '/' . $responsefile[0] . ".json";
     if (file_exists($responseFilePath)) {
         $curlbuilder->expects($instance->once())->method('execute')->will($instance->returnValue(file_get_contents($responseFilePath)));
     }
     $curlbuilder->expects($instance->any())->method('getInfo')->will($instance->returnValue($responsecode[0]));
     return $curlbuilder;
 }
开发者ID:veksa,项目名称:Pinterest-API-PHP,代码行数:33,代码来源:CurlBuilderMock.php

示例4: getFormattedMessage

 /**
  * @test
  */
 public function getFormattedMessage()
 {
     $formatter = $this->getFormatterMock();
     $record = $this->getRecordMock();
     $formatter->expects(parent::once())->method('format')->with($record)->willReturn('foobar');
     $this->formatterContainer->setFormatter($formatter);
     parent::assertSame('foobar', $this->formatterContainer->getFormattedMessage($record));
 }
开发者ID:oqq,项目名称:minc-log,代码行数:11,代码来源:FormatterContainerTest.php

示例5: create

 /**
  * Create a new mock of the curlbuilder and return 
  * the given filename as content
  * 
  * @access public
  * @param  PHPUnit_Framework_TestCase   $instance
  * @return mock
  */
 public static function create($instance)
 {
     $reflection = new \ReflectionMethod($instance, $instance->getName());
     $doc_block = $reflection->getDocComment();
     $responsefile = self::parseDocBlock($doc_block, '@responsefile');
     $responsecode = self::parseDocBlock($doc_block, '@responsecode');
     if (empty($responsecode)) {
         $responsecode = [201];
     }
     if (empty($responsefile)) {
         $responsefile = [$instance->getName()];
     }
     // Setup Curlbuilder mock
     $curlbuilder = $instance->getMockBuilder("\\DirkGroenen\\Pinterest\\Utils\\CurlBuilder")->getMock();
     $curlbuilder->expects($instance->once())->method('create')->will($instance->returnSelf());
     $curlbuilder->expects($instance->once())->method('execute')->will($instance->returnValue(file_get_contents(__DIR__ . '/../responses/' . (new \ReflectionClass($instance))->getShortName() . '/' . $responsefile[0] . ".json")));
     $curlbuilder->expects($instance->any())->method('getInfo')->will($instance->returnValue($responsecode[0]));
     return $curlbuilder;
 }
开发者ID:sfai05,项目名称:Pinterest-API-PHP,代码行数:27,代码来源:CurlBuilderMock.php

示例6: getRedirectPluginMock

 /**
  * @param \PHPUnit_Framework_MockObject_MockObject
  * @param \PHPUnit_Framework_MockObject_MockObject
  *
  * @return \PHPUnit_Framework_MockObject_MockObject
  */
 public function getRedirectPluginMock($toRouteResponse = null, $toUrlResponse = null)
 {
     $mockBuilder = new MockBuilder($this->testCase, 'Zend\\Mvc\\Controller\\Plugin\\Redirect');
     $mockBuilder->setMethods(['toRoute', 'toUrl']);
     $mockBuilder->disableOriginalConstructor();
     $redirectMock = $mockBuilder->getMock();
     if ($toRouteResponse) {
         $redirectMock->expects($this->testCase->once())->method('toRoute')->willReturn($toRouteResponse);
     }
     if ($toUrlResponse) {
         $redirectMock->expects($this->testCase->once())->method('toUrl')->willReturn($toUrlResponse);
     }
     return $redirectMock;
 }
开发者ID:peteraba,项目名称:dm-test,代码行数:20,代码来源:MockFactory.php

示例7: once

/**
 * Returns a matcher that matches when the method it is evaluated for
 * is executed exactly once.
 *
 * @return PHPUnit_Framework_MockObject_Matcher_InvokedCount
 * @since  Method available since Release 3.0.0
 */
function once()
{
    return PHPUnit_Framework_TestCase::once();
}
开发者ID:delkyd,项目名称:sugarcrm_dev,代码行数:11,代码来源:Functions.php

示例8: getCreateCronTaskTestMock

 /**
  * @param bool $commandExistsReturn
  * @return \Trovit\CronManagerBundle\Model\CommandValidator|\PHPUnit_Framework_MockObject_MockObject
  */
 public function getCreateCronTaskTestMock($commandExistsReturn)
 {
     $mock = $this->getBasicMock();
     $mock->expects($this->_testCase->once())->method('commandExists')->willReturn($commandExistsReturn);
     return $mock;
 }
开发者ID:viscat,项目名称:PCCronManagerBundle,代码行数:10,代码来源:CommandValidatorMocks.php

示例9: getProcessorWithRunOnce

 /**
  * @return \PHPUnit_Framework_MockObject_MockObject|ProcessorInterface
  */
 protected function getProcessorWithRunOnce()
 {
     $processor = $this->getProcessorMock();
     $processor->expects(parent::once())->method('process');
     return $processor;
 }
开发者ID:oqq,项目名称:minc-log,代码行数:9,代码来源:ProcessorContainerTest.php

示例10: expectsCall

 public function expectsCall($method)
 {
     return $this->expects($method, $this->testCase->once());
 }
开发者ID:schnipseljagd,项目名称:testdatabuilder,代码行数:4,代码来源:MockBuilder.php

示例11: setUp

 /**
  * @inheritdoc
  */
 public function setUp()
 {
     $this->ipProvider = $this->getMockBuilder(IpProviderInterface::class)->setMethods(['getCurrentIpAddress'])->getMock();
     $this->ipProvider->expects(parent::once())->method('getCurrentIpAddress')->willReturn(self::$ipAddress);
 }
开发者ID:oqq,项目名称:ip-provider,代码行数:8,代码来源:BufferedIpProviderTest.php


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