Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4104423
ContentDOMTransformStageTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
ContentDOMTransformStageTest.php
View Options
<?php
namespace
MediaWiki\OutputTransform
;
use
MediaWiki\Config\ServiceOptions
;
use
MediaWiki\MediaWikiServices
;
use
MediaWiki\Parser\ParserOutput
;
use
MediaWiki\Parser\Parsoid\PageBundleParserOutputConverter
;
use
MediaWiki\Tests\OutputTransform\DummyDOMTransformStage
;
use
PHPUnit\Framework\TestCase
;
use
Psr\Log\NullLogger
;
use
Wikimedia\Parsoid\Core\PageBundle
;
class
ContentDOMTransformStageTest
extends
TestCase
{
public
function
createStage
():
ContentDOMTransformStage
{
return
new
DummyDOMTransformStage
(
new
ServiceOptions
(
[]
),
new
NullLogger
()
);
}
/**
* Regression test for T365036 - checking that a very basic ParserOutput continues serializing after going
* through a ContentDOMTransformStage
* @covers \MediaWiki\OutputTransform\ContentDOMTransformStage::transformDOM
*/
public
function
testTransform
()
{
$html
=
"<div>some output</div>"
;
$po
=
new
ParserOutput
(
$html
);
PageBundleParserOutputConverter
::
applyPageBundleDataToParserOutput
(
new
PageBundle
(
$html
),
$po
);
$transform
=
$this
->
createStage
();
$options
=
[
'isParsoidContent'
=>
true
];
$po
=
$transform
->
transform
(
$po
,
null
,
$options
);
$json
=
MediaWikiServices
::
getInstance
()->
getJsonCodec
()->
serialize
(
$po
);
self
::
assertStringContainsString
(
"parsoid-page-bundle"
,
$json
);
}
/**
* @covers \MediaWiki\OutputTransform\ContentDOMTransformStage::parsoidTransform
* @covers \MediaWiki\OutputTransform\ContentDOMTransformStage::legacyTransform
*/
public
function
testTransformOption
()
{
$html
=
"<div>some output</div>"
;
$po
=
new
ParserOutput
(
$html
);
$transform
=
$this
->
createStage
();
// Legacy, should roundtrip the input
$options
=
[
'isParsoidContent'
=>
false
];
$po
=
$transform
->
transform
(
$po
,
null
,
$options
);
$text
=
$po
->
getContentHolderText
();
$this
->
assertEquals
(
$html
,
$text
);
// Parsoid, input is sullied with rich attributes
$options
=
[
'isParsoidContent'
=>
true
];
$po
=
$transform
->
transform
(
$po
,
null
,
$options
);
$text
=
$po
->
getContentHolderText
();
$this
->
assertNotEquals
(
$html
,
$text
);
// Without PageBundle data, attributes are inlined
self
::
assertStringContainsString
(
"data-parsoid"
,
$text
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, Aug 18, 18:27 (3 w, 1 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
ea/73/54590b1c7ac867756dede479c203
Default Alt Text
ContentDOMTransformStageTest.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment