Skip to content

Commit f0af3b7

Browse files
committed
Add more tests
1 parent 1ac416d commit f0af3b7

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

tests/unit/DocBlock/DescriptionFactoryTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,37 @@ public function testDescriptionCanParseAStringStartingWithInlineTag() : void
122122
$this->assertSame($contents, $description->render());
123123
}
124124

125+
/**
126+
* @uses \phpDocumentor\Reflection\DocBlock\Description
127+
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Link
128+
* @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag
129+
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter
130+
* @uses \phpDocumentor\Reflection\Types\Context
131+
*
132+
* @covers ::__construct
133+
* @covers ::create
134+
*/
135+
public function testDescriptionCanParseAStringContainingMultipleTags() : void
136+
{
137+
$contents = 'This description has a {@link http://phpdoc.org/ This} another {@link http://phpdoc.org/ This2}';
138+
$context = new Context('');
139+
$tagFactory = m::mock(TagFactory::class);
140+
$tagFactory->shouldReceive('create')
141+
->twice()
142+
->andReturnValues(
143+
[
144+
new LinkTag('http://phpdoc.org/', new Description('This')),
145+
new LinkTag('http://phpdoc.org/', new Description('This2')),
146+
]
147+
);
148+
149+
$factory = new DescriptionFactory($tagFactory);
150+
$description = $factory->create($contents, $context);
151+
152+
$this->assertSame($contents, $description->render());
153+
$this->assertSame('This description has a %1$s another %2$s', $description->getBodyTemplate());
154+
}
155+
125156
/**
126157
* @uses \phpDocumentor\Reflection\DocBlock\Description
127158
*

tests/unit/DocBlockTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,17 @@ public function testFindTagsInDocBlockByName() : void
124124
$tag1 = m::mock(DocBlock\Tag::class);
125125
$tag2 = m::mock(DocBlock\Tag::class);
126126
$tag3 = m::mock(DocBlock\Tag::class);
127-
$tags = [$tag1, $tag2, $tag3];
127+
$tag4 = m::mock(DocBlock\Tag::class);
128+
$tags = [$tag1, $tag2, $tag3, $tag4];
128129

129130
$tag1->shouldReceive('getName')->andReturn('abc');
130131
$tag2->shouldReceive('getName')->andReturn('abcd');
132+
$tag4->shouldReceive('getName')->andReturn('abcd');
131133
$tag3->shouldReceive('getName')->andReturn('ab');
132134

133135
$fixture = new DocBlock('', null, $tags);
134136

135-
$this->assertSame([$tag2], $fixture->getTagsByName('abcd'));
137+
$this->assertSame([$tag2, $tag4], $fixture->getTagsByName('abcd'));
136138
$this->assertSame([], $fixture->getTagsByName('Ebcd'));
137139
}
138140

0 commit comments

Comments
 (0)