X-Git-Url: http://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fapi%2FApiBlockTest.php;h=efefc09dc1e55ad515cf39cc66c8ce1ddfe3f4d4;hp=c0cf87eedf48f472d6f6ff3eaeb31d0e7676aa2c;hb=816ac899a7087a79e1d23b5efe867987e6dc3233;hpb=19e9e672f31c792622fc8c27ad511f27263979a8 diff --git a/tests/phpunit/includes/api/ApiBlockTest.php b/tests/phpunit/includes/api/ApiBlockTest.php index c0cf87eedf..efefc09dc1 100644 --- a/tests/phpunit/includes/api/ApiBlockTest.php +++ b/tests/phpunit/includes/api/ApiBlockTest.php @@ -12,9 +12,12 @@ class ApiBlockTest extends ApiTestCase { protected function setUp() { parent::setUp(); - $this->doLogin(); $this->mUser = $this->getMutableTestUser()->getUser(); + $this->setMwGlobals( 'wgBlockCIDRLimit', [ + 'IPv4' => 16, + 'IPv6' => 19, + ] ); } protected function tearDown() { @@ -42,7 +45,6 @@ class ApiBlockTest extends ApiTestCase { $tokens = $this->getTokens(); $this->assertNotNull( $this->mUser, 'Sanity check' ); - $this->assertNotSame( 0, $this->mUser->getId(), 'Sanity check' ); $this->assertArrayHasKey( 'blocktoken', $tokens, 'Sanity check' ); @@ -207,7 +209,7 @@ class ApiBlockTest extends ApiTestCase { ); // Allow flakiness up to one second - $this->assertLessThan( 1, + $this->assertLessThanOrEqual( 1, abs( wfTimestamp( TS_UNIX, $expiry ) - ( time() + 86400 ) ) ); } @@ -233,4 +235,18 @@ class ApiBlockTest extends ApiTestCase { self::$users['sysop']->getUser() ); } + + public function testRangeBlock() { + $this->mUser = User::newFromName( '128.0.0.0/16', false ); + $this->doBlock(); + } + + /** + * @expectedException ApiUsageException + * @expectedExceptionMessage Range blocks larger than /16 are not allowed. + */ + public function testVeryLargeRangeBlock() { + $this->mUser = User::newFromName( '128.0.0.0/1', false ); + $this->doBlock(); + } }