X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2FBlockTest.php;h=12b277e94f5d71a5423e8598075be5eee68722e6;hb=b8bf745ca957de92f447ded545179663d344191f;hp=35ebf42c2668fc67c90f7b197ef7712c4c0cfb39;hpb=c340c41b37b5079ba90489f6b212bb8e4642031a;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/BlockTest.php b/tests/phpunit/includes/BlockTest.php index 35ebf42c26..12b277e94f 100644 --- a/tests/phpunit/includes/BlockTest.php +++ b/tests/phpunit/includes/BlockTest.php @@ -15,7 +15,7 @@ class BlockTest extends MediaWikiLangTestCase { function addDBData() { $user = User::newFromName( 'UTBlockee' ); - if ( $user->getID() == 0 ) { + if ( $user->getId() == 0 ) { $user->addToDatabase(); TestUser::setPasswordForUser( $user, 'UTBlockeePassword' ); @@ -31,7 +31,7 @@ class BlockTest extends MediaWikiLangTestCase { $blockOptions = [ 'address' => 'UTBlockee', - 'user' => $user->getID(), + 'user' => $user->getId(), 'reason' => 'Parce que', 'expiry' => time() + 100500, ]; @@ -365,7 +365,7 @@ class BlockTest extends MediaWikiLangTestCase { # Set up the target $u = User::newFromName( $username ); - if ( $u->getID() == 0 ) { + if ( $u->getId() == 0 ) { $u->addToDatabase(); TestUser::setPasswordForUser( $u, 'TotallyObvious' ); } @@ -409,4 +409,33 @@ class BlockTest extends MediaWikiLangTestCase { "Account creation should not be blocked by default" ); } + + public function testSystemBlocks() { + $blockOptions = [ + 'address' => 'UTBlockee', + 'reason' => 'test system block', + 'timestamp' => wfTimestampNow(), + 'expiry' => $this->db->getInfinity(), + 'byText' => 'MetaWikiUser', + 'systemBlock' => 'test', + 'enableAutoblock' => true, + ]; + $block = new Block( $blockOptions ); + + $this->assertSame( 'test', $block->getSystemBlockType() ); + + try { + $block->insert(); + $this->fail( 'Expected exception not thrown' ); + } catch ( MWException $ex ) { + $this->assertSame( 'Cannot insert a system block into the database', $ex->getMessage() ); + } + + try { + $block->doAutoblock( '192.0.2.2' ); + $this->fail( 'Expected exception not thrown' ); + } catch ( MWException $ex ) { + $this->assertSame( 'Cannot autoblock from a system block', $ex->getMessage() ); + } + } }