MediaWiki  REL1_23
TidyTest.php
Go to the documentation of this file.
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 function provideTestWrapping() {
00029         return array(
00030             array(
00031                 '<mw:editsection page="foo" section="bar">foo</mw:editsection>',
00032                 '<mw:editsection page="foo" section="bar">foo</mw:editsection>',
00033                 '<mw:editsection> should survive tidy'
00034             ),
00035             array(
00036                 '<editsection page="foo" section="bar">foo</editsection>',
00037                 '<editsection page="foo" section="bar">foo</editsection>',
00038                 '<editsection> should survive tidy'
00039             ),
00040             array( '<mw:toc>foo</mw:toc>', '<mw:toc>foo</mw:toc>', '<mw:toc> should survive tidy' ),
00041             array( "<link foo=\"bar\" />\nfoo", '<link foo="bar"/>foo', '<link> should survive tidy' ),
00042             array( "<meta foo=\"bar\" />\nfoo", '<meta foo="bar"/>foo', '<meta> should survive tidy' ),
00043         );
00044     }
00045 }