Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F1426983
FixAutoblockLogTitlesTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
FixAutoblockLogTitlesTest.php
View Options
<?php
namespace
MediaWiki\Tests\Maintenance
;
use
ManualLogEntry
;
use
MediaWiki\Linker\LinkTarget
;
use
MediaWiki\Maintenance\FixAutoblockLogTitles
;
use
MediaWiki\Title\TitleValue
;
/**
* @covers \MediaWiki\Maintenance\FixAutoblockLogTitles
* @group Database
* @author Dreamy Jazz
*/
class
FixAutoblockLogTitlesTest
extends
MaintenanceBaseTestCase
{
protected
function
getMaintenanceClass
()
{
return
FixAutoblockLogTitles
::
class
;
}
public
function
testExecuteWhenNoMatchingLogs
()
{
$this
->
maintenance
->
execute
();
$this
->
expectOutputRegex
(
"/Fixing log entries with log_title starting with[
\s\S
]*done.
\n
$/"
);
}
private
function
getBlockTypeEntry
(
string
$subtype
,
LinkTarget
$target
,
int
$blockId
):
int
{
$logEntry
=
new
ManualLogEntry
(
'block'
,
$subtype
);
$logEntry
->
setTarget
(
$target
);
$logEntry
->
setPerformer
(
$this
->
getTestSysop
()->
getUser
()
);
$logEntry
->
setRelations
(
[
'ipb_id'
=>
$blockId
]
);
return
$logEntry
->
insert
();
}
public
function
testExecuteWhenMatchingLogs
()
{
// Get three "block" type log entries, where two have the unblock subtype and one of those two has a invalid
// title.
$brokenId
=
$this
->
getBlockTypeEntry
(
'unblock'
,
TitleValue
::
tryNew
(
NS_USER
,
'User:#1234'
),
1234
);
$notBrokenId
=
$this
->
getBlockTypeEntry
(
'unblock'
,
TitleValue
::
tryNew
(
NS_USER
,
'#1236'
),
1236
);
$notRelevantId
=
$this
->
getBlockTypeEntry
(
'block'
,
TitleValue
::
tryNew
(
NS_USER
,
'Abc'
),
1238
);
// Run the maintenance script and then check that only the $brokenId log entry was updated.
$this
->
maintenance
->
execute
();
$this
->
expectOutputString
(
"Fixing log entries with log_title starting with 'User:#'
\n
"
.
"...Processing unblock rows with IDs $brokenId to $notBrokenId
\n
"
.
"done. Fixed 1 rows.
\n
"
);
$this
->
newSelectQueryBuilder
()
->
select
(
[
'log_id'
,
'log_title'
]
)
->
from
(
'logging'
)
->
orderBy
(
'log_id'
)
->
assertResultSet
(
[
[
$brokenId
,
'#1234'
],
[
$notBrokenId
,
'#1236'
],
[
$notRelevantId
,
'Abc'
],
]
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, May 16, 14:01 (1 d, 18 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
10/8a/7092f32b43e5db9fbe018920b202
Default Alt Text
FixAutoblockLogTitlesTest.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment