MediaWiki REL1_31
AutopromoteTest.php
Go to the documentation of this file.
1<?php
2
15 public function testEditCountLookupIsSkippedIfRequirementIsZero( $editCount, $requirement ) {
16 $this->setMwGlobals( [
17 'wgAutopromote' => [
18 'autoconfirmed' => [ APCOND_EDITCOUNT, $requirement ]
19 ]
20 ] );
21
23 $userMock = $this->getMock( User::class, [ 'getEditCount' ] );
24 if ( $requirement > 0 ) {
25 $userMock->expects( $this->once() )
26 ->method( 'getEditCount' )
27 ->willReturn( $editCount );
28 } else {
29 $userMock->expects( $this->never() )
30 ->method( 'getEditCount' );
31 }
32
33 $result = Autopromote::getAutopromoteGroups( $userMock );
34 if ( $editCount >= $requirement ) {
35 $this->assertContains(
36 'autoconfirmed',
37 $result,
38 'User must be promoted if they meet edit count requirement'
39 );
40 } else {
41 $this->assertNotContains(
42 'autoconfirmed',
43 $result,
44 'User must not be promoted if they fail edit count requirement'
45 );
46 }
47 }
48
49 public static function provideEditCountsAndRequirements() {
50 return [
51 'user with sufficient editcount' => [ 100, 10 ],
52 'user with insufficient editcount' => [ 4, 10 ],
53 'edit count requirement set to 0' => [ 1, 0 ],
54 ];
55 }
56}
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:215