c869258d0e902134b76e12e70fd033cdb7df315c
6 class TidyTest
extends MediaWikiTestCase
{
8 protected function setUp() {
10 $check = MWTidy
::tidy( '' );
11 if ( strpos( $check, '<!--' ) !== false ) {
12 $this->markTestSkipped( 'Tidy not found' );
17 * @dataProvider provideTestWrapping
19 public function testTidyWrapping( $expected, $text, $msg = '' ) {
20 $text = MWTidy
::tidy( $text );
21 // We don't care about where Tidy wants to stick is <p>s
22 $text = trim( preg_replace( '#</?p>#', '', $text ) );
23 // Windows, we love you!
24 $text = str_replace( "\r", '', $text );
25 $this->assertEquals( $expected, $text, $msg );
28 public function provideTestWrapping() {
29 $testMathML = <<<'MathML'
30 <math xmlns="http://www.w3.org/1998/Math/MathML">
33 <mo>⁢</mo>
40 <mo>⁢ </mo>
49 '<mw:editsection page="foo
" section="bar
">foo</mw:editsection>',
50 '<mw:editsection page="foo
" section="bar
">foo</mw:editsection>',
51 '<mw:editsection> should survive tidy'
54 '<editsection page="foo
" section="bar
">foo</editsection>',
55 '<editsection page="foo
" section="bar
">foo</editsection>',
56 '<editsection> should survive tidy'
58 array( '<mw:toc>foo</mw:toc>', '<mw:toc>foo</mw:toc>', '<mw:toc> should survive tidy' ),
59 array( "<link foo
=\"bar\"
/>\nfoo
", '<link foo="bar
"/>foo', '<link> should survive tidy' ),
60 array( "<meta foo
=\"bar\"
/>\nfoo
", '<meta foo="bar
"/>foo', '<meta> should survive tidy' ),
61 array( $testMathML, $testMathML, '<math> should survive tidy' ),