本文整理汇总了PHP中Prophecy\Prophecy\MethodProphecy::getMethodName方法的典型用法代码示例。如果您正苦于以下问题:PHP MethodProphecy::getMethodName方法的具体用法?PHP MethodProphecy::getMethodName怎么用?PHP MethodProphecy::getMethodName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Prophecy\Prophecy\MethodProphecy
的用法示例。
在下文中一共展示了MethodProphecy::getMethodName方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: check
/**
* Tests that there was at least one call.
*
* @param Call[] $calls
* @param ObjectProphecy $object
* @param MethodProphecy $method
*
* @throws \Prophecy\Exception\Prediction\NoCallsException
*/
public function check(array $calls, ObjectProphecy $object, MethodProphecy $method)
{
if (count($calls)) {
return;
}
$methodCalls = $object->findProphecyMethodCalls($method->getMethodName(), new ArgumentsWildcard(array(new AnyValuesToken())));
if (count($methodCalls)) {
throw new NoCallsException(sprintf("No calls have been made that match:\n" . " %s->%s(%s)\n" . "but expected at least one.\n" . "Recorded `%s(...)` calls:\n%s", get_class($object->reveal()), $method->getMethodName(), $method->getArgumentsWildcard(), $method->getMethodName(), $this->util->stringifyCalls($methodCalls)), $method);
}
throw new NoCallsException(sprintf("No calls have been made that match:\n" . " %s->%s(%s)\n" . "but expected at least one.", get_class($object->reveal()), $method->getMethodName(), $method->getArgumentsWildcard()), $method);
}
示例2: check
/**
* Tests that there was exact amount of calls made.
*
* @param Call[] $calls
* @param ObjectProphecy $object
* @param MethodProphecy $method
*
* @throws \Prophecy\Exception\Prediction\UnexpectedCallsCountException
*/
public function check(array $calls, ObjectProphecy $object, MethodProphecy $method)
{
if ($this->times == count($calls)) {
return;
}
$methodCalls = $object->findProphecyMethodCalls($method->getMethodName(), new ArgumentsWildcard(array(new AnyValuesToken())));
if (count($calls)) {
$message = sprintf("Expected exactly %d calls that match:\n" . " %s->%s(%s)\n" . "but %d were made:\n%s", $this->times, get_class($object->reveal()), $method->getMethodName(), $method->getArgumentsWildcard(), count($calls), $this->util->stringifyCalls($calls));
} elseif (count($methodCalls)) {
$message = sprintf("Expected exactly %d calls that match:\n" . " %s->%s(%s)\n" . "but none were made.\n" . "Recorded `%s(...)` calls:\n%s", $this->times, get_class($object->reveal()), $method->getMethodName(), $method->getArgumentsWildcard(), $method->getMethodName(), $this->util->stringifyCalls($methodCalls));
} else {
$message = sprintf("Expected exactly %d calls that match:\n" . " %s->%s(%s)\n" . "but none were made.", $this->times, get_class($object->reveal()), $method->getMethodName(), $method->getArgumentsWildcard());
}
throw new UnexpectedCallsCountException($message, $method, $this->times, $calls);
}
示例3: check
/**
* Tests that there were no calls made.
*
* @param Call[] $calls
* @param ObjectProphecy $object
* @param MethodProphecy $method
*
* @throws \Prophecy\Exception\Prediction\UnexpectedCallsException
*/
public function check(array $calls, ObjectProphecy $object, MethodProphecy $method)
{
if (!count($calls)) {
return;
}
throw new UnexpectedCallsException(sprintf("No calls expected that match:\n" . " %s->%s(%s)\n" . "but %d were made:\n%s", get_class($object->reveal()), $method->getMethodName(), $method->getArgumentsWildcard(), count($calls), $this->util->stringifyCalls($calls)), $method, $calls);
}
示例4:
/**
* @param \Prophecy\Prophecy\ObjectProphecy $object
* @param \Prophecy\Prophecy\MethodProphecy $method
* @param \Prophecy\Argument\ArgumentsWildcard $arguments
*/
function it_throws_NoCallsException_if_no_calls_found($object, $method, $arguments)
{
$method->getObjectProphecy()->willReturn($object);
$method->getMethodName()->willReturn('getName');
$method->getArgumentsWildcard()->willReturn($arguments);
$arguments->__toString()->willReturn('123');
$object->reveal()->willReturn(new \stdClass());
$object->findProphecyMethodCalls('getName', Argument::any())->willReturn(array());
$this->shouldThrow('Prophecy\\Exception\\Prediction\\NoCallsException')->duringCheck(array(), $object, $method);
}
示例5: array
function it_returns_null_if_method_prophecy_that_matches_makeCall_arguments_has_no_promise($objectProphecy, MethodProphecy $method, ArgumentsWildcard $arguments)
{
$method->getMethodName()->willReturn('getName');
$method->getArgumentsWildcard()->willReturn($arguments);
$method->getPromise()->willReturn(null);
$arguments->scoreArguments(array('world', 'everything'))->willReturn(100);
$objectProphecy->getMethodProphecies()->willReturn(array($method));
$objectProphecy->getMethodProphecies('getName')->willReturn(array($method));
$this->makeCall($objectProphecy, 'getName', array('world', 'everything'))->shouldReturn(null);
}
示例6:
/**
* @param \Prophecy\Prophecy\ObjectProphecy $object
* @param \Prophecy\Prophecy\MethodProphecy $method
* @param \Prophecy\Call\Call $call
* @param \Prophecy\Argument\ArgumentsWildcard $arguments
*/
function it_throws_UnexpectedCallsCountException_if_calls_found($object, $method, $call, $arguments)
{
$method->getObjectProphecy()->willReturn($object);
$method->getMethodName()->willReturn('getName');
$method->getArgumentsWildcard()->willReturn($arguments);
$arguments->__toString()->willReturn('123');
$call->getMethodName()->willReturn('getName');
$call->getArguments()->willReturn(array(5, 4, 'three'));
$call->getCallPlace()->willReturn('unknown');
$this->shouldThrow('Prophecy\\Exception\\Prediction\\UnexpectedCallsCountException')->duringCheck(array($call), $object, $method);
}
示例7:
/**
* @param \Prophecy\Prophecy\MethodProphecy $method1
* @param \Prophecy\Prophecy\MethodProphecy $method2
* @param \Prophecy\Argument\ArgumentsWildcard $arguments1
* @param \Prophecy\Argument\ArgumentsWildcard $arguments2
*/
function it_throws_AggregateException_if_defined_predictions_fail($method1, $method2, $arguments1, $arguments2)
{
$method1->getMethodName()->willReturn('getName');
$method1->getArgumentsWildcard()->willReturn($arguments1);
$method1->checkPrediction()->willReturn(null);
$method2->getMethodName()->willReturn('isSet');
$method2->getArgumentsWildcard()->willReturn($arguments2);
$method2->checkPrediction()->willThrow('Prophecy\\Exception\\Prediction\\AggregateException');
$this->prophesize()->addMethodProphecy($method1);
$this->prophesize()->addMethodProphecy($method2);
$this->shouldThrow('Prophecy\\Exception\\Prediction\\AggregateException')->duringCheckPredictions();
}
示例8:
/**
* @param \Prophecy\Prophecy\MethodProphecy $methodProphecy1
* @param \Prophecy\Prophecy\MethodProphecy $methodProphecy2
* @param \Prophecy\Argument\ArgumentsWildcard $argumentsWildcard1
* @param \Prophecy\Argument\ArgumentsWildcard $argumentsWildcard2
*/
function it_throws_AggregateException_during_checkPredictions_if_predictions_fail($methodProphecy1, $methodProphecy2, $argumentsWildcard1, $argumentsWildcard2)
{
$methodProphecy1->getMethodName()->willReturn('getName');
$methodProphecy1->getArgumentsWildcard()->willReturn($argumentsWildcard1);
$methodProphecy1->checkPrediction()->willThrow('Prophecy\\Exception\\Prediction\\AggregateException');
$methodProphecy2->getMethodName()->willReturn('setName');
$methodProphecy2->getArgumentsWildcard()->willReturn($argumentsWildcard2);
$methodProphecy2->checkPrediction()->willThrow('Prophecy\\Exception\\Prediction\\AggregateException');
$this->addMethodProphecy($methodProphecy1);
$this->addMethodProphecy($methodProphecy2);
$this->shouldThrow('Prophecy\\Exception\\Prediction\\AggregateException')->duringCheckProphecyMethodsPredictions();
}
示例9: addMethodProphecy
/**
* Adds method prophecy to object prophecy.
*
* @param MethodProphecy $methodProphecy
*
* @throws \Prophecy\Exception\Prophecy\MethodProphecyException If method prophecy doesn't
* have arguments wildcard
*/
public function addMethodProphecy(MethodProphecy $methodProphecy)
{
$argumentsWildcard = $methodProphecy->getArgumentsWildcard();
if (null === $argumentsWildcard) {
throw new MethodProphecyException(sprintf("Can not add prophecy for a method `%s::%s()`\n" . "as you did not specify arguments wildcard for it.", get_class($this->reveal()), $methodProphecy->getMethodName()), $methodProphecy);
}
$methodName = $methodProphecy->getMethodName();
if (!isset($this->methodProphecies[$methodName])) {
$this->methodProphecies[$methodName] = array();
}
$this->methodProphecies[$methodName][] = $methodProphecy;
}