@@ -174,12 +174,99 @@ public function testFactoryMethod() : void
174
174
$ description = new Description ('My Description ' );
175
175
$ descriptionFactory ->shouldReceive ('create ' )->with ('My Description ' , $ context )->andReturn ($ description );
176
176
177
+ $ fixture = Param::create ('string $myParameter My Description ' , $ typeResolver , $ descriptionFactory , $ context );
178
+
179
+ $ this ->assertSame ('string $myParameter My Description ' , (string ) $ fixture );
180
+ $ this ->assertSame ('myParameter ' , $ fixture ->getVariableName ());
181
+ $ this ->assertInstanceOf (String_::class, $ fixture ->getType ());
182
+ $ this ->assertFalse ($ fixture ->isVariadic ());
183
+ $ this ->assertFalse ($ fixture ->isReference ());
184
+ $ this ->assertSame ($ description , $ fixture ->getDescription ());
185
+ }
186
+
187
+ /**
188
+ * @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public>
189
+ * @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
190
+ * @uses \phpDocumentor\Reflection\DocBlock\Description
191
+ * @uses \phpDocumentor\Reflection\Types\Context
192
+ *
193
+ * @covers ::create
194
+ */
195
+ public function testFactoryMethodWithVariadic () : void
196
+ {
197
+ $ typeResolver = new TypeResolver ();
198
+ $ descriptionFactory = m::mock (DescriptionFactory::class);
199
+ $ context = new Context ('' );
200
+
201
+ $ description = new Description ('My Description ' );
202
+ $ descriptionFactory ->shouldReceive ('create ' )->with ('My Description ' , $ context )->andReturn ($ description );
203
+
177
204
$ fixture = Param::create ('string ...$myParameter My Description ' , $ typeResolver , $ descriptionFactory , $ context );
178
205
179
206
$ this ->assertSame ('string ...$myParameter My Description ' , (string ) $ fixture );
180
207
$ this ->assertSame ('myParameter ' , $ fixture ->getVariableName ());
181
208
$ this ->assertInstanceOf (String_::class, $ fixture ->getType ());
182
209
$ this ->assertTrue ($ fixture ->isVariadic ());
210
+ $ this ->assertFalse ($ fixture ->isReference ());
211
+ $ this ->assertSame ($ description , $ fixture ->getDescription ());
212
+ }
213
+
214
+ /**
215
+ * @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public>
216
+ * @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
217
+ * @uses \phpDocumentor\Reflection\DocBlock\Description
218
+ * @uses \phpDocumentor\Reflection\Types\Context
219
+ *
220
+ * @covers ::create
221
+ */
222
+ public function testFactoryMethodWithReference () : void
223
+ {
224
+ $ typeResolver = new TypeResolver ();
225
+ $ descriptionFactory = m::mock (DescriptionFactory::class);
226
+ $ context = new Context ('' );
227
+
228
+ $ description = new Description ('My Description ' );
229
+ $ descriptionFactory ->shouldReceive ('create ' )->with ('My Description ' , $ context )->andReturn ($ description );
230
+
231
+ $ fixture = Param::create ('string &$myParameter My Description ' , $ typeResolver , $ descriptionFactory , $ context );
232
+
233
+ $ this ->assertSame ('string &$myParameter My Description ' , (string ) $ fixture );
234
+ $ this ->assertSame ('myParameter ' , $ fixture ->getVariableName ());
235
+ $ this ->assertInstanceOf (String_::class, $ fixture ->getType ());
236
+ $ this ->assertFalse ($ fixture ->isVariadic ());
237
+ $ this ->assertTrue ($ fixture ->isReference ());
238
+ $ this ->assertSame ($ description , $ fixture ->getDescription ());
239
+ }
240
+
241
+ /**
242
+ * @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public>
243
+ * @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
244
+ * @uses \phpDocumentor\Reflection\DocBlock\Description
245
+ * @uses \phpDocumentor\Reflection\Types\Context
246
+ *
247
+ * @covers ::create
248
+ */
249
+ public function testFactoryMethodWithVariadicReference () : void
250
+ {
251
+ $ typeResolver = new TypeResolver ();
252
+ $ descriptionFactory = m::mock (DescriptionFactory::class);
253
+ $ context = new Context ('' );
254
+
255
+ $ description = new Description ('My Description ' );
256
+ $ descriptionFactory ->shouldReceive ('create ' )->with ('My Description ' , $ context )->andReturn ($ description );
257
+
258
+ $ fixture = Param::create (
259
+ 'string &...$myParameter My Description ' ,
260
+ $ typeResolver ,
261
+ $ descriptionFactory ,
262
+ $ context
263
+ );
264
+
265
+ $ this ->assertSame ('string &...$myParameter My Description ' , (string ) $ fixture );
266
+ $ this ->assertSame ('myParameter ' , $ fixture ->getVariableName ());
267
+ $ this ->assertInstanceOf (String_::class, $ fixture ->getType ());
268
+ $ this ->assertTrue ($ fixture ->isVariadic ());
269
+ $ this ->assertTrue ($ fixture ->isReference ());
183
270
$ this ->assertSame ($ description , $ fixture ->getDescription ());
184
271
}
185
272
0 commit comments