Mercurial > hg > isophonics-drupal-site
comparison 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 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 namespace spec\Prophecy\Doubler\ClassPatch; | |
4 | |
5 use PhpSpec\ObjectBehavior; | |
6 use Prophecy\Argument; | |
7 use Prophecy\Doubler\Generator\Node\ArgumentNode; | |
8 use Prophecy\Doubler\Generator\Node\ClassNode; | |
9 use Prophecy\Doubler\Generator\Node\MethodNode; | |
10 | |
11 class DisableConstructorPatchSpec extends ObjectBehavior | |
12 { | |
13 function it_is_a_patch() | |
14 { | |
15 $this->shouldBeAnInstanceOf('Prophecy\Doubler\ClassPatch\ClassPatchInterface'); | |
16 } | |
17 | |
18 function its_priority_is_100() | |
19 { | |
20 $this->getPriority()->shouldReturn(100); | |
21 } | |
22 | |
23 function it_supports_anything(ClassNode $node) | |
24 { | |
25 $this->supports($node)->shouldReturn(true); | |
26 } | |
27 | |
28 function it_makes_all_constructor_arguments_optional( | |
29 ClassNode $class, | |
30 MethodNode $method, | |
31 ArgumentNode $arg1, | |
32 ArgumentNode $arg2 | |
33 ) { | |
34 $class->hasMethod('__construct')->willReturn(true); | |
35 $class->getMethod('__construct')->willReturn($method); | |
36 $method->getArguments()->willReturn(array($arg1, $arg2)); | |
37 | |
38 $arg1->setDefault(null)->shouldBeCalled(); | |
39 $arg2->setDefault(null)->shouldBeCalled(); | |
40 | |
41 $method->setCode(Argument::type('string'))->shouldBeCalled(); | |
42 | |
43 $this->apply($class); | |
44 } | |
45 | |
46 function it_creates_new_constructor_if_object_has_none(ClassNode $class) | |
47 { | |
48 $class->hasMethod('__construct')->willReturn(false); | |
49 $class->addMethod(Argument::type('Prophecy\Doubler\Generator\Node\MethodNode')) | |
50 ->shouldBeCalled(); | |
51 | |
52 $this->apply($class); | |
53 } | |
54 } |