MediaWiki
REL1_24
|
00001 <?php 00002 00006 class TidyTest extends MediaWikiTestCase { 00007 00008 protected function setUp() { 00009 parent::setUp(); 00010 $check = MWTidy::tidy( '' ); 00011 if ( strpos( $check, '<!--' ) !== false ) { 00012 $this->markTestSkipped( 'Tidy not found' ); 00013 } 00014 } 00015 00019 public function testTidyWrapping( $expected, $text, $msg = '' ) { 00020 $text = MWTidy::tidy( $text ); 00021 // We don't care about where Tidy wants to stick is <p>s 00022 $text = trim( preg_replace( '#</?p>#', '', $text ) ); 00023 // Windows, we love you! 00024 $text = str_replace( "\r", '', $text ); 00025 $this->assertEquals( $expected, $text, $msg ); 00026 } 00027 00028 public static function provideTestWrapping() { 00029 $testMathML = <<<'MathML' 00030 <math xmlns="http://www.w3.org/1998/Math/MathML"> 00031 <mrow> 00032 <mi>a</mi> 00033 <mo>⁢</mo> 00034 <msup> 00035 <mi>x</mi> 00036 <mn>2</mn> 00037 </msup> 00038 <mo>+</mo> 00039 <mi>b</mi> 00040 <mo>⁢ </mo> 00041 <mi>x</mi> 00042 <mo>+</mo> 00043 <mi>c</mi> 00044 </mrow> 00045 </math> 00046 MathML; 00047 return array( 00048 array( 00049 '<mw:editsection page="foo" section="bar">foo</mw:editsection>', 00050 '<mw:editsection page="foo" section="bar">foo</mw:editsection>', 00051 '<mw:editsection> should survive tidy' 00052 ), 00053 array( 00054 '<editsection page="foo" section="bar">foo</editsection>', 00055 '<editsection page="foo" section="bar">foo</editsection>', 00056 '<editsection> should survive tidy' 00057 ), 00058 array( '<mw:toc>foo</mw:toc>', '<mw:toc>foo</mw:toc>', '<mw:toc> should survive tidy' ), 00059 array( "<link foo=\"bar\" />\nfoo", '<link foo="bar"/>foo', '<link> should survive tidy' ), 00060 array( "<meta foo=\"bar\" />\nfoo", '<meta foo="bar"/>foo', '<meta> should survive tidy' ), 00061 array( $testMathML, $testMathML, '<math> should survive tidy' ), 00062 ); 00063 } 00064 }