| 1 |
<?php |
| 2 |
|
| 3 |
namespace MediaWiki\Tests\Storage; |
| 4 |
|
| 5 |
use MediaWiki\Content\ContentHandler; |
| 6 |
use MediaWiki\Content\TextContent; |
| 7 |
use MediaWiki\Revision\SlotRecord; |
| 8 |
use MediaWikiIntegrationTestCase; |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
class PageUpdaterFactoryIntegrationTest extends MediaWikiIntegrationTestCase { |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
public function testNewPageUpdater() { |
| 20 |
$page = $this->getExistingTestPage(); |
| 21 |
$title = $page->getTitle(); |
| 22 |
|
| 23 |
$user = $this->getTestUser()->getUserIdentity(); |
| 24 |
|
| 25 |
|
| 26 |
$content = ContentHandler::makeContent( |
| 27 |
"[[Lorem ipsum]] dolor sit amet, consetetur sadipscing elitr, sed diam " |
| 28 |
. " nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat.", |
| 29 |
$title, |
| 30 |
CONTENT_MODEL_WIKITEXT |
| 31 |
); |
| 32 |
|
| 33 |
$factory = $this->getServiceContainer()->getPageUpdaterFactory(); |
| 34 |
$updater = $factory->newPageUpdater( $page, $user ); |
| 35 |
$updater->setContent( SlotRecord::MAIN, $content ); |
| 36 |
$update = $updater->prepareUpdate(); |
| 37 |
|
| 38 |
|
| 39 |
$pstContent = $update->getRawContent( SlotRecord::MAIN ); |
| 40 |
$this->assertSame( $content->getText(), $pstContent->getText() ); |
| 41 |
|
| 42 |
$pout = $update->getCanonicalParserOutput(); |
| 43 |
$this->assertStringContainsString( 'dolor sit amet', $pout->getRawText() ); |
| 44 |
} |
| 45 |
|
| 46 |
} |