obj = new HTMLPurifier_Strategy_MakeWellFormed(); $this->config->set('AutoFormat.AutoParagraph', true); $this->config->set('AutoFormat.Linkify', true); $this->config->set('AutoFormat.RemoveEmpty', true); generate_mock_once('HTMLPurifier_Injector'); } function testEndHandler() { $mock = new HTMLPurifier_InjectorMock(); $b = new HTMLPurifier_Token_End('b'); $b->skip = array(0 => true); $b->start = new HTMLPurifier_Token_Start('b'); $b->start->skip = array(0 => true, 1 => true); $mock->expectAt(0, 'handleEnd', array($b)); $i = new HTMLPurifier_Token_End('i'); $i->start = new HTMLPurifier_Token_Start('i'); $i->skip = array(0 => true); $i->start->skip = array(0 => true, 1 => true); $mock->expectAt(1, 'handleEnd', array($i)); $mock->expectCallCount('handleEnd', 2); $mock->setReturnValue('getRewind', false); $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', '' ); } function testParagraphWrappingNodeContainingLink() { $this->assertResult( 'http://example.com', '' ); } function testParagraphWrappingPoorlyFormedNodeContainingLink() { $this->assertResult( 'http://example.com', '' ); } function testTwoParagraphsContainingOnlyOneLink() { $this->assertResult( "http://example.com\n\nhttp://dev.example.com", ' ' ); } function testParagraphNextToDivWithLinks() { $this->assertResult( 'http://example.comThis URL http://example.com is what you need
' ); } function testParagraphAfterLinkifiedURL() { $this->assertResult( "http://google.com b", "b
" ); } function testEmptyAndParagraph() { // This is a fairly degenerate case, but it demonstrates that // the two don't error out together, at least. // Change this behavior! $this->assertResult( "asdf asdf
", "asdf
asdf
" ); } function testRewindAndParagraph() { $this->assertResult( "barfoo", "
bar
foo
" ); } } // vim: et sw=4 sts=4