No Description

CallTimesPredictionSpec.php 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace spec\Prophecy\Prediction;
  3. use PhpSpec\ObjectBehavior;
  4. class CallTimesPredictionSpec extends ObjectBehavior
  5. {
  6. function let()
  7. {
  8. $this->beConstructedWith(2);
  9. }
  10. function it_is_prediction()
  11. {
  12. $this->shouldHaveType('Prophecy\Prediction\PredictionInterface');
  13. }
  14. /**
  15. * @param \Prophecy\Prophecy\ObjectProphecy $object
  16. * @param \Prophecy\Prophecy\MethodProphecy $method
  17. * @param \Prophecy\Call\Call $call1
  18. * @param \Prophecy\Call\Call $call2
  19. */
  20. function it_does_nothing_if_there_were_exact_amount_of_calls_being_made(
  21. $object, $method, $call1, $call2
  22. )
  23. {
  24. $this->check(array($call1, $call2), $object, $method)->shouldReturn(null);
  25. }
  26. /**
  27. * @param \Prophecy\Prophecy\ObjectProphecy $object
  28. * @param \Prophecy\Prophecy\MethodProphecy $method
  29. * @param \Prophecy\Call\Call $call
  30. * @param \Prophecy\Argument\ArgumentsWildcard $arguments
  31. */
  32. function it_throws_UnexpectedCallsCountException_if_calls_found(
  33. $object, $method, $call, $arguments
  34. )
  35. {
  36. $method->getObjectProphecy()->willReturn($object);
  37. $method->getMethodName()->willReturn('getName');
  38. $method->getArgumentsWildcard()->willReturn($arguments);
  39. $arguments->__toString()->willReturn('123');
  40. $call->getMethodName()->willReturn('getName');
  41. $call->getArguments()->willReturn(array(5, 4, 'three'));
  42. $call->getCallPlace()->willReturn('unknown');
  43. $this->shouldThrow('Prophecy\Exception\Prediction\UnexpectedCallsCountException')
  44. ->duringCheck(array($call), $object, $method);
  45. }
  46. }