2021-09-18 09:09:39 +00:00
|
|
|
<?php
|
|
|
|
|
use MediaWiki\Tests\Maintenance\MaintenanceBaseTestCase;
|
|
|
|
|
|
|
|
|
|
/**
|
2024-02-16 18:04:47 +00:00
|
|
|
* @covers \DeleteUserEmail
|
2023-07-17 14:08:20 +00:00
|
|
|
* @group Database
|
2021-09-18 09:09:39 +00:00
|
|
|
*/
|
|
|
|
|
class DeleteUserEmailTest extends MaintenanceBaseTestCase {
|
|
|
|
|
public function getMaintenanceClass() {
|
|
|
|
|
return DeleteUserEmail::class;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testEmailDeletion() {
|
2023-07-17 14:08:20 +00:00
|
|
|
// Target an existing user with an email attached
|
|
|
|
|
$userName = $this->getTestSysop()->getUserIdentity()->getName();
|
2021-09-18 09:09:39 +00:00
|
|
|
$userFactory = $this->getServiceContainer()->getUserFactory();
|
|
|
|
|
$testUserBeforeExecution = $userFactory->newFromName( $userName );
|
|
|
|
|
$oldEmail = $testUserBeforeExecution->getEmail();
|
|
|
|
|
$this->assertNotNull( $oldEmail );
|
|
|
|
|
|
|
|
|
|
// Execute the maintance script
|
|
|
|
|
$this->maintenance->loadWithArgv( [ $userName ] );
|
|
|
|
|
$this->maintenance->execute();
|
|
|
|
|
|
|
|
|
|
// Check that the email address was changed and invalidated
|
|
|
|
|
$testUserAfterExecution = $userFactory->newFromName( $userName );
|
|
|
|
|
$this->assertNotEquals( $oldEmail, $testUserAfterExecution->getEmail() );
|
|
|
|
|
$this->assertSame( '', $testUserAfterExecution->getEmail() );
|
|
|
|
|
$this->assertNull( $testUserAfterExecution->getEmailAuthenticationTimestamp() );
|
|
|
|
|
|
|
|
|
|
// Check that the script returns the right output
|
|
|
|
|
$this->expectOutputRegex( '/Done!/' );
|
|
|
|
|
}
|
|
|
|
|
}
|