MediaWiki REL1_30
AutopromoteTest.php
Go to the documentation of this file.
1<?php
2
12 public function testEditCountLookupIsSkippedIfRequirementIsZero( $editCount, $requirement ) {
13 $this->setMwGlobals( [
14 'wgAutopromote' => [
15 'autoconfirmed' => [ APCOND_EDITCOUNT, $requirement ]
16 ]
17 ] );
18
20 $userMock = $this->getMock( 'User', [ 'getEditCount' ] );
21 if ( $requirement > 0 ) {
22 $userMock->expects( $this->once() )
23 ->method( 'getEditCount' )
24 ->willReturn( $editCount );
25 } else {
26 $userMock->expects( $this->never() )
27 ->method( 'getEditCount' );
28 }
29
30 $result = Autopromote::getAutopromoteGroups( $userMock );
31 if ( $editCount >= $requirement ) {
32 $this->assertContains(
33 'autoconfirmed',
34 $result,
35 'User must be promoted if they meet edit count requirement'
36 );
37 } else {
38 $this->assertNotContains(
39 'autoconfirmed',
40 $result,
41 'User must not be promoted if they fail edit count requirement'
42 );
43 }
44 }
45
46 public static function provideEditCountsAndRequirements() {
47 return [
48 'user with sufficient editcount' => [ 100, 10 ],
49 'user with insufficient editcount' => [ 4, 10 ],
50 'edit count requirement set to 0' => [ 1, 0 ],
51 ];
52 }
53}
testEditCountLookupIsSkippedIfRequirementIsZero( $editCount, $requirement)
T157718: Verify Autopromote does not perform edit count lookup if requirement is 0 or invalid.
static provideEditCountsAndRequirements()
static getAutopromoteGroups(User $user)
Get the groups for the given user based on $wgAutopromote.
setMwGlobals( $pairs, $value=null)
Sets a global, maintaining a stashed version of the previous global to be restored in tearDown.
const APCOND_EDITCOUNT
Definition Defines.php:206