filterContent(); $html = $formatter->getText(); $this->assertEquals( self::normalize( $expected ), self::normalize( $html ) ); } private static function normalize( $s ) { return str_replace( "\n", '', str_replace( "\r", '', $s ) // "yay" to Windows! ); } public function getHtmlData() { $removeImages = function( HtmlFormatter $f ) { $f->setRemoveMedia(); }; $removeTags = function( HtmlFormatter $f ) { $f->remove( array( 'table', '.foo', '#bar', 'div.baz' ) ); }; $flattenSomeStuff = function( HtmlFormatter $f ) { $f->flatten( array( 's', 'div' ) ); }; $flattenEverything = function( HtmlFormatter $f ) { $f->flattenAllTags(); }; return array( // remove images if asked array( 'Blah', '', $removeImages, ), // basic tag removal array( '
foo
foo
foo
bar foobar
test
baz', '
test
baz', $removeTags, ), // don't flatten tags that start like chosen ones array( '
foo bar
', 'foo bar', $flattenSomeStuff, ), // total flattening array( '
bar2
', 'bar2', $flattenEverything, ), // UTF-8 preservation and security array( '<Тест!> &<&&&&', '<Тест!> &<&&&&', ), // https://bugzilla.wikimedia.org/show_bug.cgi?id=53086 array( 'Foo[1] Bar', 'Foo[1] Bar', ), ); } }