wiki.techinc.nl/tests/phpunit/includes/Storage/PageUpdaterFactoryIntegrationTest.php
Isabelle Hurbain-Palatin 7964b98ce9 Remove ParserOutput::getText() calls from core (getRawText)
This is the first patch of a series of patches to remove
ParserOutput::getText() calls from core. This series of patches should
be functionally equivalent to I2b4bcddb234f10fd8592570cb0496adf3271328e.

This first patch replaces the calls to getText to calls to
ParserOutput::getRawText when the pipeline has no reason to be executed.

Bug: T293512
Change-Id: I0ad53cd074ca9cf13e96e6b08179e13aeea180f4
2024-08-19 14:20:20 +02:00

46 lines
1.3 KiB
PHP

<?php
namespace MediaWiki\Tests\Storage;
use MediaWiki\Content\ContentHandler;
use MediaWiki\Content\TextContent;
use MediaWiki\Revision\SlotRecord;
use MediaWikiIntegrationTestCase;
/**
* @covers \MediaWiki\Storage\PageUpdaterFactory
* @group Database
*/
class PageUpdaterFactoryIntegrationTest extends MediaWikiIntegrationTestCase {
/**
* @covers \WikiPage::newPageUpdater
*/
public function testNewPageUpdater() {
$page = $this->getExistingTestPage();
$title = $page->getTitle();
$user = $this->getTestUser()->getUserIdentity();
/** @var TextContent $content */
$content = ContentHandler::makeContent(
"[[Lorem ipsum]] dolor sit amet, consetetur sadipscing elitr, sed diam "
. " nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat.",
$title,
CONTENT_MODEL_WIKITEXT
);
$factory = $this->getServiceContainer()->getPageUpdaterFactory();
$updater = $factory->newPageUpdater( $page, $user );
$updater->setContent( SlotRecord::MAIN, $content );
$update = $updater->prepareUpdate();
/** @var TextContent $pstContent */
$pstContent = $update->getRawContent( SlotRecord::MAIN );
$this->assertSame( $content->getText(), $pstContent->getText() );
$pout = $update->getCanonicalParserOutput();
$this->assertStringContainsString( 'dolor sit amet', $pout->getRawText() );
}
}