3 * phpDocumentor Description Test
7 * @author Vasil Rangelov <boen.robot@gmail.com>
8 * @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
9 * @license http://www.opensource.org/licenses/mit-license.php MIT
10 * @link http://phpdoc.org
13 namespace phpDocumentor\Reflection\DocBlock;
16 * Test class for \phpDocumentor\Reflection\DocBlock\Description
18 * @author Vasil Rangelov <boen.robot@gmail.com>
19 * @copyright 2010-2011 Mike van Riel / Naenius. (http://www.naenius.com)
20 * @license http://www.opensource.org/licenses/mit-license.php MIT
21 * @link http://phpdoc.org
23 class DescriptionTest extends \PHPUnit_Framework_TestCase
25 public function testConstruct()
27 $fixture = <<<LONGDESC
28 This is text for a description.
30 $object = new Description($fixture);
31 $this->assertSame($fixture, $object->getContents());
33 $parsedContents = $object->getParsedContents();
34 $this->assertCount(1, $parsedContents);
35 $this->assertSame($fixture, $parsedContents[0]);
38 public function testInlineTagParsing()
40 $fixture = <<<LONGDESC
41 This is text for a {@link http://phpdoc.org/ description} that uses inline
44 $object = new Description($fixture);
45 $this->assertSame($fixture, $object->getContents());
47 $parsedContents = $object->getParsedContents();
48 $this->assertCount(3, $parsedContents);
49 $this->assertSame('This is text for a ', $parsedContents[0]);
50 $this->assertInstanceOf(
51 __NAMESPACE__ . '\Tag\LinkTag',
61 public function testInlineTagAtStartParsing()
63 $fixture = <<<LONGDESC
64 {@link http://phpdoc.org/ This} is text for a description that uses inline
67 $object = new Description($fixture);
68 $this->assertSame($fixture, $object->getContents());
70 $parsedContents = $object->getParsedContents();
71 $this->assertCount(3, $parsedContents);
73 $this->assertSame('', $parsedContents[0]);
74 $this->assertInstanceOf(
75 __NAMESPACE__ . '\Tag\LinkTag',
79 ' is text for a description that uses inline
85 public function testNestedInlineTagParsing()
87 $fixture = <<<LONGDESC
88 This is text for a description with {@internal inline tag with
89 {@link http://phpdoc.org another inline tag} in it}.
91 $object = new Description($fixture);
92 $this->assertSame($fixture, $object->getContents());
94 $parsedContents = $object->getParsedContents();
95 $this->assertCount(3, $parsedContents);
98 'This is text for a description with ',
101 $this->assertInstanceOf(
102 __NAMESPACE__ . '\Tag',
105 $this->assertSame('.', $parsedContents[2]);
107 $parsedDescription = $parsedContents[1]->getParsedDescription();
108 $this->assertCount(3, $parsedDescription);
109 $this->assertSame("inline tag with\n", $parsedDescription[0]);
110 $this->assertInstanceOf(
111 __NAMESPACE__ . '\Tag\LinkTag',
112 $parsedDescription[1]
114 $this->assertSame(' in it', $parsedDescription[2]);
117 public function testLiteralOpeningDelimiter()
119 $fixture = <<<LONGDESC
120 This is text for a description containing { that is literal.
122 $object = new Description($fixture);
123 $this->assertSame($fixture, $object->getContents());
125 $parsedContents = $object->getParsedContents();
126 $this->assertCount(1, $parsedContents);
127 $this->assertSame($fixture, $parsedContents[0]);
130 public function testNestedLiteralOpeningDelimiter()
132 $fixture = <<<LONGDESC
133 This is text for a description containing {@internal inline tag that has { that
136 $object = new Description($fixture);
137 $this->assertSame($fixture, $object->getContents());
139 $parsedContents = $object->getParsedContents();
140 $this->assertCount(3, $parsedContents);
142 'This is text for a description containing ',
145 $this->assertInstanceOf(
146 __NAMESPACE__ . '\Tag',
149 $this->assertSame('.', $parsedContents[2]);
152 array('inline tag that has { that
154 $parsedContents[1]->getParsedDescription()
158 public function testLiteralClosingDelimiter()
160 $fixture = <<<LONGDESC
161 This is text for a description with {} that is not a tag.
163 $object = new Description($fixture);
164 $this->assertSame($fixture, $object->getContents());
166 $parsedContents = $object->getParsedContents();
167 $this->assertCount(1, $parsedContents);
169 'This is text for a description with } that is not a tag.',
174 public function testNestedLiteralClosingDelimiter()
176 $fixture = <<<LONGDESC
177 This is text for a description with {@internal inline tag with {} that is not an
180 $object = new Description($fixture);
181 $this->assertSame($fixture, $object->getContents());
183 $parsedContents = $object->getParsedContents();
184 $this->assertCount(3, $parsedContents);
186 'This is text for a description with ',
189 $this->assertInstanceOf(
190 __NAMESPACE__ . '\Tag',
193 $this->assertSame('.', $parsedContents[2]);
196 array('inline tag with } that is not an
198 $parsedContents[1]->getParsedDescription()
202 public function testInlineTagEscapingSequence()
204 $fixture = <<<LONGDESC
205 This is text for a description with literal {{@}link}.
207 $object = new Description($fixture);
208 $this->assertSame($fixture, $object->getContents());
210 $parsedContents = $object->getParsedContents();
211 $this->assertCount(1, $parsedContents);
213 'This is text for a description with literal {@link}.',
218 public function testNestedInlineTagEscapingSequence()
220 $fixture = <<<LONGDESC
221 This is text for a description with an {@internal inline tag with literal
224 $object = new Description($fixture);
225 $this->assertSame($fixture, $object->getContents());
227 $parsedContents = $object->getParsedContents();
228 $this->assertCount(3, $parsedContents);
230 'This is text for a description with an ',
233 $this->assertInstanceOf(
234 __NAMESPACE__ . '\Tag',
237 $this->assertSame('.', $parsedContents[2]);
240 array('inline tag with literal
242 $parsedContents[1]->getParsedDescription()