6 class AutopromoteTest
extends MediaWikiTestCase
{
8 * T157718: Verify Autopromote does not perform edit count lookup if requirement is 0 or invalid
10 * @see Autopromote::getAutopromoteGroups()
11 * @dataProvider provideEditCountsAndRequirements
12 * @param int $editCount edit count of user to be checked by Autopromote
13 * @param int $requirement edit count required to autopromote user
15 public function testEditCountLookupIsSkippedIfRequirementIsZero( $editCount, $requirement ) {
16 $this->setMwGlobals( [
18 'autoconfirmed' => [ APCOND_EDITCOUNT
, $requirement ]
22 /** @var PHPUnit_Framework_MockObject_MockObject|User $userMock */
23 $userMock = $this->getMock( User
::class, [ 'getEditCount' ] );
24 if ( $requirement > 0 ) {
25 $userMock->expects( $this->once() )
26 ->method( 'getEditCount' )
27 ->willReturn( $editCount );
29 $userMock->expects( $this->never() )
30 ->method( 'getEditCount' );
33 $result = Autopromote
::getAutopromoteGroups( $userMock );
34 if ( $editCount >= $requirement ) {
35 $this->assertContains(
38 'User must be promoted if they meet edit count requirement'
41 $this->assertNotContains(
44 'User must not be promoted if they fail edit count requirement'
49 public static function provideEditCountsAndRequirements() {
51 'user with sufficient editcount' => [ 100, 10 ],
52 'user with insufficient editcount' => [ 4, 10 ],
53 'edit count requirement set to 0' => [ 1, 0 ],