aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/parser
diff options
context:
space:
mode:
authorIsabelle Hurbain-Palatin <ihurbainpalatin@wikimedia.org>2024-07-30 19:13:18 +0200
committerIsabelle Hurbain-Palatin <ihurbainpalatin@wikimedia.org>2024-08-23 18:15:00 +0200
commita3cf629d2f7088a73a68d993095a89a0c34254cf (patch)
treebce957f088ad6ea053f29597611b38aa61aca980 /tests/phpunit/includes/parser
parent8220113a16a01eaf70e56f8cfab4c7a78db2e830 (diff)
downloadmediawikicore-a3cf629d2f7088a73a68d993095a89a0c34254cf.tar.gz
mediawikicore-a3cf629d2f7088a73a68d993095a89a0c34254cf.zip
Remove ParserOutput::getText() calls from core (direct pipeline)
This is the second patch of a series of patches to remove ParserOutput::getText() calls from core. This series of patches should be functionally equivalent to I2b4bcddb234f10fd8592570cb0496adf3271328e. This patch replaces the calls to getText where the legacy parser is called directly by creating a pipeline and invoking it on the generated. These should probably eventually use the Content framework to generate output instead of using Parser directly (T371008), which will also allow them to transparently support Parsoid. Bug: T293512 Change-Id: I45951a49e57a8031887ee6e4546335141d231c18
Diffstat (limited to 'tests/phpunit/includes/parser')
-rw-r--r--tests/phpunit/includes/parser/ParserOutputTest.php15
1 files changed, 9 insertions, 6 deletions
diff --git a/tests/phpunit/includes/parser/ParserOutputTest.php b/tests/phpunit/includes/parser/ParserOutputTest.php
index 8c7df0bfd745..714d5dbf6a7f 100644
--- a/tests/phpunit/includes/parser/ParserOutputTest.php
+++ b/tests/phpunit/includes/parser/ParserOutputTest.php
@@ -6,6 +6,7 @@ use LogicException;
use MediaWiki\Context\RequestContext;
use MediaWiki\Debug\MWDebug;
use MediaWiki\MainConfigNames;
+use MediaWiki\MediaWikiServices;
use MediaWiki\Parser\ParserOutput;
use MediaWiki\Parser\ParserOutputFlags;
use MediaWiki\Parser\ParserOutputStringSets;
@@ -265,6 +266,8 @@ class ParserOutputTest extends MediaWikiLangTestCase {
*/
public function testWrapperDivClass() {
$po = new ParserOutput();
+ $opts = ParserOptions::newFromAnon();
+ $pipeline = MediaWikiServices::getInstance()->getDefaultOutputPipeline();
$po->setRawText( 'Kittens' );
$this->assertStringContainsString( 'Kittens', $po->getText() );
@@ -272,29 +275,29 @@ class ParserOutputTest extends MediaWikiLangTestCase {
$this->assertSame( 'Kittens', $po->getRawText() );
$po->addWrapperDivClass( 'foo' );
- $text = $po->getText();
+ $text = $pipeline->run( $po, $opts, [] )->getContentHolderText();
$this->assertStringContainsString( 'Kittens', $text );
$this->assertStringContainsString( '<div', $text );
$this->assertStringContainsString( 'class="mw-content-ltr foo"', $text );
$po->addWrapperDivClass( 'bar' );
- $text = $po->getText();
+ $text = $pipeline->run( $po, $opts, [] )->getContentHolderText();
$this->assertStringContainsString( 'Kittens', $text );
$this->assertStringContainsString( '<div', $text );
$this->assertStringContainsString( 'class="mw-content-ltr foo bar"', $text );
$po->addWrapperDivClass( 'bar' ); // second time does nothing, no "foo bar bar".
- $text = $po->getText( [ 'unwrap' => true ] );
+ $text = $pipeline->run( $po, $opts, [ 'unwrap' => true ] )->getContentHolderText();
$this->assertStringContainsString( 'Kittens', $text );
$this->assertStringNotContainsString( '<div', $text );
$this->assertStringNotContainsString( 'class="', $text );
- $text = $po->getText( [ 'wrapperDivClass' => '' ] );
+ $text = $pipeline->run( $po, $opts, [ 'wrapperDivClass' => '' ] )->getContentHolderText();
$this->assertStringContainsString( 'Kittens', $text );
$this->assertStringNotContainsString( '<div', $text );
$this->assertStringNotContainsString( 'class="', $text );
- $text = $po->getText( [ 'wrapperDivClass' => 'xyzzy' ] );
+ $text = $pipeline->run( $po, $opts, [ 'wrapperDivClass' => 'xyzzy' ] )->getContentHolderText();
$this->assertStringContainsString( 'Kittens', $text );
$this->assertStringContainsString( '<div', $text );
$this->assertStringContainsString( 'class="mw-content-ltr xyzzy"', $text );
@@ -304,7 +307,7 @@ class ParserOutputTest extends MediaWikiLangTestCase {
$this->assertSame( 'Kittens', $text );
$po->clearWrapperDivClass();
- $text = $po->getText();
+ $text = $pipeline->run( $po, $opts, [] )->getContentHolderText();
$this->assertStringContainsString( 'Kittens', $text );
$this->assertStringNotContainsString( '<div', $text );
$this->assertStringNotContainsString( 'class="', $text );