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