This combines two changes – defaulting tidying to on, previously off, and defaulting the tidying library to RemexHtml, previously the tidy binary. Config options are going to be a bit of a mess until we drop support for the old tidy binary config route. Bug: T185753 Depends-On: I0a8973f508fbf65160177b003260831639828eeb Change-Id: I6879a77a78d780c7c056d807dde20682c6097d1b
63 lines
1.7 KiB
PHP
63 lines
1.7 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @group Parser
|
|
*/
|
|
class TidyTest extends MediaWikiTestCase {
|
|
|
|
protected function setUp() {
|
|
parent::setUp();
|
|
if ( !MWTidy::isEnabled() ) {
|
|
$this->markTestSkipped( 'Tidy not found' );
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @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;
|
|
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' ],
|
|
[ "<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' ],
|
|
];
|
|
}
|
|
}
|