Split out from the I44045b3b9e78e change. This is consistent with what Parsoid will use for the TOC marker. Bug: T287767 Bug: T270199 Bug: T311502 Depends-On: I1f607cf1ef1b61fb4d2e1880de756fb94d5a6b22 Change-Id: Ie63eed07b9bca1bfa07d4c256aba3728cedd8f93
63 lines
1.8 KiB
PHP
63 lines
1.8 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @group Parser
|
|
* @covers MWTidy
|
|
*/
|
|
class TidyTest extends \MediaWikiIntegrationTestCase {
|
|
|
|
/**
|
|
* @dataProvider provideTestWrapping
|
|
*/
|
|
public function testTidyWrapping( $expected, $text, $msg = '' ) {
|
|
$text = MWTidy::tidy( $text );
|
|
// We don't care about where Tidy wants to stick is <p>s
|
|
$text = trim( preg_replace( '#</?p>#', '', $text ) );
|
|
// Windows, we love you!
|
|
$text = str_replace( "\r", '', $text );
|
|
$this->assertEquals( $expected, $text, $msg );
|
|
}
|
|
|
|
public static function provideTestWrapping() {
|
|
$testMathML = <<<'MathML'
|
|
<math xmlns="http://www.w3.org/1998/Math/MathML">
|
|
<mrow>
|
|
<mi>a</mi>
|
|
<mo>⁢</mo>
|
|
<msup>
|
|
<mi>x</mi>
|
|
<mn>2</mn>
|
|
</msup>
|
|
<mo>+</mo>
|
|
<mi>b</mi>
|
|
<mo>⁢ </mo>
|
|
<mi>x</mi>
|
|
<mo>+</mo>
|
|
<mi>c</mi>
|
|
</mrow>
|
|
</math>
|
|
MathML;
|
|
$testMathML = Sanitizer::normalizeCharReferences( $testMathML );
|
|
return [
|
|
[
|
|
'<mw:editsection page="foo" section="bar">foo</mw:editsection>',
|
|
'<mw:editsection page="foo" section="bar">foo</mw:editsection>',
|
|
'<mw:editsection> should survive tidy'
|
|
],
|
|
[
|
|
'<editsection page="foo" section="bar">foo</editsection>',
|
|
'<editsection page="foo" section="bar">foo</editsection>',
|
|
'<editsection> should survive tidy'
|
|
],
|
|
[ '<mw:toc>foo</mw:toc>', '<mw:toc>foo</mw:toc>', '<mw:toc> should survive tidy' ],
|
|
[
|
|
'<meta property="mw:PageProp/toc" />',
|
|
'<meta property="mw:PageProp/toc" />',
|
|
'TOC_PLACEHOLDER should survive tidy',
|
|
],
|
|
[ "<link foo=\"bar\" />foo", '<link foo="bar"/>foo', '<link> should survive tidy' ],
|
|
[ "<meta foo=\"bar\" />foo", '<meta foo="bar"/>foo', '<meta> should survive tidy' ],
|
|
[ $testMathML, $testMathML, '<math> should survive tidy' ],
|
|
];
|
|
}
|
|
}
|