Skip to content

Commit e31c62d

Browse files
committed
"See" -> add more test + simplify the regex
1 parent 5a2dd88 commit e31c62d

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

src/DocBlock/Tags/See.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public static function create(
5959
$description = isset($parts[1]) ? $descriptionFactory->create($parts[1], $context) : null;
6060

6161
// https://tools.ietf.org/html/rfc2396#section-3
62-
if (preg_match('/\w:\/\/\w/i', $parts[0])) {
62+
if (preg_match('#\w://\w#', $parts[0])) {
6363
return new static(new Url($parts[0]), $description);
6464
}
6565

tests/unit/DocBlock/Tags/SeeTest.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
use Mockery as m;
1717
use phpDocumentor\Reflection\DocBlock\Description;
1818
use phpDocumentor\Reflection\DocBlock\DescriptionFactory;
19+
use phpDocumentor\Reflection\DocBlock\StandardTagFactory;
1920
use phpDocumentor\Reflection\DocBlock\Tags\Reference\Fqsen as FqsenRef;
21+
use phpDocumentor\Reflection\DocBlock\Tags\Reference\Fqsen as TagsFqsen;
2022
use phpDocumentor\Reflection\DocBlock\Tags\Reference\Url as UrlRef;
2123
use phpDocumentor\Reflection\Fqsen;
2224
use phpDocumentor\Reflection\FqsenResolver;
@@ -251,6 +253,36 @@ public function testFactoryMethodWithUrl() : void
251253
$this->assertSame($description, $fixture->getDescription());
252254
}
253255

256+
/**
257+
* @uses \phpDocumentor\Reflection\DocBlock\Tags\See::<public>
258+
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
259+
* @uses \phpDocumentor\Reflection\FqsenResolver
260+
* @uses \phpDocumentor\Reflection\DocBlock\Description
261+
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Reference\Url
262+
* @uses \phpDocumentor\Reflection\Types\Context
263+
*
264+
* @covers ::create
265+
*/
266+
public function testFactoryMethodWithoutUrl() : void
267+
{
268+
$fqsenResolver = new FqsenResolver();
269+
$tagFactory = new StandardTagFactory($fqsenResolver);
270+
$descriptionFactory = new DescriptionFactory($tagFactory);
271+
$context = new Context('');
272+
273+
$fixture = See::create(
274+
'Foo My Description ',
275+
$fqsenResolver,
276+
$descriptionFactory,
277+
$context
278+
);
279+
280+
$this->assertSame('\Foo My Description ', (string) $fixture);
281+
$this->assertInstanceOf(TagsFqsen::class, $fixture->getReference());
282+
$this->assertSame('\Foo', (string) $fixture->getReference());
283+
$this->assertSame('My Description ', $fixture->getDescription() . '');
284+
}
285+
254286
/**
255287
* @covers ::create
256288
*/

0 commit comments

Comments
 (0)