Skip to content

Commit 8228850

Browse files
committed
Add inline {@example} test coverage
1 parent 066a402 commit 8228850

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

tests/unit/DocBlock/StandardTagFactoryTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,32 @@ public function testExampleTagIsRecognisedOutOfTheBox(): void
157157
$this->assertSame(10, $tag->getLineCount());
158158
}
159159

160+
/**
161+
* @uses \phpDocumentor\Reflection\DocBlock\DescriptionFactory
162+
* @uses \phpDocumentor\Reflection\DocBlock\Description
163+
* @uses \phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
164+
* @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag
165+
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Example
166+
*
167+
* @covers ::__construct
168+
* @covers ::create
169+
*/
170+
public function testExampleTagIsRecognisedInInlineForm(): void
171+
{
172+
$context = new Context('');
173+
$tagFactory = StandardTagFactory::createInstance(m::mock(FqsenResolver::class));
174+
$tagFactory->addService(new DescriptionFactory($tagFactory), DescriptionFactory::class);
175+
176+
$tag = $tagFactory->create('@link https://phpdoc.org {@example "path/to/example.php"}', $context);
177+
178+
$description = $tag->getDescription();
179+
$this->assertNotNull($description);
180+
$inlineTags = $description->getTags();
181+
$this->assertCount(1, $inlineTags);
182+
$this->assertInstanceOf(Example::class, $inlineTags[0]);
183+
$this->assertSame('path/to/example.php', $inlineTags[0]->getFilePath());
184+
}
185+
160186
/**
161187
* @uses \phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
162188
* @uses \phpDocumentor\Reflection\DocBlock\Tags\See

0 commit comments

Comments
 (0)