108 $res = $this->title->getUserPermissionsErrors(
'create', $this->user );
109 $this->assertEquals( [],
$res );
113 $res = $this->title->getUserPermissionsErrors(
'create', $this->user );
114 $this->assertEquals( [ [
"nocreatetext" ] ],
$res );
118 $res = $this->title->getUserPermissionsErrors(
'create', $this->user );
119 $this->assertEquals( [ [
'nocreatetext' ] ],
$res );
123 $res = $this->title->getUserPermissionsErrors(
'create', $this->user );
124 $this->assertEquals( [],
$res );
128 $res = $this->title->getUserPermissionsErrors(
'create', $this->user );
129 $this->assertEquals( [ [
'nocreatetext' ] ],
$res );
131 $this->
setUser( $this->userName );
134 $res = $this->title->getUserPermissionsErrors(
'create', $this->user );
135 $this->assertEquals( [],
$res );
139 $res = $this->title->getUserPermissionsErrors(
'create', $this->user );
140 $this->assertEquals( [ [
'nocreate-loggedin' ] ],
$res );
144 $res = $this->title->getUserPermissionsErrors(
'create', $this->user );
145 $this->assertEquals( [ [
'nocreate-loggedin' ] ],
$res );
149 $res = $this->title->getUserPermissionsErrors(
'create', $this->user );
150 $this->assertEquals( [],
$res );
154 $res = $this->title->getUserPermissionsErrors(
'create', $this->user );
155 $this->assertEquals( [ [
'nocreate-loggedin' ] ],
$res );
159 $res = $this->title->getUserPermissionsErrors(
'create', $this->user );
160 $this->assertEquals( [ [
'nocreate-loggedin' ] ],
$res );
163 $this->
setTitle( NS_USER, $this->userName .
'' );
165 $res = $this->title->getUserPermissionsErrors(
'move', $this->user );
166 $this->assertEquals( [ [
'cant-move-user-page' ], [
'movenologintext' ] ],
$res );
168 $this->
setTitle( NS_USER, $this->userName .
'/subpage' );
170 $res = $this->title->getUserPermissionsErrors(
'move', $this->user );
171 $this->assertEquals( [ [
'movenologintext' ] ],
$res );
173 $this->
setTitle( NS_USER, $this->userName .
'' );
175 $res = $this->title->getUserPermissionsErrors(
'move', $this->user );
176 $this->assertEquals( [ [
'movenologintext' ] ],
$res );
178 $this->
setTitle( NS_USER, $this->userName .
'/subpage' );
180 $res = $this->title->getUserPermissionsErrors(
'move', $this->user );
181 $this->assertEquals( [ [
'movenologintext' ] ],
$res );
183 $this->
setTitle( NS_USER, $this->userName .
'' );
185 $res = $this->title->getUserPermissionsErrors(
'move', $this->user );
186 $this->assertEquals( [ [
'cant-move-user-page' ], [
'movenologintext' ] ],
$res );
188 $this->
setTitle( NS_USER, $this->userName .
'/subpage' );
190 $res = $this->title->getUserPermissionsErrors(
'move', $this->user );
191 $this->assertEquals( [ [
'movenologintext' ] ],
$res );
193 $this->
setTitle( NS_USER, $this->userName .
'' );
195 $res = $this->title->getUserPermissionsErrors(
'move', $this->user );
196 $this->assertEquals( [ [
'movenologintext' ] ],
$res );
198 $this->
setTitle( NS_USER, $this->userName .
'/subpage' );
200 $res = $this->title->getUserPermissionsErrors(
'move', $this->user );
201 $this->assertEquals( [ [
'movenologintext' ] ],
$res );
203 $this->
setUser( $this->userName );
206 $res = $this->title->getUserPermissionsErrors(
'move', $this->user );
207 $this->assertEquals( [ [
'movenotallowedfile' ], [
'movenotallowed' ] ],
$res );
211 $res = $this->title->getUserPermissionsErrors(
'move', $this->user );
212 $this->assertEquals( [ [
'movenotallowed' ] ],
$res );
217 $res = $this->title->getUserPermissionsErrors(
'move', $this->user );
218 $this->assertEquals( [ [
'movenotallowedfile' ], [
'movenologintext' ] ],
$res );
222 $res = $this->title->getUserPermissionsErrors(
'move', $this->user );
223 $this->assertEquals( [ [
'movenologintext' ] ],
$res );
225 $this->
setUser( $this->userName );
232 [ [
'movenotallowedfile' ], [
'movenotallowed' ] ]
242 [ [
'movenotallowedfile' ], [
'movenotallowed' ] ],
243 [ [
'movenotallowedfile' ], [
'movenologintext' ] ]
257 [ [
'movenologintext' ] ] );
259 $this->
setUser( $this->userName );
268 $res = $this->title->getUserPermissionsErrors(
'move-target', $this->user );
269 $this->assertEquals( [],
$res );
272 $res = $this->title->getUserPermissionsErrors(
'move-target', $this->user );
273 $this->assertEquals( [ [
'movenotallowed' ] ],
$res );
277 $this->
setUser( $this->userName );
278 $this->
setUserPerm( [
"move",
"move-rootuserpages" ] );
279 $res = $this->title->getUserPermissionsErrors(
'move-target', $this->user );
280 $this->assertEquals( [],
$res );
283 $res = $this->title->getUserPermissionsErrors(
'move-target', $this->user );
284 $this->assertEquals( [ [
'cant-move-to-user-page' ] ],
$res );
287 $this->
setUserPerm( [
"move",
"move-rootuserpages" ] );
288 $res = $this->title->getUserPermissionsErrors(
'move-target', $this->user );
289 $this->assertEquals( [],
$res );
291 $this->
setTitle( NS_USER,
"User/subpage" );
292 $this->
setUserPerm( [
"move",
"move-rootuserpages" ] );
293 $res = $this->title->getUserPermissionsErrors(
'move-target', $this->user );
294 $this->assertEquals( [],
$res );
297 $res = $this->title->getUserPermissionsErrors(
'move-target', $this->user );
298 $this->assertEquals( [],
$res );
303 [ [
'badaccess-groups',
"*, [[$prefix:Users|Users]]", 2 ] ],
304 [ [
'badaccess-group0' ] ],
311 "[[$prefix:Administrators|Administrators]]", 1 ],
314 [ [
'badaccess-group0' ], [
'protect-cantedit' ] ],
315 [ [
'protect-cantedit' ] ],
318 '' => [ [], [], [],
true ]
321 foreach ( [
"edit",
"protect",
"" ] as $action ) {
323 $this->assertEquals( $check[$action][0],
324 $this->title->getUserPermissionsErrors( $action, $this->user,
true ) );
325 $this->assertEquals( $check[$action][0],
326 $this->title->getUserPermissionsErrors( $action, $this->user,
'full' ) );
327 $this->assertEquals( $check[$action][0],
328 $this->title->getUserPermissionsErrors( $action, $this->user,
'secure' ) );
334 $this->assertEquals( $check[$action][1],
335 $this->title->getUserPermissionsErrors( $action, $this->user,
true ) );
336 $this->assertEquals( $check[$action][1],
337 $this->title->getUserPermissionsErrors( $action, $this->user,
'full' ) );
338 $this->assertEquals( $check[$action][1],
339 $this->title->getUserPermissionsErrors( $action, $this->user,
'secure' ) );
343 $this->assertEquals( $check[$action][2],
344 $this->title->getUserPermissionsErrors( $action, $this->user,
true ) );
345 $this->assertEquals( $check[$action][2],
346 $this->title->getUserPermissionsErrors( $action, $this->user,
'full' ) );
347 $this->assertEquals( $check[$action][2],
348 $this->title->getUserPermissionsErrors( $action, $this->user,
'secure' ) );
351 $this->assertEquals( $check[$action][3],
352 $this->title->userCan( $action, $this->user,
true ) );
353 $this->assertEquals( $check[$action][3],
354 $this->title->quickUserCan( $action, $this->user ) );
355 # count( User::getGroupsWithPermissions( $action ) ) < 1
608 $result = $this->title->getUserPermissionsErrors(
'bogus', $this->user );
609 $this->assertEquals( $resultNone, $result );
612 $result = $this->title->getUserPermissionsErrors(
'bogus', $this->user );
613 $this->assertEquals( $resultMyCss, $result );
616 $result = $this->title->getUserPermissionsErrors(
'bogus', $this->user );
617 $this->assertEquals( $resultMyJson, $result );
620 $result = $this->title->getUserPermissionsErrors(
'bogus', $this->user );
621 $this->assertEquals( $resultMyJs, $result );
624 $result = $this->title->getUserPermissionsErrors(
'bogus', $this->user );
625 $this->assertEquals( $resultUserCss, $result );
628 $result = $this->title->getUserPermissionsErrors(
'bogus', $this->user );
629 $this->assertEquals( $resultUserJson, $result );
632 $result = $this->title->getUserPermissionsErrors(
'bogus', $this->user );
633 $this->assertEquals( $resultUserJs, $result );
635 $this->
setUserPerm( [
'edituserjs',
'edituserjson',
'editusercss' ] );
636 $result = $this->title->getUserPermissionsErrors(
'bogus', $this->user );
637 $this->assertEquals( [ [
'badaccess-group0' ] ], $result );
651 $this->title->mRestrictionsLoaded =
true;
653 $this->title->mRestrictions = [
"bogus" => [
'bogus',
"sysop",
"protect",
"" ] ];
655 $this->assertEquals( [],
656 $this->title->getUserPermissionsErrors(
'edit',
659 $this->assertEquals(
true,
660 $this->title->quickUserCan(
'edit', $this->user ) );
661 $this->title->mRestrictions = [
"edit" => [
'bogus',
"sysop",
"protect",
"" ],
662 "bogus" => [
'bogus',
"sysop",
"protect",
"" ] ];
664 $this->assertEquals( [ [
'badaccess-group0' ],
665 [
'protectedpagetext',
'bogus',
'bogus' ],
666 [
'protectedpagetext',
'editprotected',
'bogus' ],
667 [
'protectedpagetext',
'protect',
'bogus' ] ],
668 $this->title->getUserPermissionsErrors(
'bogus',
670 $this->assertEquals( [ [
'protectedpagetext',
'bogus',
'edit' ],
671 [
'protectedpagetext',
'editprotected',
'edit' ],
672 [
'protectedpagetext',
'protect',
'edit' ] ],
673 $this->title->getUserPermissionsErrors(
'edit',
676 $this->assertEquals( [ [
'badaccess-group0' ],
677 [
'protectedpagetext',
'bogus',
'bogus' ],
678 [
'protectedpagetext',
'editprotected',
'bogus' ],
679 [
'protectedpagetext',
'protect',
'bogus' ] ],
680 $this->title->getUserPermissionsErrors(
'bogus',
682 $this->assertEquals( [ [
'badaccess-groups',
"*, [[$prefix:Users|Users]]", 2 ],
683 [
'protectedpagetext',
'bogus',
'edit' ],
684 [
'protectedpagetext',
'editprotected',
'edit' ],
685 [
'protectedpagetext',
'protect',
'edit' ] ],
686 $this->title->getUserPermissionsErrors(
'edit',
689 $this->assertEquals( [ [
'badaccess-group0' ],
690 [
'protectedpagetext',
'bogus',
'bogus' ],
691 [
'protectedpagetext',
'protect',
'bogus' ] ],
692 $this->title->getUserPermissionsErrors(
'bogus',
694 $this->assertEquals( [
695 [
'protectedpagetext',
'bogus',
'edit' ],
696 [
'protectedpagetext',
'protect',
'edit' ] ],
697 $this->title->getUserPermissionsErrors(
'edit',
700 $this->title->mCascadeRestriction =
true;
702 $this->assertEquals(
false,
703 $this->title->quickUserCan(
'bogus', $this->user ) );
704 $this->assertEquals(
false,
705 $this->title->quickUserCan(
'edit', $this->user ) );
706 $this->assertEquals( [ [
'badaccess-group0' ],
707 [
'protectedpagetext',
'bogus',
'bogus' ],
708 [
'protectedpagetext',
'editprotected',
'bogus' ],
709 [
'protectedpagetext',
'protect',
'bogus' ] ],
710 $this->title->getUserPermissionsErrors(
'bogus',
712 $this->assertEquals( [ [
'protectedpagetext',
'bogus',
'edit' ],
713 [
'protectedpagetext',
'editprotected',
'edit' ],
714 [
'protectedpagetext',
'protect',
'edit' ] ],
715 $this->title->getUserPermissionsErrors(
'edit',
719 $this->assertEquals(
false,
720 $this->title->quickUserCan(
'bogus', $this->user ) );
721 $this->assertEquals(
false,
722 $this->title->quickUserCan(
'edit', $this->user ) );
723 $this->assertEquals( [ [
'badaccess-group0' ],
724 [
'protectedpagetext',
'bogus',
'bogus' ],
725 [
'protectedpagetext',
'protect',
'bogus' ],
726 [
'protectedpagetext',
'protect',
'bogus' ] ],
727 $this->title->getUserPermissionsErrors(
'bogus',
729 $this->assertEquals( [ [
'protectedpagetext',
'bogus',
'edit' ],
730 [
'protectedpagetext',
'protect',
'edit' ],
731 [
'protectedpagetext',
'protect',
'edit' ] ],
732 $this->title->getUserPermissionsErrors(
'edit',
773 $this->title->mTitleProtection[
'permission'] =
'';
774 $this->title->mTitleProtection[
'user'] = $this->user->getId();
775 $this->title->mTitleProtection[
'expiry'] =
'infinity';
776 $this->title->mTitleProtection[
'reason'] =
'test';
777 $this->title->mCascadeRestriction =
false;
779 $this->assertEquals( [ [
'titleprotected',
'Useruser',
'test' ] ],
780 $this->title->getUserPermissionsErrors(
'create', $this->user ) );
781 $this->assertEquals(
false,
782 $this->title->userCan(
'create', $this->user ) );
784 $this->title->mTitleProtection[
'permission'] =
'editprotected';
786 $this->assertEquals( [ [
'titleprotected',
'Useruser',
'test' ] ],
787 $this->title->getUserPermissionsErrors(
'create', $this->user ) );
788 $this->assertEquals(
false,
789 $this->title->userCan(
'create', $this->user ) );
791 $this->
setUserPerm( [
'createpage',
'editprotected' ] );
792 $this->assertEquals( [],
793 $this->title->getUserPermissionsErrors(
'create', $this->user ) );
794 $this->assertEquals(
true,
795 $this->title->userCan(
'create', $this->user ) );
798 $this->assertEquals( [ [
'titleprotected',
'Useruser',
'test' ] ],
799 $this->title->getUserPermissionsErrors(
'create', $this->user ) );
800 $this->assertEquals(
false,
801 $this->title->userCan(
'create', $this->user ) );
805 $this->assertEquals(
false,
806 $this->title->userCan(
'move', $this->user ) );
807 $this->assertEquals( [ [
'immobile-source-namespace',
'Media' ] ],
808 $this->title->getUserPermissionsErrors(
'move', $this->user ) );
811 $this->assertEquals( [],
812 $this->title->getUserPermissionsErrors(
'move', $this->user ) );
813 $this->assertEquals(
true,
814 $this->title->userCan(
'move', $this->user ) );
816 $this->title->mInterwiki =
"no";
817 $this->assertEquals( [ [
'immobile-source-page' ] ],
818 $this->title->getUserPermissionsErrors(
'move', $this->user ) );
819 $this->assertEquals(
false,
820 $this->title->userCan(
'move', $this->user ) );
823 $this->assertEquals(
false,
824 $this->title->userCan(
'move-target', $this->user ) );
825 $this->assertEquals( [ [
'immobile-target-namespace',
'Media' ] ],
826 $this->title->getUserPermissionsErrors(
'move-target', $this->user ) );
829 $this->assertEquals( [],
830 $this->title->getUserPermissionsErrors(
'move-target', $this->user ) );
831 $this->assertEquals(
true,
832 $this->title->userCan(
'move-target', $this->user ) );
834 $this->title->mInterwiki =
"no";
835 $this->assertEquals( [ [
'immobile-target-page' ] ],
836 $this->title->getUserPermissionsErrors(
'move-target', $this->user ) );
837 $this->assertEquals(
false,
838 $this->title->userCan(
'move-target', $this->user ) );
846 'wgEmailConfirmToEdit' =>
true,
847 'wgEmailAuthentication' =>
true,
853 # $wgEmailConfirmToEdit only applies to 'edit' action
854 $this->assertEquals( [],
855 $this->title->getUserPermissionsErrors(
'move-target', $this->user ) );
856 $this->assertContains( [
'confirmedittext' ],
857 $this->title->getUserPermissionsErrors(
'edit', $this->user ) );
860 $this->assertNotContains( [
'confirmedittext' ],
861 $this->title->getUserPermissionsErrors(
'edit', $this->user ) );
863 # $wgEmailConfirmToEdit && !$user->isEmailConfirmed() && $action != 'createaccount'
864 $this->assertEquals( [],
865 $this->title->getUserPermissionsErrors(
'move-target',
871 $this->user->mBlockedby = $this->user->getId();
872 $this->user->mBlock =
new Block( [
873 'address' =>
'127.0.8.1',
874 'by' => $this->user->getId(),
875 'reason' =>
'no reason given',
876 'timestamp' => $prev + 3600,
880 $this->user->mBlock->mTimestamp = 0;
881 $this->assertEquals( [ [
'autoblockedtext',
882 '[[User:Useruser|Useruser]]',
'no reason given',
'127.0.0.1',
883 'Useruser',
null,
'infinite',
'127.0.8.1',
885 $this->title->getUserPermissionsErrors(
'move-target',
888 $this->assertEquals(
false, $this->title->userCan(
'move-target', $this->user ) );
890 $this->assertEquals(
true, $this->title->quickUserCan(
'move-target', $this->user ) );
894 $this->user->mBlockedby = $this->user->getName();
895 $this->user->mBlock =
new Block( [
896 'address' =>
'127.0.8.1',
897 'by' => $this->user->getId(),
898 'reason' =>
'no reason given',
903 $this->assertEquals( [ [
'blockedtext',
904 '[[User:Useruser|Useruser]]',
'no reason given',
'127.0.0.1',
905 'Useruser',
null,
'23:00, 31 December 1969',
'127.0.8.1',
907 $this->title->getUserPermissionsErrors(
'move-target', $this->user ) );
908 # $action != 'read' && $action != 'createaccount' && $user->isBlockedFrom( $this )
909 # $user->blockedFor() == ''
910 # $user->mBlock->mExpiry == 'infinity'
912 $this->user->mBlockedby = $this->user->getName();
913 $this->user->mBlock =
new Block( [
914 'address' =>
'127.0.8.1',
915 'by' => $this->user->getId(),
916 'reason' =>
'no reason given',
920 'systemBlock' =>
'test',
922 $this->assertEquals( [ [
'systemblockedtext',
923 '[[User:Useruser|Useruser]]',
'no reason given',
'127.0.0.1',
924 'Useruser',
'test',
'23:00, 31 December 1969',
'127.0.8.1',
926 $this->title->getUserPermissionsErrors(
'move-target', $this->user ) );