This changeset resumes work on T89432 and related tickets by porting an initial set of tests to the new unit test suite separated out in I69b92db3e70093570e05cc0a64c7780a278b321a. The tests were only ported if they worked immediately without requiring any changes other than changing the test case class to MediaWikiUnitTestCase and moving the test to the new suite. If a test failed for any reason (even trivial misconfiguration), it was NOT ported. With this change, the unit tests suite now consits of a total of 455 tests. As before, you can run these tests via the following command: $ composer phpunit:unit Bug: T84948 Bug: T89432 Bug: T87781 Change-Id: Ibb8175981092d7f41864e641cc3c118af70a5c76
64 lines
1.7 KiB
PHP
64 lines
1.7 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @group Parser
|
|
* @covers MWTidy
|
|
*/
|
|
class TidyTest extends \MediaWikiUnitTestCase {
|
|
|
|
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' ],
|
|
];
|
|
}
|
|
}
|