1515use Mockery as m ;
1616use phpDocumentor \Reflection \DocBlock \Description ;
1717use phpDocumentor \Reflection \DocBlock \DescriptionFactory ;
18+ use phpDocumentor \Reflection \DocBlock \Tags \Reference \Fqsen as FqsenRef ;
19+ use phpDocumentor \Reflection \DocBlock \Tags \Reference \Url as UrlRef ;
1820use phpDocumentor \Reflection \Fqsen ;
1921use phpDocumentor \Reflection \FqsenResolver ;
2022use phpDocumentor \Reflection \Types \Context ;
@@ -32,7 +34,7 @@ class SeeTest extends \PHPUnit_Framework_TestCase
3234 */
3335 public function testIfCorrectTagNameIsReturned ()
3436 {
35- $ fixture = new See (new Fqsen ('\DateTime ' ), new Description ('Description ' ));
37+ $ fixture = new See (new FqsenRef ( new Fqsen ('\DateTime ' ) ), new Description ('Description ' ));
3638
3739 $ this ->assertSame ('see ' , $ fixture ->getName ());
3840 }
@@ -47,7 +49,7 @@ public function testIfCorrectTagNameIsReturned()
4749 */
4850 public function testIfTagCanBeRenderedUsingDefaultFormatter ()
4951 {
50- $ fixture = new See (new Fqsen ('\DateTime ' ), new Description ('Description ' ));
52+ $ fixture = new See (new FqsenRef ( new Fqsen ('\DateTime ' ) ), new Description ('Description ' ));
5153
5254 $ this ->assertSame ('@see \DateTime Description ' , $ fixture ->render ());
5355 }
@@ -59,7 +61,7 @@ public function testIfTagCanBeRenderedUsingDefaultFormatter()
5961 */
6062 public function testIfTagCanBeRenderedUsingSpecificFormatter ()
6163 {
62- $ fixture = new See (new Fqsen ('\DateTime ' ), new Description ('Description ' ));
64+ $ fixture = new See (new FqsenRef ( new Fqsen ('\DateTime ' ) ), new Description ('Description ' ));
6365
6466 $ formatter = m::mock (Formatter::class);
6567 $ formatter ->shouldReceive ('format ' )->with ($ fixture )->andReturn ('Rendered output ' );
@@ -73,7 +75,7 @@ public function testIfTagCanBeRenderedUsingSpecificFormatter()
7375 */
7476 public function testHasReferenceToFqsen ()
7577 {
76- $ expected = new Fqsen ('\DateTime ' );
78+ $ expected = new FqsenRef ( new Fqsen ('\DateTime ' ) );
7779
7880 $ fixture = new See ($ expected );
7981
@@ -89,7 +91,7 @@ public function testHasDescription()
8991 {
9092 $ expected = new Description ('Description ' );
9193
92- $ fixture = new See (new Fqsen ('\DateTime ' ), $ expected );
94+ $ fixture = new See (new FqsenRef ( new Fqsen ('\DateTime ' ) ), $ expected );
9395
9496 $ this ->assertSame ($ expected , $ fixture ->getDescription ());
9597 }
@@ -101,9 +103,9 @@ public function testHasDescription()
101103 */
102104 public function testStringRepresentationIsReturned ()
103105 {
104- $ fixture = new See (new Fqsen ('\DateTime ' ), new Description ('Description ' ));
106+ $ fixture = new See (new FqsenRef ( new Fqsen ('\DateTime::format() ' ) ), new Description ('Description ' ));
105107
106- $ this ->assertSame ('\DateTime Description ' , (string )$ fixture );
108+ $ this ->assertSame ('\DateTime::format() Description ' , (string )$ fixture );
107109 }
108110
109111 /**
@@ -131,7 +133,38 @@ public function testFactoryMethod()
131133 $ fixture = See::create ('DateTime My Description ' , $ resolver , $ descriptionFactory , $ context );
132134
133135 $ this ->assertSame ('\DateTime My Description ' , (string )$ fixture );
134- $ this ->assertSame ($ fqsen , $ fixture ->getReference ());
136+ $ this ->assertInstanceOf (FqsenRef::class, $ fixture ->getReference ());
137+ $ this ->assertSame ((string )$ fqsen , (string )$ fixture ->getReference ());
138+ $ this ->assertSame ($ description , $ fixture ->getDescription ());
139+ }
140+
141+ /**
142+ * @covers ::create
143+ * @uses \phpDocumentor\Reflection\DocBlock\Tags\See::<public>
144+ * @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
145+ * @uses \phpDocumentor\Reflection\FqsenResolver
146+ * @uses \phpDocumentor\Reflection\DocBlock\Description
147+ * @uses \phpDocumentor\Reflection\DocBlock\Tags\Reference\Url
148+ * @uses \phpDocumentor\Reflection\Types\Context
149+ */
150+ public function testFactoryMethodWithUrl ()
151+ {
152+ $ descriptionFactory = m::mock (DescriptionFactory::class);
153+ $ resolver = m::mock (FqsenResolver::class);
154+ $ context = new Context ('' );
155+
156+ $ description = new Description ('My Description ' );
157+
158+ $ descriptionFactory
159+ ->shouldReceive ('create ' )->with ('My Description ' , $ context )->andReturn ($ description );
160+
161+ $ resolver ->shouldNotReceive ('resolve ' );
162+
163+ $ fixture = See::create ('https://test.org My Description ' , $ resolver , $ descriptionFactory , $ context );
164+
165+ $ this ->assertSame ('https://test.org My Description ' , (string )$ fixture );
166+ $ this ->assertInstanceOf (UrlRef::class, $ fixture ->getReference ());
167+ $ this ->assertSame ('https://test.org ' , (string )$ fixture ->getReference ());
135168 $ this ->assertSame ($ description , $ fixture ->getDescription ());
136169 }
137170
0 commit comments