No Description

LogicalAndTokenSpec.php 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. namespace spec\Prophecy\Argument\Token;
  3. use PhpSpec\ObjectBehavior;
  4. use Prophecy\Argument;
  5. class LogicalAndTokenSpec extends ObjectBehavior
  6. {
  7. function it_implements_TokenInterface()
  8. {
  9. $this->beConstructedWith(array());
  10. $this->shouldBeAnInstanceOf('Prophecy\Argument\Token\TokenInterface');
  11. }
  12. function it_is_not_last()
  13. {
  14. $this->beConstructedWith(array());
  15. $this->shouldNotBeLast();
  16. }
  17. /**
  18. * @param \Prophecy\Argument\Token\TokenInterface $token1
  19. * @param \Prophecy\Argument\Token\TokenInterface $token2
  20. * @param \Prophecy\Argument\Token\TokenInterface $token3
  21. */
  22. function it_generates_string_representation_from_all_tokens_imploded($token1, $token2, $token3)
  23. {
  24. $token1->__toString()->willReturn('token_1');
  25. $token2->__toString()->willReturn('token_2');
  26. $token3->__toString()->willReturn('token_3');
  27. $this->beConstructedWith(array($token1, $token2, $token3));
  28. $this->__toString()->shouldReturn('bool(token_1 AND token_2 AND token_3)');
  29. }
  30. function it_wraps_non_token_arguments_into_ExactValueToken()
  31. {
  32. $this->beConstructedWith(array(15, '1985'));
  33. $this->__toString()->shouldReturn("bool(exact(15) AND exact(\"1985\"))");
  34. }
  35. /**
  36. * @param \Prophecy\Argument\Token\TokenInterface $token1
  37. * @param \Prophecy\Argument\Token\TokenInterface $token2
  38. */
  39. function it_scores_the_maximum_score_from_all_scores_returned_by_tokens($token1, $token2)
  40. {
  41. $token1->scoreArgument(1)->willReturn(10);
  42. $token2->scoreArgument(1)->willReturn(5);
  43. $this->beConstructedWith(array($token1, $token2));
  44. $this->scoreArgument(1)->shouldReturn(10);
  45. }
  46. function it_does_not_score_if_there_are_no_arguments_or_tokens()
  47. {
  48. $this->beConstructedWith(array());
  49. $this->scoreArgument('any')->shouldReturn(false);
  50. }
  51. /**
  52. * @param \Prophecy\Argument\Token\TokenInterface $token1
  53. * @param \Prophecy\Argument\Token\TokenInterface $token2
  54. */
  55. function it_does_not_score_if_either_of_tokens_does_not_score($token1, $token2)
  56. {
  57. $token1->scoreArgument(1)->willReturn(10);
  58. $token1->scoreArgument(2)->willReturn(false);
  59. $token2->scoreArgument(1)->willReturn(false);
  60. $token2->scoreArgument(2)->willReturn(10);
  61. $this->beConstructedWith(array($token1, $token2));
  62. $this->scoreArgument(1)->shouldReturn(false);
  63. $this->scoreArgument(2)->shouldReturn(false);
  64. }
  65. }