Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4027743
DeleteUserEmailTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
DeleteUserEmailTest.php
View Options
<?php
use
MediaWiki\Tests\Maintenance\MaintenanceBaseTestCase
;
/**
* @covers \DeleteUserEmail
* @group Database
*/
class
DeleteUserEmailTest
extends
MaintenanceBaseTestCase
{
public
function
getMaintenanceClass
()
{
return
DeleteUserEmail
::
class
;
}
private
function
commonTestEmailDeletion
(
$userArg
,
$userName
,
$oldEmail
)
{
// Execute the maintenance script
$this
->
maintenance
->
loadWithArgv
(
[
$userArg
]
);
$this
->
maintenance
->
execute
();
// Check that the email address was changed and invalidated
$userFactory
=
$this
->
getServiceContainer
()->
getUserFactory
();
$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!/'
);
}
public
function
testEmailDeletionWhenProvidingName
()
{
// Target an existing user with an email attached
$testUserBeforeExecution
=
$this
->
getTestSysop
()->
getUser
();
$oldEmail
=
$testUserBeforeExecution
->
getEmail
();
$this
->
assertNotNull
(
$oldEmail
);
// Test providing the maintenance script with a username.
$this
->
commonTestEmailDeletion
(
$testUserBeforeExecution
->
getName
(),
$testUserBeforeExecution
->
getName
(),
$oldEmail
);
}
public
function
testEmailDeletionWhenProvidingId
()
{
// Target an existing user with an email attached
$testUserBeforeExecution
=
$this
->
getTestSysop
()->
getUser
();
$oldEmail
=
$testUserBeforeExecution
->
getEmail
();
$this
->
assertNotNull
(
$oldEmail
);
// Test providing the maintenance script with a user ID.
$this
->
commonTestEmailDeletion
(
"#"
.
$testUserBeforeExecution
->
getId
(),
$testUserBeforeExecution
->
getName
(),
$oldEmail
);
}
/** @dataProvider provideInvalidUsernameArgumentValues */
public
function
testEmailDeletionForInvalidUsername
(
$invalidUsernameArgument
)
{
$this
->
expectCallToFatalError
();
$this
->
expectOutputRegex
(
"/$invalidUsernameArgument.*could not be loaded/"
);
// Execute the maintenance script
$this
->
maintenance
->
setArg
(
'user'
,
$invalidUsernameArgument
);
$this
->
maintenance
->
execute
();
}
public
static
function
provideInvalidUsernameArgumentValues
()
{
return
[
'Invalid username'
=>
[
'Template:test#test'
],
'Non-existent user'
=>
[
'Non-existent-test-user-1234'
],
];
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Aug 14 2026, 21:10 (13 w, 3 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
c6/58/5ce3846d572c7fc9b74d958f0ec0
Default Alt Text
DeleteUserEmailTest.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment