No Description

TraversablePatchSpec.php 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace spec\Prophecy\Doubler\ClassPatch;
  3. use PhpSpec\ObjectBehavior;
  4. use Prophecy\Argument;
  5. class TraversablePatchSpec extends ObjectBehavior
  6. {
  7. function it_is_a_patch()
  8. {
  9. $this->shouldBeAnInstanceOf('Prophecy\Doubler\ClassPatch\ClassPatchInterface');
  10. }
  11. /**
  12. * @param \Prophecy\Doubler\Generator\Node\ClassNode $node
  13. */
  14. function it_supports_class_that_implements_only_Traversable($node)
  15. {
  16. $node->getInterfaces()->willReturn(array('Traversable'));
  17. $this->supports($node)->shouldReturn(true);
  18. }
  19. /**
  20. * @param \Prophecy\Doubler\Generator\Node\ClassNode $node
  21. */
  22. function it_does_not_support_class_that_implements_Iterator($node)
  23. {
  24. $node->getInterfaces()->willReturn(array('Traversable', 'Iterator'));
  25. $this->supports($node)->shouldReturn(false);
  26. }
  27. /**
  28. * @param \Prophecy\Doubler\Generator\Node\ClassNode $node
  29. */
  30. function it_does_not_support_class_that_implements_IteratorAggregate($node)
  31. {
  32. $node->getInterfaces()->willReturn(array('Traversable', 'IteratorAggregate'));
  33. $this->supports($node)->shouldReturn(false);
  34. }
  35. function it_has_100_priority()
  36. {
  37. $this->getPriority()->shouldReturn(100);
  38. }
  39. /**
  40. * @param \Prophecy\Doubler\Generator\Node\ClassNode $node
  41. */
  42. function it_forces_node_to_implement_IteratorAggregate($node)
  43. {
  44. $node->addInterface('Iterator')->shouldBeCalled();
  45. $node->addMethod(Argument::type('Prophecy\Doubler\Generator\Node\MethodNode'))->willReturn(null);
  46. $this->apply($node);
  47. }
  48. }