wiki.techinc.nl/tests/phpunit/includes/import/ImportableOldRevisionImporterTest.php
Derick Alangi 6407361b46 Migrate WikiPage::doEditUpdates() to using PageUpdaterFactory
WikiPage::doEditUpdates() has been deprecated. Using the PageUpdaterFactory's
newDerivedPageDataUpdater() is the new way forward. Also, I made sure to have
the `$options` array with the `causeAction` and `causeAgent` key/value pairs.

Change-Id: I9f2c212d7c83a46799f9f947dc372dc364289680
2021-10-07 11:17:43 +01:00

61 lines
1.5 KiB
PHP

<?php
use MediaWiki\MediaWikiServices;
use MediaWiki\Revision\SlotRecord;
use Psr\Log\NullLogger;
/**
* @group Database
* @coversDefaultClass ImportableOldRevisionImporter
*/
class ImportableOldRevisionImporterTest extends MediaWikiIntegrationTestCase {
protected function setUp(): void {
parent::setUp();
$this->tablesUsed[] = 'change_tag';
$this->tablesUsed[] = 'change_tag_def';
ChangeTags::defineTag( 'tag1' );
}
public function provideTestCases() {
yield [ [] ];
yield [ [ "tag1" ] ];
}
/**
* @covers ::import
* @dataProvider provideTestCases
*/
public function testImport( $expectedTags ) {
$services = MediaWikiServices::getInstance();
$title = Title::newFromText( __CLASS__ . rand() );
$revision = new WikiRevision( $services->getMainConfig() );
$revision->setTitle( $title );
$revision->setTags( $expectedTags );
$content = ContentHandler::makeContent( 'dummy edit', $title );
$revision->setContent( SlotRecord::MAIN, $content );
$importer = new ImportableOldRevisionImporter(
true,
new NullLogger(),
$services->getDBLoadBalancer(),
$services->getRevisionStore(),
$services->getSlotRoleRegistry(),
$services->getWikiPageFactory(),
$services->getPageUpdaterFactory()
);
$result = $importer->import( $revision );
$this->assertTrue( $result );
$page = WikiPage::factory( $title );
$tags = ChangeTags::getTags(
$services->getDBLoadBalancer()->getConnection( DB_PRIMARY ),
null,
$page->getLatest()
);
$this->assertSame( $expectedTags, $tags );
}
}