Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F7422977
UpdateUserCentralIndexJobTest.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
UpdateUserCentralIndexJobTest.php
View Options
<?php
namespace
MediaWiki\CheckUser\Tests\Integration\Jobs
;
use
MediaWiki\CheckUser\Jobs\UpdateUserCentralIndexJob
;
use
MediaWikiIntegrationTestCase
;
/**
* @covers \MediaWiki\CheckUser\Jobs\UpdateUserCentralIndexJob
* @group CheckUser
* @group Database
* @see CheckUserCentralIndexManagerTest::testRecordActionInCentralIndexesForSuccessfulUserIndexInsert for other
* tests that cover this job
*/
class
UpdateUserCentralIndexJobTest
extends
MediaWikiIntegrationTestCase
{
private
function
getObjectUnderTest
(
$params
):
UpdateUserCentralIndexJob
{
return
new
UpdateUserCentralIndexJob
(
null
,
$params
,
$this
->
getServiceContainer
()->
getConnectionProvider
()
);
}
public
function
testRunForNoExistingRow
()
{
$job
=
$this
->
getObjectUnderTest
(
[
'wikiMapID'
=>
1
,
'centralID'
=>
2
,
'timestamp'
=>
'20230405060708'
]
);
$this
->
assertTrue
(
$job
->
run
()
);
// Check that the job created a row for this central ID with the correct timestamp
$this
->
newSelectQueryBuilder
()
->
select
(
'ciu_timestamp'
)
->
from
(
'cuci_user'
)
->
where
(
[
'ciu_ciwm_id'
=>
1
,
'ciu_central_id'
=>
2
]
)
->
caller
(
__METHOD__
)
->
assertFieldValue
(
$this
->
getDb
()->
timestamp
(
'20230405060708'
)
);
}
/** @dataProvider provideRunForExistingRow */
public
function
testRunForExistingRow
(
$lastTimestamp
,
$timestamp
,
$expectedTimestampAfterRun
)
{
// Insert a pre-existing entry with the $lastTimestamp as the timestamp
$this
->
getDb
()->
newInsertQueryBuilder
()
->
insertInto
(
'cuci_user'
)
->
row
(
[
'ciu_timestamp'
=>
$this
->
getDb
()->
timestamp
(
$lastTimestamp
),
'ciu_ciwm_id'
=>
1
,
'ciu_central_id'
=>
2
,
]
)
->
caller
(
__METHOD__
)
->
execute
();
$job
=
$this
->
getObjectUnderTest
(
[
'wikiMapID'
=>
1
,
'centralID'
=>
2
,
'timestamp'
=>
$timestamp
]
);
$this
->
assertTrue
(
$job
->
run
()
);
// Check that the job created a row for this central ID with the correct timestamp
$this
->
newSelectQueryBuilder
()
->
select
(
'ciu_timestamp'
)
->
from
(
'cuci_user'
)
->
where
(
[
'ciu_ciwm_id'
=>
1
,
'ciu_central_id'
=>
2
]
)
->
caller
(
__METHOD__
)
->
assertFieldValue
(
$this
->
getDb
()->
timestamp
(
$expectedTimestampAfterRun
)
);
}
public
static
function
provideRunForExistingRow
()
{
return
[
'Last timestamp before new timestamp'
=>
[
'20230405060708'
,
'20230405060750'
,
'20230405060750'
],
'Last timestamp after new timestamp'
=>
[
'20230405060750'
,
'20230405060708'
,
'20230405060750'
],
];
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Nov 22, 06:18 (47 m, 15 s)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
7b/12/bca3380d465b55a2953c6811e49f
Default Alt Text
UpdateUserCentralIndexJobTest.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment