From 63ce38567c6197ff397fadc336f1d6af859ee343 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Tue, 10 Jun 2014 21:37:37 +0200 Subject: [PATCH] LinkerTest: A bunch of tests for Linker::formatComment and friends Change-Id: Ie805d2945ddc1596545ef3f22d32b429caca8a27 --- tests/phpunit/includes/LinkerTest.php | 101 ++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) diff --git a/tests/phpunit/includes/LinkerTest.php b/tests/phpunit/includes/LinkerTest.php index 110cbacfe9..9889b0863e 100644 --- a/tests/phpunit/includes/LinkerTest.php +++ b/tests/phpunit/includes/LinkerTest.php @@ -82,4 +82,105 @@ class LinkerTest extends MediaWikiLangTestCase { # TODO! ); } + + /** + * @dataProvider provideCasesForFormatComment + * @covers Linker::formatComment + * @covers Linker::formatAutocomments + * @covers Linker::formatLinksInComment + */ + public function testFormatComment( $expected, $comment, $title = false, $local = false ) { + $this->setMwGlobals( array( + 'wgArticlePath' => '/wiki/$1', + 'wgWellFormedXml' => true, + ) ); + + if ( $title === false ) { + // We need a page title that exists + $title = Title::newFromText( 'Special:BlankPage' ); + } + + $this->assertEquals( + $expected, + Linker::formatComment( $comment, $title, $local ) + ); + } + + public static function provideCasesForFormatComment() { + return array( + // Linker::formatComment + array( + 'a<script>b', + 'a