@@ -282,6 +282,115 @@ public function testFactoryMethodWithoutUrl(): void
282282 $ this ->assertSame ('My Description ' , $ fixture ->getDescription () . '' );
283283 }
284284
285+ /**
286+ * @uses \phpDocumentor\Reflection\DocBlock\Tags\See::<public>
287+ * @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
288+ * @uses \phpDocumentor\Reflection\FqsenResolver
289+ * @uses \phpDocumentor\Reflection\DocBlock\Description
290+ * @uses \phpDocumentor\Reflection\DocBlock\Tags\Reference\Fqsen
291+ * @uses \phpDocumentor\Reflection\Fqsen
292+ * @uses \phpDocumentor\Reflection\Types\Context
293+ *
294+ * @covers ::create
295+ */
296+ public function testFactoryMethodWithBookmark (): void
297+ {
298+ $ fqsenResolver = new FqsenResolver ();
299+ $ descriptionFactory = new DescriptionFactory ($ this ->createMock (TagFactory::class));
300+ $ context = new Context ('' );
301+
302+ $ fixture = See::create (
303+ '\DateTime::format()#42 Jumps inside the formatter ' ,
304+ $ fqsenResolver ,
305+ $ descriptionFactory ,
306+ $ context
307+ );
308+
309+ $ reference = $ fixture ->getReference ();
310+ $ this ->assertInstanceOf (TagsFqsen::class, $ reference );
311+ $ this ->assertSame ('42 ' , $ reference ->getBookmark ());
312+ $ this ->assertSame ('\DateTime::format() ' , (string ) $ reference );
313+ $ this ->assertSame (
314+ '\DateTime::format()#42 Jumps inside the formatter ' ,
315+ (string ) $ fixture
316+ );
317+ }
318+
319+ /**
320+ * @uses \phpDocumentor\Reflection\DocBlock\Tags\See::<public>
321+ * @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
322+ * @uses \phpDocumentor\Reflection\FqsenResolver
323+ * @uses \phpDocumentor\Reflection\DocBlock\Description
324+ * @uses \phpDocumentor\Reflection\DocBlock\Tags\Reference\Fqsen
325+ * @uses \phpDocumentor\Reflection\Fqsen
326+ * @uses \phpDocumentor\Reflection\Types\Context
327+ *
328+ * @covers ::create
329+ */
330+ public function testFactoryMethodNormalizesTrailingHashToNullBookmark (): void
331+ {
332+ $ fqsenResolver = new FqsenResolver ();
333+ $ descriptionFactory = new DescriptionFactory ($ this ->createMock (TagFactory::class));
334+ $ context = new Context ('' );
335+
336+ $ fixture = See::create ('\DateTime# ' , $ fqsenResolver , $ descriptionFactory , $ context );
337+
338+ $ reference = $ fixture ->getReference ();
339+ $ this ->assertInstanceOf (TagsFqsen::class, $ reference );
340+ $ this ->assertNull ($ reference ->getBookmark ());
341+ $ this ->assertSame ('\DateTime ' , (string ) $ reference );
342+ }
343+
344+ /**
345+ * @uses \phpDocumentor\Reflection\DocBlock\Tags\See::<public>
346+ * @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
347+ * @uses \phpDocumentor\Reflection\FqsenResolver
348+ * @uses \phpDocumentor\Reflection\DocBlock\Description
349+ * @uses \phpDocumentor\Reflection\DocBlock\Tags\Reference\Url
350+ * @uses \phpDocumentor\Reflection\Types\Context
351+ *
352+ * @covers ::create
353+ */
354+ public function testFactoryMethodKeepsUrlFragmentWithinUrlReference (): void
355+ {
356+ $ descriptionFactory = m::mock (DescriptionFactory::class);
357+ $ resolver = m::mock (FqsenResolver::class);
358+ $ context = new Context ('' );
359+
360+ $ descriptionFactory ->shouldReceive ('create ' )->andReturn (new Description ('' ));
361+ $ resolver ->shouldNotReceive ('resolve ' );
362+
363+ $ fixture = See::create ('https://example.org/page#section ' , $ resolver , $ descriptionFactory , $ context );
364+
365+ $ this ->assertInstanceOf (UrlRef::class, $ fixture ->getReference ());
366+ $ this ->assertSame ('https://example.org/page#section ' , (string ) $ fixture ->getReference ());
367+ }
368+
369+ /**
370+ * @uses \phpDocumentor\Reflection\DocBlock\Tags\See::<public>
371+ * @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
372+ * @uses \phpDocumentor\Reflection\FqsenResolver
373+ * @uses \phpDocumentor\Reflection\DocBlock\Description
374+ * @uses \phpDocumentor\Reflection\DocBlock\Tags\Reference\Fqsen
375+ * @uses \phpDocumentor\Reflection\Fqsen
376+ * @uses \phpDocumentor\Reflection\Types\Context
377+ *
378+ * @covers ::create
379+ */
380+ public function testFactoryMethodLeavesBookmarkNullWhenAbsent (): void
381+ {
382+ $ fqsenResolver = new FqsenResolver ();
383+ $ descriptionFactory = new DescriptionFactory ($ this ->createMock (TagFactory::class));
384+ $ context = new Context ('' );
385+
386+ $ fixture = See::create ('\DateTime::format() ' , $ fqsenResolver , $ descriptionFactory , $ context );
387+
388+ $ reference = $ fixture ->getReference ();
389+ $ this ->assertInstanceOf (TagsFqsen::class, $ reference );
390+ $ this ->assertNull ($ reference ->getBookmark ());
391+ $ this ->assertSame ('\DateTime::format() ' , (string ) $ reference );
392+ }
393+
285394 /**
286395 * @covers ::create
287396 */
0 commit comments