當前位置: 首頁>>代碼示例>>PHP>>正文


PHP MethodProphecy::getMethodName方法代碼示例

本文整理匯總了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);
 }
開發者ID:scrobot,項目名稱:Lumen,代碼行數:20,代碼來源:CallPrediction.php

示例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);
 }
開發者ID:ngitimfoyo,項目名稱:Nyari-AppPHP,代碼行數:24,代碼來源:CallTimesPrediction.php

示例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);
 }
開發者ID:burimshala,項目名稱:numbertowords,代碼行數:16,代碼來源:NoCallsPrediction.php

示例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);
 }
開發者ID:EnmanuelCode,項目名稱:backend-laravel,代碼行數:15,代碼來源:CallPredictionSpec.php

示例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);
 }
開發者ID:phpspec,項目名稱:prophecy,代碼行數:10,代碼來源:CallCenterSpec.php

示例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);
 }
開發者ID:Ceciceciceci,項目名稱:MySJSU-Class-Registration,代碼行數:17,代碼來源:CallTimesPredictionSpec.php

示例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();
 }
開發者ID:TheTypoMaster,項目名稱:SPHERE-Framework,代碼行數:18,代碼來源:ProphetSpec.php

示例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();
 }
開發者ID:burimshala,項目名稱:numbertowords,代碼行數:18,代碼來源:ObjectProphecySpec.php

示例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;
 }
開發者ID:NikoNick,項目名稱:EventsBerry,代碼行數:20,代碼來源:ObjectProphecy.php


注:本文中的Prophecy\Prophecy\MethodProphecy::getMethodName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。