ArrayCountTokenSpec.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace spec\Prophecy\Argument\Token;
  3. use PhpSpec\ObjectBehavior;
  4. class ArrayCountTokenSpec extends ObjectBehavior
  5. {
  6. function let()
  7. {
  8. $this->beConstructedWith(2);
  9. }
  10. function it_implements_TokenInterface()
  11. {
  12. $this->shouldBeAnInstanceOf('Prophecy\Argument\Token\TokenInterface');
  13. }
  14. function it_is_not_last()
  15. {
  16. $this->shouldNotBeLast();
  17. }
  18. function it_scores_6_if_argument_array_has_proper_count()
  19. {
  20. $this->scoreArgument(array(1,2))->shouldReturn(6);
  21. }
  22. function it_scores_6_if_argument_countable_object_has_proper_count(\Countable $countable)
  23. {
  24. $countable->count()->willReturn(2);
  25. $this->scoreArgument($countable)->shouldReturn(6);
  26. }
  27. function it_does_not_score_if_argument_is_neither_array_nor_countable_object()
  28. {
  29. $this->scoreArgument('string')->shouldBe(false);
  30. $this->scoreArgument(5)->shouldBe(false);
  31. $this->scoreArgument(new \stdClass)->shouldBe(false);
  32. }
  33. function it_does_not_score_if_argument_array_has_wrong_count()
  34. {
  35. $this->scoreArgument(array(1))->shouldReturn(false);
  36. }
  37. function it_does_not_score_if_argument_countable_object_has_wrong_count(\Countable $countable)
  38. {
  39. $countable->count()->willReturn(3);
  40. $this->scoreArgument($countable)->shouldReturn(false);
  41. }
  42. function it_has_simple_string_representation()
  43. {
  44. $this->__toString()->shouldBe('count(2)');
  45. }
  46. }