mediawiki-extensions-Scribunto/tests/phpunit/engines/LuaCommon/TextLibraryTest.php
Subramanya Sastry 23ac31e746 Add Parsoid-specific support for handling preprocessed nowikis
* This patch builds on core functionality provided in
  Ied0295feab06027a8df885b3215435e596f0353b.

* This removes any nowiki wrappers present in unstripped text
  (which there would be for preprocssed nowiki tags) which mimics
  the effect of procssing nowikis in core when generating HTML.

* Updated lua tests to verify the new expectation.

* A previously failing parser test added to test T272507 now passes
  and has been re-enabled.

Bug: T272507
Depends-On: Ied0295feab06027a8df885b3215435e596f0353b
Change-Id: I1613ac7bd60cf3ef4a3308b08ea3705b3cf2dee0
2022-09-08 23:17:46 +00:00

33 lines
1.1 KiB
PHP

<?php
class Scribunto_LuaTextLibraryTest extends Scribunto_LuaEngineUnitTestBase {
/** @inheritDoc */
protected static $moduleName = 'TextLibraryTests';
protected function setUp(): void {
parent::setUp();
// For unstrip test
$parser = $this->getEngine()->getParser();
$markers = [
'nowiki' => Parser::MARKER_PREFIX . '-test-nowiki-' . Parser::MARKER_SUFFIX,
'general' => Parser::MARKER_PREFIX . '-test-general-' . Parser::MARKER_SUFFIX,
'ppnowiki' => Parser::MARKER_PREFIX . '-pptest-nowiki-' . Parser::MARKER_SUFFIX,
];
$parser->getStripState()->addNoWiki( $markers['nowiki'], 'NoWiki' );
$parser->getStripState()->addGeneral( $markers['general'], 'General' );
$parser->getStripState()->addNoWiki( $markers['ppnowiki'], '<nowiki>PP-NoWiki</nowiki>' );
$interpreter = $this->getEngine()->getInterpreter();
$interpreter->callFunction(
$interpreter->loadString( 'mw.text.stripTest = ...', 'fortest' ),
$markers
);
}
protected function getTestModules() {
return parent::getTestModules() + [
'TextLibraryTests' => __DIR__ . '/TextLibraryTests.lua',
];
}
}