X-Git-Url: http://git.cyclocoop.org/%28?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2FTitlePermissionTest.php;h=cb5e1f8a7998cab319b53c869c7a1128809cb4f7;hb=c073e531cf7a7fe055f002148e97159006b75c22;hp=11b9c012f8f211b3187458456b3c859cf89251a2;hpb=cb4d4c4d8f4884bfe18b1e69c0d1bc2d8d567d5c;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/TitlePermissionTest.php b/tests/phpunit/includes/TitlePermissionTest.php index 11b9c012f8..cb5e1f8a79 100644 --- a/tests/phpunit/includes/TitlePermissionTest.php +++ b/tests/phpunit/includes/TitlePermissionTest.php @@ -1,5 +1,6 @@ true, ] ); - $this->setUserPerm( [ "createpage", "move" ] ); + $this->setUserPerm( [ 'createpage', 'edit', 'move', 'rollback', 'patrol', 'upload', 'purge' ] ); $this->setTitle( NS_HELP, "test page" ); # $wgEmailConfirmToEdit only applies to 'edit' action @@ -964,11 +965,24 @@ class TitlePermissionTest extends MediaWikiLangTestCase { 'expiry' => 10, 'systemBlock' => 'test', ] ); - $this->assertEquals( [ [ 'systemblockedtext', + + $errors = [ [ 'systemblockedtext', '[[User:Useruser|Useruser]]', 'no reason given', '127.0.0.1', 'Useruser', 'test', '23:00, 31 December 1969', '127.0.8.1', - $wgLang->timeanddate( wfTimestamp( TS_MW, $now ), true ) ] ], + $wgLang->timeanddate( wfTimestamp( TS_MW, $now ), true ) ] ]; + + $this->assertEquals( $errors, + $this->title->getUserPermissionsErrors( 'edit', $this->user ) ); + $this->assertEquals( $errors, $this->title->getUserPermissionsErrors( 'move-target', $this->user ) ); + $this->assertEquals( $errors, + $this->title->getUserPermissionsErrors( 'rollback', $this->user ) ); + $this->assertEquals( $errors, + $this->title->getUserPermissionsErrors( 'patrol', $this->user ) ); + $this->assertEquals( $errors, + $this->title->getUserPermissionsErrors( 'upload', $this->user ) ); + $this->assertEquals( [], + $this->title->getUserPermissionsErrors( 'purge', $this->user ) ); // partial block message test $this->user->mBlockedby = $this->user->getName(); @@ -981,10 +995,39 @@ class TitlePermissionTest extends MediaWikiLangTestCase { 'expiry' => 10, ] ); - $this->assertEquals( [ [ 'blockedtext-partial', + $this->assertEquals( [], + $this->title->getUserPermissionsErrors( 'edit', $this->user ) ); + $this->assertEquals( [], + $this->title->getUserPermissionsErrors( 'move-target', $this->user ) ); + $this->assertEquals( [], + $this->title->getUserPermissionsErrors( 'rollback', $this->user ) ); + $this->assertEquals( [], + $this->title->getUserPermissionsErrors( 'patrol', $this->user ) ); + $this->assertEquals( [], + $this->title->getUserPermissionsErrors( 'upload', $this->user ) ); + $this->assertEquals( [], + $this->title->getUserPermissionsErrors( 'purge', $this->user ) ); + + $this->user->mBlock->setRestrictions( [ + ( new PageRestriction( 0, $this->title->getArticleID() ) )->setTitle( $this->title ), + ] ); + + $errors = [ [ 'blockedtext-partial', '[[User:Useruser|Useruser]]', 'no reason given', '127.0.0.1', 'Useruser', null, '23:00, 31 December 1969', '127.0.8.1', - $wgLang->timeanddate( wfTimestamp( TS_MW, $now ), true ) ] ], + $wgLang->timeanddate( wfTimestamp( TS_MW, $now ), true ) ] ]; + + $this->assertEquals( $errors, + $this->title->getUserPermissionsErrors( 'edit', $this->user ) ); + $this->assertEquals( $errors, $this->title->getUserPermissionsErrors( 'move-target', $this->user ) ); + $this->assertEquals( $errors, + $this->title->getUserPermissionsErrors( 'rollback', $this->user ) ); + $this->assertEquals( $errors, + $this->title->getUserPermissionsErrors( 'patrol', $this->user ) ); + $this->assertEquals( [], + $this->title->getUserPermissionsErrors( 'upload', $this->user ) ); + $this->assertEquals( [], + $this->title->getUserPermissionsErrors( 'purge', $this->user ) ); } }