MediaWiki  REL1_22
TidyTest.php
Go to the documentation of this file.
00001 <?php
00002 
00006 class TidyTest extends MediaWikiTestCase {
00007     public function setUp() {
00008         parent::setUp();
00009         $check = MWTidy::tidy( '' );
00010         if ( strpos( $check, '<!--' ) !== false ) {
00011             $this->markTestSkipped( 'Tidy not found' );
00012         }
00013     }
00014 
00018     public function testTidyWrapping( $expected, $text, $msg = '' ) {
00019         $text = MWTidy::tidy( $text );
00020         // We don't care about where Tidy wants to stick is <p>s
00021         $text = trim( preg_replace( '#</?p>#', '', $text ) );
00022         // Windows, we love you!
00023         $text = str_replace( "\r", '', $text );
00024         $this->assertEquals( $expected, $text, $msg );
00025     }
00026 
00027     public function provideTestWrapping() {
00028         return array(
00029             array(
00030                 '<mw:editsection page="foo" section="bar">foo</mw:editsection>',
00031                 '<mw:editsection page="foo" section="bar">foo</mw:editsection>',
00032                 '<mw:editsection> should survive tidy'
00033             ),
00034             array(
00035                 '<editsection page="foo" section="bar">foo</editsection>',
00036                 '<editsection page="foo" section="bar">foo</editsection>',
00037                 '<editsection> should survive tidy'
00038             ),
00039             array( '<mw:toc>foo</mw:toc>', '<mw:toc>foo</mw:toc>', '<mw:toc> should survive tidy' ),
00040             array( "<link foo=\"bar\" />\nfoo", '<link foo="bar"/>foo', '<link> should survive tidy' ),
00041             array( "<meta foo=\"bar\" />\nfoo", '<meta foo="bar"/>foo', '<meta> should survive tidy' ),
00042         );
00043     }
00044 }