No Description

MagicCallPatchSpec.php 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 MagicCallPatchSpec extends ObjectBehavior
  7. {
  8. function it_is_a_patch()
  9. {
  10. $this->shouldBeAnInstanceOf('Prophecy\Doubler\ClassPatch\ClassPatchInterface');
  11. }
  12. /**
  13. * @param \Prophecy\Doubler\Generator\Node\ClassNode $node
  14. */
  15. function it_supports_anything($node)
  16. {
  17. $this->supports($node)->shouldReturn(true);
  18. }
  19. /**
  20. * @param \Prophecy\Doubler\Generator\Node\ClassNode $node
  21. */
  22. function it_discovers_api_using_phpdoc($node)
  23. {
  24. $node->getParentClass()->willReturn('spec\Prophecy\Doubler\ClassPatch\MagicalApi');
  25. $node->addMethod(new MethodNode('undefinedMethod'))->shouldBeCalled();
  26. $this->apply($node);
  27. }
  28. /**
  29. * @param \Prophecy\Doubler\Generator\Node\ClassNode $node
  30. */
  31. function it_ignores_existing_methods($node)
  32. {
  33. $node->getParentClass()->willReturn('spec\Prophecy\Doubler\ClassPatch\MagicalApiExtended');
  34. $node->addMethod(new MethodNode('undefinedMethod'))->shouldBeCalled();
  35. $node->addMethod(new MethodNode('definedMethod'))->shouldNotBeCalled();
  36. $this->apply($node);
  37. }
  38. function it_has_50_priority()
  39. {
  40. $this->getPriority()->shouldReturn(50);
  41. }
  42. }
  43. /**
  44. * @method void undefinedMethod()
  45. */
  46. class MagicalApi
  47. {
  48. /**
  49. * @return void
  50. */
  51. public function definedMethod()
  52. {
  53. }
  54. }
  55. /**
  56. * @method void undefinedMethod()
  57. * @method void definedMethod()
  58. */
  59. class MagicalApiExtended extends MagicalApi
  60. {
  61. }