CallTimesPredictionSpec.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. }