No Description

KeywordPatchSpec.php 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace spec\Prophecy\Doubler\ClassPatch;
  3. use PhpSpec\ObjectBehavior;
  4. use Prophecy\Argument;
  5. use Prophecy\Doubler\Generator\Node\MethodNode;
  6. class KeywordPatchSpec extends ObjectBehavior
  7. {
  8. function it_is_a_patch()
  9. {
  10. $this->shouldBeAnInstanceOf('Prophecy\Doubler\ClassPatch\ClassPatchInterface');
  11. }
  12. function its_priority_is_50()
  13. {
  14. $this->getPriority()->shouldReturn(50);
  15. }
  16. /**
  17. * @param \Prophecy\Doubler\Generator\Node\ClassNode $node
  18. * @param \Prophecy\Doubler\Generator\Node\MethodNode $method1
  19. * @param \Prophecy\Doubler\Generator\Node\MethodNode $method2
  20. * @param \Prophecy\Doubler\Generator\Node\MethodNode $method3
  21. */
  22. function it_will_remove_echo_and_eval_methods($node, $method1, $method2, $method3)
  23. {
  24. $node->removeMethod('eval')->shouldBeCalled();
  25. $node->removeMethod('echo')->shouldBeCalled();
  26. $method1->getName()->willReturn('echo');
  27. $method2->getName()->willReturn('eval');
  28. $method3->getName()->willReturn('notKeyword');
  29. $node->getMethods()->willReturn(array(
  30. 'echo' => $method1,
  31. 'eval' => $method2,
  32. 'notKeyword' => $method3,
  33. ));
  34. $this->apply($node);
  35. }
  36. }