3 use MediaWiki\Context\RequestContext
;
4 use MediaWiki\MainConfigNames
;
5 use MediaWiki\Tests\User\TempUser\TempUserTestTrait
;
6 use Wikimedia\Timestamp\ConvertibleTimestamp
;
12 class ImportTemporaryUserIntegrationTest
extends MediaWikiIntegrationTestCase
{
13 use TempUserTestTrait
;
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();
29 $rc = RecentChange
::newFromConds( [
30 'rc_namespace' => NS_CATEGORY
,
32 'rc_source' => RecentChange
::SRC_CATEGORIZE
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 );
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(
65 $importer->doImport();
66 $this->assertStatusGood( $reporter->close() );