From 4ac9fa081a7c045f6a9f1cfc529d82423f485b2e Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 8 Dec 2013 09:55:49 +0100 Subject: Update to MediaWiki 1.22.0 --- tests/phpunit/includes/HtmlFormatterTest.php | 81 ++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 tests/phpunit/includes/HtmlFormatterTest.php (limited to 'tests/phpunit/includes/HtmlFormatterTest.php') diff --git a/tests/phpunit/includes/HtmlFormatterTest.php b/tests/phpunit/includes/HtmlFormatterTest.php new file mode 100644 index 00000000..a37df74f --- /dev/null +++ b/tests/phpunit/includes/HtmlFormatterTest.php @@ -0,0 +1,81 @@ +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', + ), + ); + } +} -- cgit v1.2.3-54-g00ecf