CallSpec.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace spec\Prophecy\Call;
  3. use PhpSpec\ObjectBehavior;
  4. use Prophecy\Argument\ArgumentsWildcard;
  5. class CallSpec extends ObjectBehavior
  6. {
  7. function let(\Exception $exception)
  8. {
  9. $this->beConstructedWith('setValues', array(5, 2), 42, $exception, 'some_file.php', 23);
  10. }
  11. function it_exposes_method_name_through_getter()
  12. {
  13. $this->getMethodName()->shouldReturn('setValues');
  14. }
  15. function it_exposes_arguments_through_getter()
  16. {
  17. $this->getArguments()->shouldReturn(array(5, 2));
  18. }
  19. function it_exposes_return_value_through_getter()
  20. {
  21. $this->getReturnValue()->shouldReturn(42);
  22. }
  23. function it_exposes_exception_through_getter($exception)
  24. {
  25. $this->getException()->shouldReturn($exception);
  26. }
  27. function it_exposes_file_and_line_through_getter()
  28. {
  29. $this->getFile()->shouldReturn('some_file.php');
  30. $this->getLine()->shouldReturn(23);
  31. }
  32. function it_returns_shortpath_to_callPlace()
  33. {
  34. $this->getCallPlace()->shouldReturn('some_file.php:23');
  35. }
  36. function it_returns_unknown_as_callPlace_if_no_file_or_line_provided()
  37. {
  38. $this->beConstructedWith('setValues', array(), 0, null, null, null);
  39. $this->getCallPlace()->shouldReturn('unknown');
  40. }
  41. function it_adds_wildcard_match_score(ArgumentsWildcard $wildcard)
  42. {
  43. $this->addScore($wildcard, 99)->shouldReturn($this);
  44. $this->getScore($wildcard)->shouldReturn(99);
  45. }
  46. function it_caches_and_returns_wildcard_match_score(ArgumentsWildcard $wildcard)
  47. {
  48. $wildcard->scoreArguments(array(5, 2))->willReturn(13)->shouldBeCalledTimes(1);
  49. $this->getScore($wildcard)->shouldReturn(13);
  50. $this->getScore($wildcard)->shouldReturn(13);
  51. }
  52. }