3 class HTMLPurifier_Injector_AutoParagraphTest
extends HTMLPurifier_InjectorHarness
6 public function setup()
9 $this->config
->set('AutoFormat.AutoParagraph', true);
12 public function testSingleParagraph()
20 public function testSingleMultiLineParagraph()
30 public function testTwoParagraphs()
42 public function testTwoParagraphsWithLotsOfSpace()
56 public function testTwoParagraphsWithInlineElements()
68 public function testSingleParagraphThatLooksLikeTwo()
80 public function testAddParagraphAdjacentToParagraph()
90 public function testParagraphUnclosedInlineElement()
98 public function testPreservePreTags()
107 public function testIgnoreTrailingWhitespace()
119 public function testDoNotParagraphBlockElements()
135 public function testParagraphTextAndInlineNodes()
143 public function testPreserveLeadingWhitespace()
155 public function testPreserveSurroundingWhitespace()
171 public function testParagraphInsideBlockNode()
183 public function testParagraphInlineNodeInsideBlockNode()
189 '<div><p><b>Par1</b></p>
195 public function testNoParagraphWhenOnlyOneInsideBlockNode()
197 $this->assertResult('<div>Par1</div>');
200 public function testParagraphTwoInlineNodesInsideBlockNode()
206 '<div><p><b>Par1</b></p>
208 <p><i>Par2</i></p></div>'
212 public function testPreserveInlineNodesInPreTag()
221 public function testSplitUpInternalsOfPTagInBlockNode()
233 public function testSplitUpInlineNodesInPTagInBlockNode()
238 <i>Bar</i></p></div>',
239 '<div><p><b>Foo</b></p>
241 <p><i>Bar</i></p></div>'
245 public function testNoParagraphSingleInlineNodeInBlockNode()
247 $this->assertResult( '<div><b>Foo</b></div>' );
250 public function testParagraphInBlockquote()
256 '<blockquote><p>Par1</p>
258 <p>Par2</p></blockquote>'
262 public function testNoParagraphBetweenListItem()
271 public function testParagraphSingleElementWithSurroundingSpace()
287 public function testIgnoreExtraSpaceWithLeadingInlineNode()
301 public function testAbsorbExtraEndingPTag()
313 public function testAbsorbExtraEndingDivTag()
325 public function testDoNotParagraphSingleSurroundingSpaceInBlockNode()
334 public function testBlockNodeTextDelimeterInBlockNode()
339 <div>Par2</div></div>',
342 <div>Par2</div></div>'
346 public function testBlockNodeTextDelimeterWithoutDoublespaceInBlockNode()
350 <div>Par2</div></div>'
354 public function testBlockNodeTextDelimeterWithoutDoublespace()
366 public function testTwoParagraphsOfTextAndInlineNode()
378 public function testLeadingInlineNodeParagraph()
386 public function testTrailingInlineNodeParagraph()
389 '<li>Foo <a>bar</a></li>'
393 public function testTwoInlineNodeParagraph()
396 '<li><b>baz</b><a>bar</a></li>'
400 public function testNoParagraphTrailingBlockNodeInBlockNode()
403 '<div><div>asdf</div><b>asdf</b></div>'
407 public function testParagraphTrailingBlockNodeWithDoublespaceInBlockNode()
410 '<div><div>asdf</div>
413 '<div><div>asdf</div>
415 <p><b>asdf</b></p></div>'
419 public function testParagraphTwoInlineNodesAndWhitespaceNode()
422 '<b>One</b> <i>Two</i>',
423 '<p><b>One</b> <i>Two</i></p>'
427 public function testNoParagraphWithInlineRootNode()
429 $this->config
->set('HTML.Parent', 'span');
437 public function testInlineAndBlockTagInDivNoParagraph()
440 '<div><code>bar</code> mmm <pre>asdf</pre></div>'
444 public function testInlineAndBlockTagInDivNeedingParagraph()
447 '<div><code>bar</code> mmm
449 <pre>asdf</pre></div>',
450 '<div><p><code>bar</code> mmm</p>
452 <pre>asdf</pre></div>'
456 public function testTextInlineNodeTextThenDoubleNewlineNeedsParagraph()
459 '<div>asdf <code>bar</code> mmm
461 <pre>asdf</pre></div>',
462 '<div><p>asdf <code>bar</code> mmm</p>
464 <pre>asdf</pre></div>'
468 public function testUpcomingTokenHasNewline()
471 '<div>Test<b>foo</b>bar<b>bing</b>bang
474 '<div><p>Test<b>foo</b>bar<b>bing</b>bang</p>
480 public function testEmptyTokenAtEndOfDiv()
490 public function testEmptyDoubleLineTokenAtEndOfDiv()
502 public function testTextState11Root()
504 $this->assertResult('<div></div> ');
507 public function testTextState11Element()
515 public function testTextStateLikeElementState111NoWhitespace()
517 $this->assertResult('<div><p>P</p>Boo</div>', '<div><p>P</p>Boo</div>');
520 public function testElementState111NoWhitespace()
522 $this->assertResult('<div><p>P</p><b>Boo</b></div>', '<div><p>P</p><b>Boo</b></div>');
525 public function testElementState133()
528 "<div><b>B</b><pre>Ba</pre>
531 "<div><b>B</b><pre>Ba</pre>
537 public function testElementState22()
540 '<ul><li>foo</li></ul>'
544 public function testElementState311()
547 '<p>Foo</p><b>Bar</b>',
554 public function testAutoClose()
562 public function testErrorNeeded()
564 $this->config
->set('HTML.Allowed', 'b');
565 $this->expectError('Cannot enable AutoParagraph injector because p is not allowed');
566 $this->assertResult('<b>foobar</b>');
569 public function testParentElement()
571 $this->config
->set('HTML.Allowed', 'p,ul,li');
572 $this->assertResult('Foo<ul><li>Bar</li></ul>', "<p>Foo</p>\n\n<ul><li>Bar</li></ul>");
577 // vim: et sw=4 sts=4