CallTimesPredictionSpec.php 1.5 KB

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