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