Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4142850
TidyTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
TidyTest.php
View Options
<?php
namespace
MediaWiki\Tests\Parser
;
use
MediaWiki\Parser\MWTidy
;
use
MediaWiki\Parser\Sanitizer
;
/**
* @group Parser
* @covers \MediaWiki\Parser\MWTidy
*/
class
TidyTest
extends
\MediaWikiIntegrationTestCase
{
/**
* @dataProvider provideTestWrapping
*/
public
function
testTidyWrapping
(
$expected
,
$text
,
$msg
=
''
)
{
$text
=
MWTidy
::
tidy
(
$text
);
// We don't care about where Tidy wants to stick is <p>s
$text
=
trim
(
preg_replace
(
'#</?p>#'
,
''
,
$text
)
);
// Windows, we love you!
$text
=
str_replace
(
"
\r
"
,
''
,
$text
);
$this
->
assertEquals
(
$expected
,
$text
,
$msg
);
}
public
static
function
provideTestWrapping
()
{
$testMathML
=
<<<'MathML'
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<mi>a</mi>
<mo>⁢</mo>
<msup>
<mi>x</mi>
<mn>2</mn>
</msup>
<mo>+</mo>
<mi>b</mi>
<mo>⁢ </mo>
<mi>x</mi>
<mo>+</mo>
<mi>c</mi>
</mrow>
</math>
MathML;
$testMathML
=
Sanitizer
::
normalizeCharReferences
(
$testMathML
);
return
[
[
'<mw:editsection page="foo" section="bar">foo</mw:editsection>'
,
'<mw:editsection page="foo" section="bar">foo</mw:editsection>'
,
'<mw:editsection> should survive tidy'
],
[
'<meta property="mw:PageProp/toc" />'
,
'<meta property="mw:PageProp/toc" />'
,
'TOC_PLACEHOLDER should survive tidy'
,
],
[
"<link foo=
\"
bar
\"
/>foo"
,
'<link foo="bar"/>foo'
,
'<link> should survive tidy'
],
[
"<meta foo=
\"
bar
\"
/>foo"
,
'<meta foo="bar"/>foo'
,
'<meta> should survive tidy'
],
[
$testMathML
,
$testMathML
,
'<math> should survive tidy'
],
];
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Aug 19 2026, 16:33 (4 w, 2 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
74/d0/2212bf8f81977355dd045d129757
Default Alt Text
TidyTest.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment