rdbms: Rename "memCache" to "memStash" in LBFactory
[mediawiki.git] / tests / phpunit / includes / AutopromoteTest.php
blob785aa4e3d4e675377bbf48f82f976a7d8ed8b5ae
1 <?php
3 class AutopromoteTest extends MediaWikiTestCase {
4 /**
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( [
14 'wgAutopromote' => [
15 'autoconfirmed' => [ APCOND_EDITCOUNT, $requirement ]
17 ] );
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 );
25 } else {
26 $userMock->expects( $this->never() )
27 ->method( 'getEditCount' );
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'
37 } else {
38 $this->assertNotContains(
39 'autoconfirmed',
40 $result,
41 'User must not be promoted if they fail edit count requirement'
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 ],