From 7a40f4354b32809af3d0cfd6e3af0eda02ab0e0a Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 12 May 2012 17:57:41 -0700 Subject: some important stuff we'll need --- .../HTMLPurifier/Injector/AutoParagraphTest.php | 515 +++++++++++++++++++++ 1 file changed, 515 insertions(+) create mode 100644 lib/htmlpurifier/tests/HTMLPurifier/Injector/AutoParagraphTest.php (limited to 'lib/htmlpurifier/tests/HTMLPurifier/Injector/AutoParagraphTest.php') diff --git a/lib/htmlpurifier/tests/HTMLPurifier/Injector/AutoParagraphTest.php b/lib/htmlpurifier/tests/HTMLPurifier/Injector/AutoParagraphTest.php new file mode 100644 index 000000000..e6abbd1ff --- /dev/null +++ b/lib/htmlpurifier/tests/HTMLPurifier/Injector/AutoParagraphTest.php @@ -0,0 +1,515 @@ +config->set('AutoFormat.AutoParagraph', true); + } + + function testSingleParagraph() { + $this->assertResult( + 'Foobar', + '

Foobar

' + ); + } + + function testSingleMultiLineParagraph() { + $this->assertResult( +'Par 1 +Par 1 still', +'

Par 1 +Par 1 still

' + ); + } + + function testTwoParagraphs() { + $this->assertResult( +'Par1 + +Par2', +"

Par1

+ +

Par2

" + ); + } + + function testTwoParagraphsWithLotsOfSpace() { + $this->assertResult( +'Par1 + + + +Par2', +'

Par1

+ +

Par2

' + ); + } + + function testTwoParagraphsWithInlineElements() { + $this->assertResult( +'Par1 + +Par2', +'

Par1

+ +

Par2

' + ); + } + + function testSingleParagraphThatLooksLikeTwo() { + $this->assertResult( +'Par1 + +Par2', +'

Par1 + +Par2

' + ); + } + + function testAddParagraphAdjacentToParagraph() { + $this->assertResult( + 'Par1

Par2

', +'

Par1

+ +

Par2

' + ); + } + + function testParagraphUnclosedInlineElement() { + $this->assertResult( + 'Par1', + '

Par1

' + ); + } + + function testPreservePreTags() { + $this->assertResult( +'
Par1
+
+Par1
' + ); + } + + function testIgnoreTrailingWhitespace() { + $this->assertResult( +'Par1 + + ', +'

Par1

+ +' + ); + } + + function testDoNotParagraphBlockElements() { + $this->assertResult( +'Par1 + +
Par2
+ +Par3', +'

Par1

+ +
Par2
+ +

Par3

' + ); + } + + function testParagraphTextAndInlineNodes() { + $this->assertResult( +'Par1', + '

Par1

' + ); + } + + function testPreserveLeadingWhitespace() { + $this->assertResult( +' + +Par', +' + +

Par

' + ); + } + + function testPreserveSurroundingWhitespace() { + $this->assertResult( +' + +Par + +', +' + +

Par

+ +' + ); + } + + function testParagraphInsideBlockNode() { + $this->assertResult( +'
Par1 + +Par2
', +'

Par1

+ +

Par2

' + ); + } + + function testParagraphInlineNodeInsideBlockNode() { + $this->assertResult( +'
Par1 + +Par2
', +'

Par1

+ +

Par2

' + ); + } + + function testNoParagraphWhenOnlyOneInsideBlockNode() { + $this->assertResult('
Par1
'); + } + + function testParagraphTwoInlineNodesInsideBlockNode() { + $this->assertResult( +'
Par1 + +Par2
', +'

Par1

+ +

Par2

' + ); + } + + function testPreserveInlineNodesInPreTag() { + $this->assertResult( +'
Par1
+
+Par2
' + ); + } + + function testSplitUpInternalsOfPTagInBlockNode() { + $this->assertResult( +'

Foo + +Bar

', +'

Foo

+ +

Bar

' + ); + } + + function testSplitUpInlineNodesInPTagInBlockNode() { + $this->assertResult( +'

Foo + +Bar

', +'

Foo

+ +

Bar

' + ); + } + + function testNoParagraphSingleInlineNodeInBlockNode() { + $this->assertResult( '
Foo
' ); + } + + function testParagraphInBlockquote() { + $this->assertResult( +'
Par1 + +Par2
', +'

Par1

+ +

Par2

' + ); + } + + function testNoParagraphBetweenListItem() { + $this->assertResult( +'' + ); + } + + function testParagraphSingleElementWithSurroundingSpace() { + $this->assertResult( +'
+ +Bar + +
', + '
+ +

Bar

+ +
' + ); + } + + function testIgnoreExtraSpaceWithLeadingInlineNode() { + $this->assertResult( +'Par1a + + + +Par2', +'

Par1a

+ +

Par2

' + ); + } + + function testAbsorbExtraEndingPTag() { + $this->assertResult( +'Par1 + +Par2

', +'

Par1

+ +

Par2

' + ); + } + + function testAbsorbExtraEndingDivTag() { + $this->assertResult( +'Par1 + +Par2', +'

Par1

+ +

Par2

' + ); + } + + function testDoNotParagraphSingleSurroundingSpaceInBlockNode() { + $this->assertResult( +'
+Par1 +
' + ); + } + + function testBlockNodeTextDelimeterInBlockNode() { + $this->assertResult( +'
Par1 + +
Par2
', +'

Par1

+ +
Par2
' + ); + } + + function testBlockNodeTextDelimeterWithoutDoublespaceInBlockNode() { + $this->assertResult( +'
Par1 +
Par2
' + ); + } + + function testBlockNodeTextDelimeterWithoutDoublespace() { + $this->assertResult( +'Par1 +
Par2
', +'

Par1 +

+ +
Par2
' + ); + } + + function testTwoParagraphsOfTextAndInlineNode() { + $this->assertResult( +'Par1 + +Par2', +'

Par1

+ +

Par2

' + ); + } + + function testLeadingInlineNodeParagraph() { + $this->assertResult( +' Foo', +'

Foo

' + ); + } + + function testTrailingInlineNodeParagraph() { + $this->assertResult( +'
  • Foo bar
  • ' + ); + } + + function testTwoInlineNodeParagraph() { + $this->assertResult( +'
  • bazbar
  • ' + ); + } + + function testNoParagraphTrailingBlockNodeInBlockNode() { + $this->assertResult( +'
    asdf
    asdf
    ' + ); + } + + function testParagraphTrailingBlockNodeWithDoublespaceInBlockNode() { + $this->assertResult( +'
    asdf
    + +asdf
    ', +'
    asdf
    + +

    asdf

    ' + ); + } + + function testParagraphTwoInlineNodesAndWhitespaceNode() { + $this->assertResult( +'One Two', +'

    One Two

    ' + ); + } + + function testNoParagraphWithInlineRootNode() { + $this->config->set('HTML.Parent', 'span'); + $this->assertResult( +'Par + +Par2' + ); + } + + function testInlineAndBlockTagInDivNoParagraph() { + $this->assertResult( + '
    bar mmm
    asdf
    ' + ); + } + + function testInlineAndBlockTagInDivNeedingParagraph() { + $this->assertResult( +'
    bar mmm + +
    asdf
    ', +'

    bar mmm

    + +
    asdf
    ' + ); + } + + function testTextInlineNodeTextThenDoubleNewlineNeedsParagraph() { + $this->assertResult( +'
    asdf bar mmm + +
    asdf
    ', +'

    asdf bar mmm

    + +
    asdf
    ' + ); + } + + function testUpcomingTokenHasNewline() { + $this->assertResult( +'
    Testfoobarbingbang + +boo
    ', +'

    Testfoobarbingbang

    + +

    boo

    ' +); + } + + function testEmptyTokenAtEndOfDiv() { + $this->assertResult( +'

    foo

    +
    ', +'

    foo

    +
    ' +); + } + + function testEmptyDoubleLineTokenAtEndOfDiv() { + $this->assertResult( +'

    foo

    + +
    ', +'

    foo

    + +
    ' +); + } + + function testTextState11Root() { + $this->assertResult('
    '); + } + + function testTextState11Element() { + $this->assertResult( +"
    + +
    "); + } + + function testTextStateLikeElementState111NoWhitespace() { + $this->assertResult('

    P

    Boo
    ', '

    P

    Boo
    '); + } + + function testElementState111NoWhitespace() { + $this->assertResult('

    P

    Boo
    ', '

    P

    Boo
    '); + } + + function testElementState133() { + $this->assertResult( +"
    B
    Ba
    + +Bar
    ", +"
    B
    Ba
    + +

    Bar

    " +); + } + + function testElementState22() { + $this->assertResult( + '' + ); + } + + function testElementState311() { + $this->assertResult( + '

    Foo

    Bar', +'

    Foo

    + +

    Bar

    ' + ); + } + + function testAutoClose() { + $this->assertResult( + '

    +
    ' + ); + } + + function testErrorNeeded() { + $this->config->set('HTML.Allowed', 'b'); + $this->expectError('Cannot enable AutoParagraph injector because p is not allowed'); + $this->assertResult('foobar'); + } + +} + +// vim: et sw=4 sts=4 -- cgit v1.2.3