wiki.techinc.nl/tests/phpunit/includes/parser/TidyTest.php
Timo Tijhof 96771e3a65 test: Clean up data providers that should be static
Follows-up b36d883.

By far most data providers are static (and PHPUnit expects them
to be static and calls them that way).

Most of these classes already had their data providers static
but additional commits sloppily introduced non-static ones.

* ResourceLoaderWikiModuleTest, 8968d8787f.
* TitleTest, 545f1d3a73.
  Odd unused method 'dataTestIsValidMoveOperation' was introduced
  in 550b878e63.
* GlobalVarConfigTest, a3e18c3670.

Change-Id: I5da99f7cd3da68c550ae507ffe1f725d31e7666f
2014-09-18 12:52:44 -07:00

64 lines
1.8 KiB
PHP

<?php
/**
* @group Parser
*/
class TidyTest extends MediaWikiTestCase {
protected function setUp() {
parent::setUp();
$check = MWTidy::tidy( '' );
if ( strpos( $check, '<!--' ) !== false ) {
$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>&InvisibleTimes;</mo>
<msup>
<mi>x</mi>
<mn>2</mn>
</msup>
<mo>+</mo>
<mi>b</mi>
<mo>&InvisibleTimes; </mo>
<mi>x</mi>
<mo>+</mo>
<mi>c</mi>
</mrow>
</math>
MathML;
return array(
array(
'<mw:editsection page="foo" section="bar">foo</mw:editsection>',
'<mw:editsection page="foo" section="bar">foo</mw:editsection>',
'<mw:editsection> should survive tidy'
),
array(
'<editsection page="foo" section="bar">foo</editsection>',
'<editsection page="foo" section="bar">foo</editsection>',
'<editsection> should survive tidy'
),
array( '<mw:toc>foo</mw:toc>', '<mw:toc>foo</mw:toc>', '<mw:toc> should survive tidy' ),
array( "<link foo=\"bar\" />\nfoo", '<link foo="bar"/>foo', '<link> should survive tidy' ),
array( "<meta foo=\"bar\" />\nfoo", '<meta foo="bar"/>foo', '<meta> should survive tidy' ),
array( $testMathML, $testMathML, '<math> should survive tidy' ),
);
}
}