From: jenkins-bot Date: Wed, 27 Feb 2019 17:25:09 +0000 (+0000) Subject: Merge "Add tests to ensure that retrieved actions match passed in restrictions" X-Git-Tag: 1.34.0-rc.0~2708 X-Git-Url: http://git.cyclocoop.org/%22.%24h.%22?a=commitdiff_plain;h=10e2511f81d329c9ad401dd979e6ccd9fb64d987;p=lhc%2Fweb%2Fwiklou.git Merge "Add tests to ensure that retrieved actions match passed in restrictions" --- 10e2511f81d329c9ad401dd979e6ccd9fb64d987 diff --cc tests/phpunit/includes/TitlePermissionTest.php index 1157331eec,cac5d6b2ee..3d8c6439bf --- a/tests/phpunit/includes/TitlePermissionTest.php +++ b/tests/phpunit/includes/TitlePermissionTest.php @@@ -1029,12 -1029,55 +1029,62 @@@ class TitlePermissionTest extends Media $this->title->getUserPermissionsErrors( 'upload', $this->user ) ); $this->assertEquals( [], $this->title->getUserPermissionsErrors( 'purge', $this->user ) ); + + // Test no block. + $this->user->mBlockedby = null; + $this->user->mBlock = null; + + $this->assertEquals( [], + $this->title->getUserPermissionsErrors( 'edit', $this->user ) ); } + + /** + * @covers Title::checkUserBlock + * + * Tests to determine that the passed in permission does not get mixed up with + * an action of the same name. + */ + public function testUserBlockAction() { + global $wgLang; + + $tester = $this->getMockBuilder( Action::class ) + ->disableOriginalConstructor() + ->getMock(); + $tester->method( 'getName' ) + ->willReturn( 'tester' ); + $tester->method( 'getRestriction' ) + ->willReturn( 'test' ); + $tester->method( 'requiresUnblock' ) + ->willReturn( false ); + + $this->setMwGlobals( [ + 'wgActions' => [ + 'tester' => $tester, + ], + 'wgGroupPermissions' => [ + '*' => [ + 'tester' => true, + ], + ], + ] ); + + $now = time(); + $this->user->mBlockedby = $this->user->getName(); + $this->user->mBlock = new Block( [ + 'address' => '127.0.8.1', + 'by' => $this->user->getId(), + 'reason' => 'no reason given', + 'timestamp' => $now, + 'auto' => false, + 'expiry' => 'infinity', + ] ); + + $errors = [ [ 'blockedtext', + '[[User:Useruser|Useruser]]', 'no reason given', '127.0.0.1', + 'Useruser', null, 'infinite', '127.0.8.1', + $wgLang->timeanddate( wfTimestamp( TS_MW, $now ), true ) ] ]; + + $this->assertEquals( $errors, + $this->title->getUserPermissionsErrors( 'tester', $this->user ) ); + } }