本文整理匯總了PHP中Mockery\MockInterface::mockery_isAnonymous方法的典型用法代碼示例。如果您正苦於以下問題:PHP MockInterface::mockery_isAnonymous方法的具體用法?PHP MockInterface::mockery_isAnonymous怎麽用?PHP MockInterface::mockery_isAnonymous使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Mockery\MockInterface
的用法示例。
在下文中一共展示了MockInterface::mockery_isAnonymous方法的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() && !$mock->mockery_isAnonymous() && !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;
}