wiki.techinc.nl/tests/phpunit/includes/import/ImportableOldRevisionImporterTest.php
Thiemo Kreuz b655f382db Remove broken/outdated @param/@throws tags from @dataProviders
My personal best practice is to not document @params when there
is a @dataProvider. I mean, these test…() functions are not
meant to be called from anywhere. They do not really need
documentation. @param tags don't do much but duplicate what the
@dataProvider does. This is error-prone, as demonstrated by the
examples in this patch.

This patch also removes @throws tags from tests. A test…() can
never throw an exception. Otherwise the test would fail.

Most of these are found by the not yet released I10559d8.

Change-Id: I3782bca43f875687cd2be972144a7ab6b298454e
2021-01-21 03:42:42 +00:00

60 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()
);
$result = $importer->import( $revision );
$this->assertTrue( $result );
$page = WikiPage::factory( $title );
$tags = ChangeTags::getTags(
$services->getDBLoadBalancer()->getConnection( DB_MASTER ),
null,
$page->getLatest()
);
$this->assertSame( $expectedTags, $tags );
}
}