No Description

ReflectionClassNewInstancePatchSpec.php 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace spec\Prophecy\Doubler\ClassPatch;
  3. use PhpSpec\ObjectBehavior;
  4. use Prophecy\Argument;
  5. class ReflectionClassNewInstancePatchSpec extends ObjectBehavior
  6. {
  7. function it_is_a_patch()
  8. {
  9. $this->shouldBeAnInstanceOf('Prophecy\Doubler\ClassPatch\ClassPatchInterface');
  10. }
  11. function its_priority_is_50()
  12. {
  13. $this->getPriority()->shouldReturn(50);
  14. }
  15. /**
  16. * @param \Prophecy\Doubler\Generator\Node\ClassNode $reflectionClassNode
  17. * @param \Prophecy\Doubler\Generator\Node\ClassNode $anotherClassNode
  18. */
  19. function it_supports_ReflectionClass_only($reflectionClassNode, $anotherClassNode)
  20. {
  21. $reflectionClassNode->getParentClass()->willReturn('ReflectionClass');
  22. $anotherClassNode->getParentClass()->willReturn('stdClass');
  23. $this->supports($reflectionClassNode)->shouldReturn(true);
  24. $this->supports($anotherClassNode)->shouldReturn(false);
  25. }
  26. /**
  27. * @param \Prophecy\Doubler\Generator\Node\ClassNode $class
  28. * @param \Prophecy\Doubler\Generator\Node\MethodNode $method
  29. * @param \Prophecy\Doubler\Generator\Node\ArgumentNode $arg1
  30. * @param \Prophecy\Doubler\Generator\Node\ArgumentNode $arg2
  31. */
  32. function it_makes_all_newInstance_arguments_optional($class, $method, $arg1, $arg2)
  33. {
  34. $class->getMethod('newInstance')->willReturn($method);
  35. $method->getArguments()->willReturn(array($arg1));
  36. $arg1->setDefault(null)->shouldBeCalled();
  37. $this->apply($class);
  38. }
  39. }