|
16 | 16 | use Mockery as m; |
17 | 17 | use phpDocumentor\Reflection\DocBlock\Description; |
18 | 18 | use phpDocumentor\Reflection\DocBlock\DescriptionFactory; |
| 19 | +use phpDocumentor\Reflection\DocBlock\StandardTagFactory; |
| 20 | +use phpDocumentor\Reflection\FqsenResolver; |
19 | 21 | use phpDocumentor\Reflection\TypeResolver; |
20 | 22 | use phpDocumentor\Reflection\Types\Context; |
| 23 | +use phpDocumentor\Reflection\Types\Integer; |
21 | 24 | use phpDocumentor\Reflection\Types\String_; |
22 | 25 | use PHPUnit\Framework\TestCase; |
23 | 26 |
|
@@ -270,6 +273,128 @@ public function testFactoryMethodWithVariadicReference() : void |
270 | 273 | $this->assertSame($description, $fixture->getDescription()); |
271 | 274 | } |
272 | 275 |
|
| 276 | + /** |
| 277 | + * @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public> |
| 278 | + * @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory |
| 279 | + * @uses \phpDocumentor\Reflection\DocBlock\Description |
| 280 | + * @uses \phpDocumentor\Reflection\Types\Context |
| 281 | + * |
| 282 | + * @covers ::create |
| 283 | + */ |
| 284 | + public function testFactoryMethodWithReferenceWithoutType() : void |
| 285 | + { |
| 286 | + $typeResolver = new TypeResolver(); |
| 287 | + $fqsenResolver = new FqsenResolver(); |
| 288 | + $tagFactory = new StandardTagFactory($fqsenResolver); |
| 289 | + $descriptionFactory = new DescriptionFactory($tagFactory); |
| 290 | + $context = new Context(''); |
| 291 | + |
| 292 | + $fixture = Param::create( |
| 293 | + '&$myParameter My Description', |
| 294 | + $typeResolver, |
| 295 | + $descriptionFactory, |
| 296 | + $context |
| 297 | + ); |
| 298 | + |
| 299 | + $this->assertSame('&$myParameter My Description', (string) $fixture); |
| 300 | + $this->assertSame('myParameter', $fixture->getVariableName()); |
| 301 | + $this->assertNull($fixture->getType()); |
| 302 | + $this->assertFalse($fixture->isVariadic()); |
| 303 | + $this->assertTrue($fixture->isReference()); |
| 304 | + $this->assertSame('My Description', $fixture->getDescription() . ''); |
| 305 | + } |
| 306 | + |
| 307 | + /** |
| 308 | + * @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public> |
| 309 | + * @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory |
| 310 | + * @uses \phpDocumentor\Reflection\DocBlock\Description |
| 311 | + * @uses \phpDocumentor\Reflection\Types\Context |
| 312 | + * |
| 313 | + * @covers ::create |
| 314 | + */ |
| 315 | + public function testFactoryMethodWithVariadicReferenceWithoutType() : void |
| 316 | + { |
| 317 | + $typeResolver = new TypeResolver(); |
| 318 | + $fqsenResolver = new FqsenResolver(); |
| 319 | + $tagFactory = new StandardTagFactory($fqsenResolver); |
| 320 | + $descriptionFactory = new DescriptionFactory($tagFactory); |
| 321 | + $context = new Context(''); |
| 322 | + |
| 323 | + $fixture = Param::create( |
| 324 | + '&...$myParameter My Description', |
| 325 | + $typeResolver, |
| 326 | + $descriptionFactory, |
| 327 | + $context |
| 328 | + ); |
| 329 | + |
| 330 | + $this->assertSame('&...$myParameter My Description', (string) $fixture); |
| 331 | + $this->assertSame('myParameter', $fixture->getVariableName()); |
| 332 | + $this->assertNull($fixture->getType()); |
| 333 | + $this->assertTrue($fixture->isVariadic()); |
| 334 | + $this->assertTrue($fixture->isReference()); |
| 335 | + $this->assertSame('My Description', $fixture->getDescription() . ''); |
| 336 | + } |
| 337 | + |
| 338 | + /** |
| 339 | + * @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public> |
| 340 | + * @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory |
| 341 | + * @uses \phpDocumentor\Reflection\DocBlock\Description |
| 342 | + * @uses \phpDocumentor\Reflection\Types\Context |
| 343 | + * |
| 344 | + * @covers ::create |
| 345 | + */ |
| 346 | + public function testFactoryMethodWithoutType() : void |
| 347 | + { |
| 348 | + $typeResolver = new TypeResolver(); |
| 349 | + $fqsenResolver = new FqsenResolver(); |
| 350 | + $tagFactory = new StandardTagFactory($fqsenResolver); |
| 351 | + $descriptionFactory = new DescriptionFactory($tagFactory); |
| 352 | + $context = new Context(''); |
| 353 | + |
| 354 | + $fixture = Param::create( |
| 355 | + '$myParameter My Description', |
| 356 | + $typeResolver, |
| 357 | + $descriptionFactory, |
| 358 | + $context |
| 359 | + ); |
| 360 | + |
| 361 | + $this->assertSame('$myParameter My Description', (string) $fixture); |
| 362 | + $this->assertSame('myParameter', $fixture->getVariableName()); |
| 363 | + $this->assertNull($fixture->getType()); |
| 364 | + $this->assertFalse($fixture->isVariadic()); |
| 365 | + $this->assertFalse($fixture->isReference()); |
| 366 | + $this->assertSame('My Description', $fixture->getDescription() . ''); |
| 367 | + } |
| 368 | + |
| 369 | + /** |
| 370 | + * @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public> |
| 371 | + * @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory |
| 372 | + * @uses \phpDocumentor\Reflection\DocBlock\Description |
| 373 | + * @uses \phpDocumentor\Reflection\Types\Context |
| 374 | + * |
| 375 | + * @covers ::create |
| 376 | + */ |
| 377 | + public function testFactoryMethodWithType() : void |
| 378 | + { |
| 379 | + $typeResolver = new TypeResolver(); |
| 380 | + $fqsenResolver = new FqsenResolver(); |
| 381 | + $tagFactory = new StandardTagFactory($fqsenResolver); |
| 382 | + $descriptionFactory = new DescriptionFactory($tagFactory); |
| 383 | + $context = new Context(''); |
| 384 | + |
| 385 | + $fixture = Param::create( |
| 386 | + 'int My Description', |
| 387 | + $typeResolver, |
| 388 | + $descriptionFactory, |
| 389 | + $context |
| 390 | + ); |
| 391 | + |
| 392 | + $this->assertSame('int My Description', (string) $fixture); |
| 393 | + $this->assertSame('', $fixture->getVariableName()); |
| 394 | + $this->assertInstanceOf(Integer::class, $fixture->getType()); |
| 395 | + $this->assertSame('My Description', $fixture->getDescription() . ''); |
| 396 | + } |
| 397 | + |
273 | 398 | /** |
274 | 399 | * @uses \phpDocumentor\Reflection\DocBlock\Tags\Param::<public> |
275 | 400 | * @uses \phpDocumentor\Reflection\TypeResolver |
|
0 commit comments