diff options
author | Isabelle Hurbain-Palatin <ihurbainpalatin@wikimedia.org> | 2024-08-19 09:17:23 +0200 |
---|---|---|
committer | Isabelle Hurbain-Palatin <ihurbainpalatin@wikimedia.org> | 2024-09-06 19:07:49 +0000 |
commit | ce2bccc0a82d069743a1770327fafa9882376ff2 (patch) | |
tree | cd26aa1f2b2e0eb22ecfe3000d1e8ff683635a33 /tests/phpunit/includes/parser/ParserOutputTest.php | |
parent | cd3240f04464281e5238eb418472373c5c43df3e (diff) | |
download | mediawikicore-ce2bccc0a82d069743a1770327fafa9882376ff2.tar.gz mediawikicore-ce2bccc0a82d069743a1770327fafa9882376ff2.zip |
Remove ParserOutput::getText() calls from core (runOutputPipeline)
This is the fourth patch of a series of patches to remove
ParserOutput::getText() calls from core. This series of patches should
be functionally equivalent to I2b4bcddb234f10fd8592570cb0496adf3271328e.
Here we replace calls to getText where a ContentRenderer is available
close by by temporary ParserOutput::runOutputPipeline that will
eventually be replaced by a call to (probably) ContentRenderer
(T371004). Doing this work in stages allows us to separate the work of
"bring ParserOptions to the call site" from the work of "bringing
ContentRenderer(ish) to the call site", since both need to be done for
to make ParserOutput a value object (T293512).
Change-Id: Ib4f9357293dc230df6e0ca2379a1e2a4cc1b91b7
Bug: T293512
Diffstat (limited to 'tests/phpunit/includes/parser/ParserOutputTest.php')
-rw-r--r-- | tests/phpunit/includes/parser/ParserOutputTest.php | 44 |
1 files changed, 3 insertions, 41 deletions
diff --git a/tests/phpunit/includes/parser/ParserOutputTest.php b/tests/phpunit/includes/parser/ParserOutputTest.php index 714d5dbf6a7f..580fc15b132e 100644 --- a/tests/phpunit/includes/parser/ParserOutputTest.php +++ b/tests/phpunit/includes/parser/ParserOutputTest.php @@ -262,7 +262,6 @@ class ParserOutputTest extends MediaWikiLangTestCase { * @covers \MediaWiki\Parser\ParserOutput::getWrapperDivClass * @covers \MediaWiki\Parser\ParserOutput::addWrapperDivClass * @covers \MediaWiki\Parser\ParserOutput::clearWrapperDivClass - * @covers \MediaWiki\Parser\ParserOutput::getText */ public function testWrapperDivClass() { $po = new ParserOutput(); @@ -270,8 +269,9 @@ class ParserOutputTest extends MediaWikiLangTestCase { $pipeline = MediaWikiServices::getInstance()->getDefaultOutputPipeline(); $po->setRawText( 'Kittens' ); - $this->assertStringContainsString( 'Kittens', $po->getText() ); - $this->assertStringNotContainsString( '<div', $po->getText() ); + $text = $pipeline->run( $po, $opts, [] )->getContentHolderText(); + $this->assertStringContainsString( 'Kittens', $text ); + $this->assertStringNotContainsString( '<div', $text ); $this->assertSame( 'Kittens', $po->getRawText() ); $po->addWrapperDivClass( 'foo' ); @@ -545,44 +545,6 @@ EOF $po->getText(); } - public static function provideGetText_absoluteURLs() { - yield 'empty' => [ - 'text' => '', - 'expectedText' => '', - ]; - yield 'no-links' => [ - 'text' => '<p>test</p>', - 'expectedText' => '<p>test</p>', - ]; - yield 'simple link' => [ - 'text' => '<a href="/wiki/Test">test</a>', - 'expectedText' => '<a href="//TEST_SERVER/wiki/Test">test</a>', - ]; - yield 'already absolute, relative' => [ - 'text' => '<a href="//TEST_SERVER/wiki/Test">test</a>', - 'expectedText' => '<a href="//TEST_SERVER/wiki/Test">test</a>', - ]; - yield 'already absolute, https' => [ - 'text' => '<a href="https://TEST_SERVER/wiki/Test">test</a>', - 'expectedText' => '<a href="https://TEST_SERVER/wiki/Test">test</a>', - ]; - yield 'external' => [ - 'text' => '<a href="https://en.wikipedia.org/wiki/Test">test</a>', - 'expectedText' => '<a href="https://en.wikipedia.org/wiki/Test">test</a>', - ]; - } - - /** - * This test aims at being replaced by its version in DefaultOutputTransformTest when ParserOutput::getText - * gets deprecated. - * @dataProvider provideGetText_absoluteURLs - */ - public function testGetText_absoluteURLs( string $text, string $expectedText ) { - $this->overrideConfigValue( MainConfigNames::Server, '//TEST_SERVER' ); - $parserOutput = new ParserOutput( $text ); - $this->assertSame( $expectedText, $parserOutput->getText( [ 'absoluteURLs' => true ] ) ); - } - /** * @covers \MediaWiki\Parser\ParserOutput::getRawText */ |