Localisation updates from https://translatewiki.net.
[mediawiki.git] / tests / phpunit / includes / import / ImportTemporaryUserIntegrationTest.php
blob767e1007b1bacf8ee42d0f12ce0e571fea6f705b
1 <?php
3 use MediaWiki\Context\RequestContext;
4 use MediaWiki\MainConfigNames;
5 use MediaWiki\Tests\User\TempUser\TempUserTestTrait;
6 use Wikimedia\Timestamp\ConvertibleTimestamp;
8 /**
9 * @group Database
10 * @coversNothing
12 class ImportTemporaryUserIntegrationTest extends MediaWikiIntegrationTestCase {
13 use TempUserTestTrait;
15 /**
16 * Test that category membership changes in RC function for imported anonymous revisions
17 * when temporary users are enabled (T373318).
19 public function testShouldSuccessfullyUpdateCategoryMembershipInRecentChanges(): void {
20 $this->enableAutoCreateTempUser();
21 $this->overrideConfigValue( MainConfigNames::RCWatchCategoryMembership, true );
23 $referenceTime = wfTimestampNow();
24 ConvertibleTimestamp::setFakeTime( $referenceTime );
26 $this->importTestData();
27 $this->runJobs();
29 $rc = RecentChange::newFromConds( [
30 'rc_namespace' => NS_CATEGORY,
31 'rc_title' => 'Test',
32 'rc_source' => RecentChange::SRC_CATEGORIZE
33 ], __METHOD__ );
35 $this->assertSame( '192.0.2.14', $rc->getPerformerIdentity()->getName() );
36 $this->assertSame( $referenceTime, $rc->getAttribute( 'rc_timestamp' ) );
39 private function importTestData(): void {
40 $file = __DIR__ . '/../../data/import/ImportAnonUserTest.xml';
42 $importStreamSource = ImportStreamSource::newFromFile( $file );
44 $this->assertTrue(
45 $importStreamSource->isGood(),
46 "Import source {$file} failed"
49 $importer = $this->getServiceContainer()
50 ->getWikiImporterFactory()
51 ->getWikiImporter( $importStreamSource->value, $this->getTestSysop()->getAuthority() );
52 $importer->setDebug( true );
54 $context = RequestContext::getMain();
55 $context->setUser( $this->getTestUser()->getUser() );
56 $reporter = new ImportReporter(
57 $importer,
58 false,
59 '',
60 false,
61 $context
64 $reporter->open();
65 $importer->doImport();
66 $this->assertStatusGood( $reporter->close() );