Mercurial > hg > isophonics-drupal-site
comparison vendor/phpspec/prophecy/spec/Prophecy/Doubler/ClassPatch/MagicCallPatchSpec.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\ClassNode; | |
8 use Prophecy\Doubler\Generator\Node\MethodNode; | |
9 | |
10 class MagicCallPatchSpec extends ObjectBehavior | |
11 { | |
12 function it_is_a_patch() | |
13 { | |
14 $this->shouldBeAnInstanceOf('Prophecy\Doubler\ClassPatch\ClassPatchInterface'); | |
15 } | |
16 | |
17 function it_supports_anything(ClassNode $node) | |
18 { | |
19 $this->supports($node)->shouldReturn(true); | |
20 } | |
21 | |
22 function it_discovers_api_using_phpdoc(ClassNode $node) | |
23 { | |
24 $node->getParentClass()->willReturn('spec\Prophecy\Doubler\ClassPatch\MagicalApi'); | |
25 $node->getInterfaces()->willReturn(array()); | |
26 | |
27 $node->addMethod(new MethodNode('undefinedMethod'))->shouldBeCalled(); | |
28 | |
29 $this->apply($node); | |
30 } | |
31 | |
32 function it_ignores_existing_methods(ClassNode $node) | |
33 { | |
34 $node->getParentClass()->willReturn('spec\Prophecy\Doubler\ClassPatch\MagicalApiExtended'); | |
35 $node->getInterfaces()->willReturn(array()); | |
36 | |
37 $node->addMethod(new MethodNode('undefinedMethod'))->shouldBeCalled(); | |
38 $node->addMethod(new MethodNode('definedMethod'))->shouldNotBeCalled(); | |
39 | |
40 $this->apply($node); | |
41 } | |
42 | |
43 function it_ignores_empty_methods_from_phpdoc(ClassNode $node) | |
44 { | |
45 $node->getParentClass()->willReturn('spec\Prophecy\Doubler\ClassPatch\MagicalApiInvalidMethodDefinition'); | |
46 $node->getInterfaces()->willReturn(array()); | |
47 | |
48 $node->addMethod(new MethodNode(''))->shouldNotBeCalled(); | |
49 | |
50 $this->apply($node); | |
51 } | |
52 | |
53 function it_discovers_api_using_phpdoc_from_implemented_interfaces(ClassNode $node) | |
54 { | |
55 $node->getParentClass()->willReturn('spec\Prophecy\Doubler\ClassPatch\MagicalApiImplemented'); | |
56 $node->getInterfaces()->willReturn(array()); | |
57 | |
58 $node->addMethod(new MethodNode('implementedMethod'))->shouldBeCalled(); | |
59 | |
60 $this->apply($node); | |
61 } | |
62 | |
63 function it_discovers_api_using_phpdoc_from_own_interfaces(ClassNode $node) | |
64 { | |
65 $node->getParentClass()->willReturn('stdClass'); | |
66 $node->getInterfaces()->willReturn(array('spec\Prophecy\Doubler\ClassPatch\MagicalApiImplemented')); | |
67 | |
68 $node->addMethod(new MethodNode('implementedMethod'))->shouldBeCalled(); | |
69 | |
70 $this->apply($node); | |
71 } | |
72 | |
73 function it_discovers_api_using_phpdoc_from_extended_parent_interfaces(ClassNode $node) | |
74 { | |
75 $node->getParentClass()->willReturn('spec\Prophecy\Doubler\ClassPatch\MagicalApiImplementedExtended'); | |
76 $node->getInterfaces()->willReturn(array()); | |
77 | |
78 $node->addMethod(new MethodNode('implementedMethod'))->shouldBeCalled(); | |
79 | |
80 $this->apply($node); | |
81 } | |
82 | |
83 function it_has_50_priority() | |
84 { | |
85 $this->getPriority()->shouldReturn(50); | |
86 } | |
87 } | |
88 | |
89 /** | |
90 * @method void undefinedMethod() | |
91 */ | |
92 class MagicalApi | |
93 { | |
94 /** | |
95 * @return void | |
96 */ | |
97 public function definedMethod() | |
98 { | |
99 | |
100 } | |
101 } | |
102 | |
103 /** | |
104 * @method void invalidMethodDefinition | |
105 * @method void | |
106 * @method | |
107 */ | |
108 class MagicalApiInvalidMethodDefinition | |
109 { | |
110 } | |
111 | |
112 /** | |
113 * @method void undefinedMethod() | |
114 * @method void definedMethod() | |
115 */ | |
116 class MagicalApiExtended extends MagicalApi | |
117 { | |
118 | |
119 } | |
120 | |
121 /** | |
122 */ | |
123 class MagicalApiImplemented implements MagicalApiInterface | |
124 { | |
125 | |
126 } | |
127 | |
128 /** | |
129 */ | |
130 class MagicalApiImplementedExtended extends MagicalApiImplemented | |
131 { | |
132 } | |
133 | |
134 /** | |
135 * @method void implementedMethod() | |
136 */ | |
137 interface MagicalApiInterface | |
138 { | |
139 | |
140 } |