Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4146823
FixUserRegistrationTest.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
FixUserRegistrationTest.php
View Options
<?php
namespace
MediaWiki\Tests\Maintenance
;
use
FixUserRegistration
;
use
MediaWiki\Title\Title
;
use
Wikimedia\Timestamp\ConvertibleTimestamp
;
/**
* @covers \FixUserRegistration
* @group Database
* @author Dreamy Jazz
*/
class
FixUserRegistrationTest
extends
MaintenanceBaseTestCase
{
protected
function
getMaintenanceClass
()
{
return
FixUserRegistration
::
class
;
}
public
function
testExecute
()
{
$userWithValidRegistration
=
$this
->
getMutableTestUser
()->
getUser
();
$this
->
getDb
()->
newUpdateQueryBuilder
()
->
update
(
'user'
)
->
set
(
[
'user_registration'
=>
$this
->
getDb
()->
timestamp
(
'20220405060708'
)
]
)
->
where
(
[
'user_id'
=>
$userWithValidRegistration
->
getId
()
]
)
->
execute
();
ConvertibleTimestamp
::
setFakeTime
(
'20230405060708'
);
$userWithNullRegistrationButNoEdits
=
$this
->
getMutableTestUser
()->
getUser
();
$userWithNullRegistrationAndEdits
=
$this
->
getMutableTestUser
()->
getUser
();
$this
->
getDb
()->
newUpdateQueryBuilder
()
->
update
(
'user'
)
->
set
(
[
'user_registration'
=>
null
]
)
->
where
(
[
'user_id'
=>
[
$userWithNullRegistrationButNoEdits
->
getId
(),
$userWithNullRegistrationAndEdits
->
getId
()
]
]
)
->
execute
();
// Make a testing edit for the $userWithNullRegistrationAndEdits
ConvertibleTimestamp
::
setFakeTime
(
'20230505060708'
);
$this
->
editPage
(
Title
::
newFromText
(
'Test'
),
"testcontent"
,
''
,
NS_MAIN
,
$userWithNullRegistrationAndEdits
);
ConvertibleTimestamp
::
setFakeTime
(
false
);
// Verify that the user_registration column is set up correctly for the test.
$expectedRows
=
[
[
$userWithValidRegistration
->
getId
(),
$this
->
getDb
()->
timestamp
(
'20220405060708'
)
],
[
$userWithNullRegistrationButNoEdits
->
getId
(),
null
],
[
$userWithNullRegistrationAndEdits
->
getId
(),
null
],
];
$this
->
newSelectQueryBuilder
()
->
select
(
[
'user_id'
,
'user_registration'
]
)
->
from
(
'user'
)
->
orderBy
(
'user_id'
)
->
assertResultSet
(
$expectedRows
);
// Run the maintenance script
$this
->
maintenance
->
execute
();
$expectedOutputRegex
=
'/Could not find registration for #2[
\s\S
]*Set registration for #3 to '
.
preg_quote
(
$this
->
getDb
()->
timestamp
(
'20230505060708'
),
'/'
)
.
'/'
;
$this
->
expectOutputRegex
(
$expectedOutputRegex
);
$expectedRows
=
[
[
$userWithValidRegistration
->
getId
(),
$this
->
getDb
()->
timestamp
(
'20220405060708'
)
],
[
$userWithNullRegistrationButNoEdits
->
getId
(),
null
],
[
$userWithNullRegistrationAndEdits
->
getId
(),
$this
->
getDb
()->
timestamp
(
'20230505060708'
)
],
];
$this
->
newSelectQueryBuilder
()
->
select
(
[
'user_id'
,
'user_registration'
]
)
->
from
(
'user'
)
->
orderBy
(
'user_id'
)
->
assertResultSet
(
$expectedRows
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Aug 19 2026, 18:10 (5 w, 6 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
dd/53/b3c95c78841b30818d781269eb9d
Default Alt Text
FixUserRegistrationTest.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment