7 class UserEditCountInitJobTest
extends MediaWikiIntegrationTestCase
{
9 public static function provideTestCases() {
10 // $startingEditCount, $setCount, $finalCount
11 yield
'Initiate count if not yet set' => [ false, 2, 2 ];
12 yield
'Update count when increasing' => [ 2, 3, 3 ];
13 yield
'Never decrease count' => [ 10, 3, 10 ];
17 * @covers \UserEditCountInitJob
18 * @dataProvider provideTestCases
20 public function testUserEditCountInitJob( $startingEditCount, $setCount, $finalCount ) {
21 $user = $this->getMutableTestUser()->getUser();
23 if ( $startingEditCount !== false ) {
24 $this->getServiceContainer()->getConnectionProvider()->getPrimaryDatabase()
25 ->newUpdateQueryBuilder()
27 ->set( [ 'user_editcount' => $startingEditCount ] )
28 ->where( [ 'user_id' => $user->getId() ] )
29 ->caller( __METHOD__
)
33 $job = new UserEditCountInitJob( [
34 'userId' => $user->getId(),
35 'editCount' => $setCount
38 $result = $job->run();
40 $this->assertTrue( $result );
41 $this->assertEquals( $finalCount, $user->getEditCount() );