Mercurial > hg > isophonics-drupal-site
annotate vendor/phpspec/prophecy/spec/Prophecy/Doubler/ClassPatch/DisableConstructorPatchSpec.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children |
rev | line source |
---|---|
Chris@0 | 1 <?php |
Chris@0 | 2 |
Chris@0 | 3 namespace spec\Prophecy\Doubler\ClassPatch; |
Chris@0 | 4 |
Chris@0 | 5 use PhpSpec\ObjectBehavior; |
Chris@0 | 6 use Prophecy\Argument; |
Chris@0 | 7 use Prophecy\Doubler\Generator\Node\ArgumentNode; |
Chris@0 | 8 use Prophecy\Doubler\Generator\Node\ClassNode; |
Chris@0 | 9 use Prophecy\Doubler\Generator\Node\MethodNode; |
Chris@0 | 10 |
Chris@0 | 11 class DisableConstructorPatchSpec extends ObjectBehavior |
Chris@0 | 12 { |
Chris@0 | 13 function it_is_a_patch() |
Chris@0 | 14 { |
Chris@0 | 15 $this->shouldBeAnInstanceOf('Prophecy\Doubler\ClassPatch\ClassPatchInterface'); |
Chris@0 | 16 } |
Chris@0 | 17 |
Chris@0 | 18 function its_priority_is_100() |
Chris@0 | 19 { |
Chris@0 | 20 $this->getPriority()->shouldReturn(100); |
Chris@0 | 21 } |
Chris@0 | 22 |
Chris@0 | 23 function it_supports_anything(ClassNode $node) |
Chris@0 | 24 { |
Chris@0 | 25 $this->supports($node)->shouldReturn(true); |
Chris@0 | 26 } |
Chris@0 | 27 |
Chris@0 | 28 function it_makes_all_constructor_arguments_optional( |
Chris@0 | 29 ClassNode $class, |
Chris@0 | 30 MethodNode $method, |
Chris@0 | 31 ArgumentNode $arg1, |
Chris@0 | 32 ArgumentNode $arg2 |
Chris@0 | 33 ) { |
Chris@0 | 34 $class->hasMethod('__construct')->willReturn(true); |
Chris@0 | 35 $class->getMethod('__construct')->willReturn($method); |
Chris@0 | 36 $method->getArguments()->willReturn(array($arg1, $arg2)); |
Chris@0 | 37 |
Chris@0 | 38 $arg1->setDefault(null)->shouldBeCalled(); |
Chris@0 | 39 $arg2->setDefault(null)->shouldBeCalled(); |
Chris@0 | 40 |
Chris@0 | 41 $method->setCode(Argument::type('string'))->shouldBeCalled(); |
Chris@0 | 42 |
Chris@0 | 43 $this->apply($class); |
Chris@0 | 44 } |
Chris@0 | 45 |
Chris@0 | 46 function it_creates_new_constructor_if_object_has_none(ClassNode $class) |
Chris@0 | 47 { |
Chris@0 | 48 $class->hasMethod('__construct')->willReturn(false); |
Chris@0 | 49 $class->addMethod(Argument::type('Prophecy\Doubler\Generator\Node\MethodNode')) |
Chris@0 | 50 ->shouldBeCalled(); |
Chris@0 | 51 |
Chris@0 | 52 $this->apply($class); |
Chris@0 | 53 } |
Chris@0 | 54 } |