15
15
use Mockery as m ;
16
16
use phpDocumentor \Reflection \DocBlock \Description ;
17
17
use phpDocumentor \Reflection \DocBlock \DescriptionFactory ;
18
+ use phpDocumentor \Reflection \Fqsen ;
18
19
use phpDocumentor \Reflection \TypeResolver ;
19
20
use phpDocumentor \Reflection \Types \Array_ ;
20
21
use phpDocumentor \Reflection \Types \Compound ;
@@ -469,6 +470,16 @@ public function testCreateMethodParenthesisMissing()
469
470
$ this ->assertSame ($ description , $ fixture ->getDescription ());
470
471
}
471
472
473
+ /**
474
+ * @covers ::create
475
+ * @uses \phpDocumentor\Reflection\DocBlock\Tags\Method::<public>
476
+ * @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
477
+ * @uses \phpDocumentor\Reflection\TypeResolver
478
+ * @uses \phpDocumentor\Reflection\DocBlock\Description
479
+ * @uses \phpDocumentor\Reflection\Fqsen
480
+ * @uses \phpDocumentor\Reflection\Types\Context
481
+ * @uses \phpDocumentor\Reflection\Types\Void_
482
+ */
472
483
public function testCreateWithoutReturnType ()
473
484
{
474
485
$ descriptionFactory = m::mock (DescriptionFactory::class);
@@ -492,4 +503,44 @@ public function testCreateWithoutReturnType()
492
503
$ this ->assertInstanceOf (Void_::class, $ fixture ->getReturnType ());
493
504
$ this ->assertSame ($ description , $ fixture ->getDescription ());
494
505
}
506
+
507
+ /**
508
+ * @covers ::create
509
+ * @uses \phpDocumentor\Reflection\DocBlock\Tags\Method::<public>
510
+ * @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
511
+ * @uses \phpDocumentor\Reflection\TypeResolver
512
+ * @uses \phpDocumentor\Reflection\DocBlock\Description
513
+ * @uses \phpDocumentor\Reflection\Fqsen
514
+ * @uses \phpDocumentor\Reflection\Types\Context
515
+ * @uses \phpDocumentor\Reflection\Types\Array_
516
+ * @uses \phpDocumentor\Reflection\Types\Compound
517
+ * @uses \phpDocumentor\Reflection\Types\Integer
518
+ * @uses \phpDocumentor\Reflection\Types\Object_
519
+ */
520
+ public function testCreateWithMixedReturnTypes ()
521
+ {
522
+ $ descriptionFactory = m::mock (DescriptionFactory::class);
523
+ $ resolver = new TypeResolver ();
524
+ $ context = new Context ('' );
525
+
526
+ $ descriptionFactory ->shouldReceive ('create ' )->andReturn (new Description ('' ));
527
+
528
+ $ fixture = Method::create (
529
+ 'MyClass[]|int[] myMethod() ' ,
530
+ $ resolver ,
531
+ $ descriptionFactory ,
532
+ $ context
533
+ );
534
+
535
+ $ this ->assertSame ('\MyClass[]|int[] myMethod() ' , (string )$ fixture );
536
+ $ this ->assertSame ('myMethod ' , $ fixture ->getMethodName ());
537
+ $ this ->assertEquals ([], $ fixture ->getArguments ());
538
+
539
+ $ this ->assertEquals (
540
+ new Compound ([
541
+ new Array_ (new Object_ (new Fqsen ('\MyClass ' ))),
542
+ new Array_ (new Integer ()),
543
+ ])
544
+ , $ fixture ->getReturnType ());
545
+ }
495
546
}
0 commit comments