15
15
use Mockery as m ;
16
16
use phpDocumentor \Reflection \DocBlock \Description ;
17
17
use phpDocumentor \Reflection \DocBlock \DescriptionFactory ;
18
+ use phpDocumentor \Reflection \DocBlock \Tags \Reference \Fqsen as FqsenRef ;
19
+ use phpDocumentor \Reflection \DocBlock \Tags \Reference \Url as UrlRef ;
18
20
use phpDocumentor \Reflection \Fqsen ;
19
21
use phpDocumentor \Reflection \FqsenResolver ;
20
22
use phpDocumentor \Reflection \Types \Context ;
@@ -32,7 +34,7 @@ class SeeTest extends \PHPUnit_Framework_TestCase
32
34
*/
33
35
public function testIfCorrectTagNameIsReturned ()
34
36
{
35
- $ fixture = new See (new Fqsen ('\DateTime ' ), new Description ('Description ' ));
37
+ $ fixture = new See (new FqsenRef ( new Fqsen ('\DateTime ' ) ), new Description ('Description ' ));
36
38
37
39
$ this ->assertSame ('see ' , $ fixture ->getName ());
38
40
}
@@ -47,7 +49,7 @@ public function testIfCorrectTagNameIsReturned()
47
49
*/
48
50
public function testIfTagCanBeRenderedUsingDefaultFormatter ()
49
51
{
50
- $ fixture = new See (new Fqsen ('\DateTime ' ), new Description ('Description ' ));
52
+ $ fixture = new See (new FqsenRef ( new Fqsen ('\DateTime ' ) ), new Description ('Description ' ));
51
53
52
54
$ this ->assertSame ('@see \DateTime Description ' , $ fixture ->render ());
53
55
}
@@ -59,7 +61,7 @@ public function testIfTagCanBeRenderedUsingDefaultFormatter()
59
61
*/
60
62
public function testIfTagCanBeRenderedUsingSpecificFormatter ()
61
63
{
62
- $ fixture = new See (new Fqsen ('\DateTime ' ), new Description ('Description ' ));
64
+ $ fixture = new See (new FqsenRef ( new Fqsen ('\DateTime ' ) ), new Description ('Description ' ));
63
65
64
66
$ formatter = m::mock (Formatter::class);
65
67
$ formatter ->shouldReceive ('format ' )->with ($ fixture )->andReturn ('Rendered output ' );
@@ -73,7 +75,7 @@ public function testIfTagCanBeRenderedUsingSpecificFormatter()
73
75
*/
74
76
public function testHasReferenceToFqsen ()
75
77
{
76
- $ expected = new Fqsen ('\DateTime ' );
78
+ $ expected = new FqsenRef ( new Fqsen ('\DateTime ' ) );
77
79
78
80
$ fixture = new See ($ expected );
79
81
@@ -89,7 +91,7 @@ public function testHasDescription()
89
91
{
90
92
$ expected = new Description ('Description ' );
91
93
92
- $ fixture = new See (new Fqsen ('\DateTime ' ), $ expected );
94
+ $ fixture = new See (new FqsenRef ( new Fqsen ('\DateTime ' ) ), $ expected );
93
95
94
96
$ this ->assertSame ($ expected , $ fixture ->getDescription ());
95
97
}
@@ -101,9 +103,9 @@ public function testHasDescription()
101
103
*/
102
104
public function testStringRepresentationIsReturned ()
103
105
{
104
- $ fixture = new See (new Fqsen ('\DateTime ' ), new Description ('Description ' ));
106
+ $ fixture = new See (new FqsenRef ( new Fqsen ('\DateTime::format() ' ) ), new Description ('Description ' ));
105
107
106
- $ this ->assertSame ('\DateTime Description ' , (string )$ fixture );
108
+ $ this ->assertSame ('\DateTime::format() Description ' , (string )$ fixture );
107
109
}
108
110
109
111
/**
@@ -131,7 +133,38 @@ public function testFactoryMethod()
131
133
$ fixture = See::create ('DateTime My Description ' , $ resolver , $ descriptionFactory , $ context );
132
134
133
135
$ 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 ());
135
168
$ this ->assertSame ($ description , $ fixture ->getDescription ());
136
169
}
137
170
0 commit comments