obj = new HTMLPurifier_Strategy_MakeWellFormed(); $this->config->set('AutoFormat', 'AutoParagraph', true); $this->config->set('AutoFormat', 'Linkify', true); generate_mock_once('HTMLPurifier_Injector'); } function testEndNotification() { $mock = new HTMLPurifier_InjectorMock(); $mock->skip = false; $mock->expectAt(0, 'notifyEnd', array(new HTMLPurifier_Token_End('b'))); $mock->expectAt(1, 'notifyEnd', array(new HTMLPurifier_Token_End('i'))); $mock->expectCallCount('notifyEnd', 2); $this->config->set('AutoFormat', 'AutoParagraph', false); $this->config->set('AutoFormat', 'Linkify', false); $this->config->set('AutoFormat', 'Custom', array($mock)); $this->assertResult('asdf', 'asdf'); } function testErrorRequiredElementNotAllowed() { $this->config->set('HTML', 'Allowed', ''); $this->expectError('Cannot enable AutoParagraph injector because p is not allowed'); $this->expectError('Cannot enable Linkify injector because a is not allowed'); $this->assertResult('Foobar'); } function testErrorRequiredAttributeNotAllowed() { $this->config->set('HTML', 'Allowed', 'a,p'); $this->expectError('Cannot enable Linkify injector because a.href is not allowed'); $this->assertResult('

http://example.com

'); } function testOnlyAutoParagraph() { $this->assertResult( 'Foobar', '

Foobar

' ); } function testParagraphWrappingOnlyLink() { $this->assertResult( 'http://example.com', '

http://example.com

' ); } function testParagraphWrappingNodeContainingLink() { $this->assertResult( 'http://example.com', '

http://example.com

' ); } function testParagraphWrappingPoorlyFormedNodeContainingLink() { $this->assertResult( 'http://example.com', '

http://example.com

' ); } function testTwoParagraphsContainingOnlyOneLink() { $this->assertResult( "http://example.com\n\nhttp://dev.example.com", '

http://example.com

http://dev.example.com

' ); } function testParagraphNextToDivWithLinks() { $this->assertResult( 'http://example.com
http://example.com
', '

http://example.com

http://example.com
' ); } function testRealisticLinkInSentence() { $this->assertResult( 'This URL http://example.com is what you need', '

This URL http://example.com is what you need

' ); } function testParagraphAfterLinkifiedURL() { $this->assertResult( "http://google.com\n\nb", "

http://google.com

b

" ); } }