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