true ]; $mockEnv = new MockEnv( $opts ); $mockSerializer = new WikitextSerializer( [ 'env' => $mockEnv ] ); $mockState = new SerializerState( $mockSerializer, [ 'selserMode' => false, 'rtTestMode' => false, ] ); /** @var DOMNormalizer $DOMNormalizer */ $DOMNormalizer = TestingAccessWrapper::newFromObject( new DOMNormalizer( $mockState ) ); $body = ContentUtils::ppToDOM( $mockEnv, $html, [ 'markNew' => true ] ); $DOMNormalizer->normalize( $body ); if ( $stripDiffMarkers ) { DOMUtils::visitDOM( $body, function ( \DOMNode $node ) { if ( DOMUtils::isDiffMarker( $node ) ) { $node->parentNode->removeChild( $node ); } } ); } $actual = ContentUtils::ppToXML( $body, [ 'discardDataParsoid' => true, 'innerXML' => true ] ); $this->assertEquals( $expected, $actual, $message ); } public function provideNormalize() { return [ // Tag Minimization [ 'XY', 'XY', 'Tag Minimization #1', ], [ 'XY', 'XY', 'Tag Minimization #2', ], [ 'AXYZ', 'AXYZ', 'Tag Minimization #3', ], [ // Second node is a newly inserted node 'FootBall', 'FootBall', 'Tag Minimization #4 Second node is a newly inserted node', ], [ // Both nodes are old unedited nodes 'FootBall', 'FootBall', 'Tag Minimization #5 Both nodes are old unedited nodes', ], // Headings (with scrubWikitext) [ '

H2

', '

H2

', 'Headings (with scrubWikitext) #1' ], [ '

ok

', '

ok

', 'Headings (with scrubWikitext) #2' ], // Empty tag normalization // These are stripped [ '', '', 'Empty tag normalization #1' ], [ '', '', 'Empty tag normalization #2' ], [ '

', '', 'Empty tag normalization #3' ], [ '', '', 'Empty tag normalization #4' ], // These should not be stripped [ '

', '

', 'Empty tag normalization #5' ], [ '
', '
', 'Empty tag normalization #6' ], [ '', '', 'Empty tag normalization #7', ], // Trailing spaces in links [ 'Foo ', 'Foo', 'Trailing spaces in links #1', ], [ 'Foo bar', 'Foo bar', 'Trailing spaces in links #2', ], [ 'Foo bar', 'Foo bar', 'Trailing spaces in links #3', ], // Formatting tags in links [ 'Football', 'Football', 'Formatting tags in links #1 Reordered HTML serializable to simplified form', ], [ 'Football', 'Football', 'Formatting tags in links #2 Reordered HTML changes semantics', ], [ 'Soccer', 'Soccer', 'Formatting tags in links #3 Reordered HTML NOT serializable to simplified form', ], [ '
+-
', '
+ -
', 'Escapable prefixes in table cells' ], // Without ScrubWikitext // Minimizable tags [ "XY", "XY", 'Minimizable tags Without ScrubWikitext #1', [ 'scrubWikitext' => false ], ], [ "XY", "XY", 'Minimizable tags Without ScrubWikitext #2', [ 'scrubWikitext' => false ] ], [ "AXYZ", "AXYZ", 'Minimizable tags Without ScrubWikitext #3', [ 'scrubWikitext' => false ], ], // Headings [ '

H2

', '

H2

', 'Headings (without scrubWikitext)', [ 'scrubWikitext' => false ], ], // Tables [ '
+-
', '
+-
', 'Tables (without scrubWikitext)', [ 'scrubWikitext' => false ], ], // Links [ 'FootBall', // NOTE: we are stripping data-parsoid before comparing output in our testing. // Hence the difference in output. 'FootBall', 'Links (without scrubWikitext) #1', [ 'scrubWikitext' => false ], ], [ 'Football', 'Football', 'Links (without scrubWikitext) #2', [ 'scrubWikitext' => false ], ], [ 'Foo bar', 'Foo bar', 'Links (without scrubWikitext) #3', [ 'scrubWikitext' => false ], ], ]; } }