X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2FBlockTest.php;h=19780a684a79c956f108390d2eb5258adf7555e9;hp=c422b515ccbcecc539c877a8e4069f133792192e;hb=8269ed4dfd5e4395e25945b1fa2ed391684606ed;hpb=1b13888ed6bd09731f10045650714a3392bb55df diff --git a/tests/phpunit/includes/BlockTest.php b/tests/phpunit/includes/BlockTest.php index c422b515cc..19780a684a 100644 --- a/tests/phpunit/includes/BlockTest.php +++ b/tests/phpunit/includes/BlockTest.php @@ -35,6 +35,7 @@ class BlockTest extends MediaWikiLangTestCase { $blockOptions = [ 'address' => $user->getName(), 'user' => $user->getId(), + 'by' => $this->getTestSysop()->getUser()->getId(), 'reason' => 'Parce que', 'expiry' => time() + 100500, ]; @@ -81,6 +82,7 @@ class BlockTest extends MediaWikiLangTestCase { /** * per T28425 + * @covers Block::__construct */ public function testBug26425BlockTimestampDefaultsToTime() { $user = $this->getUserForBlocking(); @@ -160,7 +162,7 @@ class BlockTest extends MediaWikiLangTestCase { 'enableAutoblock' => true, 'hideName' => true, 'blockEmail' => true, - 'byText' => 'MetaWikiUser', + 'byText' => 'm>MetaWikiUser', ]; $block = new Block( $blockOptions ); $block->insert(); @@ -173,7 +175,7 @@ class BlockTest extends MediaWikiLangTestCase { ); $this->assertInstanceOf( - 'Block', + Block::class, $userBlock, "'$username' block block object should be existent" ); @@ -214,7 +216,7 @@ class BlockTest extends MediaWikiLangTestCase { 'enableAutoblock' => true, 'hideName' => true, 'blockEmail' => true, - 'byText' => 'MetaWikiUser', + 'byText' => 'Meta>MetaWikiUser', ]; $block = new Block( $blockOptions ); @@ -230,8 +232,9 @@ class BlockTest extends MediaWikiLangTestCase { 'Correct blockee name' ); $this->assertEquals( $userId, $block->getTarget()->getId(), 'Correct blockee id' ); - $this->assertEquals( 'MetaWikiUser', $block->getBlocker(), 'Correct blocker name' ); - $this->assertEquals( 'MetaWikiUser', $block->getByName(), 'Correct blocker name' ); + $this->assertEquals( 'Meta>MetaWikiUser', $block->getBlocker()->getName(), + 'Correct blocker name' ); + $this->assertEquals( 'Meta>MetaWikiUser', $block->getByName(), 'Correct blocker name' ); $this->assertEquals( 0, $block->getBy(), 'Correct blocker id' ); } @@ -282,6 +285,7 @@ class BlockTest extends MediaWikiLangTestCase { ], ]; + $blocker = $this->getTestUser()->getUser(); foreach ( $blockList as $insBlock ) { $target = $insBlock['target']; @@ -293,7 +297,7 @@ class BlockTest extends MediaWikiLangTestCase { $block = new Block(); $block->setTarget( $target ); - $block->setBlocker( 'testblocker@global' ); + $block->setBlocker( $blocker ); $block->mReason = $insBlock['desc']; $block->mExpiry = 'infinity'; $block->prevents( 'createaccount', $insBlock['ACDisable'] ); @@ -364,6 +368,9 @@ class BlockTest extends MediaWikiLangTestCase { $this->assertEquals( $exResult, $block->mReason, 'Correct block type for XFF header ' . $xff ); } + /** + * @covers Block::__construct + */ public function testDeprecatedConstructor() { $this->hideDeprecated( 'Block::__construct with multiple arguments' ); $username = 'UnthinkablySecretRandomUsername'; @@ -387,7 +394,7 @@ class BlockTest extends MediaWikiLangTestCase { $block = new Block( /* address */ $username, /* user */ 0, - /* by */ 0, + /* by */ $this->getTestSysop()->getUser()->getId(), /* reason */ $reason, /* timestamp */ 0, /* auto */ false, @@ -416,6 +423,11 @@ class BlockTest extends MediaWikiLangTestCase { ); } + /** + * @covers Block::getSystemBlockType + * @covers Block::insert + * @covers Block::doAutoblock + */ public function testSystemBlocks() { $user = $this->getUserForBlocking(); $this->addBlockForUser( $user ); @@ -425,7 +437,7 @@ class BlockTest extends MediaWikiLangTestCase { 'reason' => 'test system block', 'timestamp' => wfTimestampNow(), 'expiry' => $this->db->getInfinity(), - 'byText' => 'MetaWikiUser', + 'byText' => 'MediaWiki default', 'systemBlock' => 'test', 'enableAutoblock' => true, ];