Debian Codegraph @

tests/phpunit/integration/includes/parser/TidyTest.php

raw symbols SCIP
1 <?php
2
3 namespace MediaWiki\Tests\Parser;
4
5 use MediaWiki\Parser\MWTidy;
6 use MediaWiki\Parser\Sanitizer;
7
8 /**
9 * @group Parser
10 * @covers \MediaWiki\Parser\MWTidy
11 */
12 class TidyTest extends \MediaWikiIntegrationTestCase {
13
14 /**
15 * @dataProvider provideTestWrapping
16 */
17 public function testTidyWrapping( $expected, $text, $msg = '' ) {
18 $text = MWTidy::tidy( $text );
19 // We don't care about where Tidy wants to stick is <p>s
20 $text = trim( preg_replace( '#</?p>#', '', $text ) );
21 // Windows, we love you!
22 $text = str_replace( "\r", '', $text );
23 $this->assertEquals( $expected, $text, $msg );
24 }
25
26 public static function provideTestWrapping() {
27 $testMathML = <<<'MathML'
28 <math xmlns="http://www.w3.org/1998/Math/MathML">
29 <mrow>
30 <mi>a</mi>
31 <mo>&InvisibleTimes;</mo>
32 <msup>
33 <mi>x</mi>
34 <mn>2</mn>
35 </msup>
36 <mo>+</mo>
37 <mi>b</mi>
38 <mo>&InvisibleTimes; </mo>
39 <mi>x</mi>
40 <mo>+</mo>
41 <mi>c</mi>
42 </mrow>
43 </math>
44 MathML;
45 $testMathML = Sanitizer::normalizeCharReferences( $testMathML );
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 '<meta property="mw:PageProp/toc" />',
54 '<meta property="mw:PageProp/toc" />',
55 'TOC_PLACEHOLDER should survive tidy',
56 ],
57 [ "<link foo=\"bar\" />foo", '<link foo="bar"/>foo', '<link> should survive tidy' ],
58 [ "<meta foo=\"bar\" />foo", '<meta foo="bar"/>foo', '<meta> should survive tidy' ],
59 [ $testMathML, $testMathML, '<math> should survive tidy' ],
60 ];
61 }
62 }