本文整理汇总了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;
}
示例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];
}
示例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;
}
示例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));
}
示例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;
}
示例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;
}
示例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();
}
示例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;
}
示例9: getProcessorWithRunOnce
/**
* @return \PHPUnit_Framework_MockObject_MockObject|ProcessorInterface
*/
protected function getProcessorWithRunOnce()
{
$processor = $this->getProcessorMock();
$processor->expects(parent::once())->method('process');
return $processor;
}
示例10: expectsCall
public function expectsCall($method)
{
return $this->expects($method, $this->testCase->once());
}
示例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);
}