NoCallsPredictionSpec.php 1.4 KB

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