| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245 |
- <?php
- /**
- * phpDocumentor Description Test
- *
- * PHP Version 5.3
- *
- * @author Vasil Rangelov <boen.robot@gmail.com>
- * @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
- * @license http://www.opensource.org/licenses/mit-license.php MIT
- * @link http://phpdoc.org
- */
- namespace Barryvdh\Reflection\DocBlock;
- /**
- * Test class for \Barryvdh\Reflection\DocBlock\Description
- *
- * @author Vasil Rangelov <boen.robot@gmail.com>
- * @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
- * @license http://www.opensource.org/licenses/mit-license.php MIT
- * @link http://phpdoc.org
- */
- class DescriptionTest extends \PHPUnit_Framework_TestCase
- {
- public function testConstruct()
- {
- $fixture = <<<LONGDESC
- This is text for a description.
- LONGDESC;
- $object = new Description($fixture);
- $this->assertSame($fixture, $object->getContents());
- $parsedContents = $object->getParsedContents();
- $this->assertCount(1, $parsedContents);
- $this->assertSame($fixture, $parsedContents[0]);
- }
- public function testInlineTagParsing()
- {
- $fixture = <<<LONGDESC
- This is text for a {@link http://phpdoc.org/ description} that uses inline
- tags.
- LONGDESC;
- $object = new Description($fixture);
- $this->assertSame($fixture, $object->getContents());
- $parsedContents = $object->getParsedContents();
- $this->assertCount(3, $parsedContents);
- $this->assertSame('This is text for a ', $parsedContents[0]);
- $this->assertInstanceOf(
- __NAMESPACE__ . '\Tag\LinkTag',
- $parsedContents[1]
- );
- $this->assertSame(
- ' that uses inline
- tags.',
- $parsedContents[2]
- );
- }
- public function testInlineTagAtStartParsing()
- {
- $fixture = <<<LONGDESC
- {@link http://phpdoc.org/ This} is text for a description that uses inline
- tags.
- LONGDESC;
- $object = new Description($fixture);
- $this->assertSame($fixture, $object->getContents());
- $parsedContents = $object->getParsedContents();
- $this->assertCount(3, $parsedContents);
- $this->assertSame('', $parsedContents[0]);
- $this->assertInstanceOf(
- __NAMESPACE__ . '\Tag\LinkTag',
- $parsedContents[1]
- );
- $this->assertSame(
- ' is text for a description that uses inline
- tags.',
- $parsedContents[2]
- );
- }
- public function testNestedInlineTagParsing()
- {
- $fixture = <<<LONGDESC
- This is text for a description with {@internal inline tag with
- {@link http://phpdoc.org another inline tag} in it}.
- LONGDESC;
- $object = new Description($fixture);
- $this->assertSame($fixture, $object->getContents());
- $parsedContents = $object->getParsedContents();
- $this->assertCount(3, $parsedContents);
- $this->assertSame(
- 'This is text for a description with ',
- $parsedContents[0]
- );
- $this->assertInstanceOf(
- __NAMESPACE__ . '\Tag',
- $parsedContents[1]
- );
- $this->assertSame('.', $parsedContents[2]);
- $parsedDescription = $parsedContents[1]->getParsedDescription();
- $this->assertCount(3, $parsedDescription);
- $this->assertSame("inline tag with\n", $parsedDescription[0]);
- $this->assertInstanceOf(
- __NAMESPACE__ . '\Tag\LinkTag',
- $parsedDescription[1]
- );
- $this->assertSame(' in it', $parsedDescription[2]);
- }
- public function testLiteralOpeningDelimiter()
- {
- $fixture = <<<LONGDESC
- This is text for a description containing { that is literal.
- LONGDESC;
- $object = new Description($fixture);
- $this->assertSame($fixture, $object->getContents());
- $parsedContents = $object->getParsedContents();
- $this->assertCount(1, $parsedContents);
- $this->assertSame($fixture, $parsedContents[0]);
- }
- public function testNestedLiteralOpeningDelimiter()
- {
- $fixture = <<<LONGDESC
- This is text for a description containing {@internal inline tag that has { that
- is literal}.
- LONGDESC;
- $object = new Description($fixture);
- $this->assertSame($fixture, $object->getContents());
- $parsedContents = $object->getParsedContents();
- $this->assertCount(3, $parsedContents);
- $this->assertSame(
- 'This is text for a description containing ',
- $parsedContents[0]
- );
- $this->assertInstanceOf(
- __NAMESPACE__ . '\Tag',
- $parsedContents[1]
- );
- $this->assertSame('.', $parsedContents[2]);
- $this->assertSame(
- array('inline tag that has { that
- is literal'),
- $parsedContents[1]->getParsedDescription()
- );
- }
- public function testLiteralClosingDelimiter()
- {
- $fixture = <<<LONGDESC
- This is text for a description with {} that is not a tag.
- LONGDESC;
- $object = new Description($fixture);
- $this->assertSame($fixture, $object->getContents());
- $parsedContents = $object->getParsedContents();
- $this->assertCount(1, $parsedContents);
- $this->assertSame(
- 'This is text for a description with } that is not a tag.',
- $parsedContents[0]
- );
- }
- public function testNestedLiteralClosingDelimiter()
- {
- $fixture = <<<LONGDESC
- This is text for a description with {@internal inline tag with {} that is not an
- inline tag}.
- LONGDESC;
- $object = new Description($fixture);
- $this->assertSame($fixture, $object->getContents());
- $parsedContents = $object->getParsedContents();
- $this->assertCount(3, $parsedContents);
- $this->assertSame(
- 'This is text for a description with ',
- $parsedContents[0]
- );
- $this->assertInstanceOf(
- __NAMESPACE__ . '\Tag',
- $parsedContents[1]
- );
- $this->assertSame('.', $parsedContents[2]);
- $this->assertSame(
- array('inline tag with } that is not an
- inline tag'),
- $parsedContents[1]->getParsedDescription()
- );
- }
- public function testInlineTagEscapingSequence()
- {
- $fixture = <<<LONGDESC
- This is text for a description with literal {{@}link}.
- LONGDESC;
- $object = new Description($fixture);
- $this->assertSame($fixture, $object->getContents());
- $parsedContents = $object->getParsedContents();
- $this->assertCount(1, $parsedContents);
- $this->assertSame(
- 'This is text for a description with literal {@link}.',
- $parsedContents[0]
- );
- }
- public function testNestedInlineTagEscapingSequence()
- {
- $fixture = <<<LONGDESC
- This is text for a description with an {@internal inline tag with literal
- {{@}link{} in it}.
- LONGDESC;
- $object = new Description($fixture);
- $this->assertSame($fixture, $object->getContents());
- $parsedContents = $object->getParsedContents();
- $this->assertCount(3, $parsedContents);
- $this->assertSame(
- 'This is text for a description with an ',
- $parsedContents[0]
- );
- $this->assertInstanceOf(
- __NAMESPACE__ . '\Tag',
- $parsedContents[1]
- );
- $this->assertSame('.', $parsedContents[2]);
- $this->assertSame(
- array('inline tag with literal
- {@link} in it'),
- $parsedContents[1]->getParsedDescription()
- );
- }
- }
|