No Description

ArrayCountTokenSpec.php 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. /**
  23. * @param \Countable $countable
  24. */
  25. function it_scores_6_if_argument_countable_object_has_proper_count($countable)
  26. {
  27. $countable->count()->willReturn(2);
  28. $this->scoreArgument($countable)->shouldReturn(6);
  29. }
  30. function it_does_not_score_if_argument_is_neither_array_nor_countable_object()
  31. {
  32. $this->scoreArgument('string')->shouldBe(false);
  33. $this->scoreArgument(5)->shouldBe(false);
  34. $this->scoreArgument(new \stdClass)->shouldBe(false);
  35. }
  36. function it_does_not_score_if_argument_array_has_wrong_count()
  37. {
  38. $this->scoreArgument(array(1))->shouldReturn(false);
  39. }
  40. /**
  41. * @param \Countable $countable
  42. */
  43. function it_does_not_score_if_argument_countable_object_has_wrong_count($countable)
  44. {
  45. $countable->count()->willReturn(3);
  46. $this->scoreArgument($countable)->shouldReturn(false);
  47. }
  48. function it_has_simple_string_representation()
  49. {
  50. $this->__toString()->shouldBe('count(2)');
  51. }
  52. }