Merge "mediawiki.Title: Add 'params' parameter to #getUrl"
[lhc/web/wiklou.git] / tests / phpunit / includes / parser / TidyTest.php
1 <?php
2
3 /**
4 * @group Parser
5 */
6 class TidyTest extends MediaWikiTestCase {
7 public function setUp() {
8 parent::setUp();
9 $check = MWTidy::tidy( '' );
10 if ( strpos( $check, '<!--' ) !== false ) {
11 $this->markTestSkipped( 'Tidy not found' );
12 }
13 }
14
15 /**
16 * @dataProvider provideTestWrapping
17 */
18 public function testTidyWrapping( $expected, $text, $msg = '' ) {
19 $text = MWTidy::tidy( $text );
20 // We don't care about where Tidy wants to stick is <p>s
21 $text = trim( preg_replace( '#</?p>#', '', $text ) );
22 // Windows, we love you!
23 $text = str_replace( "\r", '', $text );
24 $this->assertEquals( $expected, $text, $msg );
25 }
26
27 public function provideTestWrapping() {
28 return array(
29 array(
30 '<mw:editsection page="foo" section="bar">foo</mw:editsection>',
31 '<mw:editsection page="foo" section="bar">foo</mw:editsection>',
32 '<mw:editsection> should survive tidy'
33 ),
34 array(
35 '<editsection page="foo" section="bar">foo</editsection>',
36 '<editsection page="foo" section="bar">foo</editsection>',
37 '<editsection> should survive tidy'
38 ),
39 array( '<mw:toc>foo</mw:toc>', '<mw:toc>foo</mw:toc>', '<mw:toc> should survive tidy' ),
40 array( "<link foo=\"bar\" />\nfoo", '<link foo="bar"/>foo', '<link> should survive tidy' ),
41 array( "<meta foo=\"bar\" />\nfoo", '<meta foo="bar"/>foo', '<meta> should survive tidy' ),
42 );
43 }
44 }