Add OutputPage::wrapWikiTextAsInterface() to safely wrap wikitext
[lhc/web/wiklou.git] / tests / phpunit / includes / OutputPageTest.php
index 53e6f46..211169e 100644 (file)
@@ -1430,6 +1430,7 @@ class OutputPageTest extends MediaWikiTestCase {
         * @dataProvider provideAddWikiText
         * @covers OutputPage::addWikiText
         * @covers OutputPage::addWikiTextAsInterface
+        * @covers OutputPage::wrapWikiTextAsInterface
         * @covers OutputPage::addWikiTextAsContent
         * @covers OutputPage::addWikiTextWithTitle
         * @covers OutputPage::addWikiTextTitle
@@ -1545,6 +1546,21 @@ class OutputPageTest extends MediaWikiTestCase {
                                        '<div class="mw-editintro">' . "Some page\n</div>"
                                ],
                        ],
+                       'wrapWikiTextAsInterface' => [
+                               'Simple' => [
+                                       [ 'wrapperClass', 'text' ],
+                                       "<div class=\"wrapperClass\"><p>text\n</p></div>"
+                               ], 'Spurious </div>' => [
+                                       [ 'wrapperClass', 'text</div><div>more' ],
+                                       "<div class=\"wrapperClass\"><p>text</p><div>more\n</div></div>"
+                               ], 'Extra newlines would break <p> wrappers' => [
+                                       [ 'two classes', "1\n\n2\n\n3" ],
+                                       "<div class=\"two classes\"><p>1\n</p><p>2\n</p><p>3\n</p></div>"
+                               ], 'Other unclosed tags' => [
+                                       [ 'error', 'a<b>c<i>d' ],
+                                       "<div class=\"error\"><p>a<b>c<i>d\n</i></b></p></div>"
+                               ],
+                       ],
                ];
 
                // Test all the others on addWikiTextTitle as well