| 1 |
<?php |
| 2 |
|
| 3 |
namespace MediaWiki\Tests\Block; |
| 4 |
|
| 5 |
use MediaWiki\Title\Title; |
| 6 |
use MediaWikiIntegrationTestCase; |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
class AutoblockExemptionListTest extends MediaWikiIntegrationTestCase { |
| 14 |
|
| 15 |
protected function setUp(): void { |
| 16 |
|
| 17 |
$this->getServiceContainer()->getMessageCache()->enable(); |
| 18 |
} |
| 19 |
|
| 20 |
|
| 21 |
public function testIsExempt( $ip, $expectedReturnValue ) { |
| 22 |
$this->assertSame( |
| 23 |
$expectedReturnValue, |
| 24 |
$this->getServiceContainer()->getAutoblockExemptionList()->isExempt( $ip ) |
| 25 |
); |
| 26 |
} |
| 27 |
|
| 28 |
public static function provideIsExempt() { |
| 29 |
return [ |
| 30 |
'IP is exempt from autoblocks' => [ '1.2.3.4', true ], |
| 31 |
'IP is not exempt from autoblocks' => [ '1.2.3.5', false ], |
| 32 |
'IP is exempt from autoblocks based on IP range exemption' => [ '7.8.9.40', true ], |
| 33 |
]; |
| 34 |
} |
| 35 |
|
| 36 |
public function addDBDataOnce() { |
| 37 |
$this->editPage( |
| 38 |
Title::newFromText( 'block-autoblock-exemptionlist', NS_MEDIAWIKI ), |
| 39 |
'[[Test]]. This is a autoblocking exemption list description.' . |
| 40 |
"\n\n* 1.2.3.4\n** 1.2.3.6\n* 7.8.9.0/24" |
| 41 |
); |
| 42 |
} |
| 43 |
} |