Нет описания

ObjectStateTokenSpec.php 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. namespace spec\Prophecy\Argument\Token;
  3. use PhpSpec\ObjectBehavior;
  4. class MyClass
  5. {
  6. }
  7. class ObjectStateTokenSpec extends ObjectBehavior
  8. {
  9. function let()
  10. {
  11. $this->beConstructedWith('getName', 'stdClass');
  12. }
  13. function it_implements_TokenInterface()
  14. {
  15. $this->shouldBeAnInstanceOf('Prophecy\Argument\Token\TokenInterface');
  16. }
  17. function it_is_not_last()
  18. {
  19. $this->shouldNotBeLast();
  20. }
  21. /**
  22. * @param \ReflectionClass $reflection
  23. */
  24. function it_scores_8_if_argument_object_has_specific_method_state($reflection)
  25. {
  26. $reflection->getName()->willReturn('stdClass');
  27. $this->scoreArgument($reflection)->shouldReturn(8);
  28. }
  29. /**
  30. * @param \stdClass $class
  31. */
  32. function it_scores_8_if_argument_object_has_specific_property_state($class)
  33. {
  34. $class->getName = 'stdClass';
  35. $this->scoreArgument($class)->shouldReturn(8);
  36. }
  37. /**
  38. * @param \ReflectionClass $reflection
  39. */
  40. function it_does_not_score_if_argument_method_state_does_not_match($reflection)
  41. {
  42. $reflection->getName()->willReturn('SplFileInfo');
  43. $this->scoreArgument($reflection)->shouldReturn(false);
  44. }
  45. /**
  46. * @param \stdClass $class
  47. */
  48. function it_does_not_score_if_argument_property_state_does_not_match($class)
  49. {
  50. $class->getName = 'SplFileInfo';
  51. $this->scoreArgument($class)->shouldReturn(false);
  52. }
  53. /**
  54. * @param \spec\Prophecy\Argument\Token\MyClass $class
  55. */
  56. function it_does_not_score_if_argument_object_does_not_have_method_or_property($class)
  57. {
  58. $this->scoreArgument($class)->shouldReturn(false);
  59. }
  60. function it_does_not_score_if_argument_is_not_object()
  61. {
  62. $this->scoreArgument(42)->shouldReturn(false);
  63. }
  64. function it_has_simple_string_representation()
  65. {
  66. $this->__toString()->shouldReturn('state(getName(), "stdClass")');
  67. }
  68. }