MediaWiki REL1_33
TidyTest.php
Go to the documentation of this file.
1<?php
2
8
9 protected function setUp() {
10 parent::setUp();
11 if ( !MWTidy::isEnabled() ) {
12 $this->markTestSkipped( 'Tidy not found' );
13 }
14 }
15
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 static function provideTestWrapping() {
29 $testMathML = <<<'MathML'
30<math xmlns="http://www.w3.org/1998/Math/MathML">
31 <mrow>
32 <mi>a</mi>
33 <mo>&InvisibleTimes;</mo>
34 <msup>
35 <mi>x</mi>
36 <mn>2</mn>
37 </msup>
38 <mo>+</mo>
39 <mi>b</mi>
40 <mo>&InvisibleTimes; </mo>
41 <mi>x</mi>
42 <mo>+</mo>
43 <mi>c</mi>
44 </mrow>
45 </math>
46MathML;
47 return [
48 [
49 '<mw:editsection page="foo" section="bar">foo</mw:editsection>',
50 '<mw:editsection page="foo" section="bar">foo</mw:editsection>',
51 '<mw:editsection> should survive tidy'
52 ],
53 [
54 '<editsection page="foo" section="bar">foo</editsection>',
55 '<editsection page="foo" section="bar">foo</editsection>',
56 '<editsection> should survive tidy'
57 ],
58 [ '<mw:toc>foo</mw:toc>', '<mw:toc>foo</mw:toc>', '<mw:toc> should survive tidy' ],
59 [ "<link foo=\"bar\" />foo", '<link foo="bar"/>foo', '<link> should survive tidy' ],
60 [ "<meta foo=\"bar\" />foo", '<meta foo="bar"/>foo', '<meta> should survive tidy' ],
61 [ $testMathML, $testMathML, '<math> should survive tidy' ],
62 ];
63 }
64}
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
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
static tidy( $text)
Interface with Remex tidy.
Definition MWTidy.php:42
static isEnabled()
Definition MWTidy.php:54
Parser MWTidy.
Definition TidyTest.php:7
static provideTestWrapping()
Definition TidyTest.php:28
testTidyWrapping( $expected, $text, $msg='')
provideTestWrapping
Definition TidyTest.php:19