diff --git a/tests/unit/DocBlock/DescriptionFactoryTest.php b/tests/unit/DocBlock/DescriptionFactoryTest.php index 3c4647f..04280fd 100644 --- a/tests/unit/DocBlock/DescriptionFactoryTest.php +++ b/tests/unit/DocBlock/DescriptionFactoryTest.php @@ -122,6 +122,37 @@ class DescriptionFactoryTest extends TestCase $this->assertSame($contents, $description->render()); } + /** + * @uses \phpDocumentor\Reflection\DocBlock\Description + * @uses \phpDocumentor\Reflection\DocBlock\Tags\Link + * @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag + * @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter + * @uses \phpDocumentor\Reflection\Types\Context + * + * @covers ::__construct + * @covers ::create + */ + public function testDescriptionCanParseAStringContainingMultipleTags() : void + { + $contents = 'This description has a {@link http://phpdoc.org/ This} another {@link http://phpdoc.org/ This2}'; + $context = new Context(''); + $tagFactory = m::mock(TagFactory::class); + $tagFactory->shouldReceive('create') + ->twice() + ->andReturnValues( + [ + new LinkTag('http://phpdoc.org/', new Description('This')), + new LinkTag('http://phpdoc.org/', new Description('This2')), + ] + ); + + $factory = new DescriptionFactory($tagFactory); + $description = $factory->create($contents, $context); + + $this->assertSame($contents, $description->render()); + $this->assertSame('This description has a %1$s another %2$s', $description->getBodyTemplate()); + } + /** * @uses \phpDocumentor\Reflection\DocBlock\Description * diff --git a/tests/unit/DocBlockTest.php b/tests/unit/DocBlockTest.php index 177e914..3d4923a 100644 --- a/tests/unit/DocBlockTest.php +++ b/tests/unit/DocBlockTest.php @@ -124,15 +124,17 @@ class DocBlockTest extends TestCase $tag1 = m::mock(DocBlock\Tag::class); $tag2 = m::mock(DocBlock\Tag::class); $tag3 = m::mock(DocBlock\Tag::class); - $tags = [$tag1, $tag2, $tag3]; + $tag4 = m::mock(DocBlock\Tag::class); + $tags = [$tag1, $tag2, $tag3, $tag4]; $tag1->shouldReceive('getName')->andReturn('abc'); $tag2->shouldReceive('getName')->andReturn('abcd'); + $tag4->shouldReceive('getName')->andReturn('abcd'); $tag3->shouldReceive('getName')->andReturn('ab'); $fixture = new DocBlock('', null, $tags); - $this->assertSame([$tag2], $fixture->getTagsByName('abcd')); + $this->assertSame([$tag2, $tag4], $fixture->getTagsByName('abcd')); $this->assertSame([], $fixture->getTagsByName('Ebcd')); }