MediaWiki REL1_33
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}
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
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:214