本文整理汇总了PHP中Mockery\MockInterface::mockery_getMockableMethods方法的典型用法代码示例。如果您正苦于以下问题:PHP MockInterface::mockery_getMockableMethods方法的具体用法?PHP MockInterface::mockery_getMockableMethods怎么用?PHP MockInterface::mockery_getMockableMethods使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mockery\MockInterface
的用法示例。
在下文中一共展示了MockInterface::mockery_getMockableMethods方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _buildDemeterChain
/**
* Sets up expectations on the members of the CompositeExpectation and
* builds up any demeter chain that was passed to shouldReceive
*
* @param \Mockery\MockInterface $mock
* @param string $arg
* @param callable $add
* @throws Mockery\Exception
* @return \Mockery\ExpectationDirector
*/
protected static function _buildDemeterChain(\Mockery\MockInterface $mock, $arg, $add)
{
/** @var Mockery\Container $container */
$container = $mock->mockery_getContainer();
$methodNames = explode('->', $arg);
reset($methodNames);
if (!\Mockery::getConfiguration()->mockingNonExistentMethodsAllowed() && !$mock->mockery_isAnonymous() && !in_array(current($methodNames), $mock->mockery_getMockableMethods())) {
throw new \Mockery\Exception('Mockery\'s configuration currently forbids mocking the method ' . current($methodNames) . ' as it does not exist on the class or object ' . 'being mocked');
}
/** @var ExpectationInterface|null $exp */
$exp = null;
/** @var Callable $nextExp */
$nextExp = function ($method) use($add) {
return $add($method);
};
while (true) {
$method = array_shift($methodNames);
$exp = $mock->mockery_getExpectationsFor($method);
if (is_null($exp) || self::noMoreElementsInChain($methodNames)) {
$exp = $nextExp($method);
if (self::noMoreElementsInChain($methodNames)) {
break;
}
$mock = self::getNewDemeterMock($container, $method, $exp);
} else {
$demeterMockKey = $container->getKeyOfDemeterMockFor($method);
if ($demeterMockKey) {
$mock = self::getExistingDemeterMock($container, $demeterMockKey);
}
}
$nextExp = function ($n) use($mock) {
return $mock->shouldReceive($n);
};
}
return $exp;
}
示例2: _buildDemeterChain
/**
* Sets up expectations on the members of the CompositeExpectation and
* builds up any demeter chain that was passed to shouldReceive
*
* @param \Mockery\MockInterface $mock
* @param string $arg
* @param Closure $add
* @return \Mockery\ExpectationDirector
*/
protected static function _buildDemeterChain(\Mockery\MockInterface $mock, $arg, $add)
{
$container = $mock->mockery_getContainer();
$names = explode('->', $arg);
reset($names);
if (!\Mockery::getConfiguration()->mockingNonExistentMethodsAllowed() && !in_array(current($names), $mock->mockery_getMockableMethods())) {
throw new \Mockery\Exception('Mockery\'s configuration currently forbids mocking the method ' . current($names) . ' as it does not exist on the class or object ' . 'being mocked');
}
$exp = null;
$nextExp = function ($n) use($add) {
return $add($n);
};
while (true) {
$method = array_shift($names);
$exp = $mock->mockery_getExpectationsFor($method);
$needNew = false;
if (is_null($exp) || empty($names)) {
$needNew = true;
}
if ($needNew) {
$exp = $nextExp($method);
}
if (empty($names)) {
break;
}
if ($needNew) {
$mock = $container->mock('demeter_' . $method);
$exp->andReturn($mock);
}
$nextExp = function ($n) use($mock) {
return $mock->shouldReceive($n);
};
}
return $exp;
}