MediaWiki REL1_31
TidyTest.php
Go to the documentation of this file.
1<?php
2
7
8 protected function setUp() {
9 parent::setUp();
10 if ( !MWTidy::isEnabled() ) {
11 $this->markTestSkipped( 'Tidy not found' );
12 }
13 }
14
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 static function provideTestWrapping() {
28 $testMathML = <<<'MathML'
29<math xmlns="http://www.w3.org/1998/Math/MathML">
30 <mrow>
31 <mi>a</mi>
32 <mo>&InvisibleTimes;</mo>
33 <msup>
34 <mi>x</mi>
35 <mn>2</mn>
36 </msup>
37 <mo>+</mo>
38 <mi>b</mi>
39 <mo>&InvisibleTimes; </mo>
40 <mi>x</mi>
41 <mo>+</mo>
42 <mi>c</mi>
43 </mrow>
44 </math>
45MathML;
46 return [
47 [
48 '<mw:editsection page="foo" section="bar">foo</mw:editsection>',
49 '<mw:editsection page="foo" section="bar">foo</mw:editsection>',
50 '<mw:editsection> should survive tidy'
51 ],
52 [
53 '<editsection page="foo" section="bar">foo</editsection>',
54 '<editsection page="foo" section="bar">foo</editsection>',
55 '<editsection> should survive tidy'
56 ],
57 [ '<mw:toc>foo</mw:toc>', '<mw:toc>foo</mw:toc>', '<mw:toc> should survive tidy' ],
58 [ "<link foo=\"bar\" />foo", '<link foo="bar"/>foo', '<link> should survive tidy' ],
59 [ "<meta foo=\"bar\" />foo", '<meta foo="bar"/>foo', '<meta> should survive tidy' ],
60 [ $testMathML, $testMathML, '<math> should survive tidy' ],
61 ];
62 }
63}
type show c for details The hypothetical commands show w and show c should show the appropriate parts of the General Public License Of the commands you use may be called something other than show w and show c
Definition COPYING.txt:322
static tidy( $text)
Interface with html tidy.
Definition MWTidy.php:46
static isEnabled()
Definition MWTidy.php:58
Parser.
Definition TidyTest.php:6
static provideTestWrapping()
Definition TidyTest.php:27
testTidyWrapping( $expected, $text, $msg='')
provideTestWrapping
Definition TidyTest.php:18