No Description

KeywordPatchSpec.php 1.1KB

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