blob: 6c1a26f7a2194b1a8eb777bff57ed5d50e0d17b2 [file] [log] [blame]
Brent Shaffer12acbc22017-06-27 16:28:28 -07001<?php
2
3require_once('generated/NoNamespaceEnum.php');
4require_once('generated/NoNamespaceMessage.php');
5require_once('test_base.php');
6require_once('test_util.php');
7
8use Foo\TestMessage;
9
10class GeneratedPhpdocTest extends TestBase
11{
12 public function testPhpDocForClass()
13 {
14 $class = new ReflectionClass('Foo\TestMessage');
15 $doc = $class->getDocComment();
16 $this->assertContains('foo.TestMessage', $doc);
17 }
18
19 /**
20 * @dataProvider providePhpDocForGettersAndSetters
21 */
22 public function testPhpDocForIntGetters($methods, $expectedDoc)
23 {
24 $class = new ReflectionClass('Foo\TestMessage');
25 foreach ($methods as $method) {
26 $doc = $class->getMethod($method)->getDocComment();
27 $this->assertContains($expectedDoc, $doc);
28 }
29 }
30
31 public function providePhpDocForGettersAndSetters()
32 {
33 return [
34 [
35 [
36 'setOptionalInt32',
37 'setOptionalUint32',
38 'setOptionalSint32',
39 'setOptionalFixed32',
40 'setOptionalSfixed32',
41 'setOneofInt32',
42 'setOneofUint32',
43 'setOneofSint32',
44 'setOneofFixed32',
45 'setOneofSfixed32',
46 'setOptionalEnum',
47 'setOptionalNoNamespaceEnum',
48 'setOptionalNestedEnum',
49 'setOneofEnum'
50 ],
51 '@param int $var'
52 ],
53 [
54 [
55 'setOptionalInt64',
56 'setOptionalUint64',
57 'setOptionalSint64',
58 'setOptionalFixed64',
59 'setOptionalSfixed64',
60 'setOneofInt64',
61 'setOneofUint64',
62 'setOneofSint64',
63 'setOneofFixed64',
64 'setOneofSfixed64',
65 ],
66 '@param int|string $var'
67 ],
68 [
69 [
70 'getOptionalInt32',
71 'getOptionalUint32',
72 'getOptionalSint32',
73 'getOptionalFixed32',
74 'getOptionalSfixed32',
75 'getOneofInt32',
76 'getOneofUint32',
77 'getOneofSint32',
78 'getOneofFixed32',
79 'getOneofSfixed32',
80 'getOptionalEnum',
81 'getOptionalNoNamespaceEnum',
82 'getOptionalNestedEnum',
83 'getOneofEnum',
84 ],
85 '@return int'
86 ],
87 [
88 [
89 'setOptionalInt64',
90 'setOptionalUint64',
91 'setOptionalSint64',
92 'setOptionalFixed64',
93 'setOptionalSfixed64',
94 'setOneofInt64',
95 'setOneofUint64',
96 'setOneofSint64',
97 'setOneofFixed64',
98 'setOneofSfixed64',
99 ],
100 '@param int|string $var'
101 ],
102 [
103 [
104 'getRepeatedInt32',
105 'getRepeatedInt64',
106 'getRepeatedUint32',
107 'getRepeatedUint64',
108 'getRepeatedSint32',
109 'getRepeatedSint64',
110 'getRepeatedFixed32',
111 'getRepeatedFixed64',
112 'getRepeatedSfixed32',
113 'getRepeatedSfixed64',
114 'getRepeatedFloat',
115 'getRepeatedDouble',
116 'getRepeatedBool',
117 'getRepeatedString',
118 'getRepeatedBytes',
119 'getRepeatedEnum',
120 'getRepeatedMessage',
121 'getRepeatedRecursive',
122 'getRepeatedNoNamespaceMessage',
123 'getRepeatedNoNamespaceEnum',
124 ],
125 '@return \Google\Protobuf\Internal\RepeatedField'
126 ],
127 [
128 [
129 'getMapInt32Int32',
130 'getMapInt64Int64',
131 'getMapUint32Uint32',
132 'getMapUint64Uint64',
133 'getMapSint32Sint32',
134 'getMapSint64Sint64',
135 'getMapFixed32Fixed32',
136 'getMapFixed64Fixed64',
137 'getMapSfixed32Sfixed32',
138 'getMapSfixed64Sfixed64',
139 'getMapInt32Float',
140 'getMapInt32Double',
141 'getMapBoolBool',
142 'getMapStringString',
143 'getMapInt32Bytes',
144 'getMapInt32Enum',
145 'getMapInt32Message',
146 'getMapRecursive',
147 ],
148 '@return \Google\Protobuf\Internal\MapField'
149 ],
150 [
151 [
152 'setRepeatedInt32',
153 'setRepeatedUint32',
154 'setRepeatedSint32',
155 'setRepeatedFixed32',
156 'setRepeatedSfixed32',
157 'setRepeatedEnum',
158 'setRepeatedNoNamespaceEnum',
159 ],
160 '@param int[]|\Google\Protobuf\Internal\RepeatedField $var'
161 ],
162 [
163 [
164 'setRepeatedInt64',
165 'setRepeatedUint64',
166 'setRepeatedSint64',
167 'setRepeatedFixed64',
168 'setRepeatedSfixed64',
169 ],
170 '@param int[]|string[]|\Google\Protobuf\Internal\RepeatedField $var'
171 ],
172 [
173 [
174 'setRepeatedFloat',
175 'setRepeatedDouble',
176 ],
177 '@param float[]|\Google\Protobuf\Internal\RepeatedField $var'
178 ],
179 [
180 [
181 'setRepeatedBool',
182 ],
183 '@param bool[]|\Google\Protobuf\Internal\RepeatedField $var'
184 ],
185 [
186 [
187 'setRepeatedString',
188 'setRepeatedBytes',
189 ],
190 '@param string[]|\Google\Protobuf\Internal\RepeatedField $var'
191 ],
192 [
193 [
194 'setRepeatedMessage',
195 ],
196 '@param \Foo\TestMessage_Sub[]|\Google\Protobuf\Internal\RepeatedField $var'
197 ],
198 [
199 [
200 'setRepeatedRecursive',
201 ],
202 '@param \Foo\TestMessage[]|\Google\Protobuf\Internal\RepeatedField $var'
203 ],
204 [
205 [
206 'setRepeatedNoNamespaceMessage',
207 ],
208 '@param \NoNamespaceMessage[]|\Google\Protobuf\Internal\RepeatedField $var'
209 ],
210 [
211 [
212 'setMapInt32Int32',
213 'setMapInt64Int64',
214 'setMapUint32Uint32',
215 'setMapUint64Uint64',
216 'setMapSint32Sint32',
217 'setMapSint64Sint64',
218 'setMapFixed32Fixed32',
219 'setMapFixed64Fixed64',
220 'setMapSfixed32Sfixed32',
221 'setMapSfixed64Sfixed64',
222 'setMapInt32Float',
223 'setMapInt32Double',
224 'setMapBoolBool',
225 'setMapStringString',
226 'setMapInt32Bytes',
227 'setMapInt32Enum',
228 'setMapInt32Message',
229 'setMapRecursive',
230 ],
231 '@param array|\Google\Protobuf\Internal\MapField $var'
232 ],
233 [
234 [
235 'getOptionalFloat',
236 'getOptionalDouble',
237 'getOneofDouble',
238 'getOneofFloat',
239 ],
240 '@return float'
241 ],
242 [
243 [
244 'setOptionalFloat',
245 'setOptionalDouble',
246 'setOneofDouble',
247 'setOneofFloat',
248 ],
249 '@param float $var'
250 ],
251 [
252 [
253 'getOptionalBool',
254 'getOneofBool',
255 ],
256 '@return bool'],
257 [
258 [
259 'setOptionalBool',
260 'setOneofBool',
261 ],
262 '@param bool $var'
263 ],
264 [
265 [
266 'getOptionalString',
267 'getOptionalBytes',
268 'getOneofString',
269 'getOneofBytes',
270 'getMyOneof',
271 ],
272 '@return string'
273 ],
274 [
275 [
276 'setOptionalString',
277 'setOptionalBytes',
278 'setOneofString',
279 'setOneofBytes',
280 ],
281 '@param string $var'
282 ],
283
284 [
285 [
286 'getOptionalMessage',
287 'getOneofMessage'
288 ],
289 '@return \Foo\TestMessage_Sub'
290 ],
291 [
292 [
293 'setOptionalMessage',
294 'setOneofMessage'
295 ],
296 '@param \Foo\TestMessage_Sub $var'
297 ],
298 [
299 [
300 'getOptionalIncludedMessage'
301 ],
302 '@return \Bar\TestInclude'
303 ],
304 [
305 [
306 'setOptionalIncludedMessage'
307 ],
308 '@param \Bar\TestInclude $var'
309 ],
310 [
311 [
312 'getRecursive'
313 ],
314 '@return \Foo\TestMessage'
315 ],
316 [
317 [
318 'setRecursive'
319 ],
320 '@param \Foo\TestMessage $var'
321 ],
322
323 [
324 [
325 'getOptionalNoNamespaceMessage'
326 ],
327 '@return \NoNamespaceMessage'
328 ],
329 [
330 [
331 'setOptionalNoNamespaceMessage'
332 ],
333 '@param \NoNamespaceMessage $var'
334 ],
335 ];
336 }
337}