CallPredictionSpec.php 1.4 KB

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