* @license http://www.opensource.org/licenses/mit-license.php MIT * @link http://phpdoc.org */ namespace phpDocumentor\Reflection\DocBlock; use Mockery as m; use phpDocumentor\Reflection\DocBlock\Tags\Deprecated; use phpDocumentor\Reflection\DocBlock\Tags\Link; /** * @coversDefaultClass \phpDocumentor\Reflection\DocBlock\Description */ class DescriptionTest extends \PHPUnit_Framework_TestCase { /** * @param array $examples * @dataProvider provideExampleDescriptions * @covers ::__construct * @covers ::render * @covers ::parse * @uses phpDocumentor\Reflection\DocBlock\Description\PassthroughFormatter * @uses phpDocumentor\Reflection\DocBlock\Tag * @uses phpDocumentor\Reflection\DocBlock\Tags\Link */ public function testParsesDescription($example) { $object = new Description($example); $this->assertSame($example, $object->render()); } /** * @covers ::__construct * @covers ::render * @covers ::parse * @uses phpDocumentor\Reflection\DocBlock\Description\PassthroughFormatter */ public function testInlineTagEscapingSequence() { $fixture = 'This is text for a description with literal {{@}link}.'; $expected = 'This is text for a description with literal {@link}.'; $object = new Description($fixture); $this->assertSame($expected, $object->render()); } /** * @covers ::__construct * @covers ::render * @covers ::parse * @uses phpDocumentor\Reflection\DocBlock\Tag * @uses phpDocumentor\Reflection\DocBlock\Tags\Version * @uses phpDocumentor\Reflection\DocBlock\Tags\Link */ public function testFormatterReceivesContentsAsTokens() { $fixture = <<shouldReceive('format')->with($expected)->andReturn($fixture); $object = new Description($fixture); $this->assertSame($fixture, $object->render($formatter)); } /** * Provides a series of example strings that the parser should correctly interpret and return. * * @return string[][] */ public function provideExampleDescriptions() { return [ ['This is text for a description.'], ['This is text for a {@link http://phpdoc.org/ description} that uses an inline tag.'], ['{@link http://phpdoc.org/ This} is text for a description that starts with an inline tag.'], [ 'This is text for a description with {@internal inline tag with {@link http://phpdoc.org another ' . 'inline tag} in it}.' ], ['This is text for a description containing { that is literal.'], ['This is text for a description containing {@internal inline tag that has { that is literal}.'], ['This is text for a description with {} that is not a tag.'], ['This is text for a description with {@internal inline tag with {} that is not an inline tag}.'], ['This is text for a description with an {@internal inline tag with literal {{@}link{} in it}.'] ]; } }