33 $localOffset = date(
'Z' ) / 60;
36 'wgLocaltimezone' => $localZone,
37 'wgLocalTZoffset' => $localOffset,
38 'wgNamespaceProtection' => [
46 $this->userName =
'Useruser';
47 $this->altUserName =
'Altuseruser';
48 date_default_timezone_set( $localZone );
51 if ( !isset( $this->userUser ) || !( $this->userUser instanceof
User ) ) {
54 if ( !$this->userUser->getId() ) {
56 "email" =>
"test@example.com",
57 "real_name" =>
"Test User" ] );
58 $this->userUser->load();
62 if ( !$this->altUser->getId() ) {
64 "email" =>
"alttest@example.com",
65 "real_name" =>
"Test User Alt" ] );
66 $this->altUser->load();
79 if ( is_array( $perm ) ) {
80 $this->
user->mRights = $perm;
82 $this->
user->mRights = [ $perm ];
110 $prefix = MediaWikiServices::getInstance()->getContentLanguage()->
116 $res = $this->
title->getUserPermissionsErrors(
'create', $this->
user );
117 $this->assertEquals( [],
$res );
121 $res = $this->
title->getUserPermissionsErrors(
'create', $this->
user );
122 $this->assertEquals( [ [
"nocreatetext" ] ],
$res );
126 $res = $this->
title->getUserPermissionsErrors(
'create', $this->
user );
127 $this->assertEquals( [ [
'nocreatetext' ] ],
$res );
131 $res = $this->
title->getUserPermissionsErrors(
'create', $this->
user );
132 $this->assertEquals( [],
$res );
136 $res = $this->
title->getUserPermissionsErrors(
'create', $this->
user );
137 $this->assertEquals( [ [
'nocreatetext' ] ],
$res );
139 $this->
setUser( $this->userName );
142 $res = $this->
title->getUserPermissionsErrors(
'create', $this->
user );
143 $this->assertEquals( [],
$res );
147 $res = $this->
title->getUserPermissionsErrors(
'create', $this->
user );
148 $this->assertEquals( [ [
'nocreate-loggedin' ] ],
$res );
152 $res = $this->
title->getUserPermissionsErrors(
'create', $this->
user );
153 $this->assertEquals( [ [
'nocreate-loggedin' ] ],
$res );
157 $res = $this->
title->getUserPermissionsErrors(
'create', $this->
user );
158 $this->assertEquals( [],
$res );
162 $res = $this->
title->getUserPermissionsErrors(
'create', $this->
user );
163 $this->assertEquals( [ [
'nocreate-loggedin' ] ],
$res );
167 $res = $this->
title->getUserPermissionsErrors(
'create', $this->
user );
168 $this->assertEquals( [ [
'nocreate-loggedin' ] ],
$res );
173 $res = $this->
title->getUserPermissionsErrors(
'move', $this->
user );
174 $this->assertEquals( [ [
'cant-move-user-page' ], [
'movenologintext' ] ],
$res );
178 $res = $this->
title->getUserPermissionsErrors(
'move', $this->
user );
179 $this->assertEquals( [ [
'movenologintext' ] ],
$res );
183 $res = $this->
title->getUserPermissionsErrors(
'move', $this->
user );
184 $this->assertEquals( [ [
'movenologintext' ] ],
$res );
188 $res = $this->
title->getUserPermissionsErrors(
'move', $this->
user );
189 $this->assertEquals( [ [
'movenologintext' ] ],
$res );
193 $res = $this->
title->getUserPermissionsErrors(
'move', $this->
user );
194 $this->assertEquals( [ [
'cant-move-user-page' ], [
'movenologintext' ] ],
$res );
198 $res = $this->
title->getUserPermissionsErrors(
'move', $this->
user );
199 $this->assertEquals( [ [
'movenologintext' ] ],
$res );
203 $res = $this->
title->getUserPermissionsErrors(
'move', $this->
user );
204 $this->assertEquals( [ [
'movenologintext' ] ],
$res );
208 $res = $this->
title->getUserPermissionsErrors(
'move', $this->
user );
209 $this->assertEquals( [ [
'movenologintext' ] ],
$res );
211 $this->
setUser( $this->userName );
214 $res = $this->
title->getUserPermissionsErrors(
'move', $this->
user );
215 $this->assertEquals( [ [
'movenotallowedfile' ], [
'movenotallowed' ] ],
$res );
219 $res = $this->
title->getUserPermissionsErrors(
'move', $this->
user );
220 $this->assertEquals( [ [
'movenotallowed' ] ],
$res );
225 $res = $this->
title->getUserPermissionsErrors(
'move', $this->
user );
226 $this->assertEquals( [ [
'movenotallowedfile' ], [
'movenologintext' ] ],
$res );
230 $res = $this->
title->getUserPermissionsErrors(
'move', $this->
user );
231 $this->assertEquals( [ [
'movenologintext' ] ],
$res );
233 $this->
setUser( $this->userName );
240 [ [
'movenotallowedfile' ], [
'movenotallowed' ] ]
250 [ [
'movenotallowedfile' ], [
'movenotallowed' ] ],
251 [ [
'movenotallowedfile' ], [
'movenologintext' ] ]
265 [ [
'movenologintext' ] ] );
267 $this->
setUser( $this->userName );
276 $res = $this->
title->getUserPermissionsErrors(
'move-target', $this->
user );
277 $this->assertEquals( [],
$res );
280 $res = $this->
title->getUserPermissionsErrors(
'move-target', $this->
user );
281 $this->assertEquals( [ [
'movenotallowed' ] ],
$res );
285 $this->
setUser( $this->userName );
286 $this->
setUserPerm( [
"move",
"move-rootuserpages" ] );
287 $res = $this->
title->getUserPermissionsErrors(
'move-target', $this->
user );
288 $this->assertEquals( [],
$res );
291 $res = $this->
title->getUserPermissionsErrors(
'move-target', $this->
user );
292 $this->assertEquals( [ [
'cant-move-to-user-page' ] ],
$res );
295 $this->
setUserPerm( [
"move",
"move-rootuserpages" ] );
296 $res = $this->
title->getUserPermissionsErrors(
'move-target', $this->
user );
297 $this->assertEquals( [],
$res );
300 $this->
setUserPerm( [
"move",
"move-rootuserpages" ] );
301 $res = $this->
title->getUserPermissionsErrors(
'move-target', $this->
user );
302 $this->assertEquals( [],
$res );
305 $res = $this->
title->getUserPermissionsErrors(
'move-target', $this->
user );
306 $this->assertEquals( [],
$res );
311 [ [
'badaccess-groups',
"*, [[$prefix:Users|Users]]", 2 ] ],
312 [ [
'badaccess-group0' ] ],
319 "[[$prefix:Administrators|Administrators]]", 1 ],
322 [ [
'badaccess-group0' ], [
'protect-cantedit' ] ],
323 [ [
'protect-cantedit' ] ],
326 '' => [ [], [], [],
true ]
329 foreach ( [
"edit",
"protect",
"" ]
as $action ) {
331 $this->assertEquals( $check[$action][0],
332 $this->
title->getUserPermissionsErrors( $action, $this->user,
true ) );
333 $this->assertEquals( $check[$action][0],
334 $this->
title->getUserPermissionsErrors( $action, $this->user,
'full' ) );
335 $this->assertEquals( $check[$action][0],
336 $this->
title->getUserPermissionsErrors( $action, $this->user,
'secure' ) );
342 $this->assertEquals( $check[$action][1],
343 $this->
title->getUserPermissionsErrors( $action, $this->user,
true ) );
344 $this->assertEquals( $check[$action][1],
345 $this->
title->getUserPermissionsErrors( $action, $this->user,
'full' ) );
346 $this->assertEquals( $check[$action][1],
347 $this->
title->getUserPermissionsErrors( $action, $this->user,
'secure' ) );
351 $this->assertEquals( $check[$action][2],
352 $this->
title->getUserPermissionsErrors( $action, $this->user,
true ) );
353 $this->assertEquals( $check[$action][2],
354 $this->
title->getUserPermissionsErrors( $action, $this->user,
'full' ) );
355 $this->assertEquals( $check[$action][2],
356 $this->
title->getUserPermissionsErrors( $action, $this->user,
'secure' ) );
359 $this->assertEquals( $check[$action][3],
360 $this->
title->userCan( $action, $this->user,
true ) );
361 $this->assertEquals( $check[$action][3],
362 $this->
title->quickUserCan( $action, $this->user ) );
363 # count( User::getGroupsWithPermissions( $action ) ) < 1
370 if ( $result2 ===
null ) {
376 $res = $this->
title->getUserPermissionsErrors( $action, $this->
user );
381 $res = $this->
title->getUserPermissionsErrors( $action, $this->
user );
382 $this->assertEquals( $result2,
$res );
386 $res = $this->
title->getUserPermissionsErrors( $action, $this->
user );
387 $this->assertEquals( $result2,
$res );
391 $res = $this->
title->getUserPermissionsErrors( $action, $this->
user );
392 $this->assertEquals( $result2,
$res );
402 $this->
setUser( $this->userName );
406 $this->assertEquals( [ [
'badaccess-group0' ], [
'ns-specialprotected' ] ],
407 $this->
title->getUserPermissionsErrors(
'bogus', $this->user ) );
411 $this->assertEquals( [],
412 $this->
title->getUserPermissionsErrors(
'bogus', $this->user ) );
416 $this->assertEquals( [ [
'badaccess-group0' ] ],
417 $this->
title->getUserPermissionsErrors(
'bogus', $this->user ) );
423 $this->assertEquals( [ [
'badaccess-group0' ],
424 [
'namespaceprotected',
'User',
'bogus' ] ],
425 $this->
title->getUserPermissionsErrors(
'bogus', $this->user ) );
429 $this->assertEquals( [ [
'protectedinterface',
'bogus' ] ],
430 $this->
title->getUserPermissionsErrors(
'bogus', $this->user ) );
434 $this->assertEquals( [ [
'protectedinterface',
'bogus' ] ],
435 $this->
title->getUserPermissionsErrors(
'bogus', $this->user ) );
440 $this->assertEquals( [],
441 $this->
title->getUserPermissionsErrors(
'bogus', $this->user ) );
442 $this->assertEquals(
true,
443 $this->
title->userCan(
'bogus', $this->user ) );
446 $this->assertEquals( [ [
'badaccess-group0' ] ],
447 $this->
title->getUserPermissionsErrors(
'bogus', $this->user ) );
448 $this->assertEquals(
false,
449 $this->
title->userCan(
'bogus', $this->user ) );
458 $this->
setUser( $this->userName );
462 [ [
'badaccess-group0' ], [
'mycustomjsprotected',
'bogus' ] ],
464 [ [
'badaccess-group0' ], [
'mycustomjsprotected',
'bogus' ] ],
465 [ [
'badaccess-group0' ], [
'mycustomjsprotected',
'bogus' ] ],
466 [ [
'badaccess-group0' ] ],
468 [ [
'badaccess-group0' ], [
'mycustomjsprotected',
'bogus' ] ],
469 [ [
'badaccess-group0' ], [
'mycustomjsprotected',
'bogus' ] ],
470 [ [
'badaccess-group0' ] ],
471 [ [
'badaccess-groups' ] ]
481 $prefix = MediaWikiServices::getInstance()->getContentLanguage()->
483 $this->
setUser( $this->userName );
487 [ [
'badaccess-group0' ], [
'mycustomjsonprotected',
'bogus' ] ],
489 [ [
'badaccess-group0' ], [
'mycustomjsonprotected',
'bogus' ] ],
490 [ [
'badaccess-group0' ] ],
491 [ [
'badaccess-group0' ], [
'mycustomjsonprotected',
'bogus' ] ],
493 [ [
'badaccess-group0' ], [
'mycustomjsonprotected',
'bogus' ] ],
494 [ [
'badaccess-group0' ] ],
495 [ [
'badaccess-group0' ], [
'mycustomjsonprotected',
'bogus' ] ],
496 [ [
'badaccess-groups' ] ]
506 $this->
setUser( $this->userName );
510 [ [
'badaccess-group0' ], [
'mycustomcssprotected',
'bogus' ] ],
512 [ [
'badaccess-group0' ] ],
513 [ [
'badaccess-group0' ], [
'mycustomcssprotected',
'bogus' ] ],
514 [ [
'badaccess-group0' ], [
'mycustomcssprotected',
'bogus' ] ],
516 [ [
'badaccess-group0' ] ],
517 [ [
'badaccess-group0' ], [
'mycustomcssprotected',
'bogus' ] ],
518 [ [
'badaccess-group0' ], [
'mycustomcssprotected',
'bogus' ] ],
519 [ [
'badaccess-groups' ] ]
529 $this->
setUser( $this->userName );
533 [ [
'badaccess-group0' ], [
'customjsprotected',
'bogus' ] ],
535 [ [
'badaccess-group0' ], [
'customjsprotected',
'bogus' ] ],
536 [ [
'badaccess-group0' ], [
'customjsprotected',
'bogus' ] ],
537 [ [
'badaccess-group0' ], [
'customjsprotected',
'bogus' ] ],
539 [ [
'badaccess-group0' ], [
'customjsprotected',
'bogus' ] ],
540 [ [
'badaccess-group0' ], [
'customjsprotected',
'bogus' ] ],
541 [ [
'badaccess-group0' ] ],
542 [ [
'badaccess-groups' ] ]
552 $this->
setUser( $this->userName );
556 [ [
'badaccess-group0' ], [
'customjsonprotected',
'bogus' ] ],
558 [ [
'badaccess-group0' ], [
'customjsonprotected',
'bogus' ] ],
559 [ [
'badaccess-group0' ], [
'customjsonprotected',
'bogus' ] ],
560 [ [
'badaccess-group0' ], [
'customjsonprotected',
'bogus' ] ],
562 [ [
'badaccess-group0' ], [
'customjsonprotected',
'bogus' ] ],
563 [ [
'badaccess-group0' ] ],
564 [ [
'badaccess-group0' ], [
'customjsonprotected',
'bogus' ] ],
565 [ [
'badaccess-groups' ] ]
575 $this->
setUser( $this->userName );
579 [ [
'badaccess-group0' ], [
'customcssprotected',
'bogus' ] ],
581 [ [
'badaccess-group0' ], [
'customcssprotected',
'bogus' ] ],
582 [ [
'badaccess-group0' ], [
'customcssprotected',
'bogus' ] ],
583 [ [
'badaccess-group0' ], [
'customcssprotected',
'bogus' ] ],
585 [ [
'badaccess-group0' ] ],
586 [ [
'badaccess-group0' ], [
'customcssprotected',
'bogus' ] ],
587 [ [
'badaccess-group0' ], [
'customcssprotected',
'bogus' ] ],
588 [ [
'badaccess-groups' ] ]
598 $this->
setUser( $this->userName );
602 [ [
'badaccess-group0' ] ],
604 [ [
'badaccess-group0' ] ],
605 [ [
'badaccess-group0' ] ],
606 [ [
'badaccess-group0' ] ],
608 [ [
'badaccess-group0' ] ],
609 [ [
'badaccess-group0' ] ],
610 [ [
'badaccess-group0' ] ],
611 [ [
'badaccess-groups' ] ]
623 [ [
'badaccess-group0' ] ],
625 [ [
'badaccess-group0' ] ],
626 [ [
'badaccess-group0' ] ],
627 [ [
'badaccess-group0' ] ],
629 [ [
'badaccess-group0' ] ],
630 [ [
'badaccess-group0' ] ],
631 [ [
'badaccess-group0' ] ],
632 [ [
'badaccess-groups' ] ]
648 $this->assertEquals( $resultNone,
$result );
652 $this->assertEquals( $resultMyCss,
$result );
656 $this->assertEquals( $resultMyJson,
$result );
660 $this->assertEquals( $resultMyJs,
$result );
664 $this->assertEquals( $resultUserCss,
$result );
668 $this->assertEquals( $resultUserJson,
$result );
672 $this->assertEquals( $resultUserJs,
$result );
676 $this->assertEquals( reset( $resultPatrol[0] ), reset(
$result[0] ) );
678 $this->
setUserPerm( [
'edituserjs',
'edituserjson',
'editusercss' ] );
680 $this->assertEquals( [ [
'badaccess-group0' ] ],
$result );
693 $prefix = MediaWikiServices::getInstance()->getContentLanguage()->
697 $this->
title->mRestrictionsLoaded =
true;
699 $this->
title->mRestrictions = [
"bogus" => [
'bogus',
"sysop",
"protect",
"" ] ];
701 $this->assertEquals( [],
702 $this->
title->getUserPermissionsErrors(
'edit',
705 $this->assertEquals(
true,
706 $this->
title->quickUserCan(
'edit', $this->user ) );
707 $this->
title->mRestrictions = [
"edit" => [
'bogus',
"sysop",
"protect",
"" ],
708 "bogus" => [
'bogus',
"sysop",
"protect",
"" ] ];
710 $this->assertEquals( [ [
'badaccess-group0' ],
711 [
'protectedpagetext',
'bogus',
'bogus' ],
712 [
'protectedpagetext',
'editprotected',
'bogus' ],
713 [
'protectedpagetext',
'protect',
'bogus' ] ],
714 $this->
title->getUserPermissionsErrors(
'bogus',
716 $this->assertEquals( [ [
'protectedpagetext',
'bogus',
'edit' ],
717 [
'protectedpagetext',
'editprotected',
'edit' ],
718 [
'protectedpagetext',
'protect',
'edit' ] ],
719 $this->
title->getUserPermissionsErrors(
'edit',
722 $this->assertEquals( [ [
'badaccess-group0' ],
723 [
'protectedpagetext',
'bogus',
'bogus' ],
724 [
'protectedpagetext',
'editprotected',
'bogus' ],
725 [
'protectedpagetext',
'protect',
'bogus' ] ],
726 $this->
title->getUserPermissionsErrors(
'bogus',
728 $this->assertEquals( [ [
'badaccess-groups',
"*, [[$prefix:Users|Users]]", 2 ],
729 [
'protectedpagetext',
'bogus',
'edit' ],
730 [
'protectedpagetext',
'editprotected',
'edit' ],
731 [
'protectedpagetext',
'protect',
'edit' ] ],
732 $this->
title->getUserPermissionsErrors(
'edit',
735 $this->assertEquals( [ [
'badaccess-group0' ],
736 [
'protectedpagetext',
'bogus',
'bogus' ],
737 [
'protectedpagetext',
'protect',
'bogus' ] ],
738 $this->
title->getUserPermissionsErrors(
'bogus',
740 $this->assertEquals( [
741 [
'protectedpagetext',
'bogus',
'edit' ],
742 [
'protectedpagetext',
'protect',
'edit' ] ],
743 $this->
title->getUserPermissionsErrors(
'edit',
746 $this->
title->mCascadeRestriction =
true;
748 $this->assertEquals(
false,
749 $this->
title->quickUserCan(
'bogus', $this->user ) );
750 $this->assertEquals(
false,
751 $this->
title->quickUserCan(
'edit', $this->user ) );
752 $this->assertEquals( [ [
'badaccess-group0' ],
753 [
'protectedpagetext',
'bogus',
'bogus' ],
754 [
'protectedpagetext',
'editprotected',
'bogus' ],
755 [
'protectedpagetext',
'protect',
'bogus' ] ],
756 $this->
title->getUserPermissionsErrors(
'bogus',
758 $this->assertEquals( [ [
'protectedpagetext',
'bogus',
'edit' ],
759 [
'protectedpagetext',
'editprotected',
'edit' ],
760 [
'protectedpagetext',
'protect',
'edit' ] ],
761 $this->
title->getUserPermissionsErrors(
'edit',
765 $this->assertEquals(
false,
766 $this->
title->quickUserCan(
'bogus', $this->user ) );
767 $this->assertEquals(
false,
768 $this->
title->quickUserCan(
'edit', $this->user ) );
769 $this->assertEquals( [ [
'badaccess-group0' ],
770 [
'protectedpagetext',
'bogus',
'bogus' ],
771 [
'protectedpagetext',
'protect',
'bogus' ],
772 [
'protectedpagetext',
'protect',
'bogus' ] ],
773 $this->
title->getUserPermissionsErrors(
'bogus',
775 $this->assertEquals( [ [
'protectedpagetext',
'bogus',
'edit' ],
776 [
'protectedpagetext',
'protect',
'edit' ],
777 [
'protectedpagetext',
'protect',
'edit' ] ],
778 $this->
title->getUserPermissionsErrors(
'edit',
789 $this->
title->mCascadeSources = [
793 $this->
title->mCascadingRestrictions = [
794 "bogus" => [
'bogus',
"sysop",
"protect",
"" ]
797 $this->assertEquals(
false,
798 $this->
title->userCan(
'bogus', $this->user ) );
799 $this->assertEquals( [
800 [
"cascadeprotected", 2,
"* [[:Bogus]]\n* [[:UnBogus]]\n",
'bogus' ],
801 [
"cascadeprotected", 2,
"* [[:Bogus]]\n* [[:UnBogus]]\n",
'bogus' ],
802 [
"cascadeprotected", 2,
"* [[:Bogus]]\n* [[:UnBogus]]\n",
'bogus' ] ],
803 $this->
title->getUserPermissionsErrors(
'bogus', $this->user ) );
805 $this->assertEquals(
true,
806 $this->
title->userCan(
'edit', $this->user ) );
807 $this->assertEquals( [],
808 $this->
title->getUserPermissionsErrors(
'edit', $this->user ) );
819 $this->
title->mTitleProtection[
'permission'] =
'';
820 $this->
title->mTitleProtection[
'user'] = $this->
user->getId();
821 $this->
title->mTitleProtection[
'expiry'] =
'infinity';
822 $this->
title->mTitleProtection[
'reason'] =
'test';
823 $this->
title->mCascadeRestriction =
false;
825 $this->assertEquals( [ [
'titleprotected',
'Useruser',
'test' ] ],
826 $this->
title->getUserPermissionsErrors(
'create', $this->user ) );
827 $this->assertEquals(
false,
828 $this->
title->userCan(
'create', $this->user ) );
830 $this->
title->mTitleProtection[
'permission'] =
'editprotected';
832 $this->assertEquals( [ [
'titleprotected',
'Useruser',
'test' ] ],
833 $this->
title->getUserPermissionsErrors(
'create', $this->user ) );
834 $this->assertEquals(
false,
835 $this->
title->userCan(
'create', $this->user ) );
837 $this->
setUserPerm( [
'createpage',
'editprotected' ] );
838 $this->assertEquals( [],
839 $this->
title->getUserPermissionsErrors(
'create', $this->user ) );
840 $this->assertEquals(
true,
841 $this->
title->userCan(
'create', $this->user ) );
844 $this->assertEquals( [ [
'titleprotected',
'Useruser',
'test' ] ],
845 $this->
title->getUserPermissionsErrors(
'create', $this->user ) );
846 $this->assertEquals(
false,
847 $this->
title->userCan(
'create', $this->user ) );
851 $this->assertEquals(
false,
852 $this->
title->userCan(
'move', $this->user ) );
853 $this->assertEquals( [ [
'immobile-source-namespace',
'Media' ] ],
854 $this->
title->getUserPermissionsErrors(
'move', $this->user ) );
857 $this->assertEquals( [],
858 $this->
title->getUserPermissionsErrors(
'move', $this->user ) );
859 $this->assertEquals(
true,
860 $this->
title->userCan(
'move', $this->user ) );
862 $this->
title->mInterwiki =
"no";
863 $this->assertEquals( [ [
'immobile-source-page' ] ],
864 $this->
title->getUserPermissionsErrors(
'move', $this->user ) );
865 $this->assertEquals(
false,
866 $this->
title->userCan(
'move', $this->user ) );
869 $this->assertEquals(
false,
870 $this->
title->userCan(
'move-target', $this->user ) );
871 $this->assertEquals( [ [
'immobile-target-namespace',
'Media' ] ],
872 $this->
title->getUserPermissionsErrors(
'move-target', $this->user ) );
875 $this->assertEquals( [],
876 $this->
title->getUserPermissionsErrors(
'move-target', $this->user ) );
877 $this->assertEquals(
true,
878 $this->
title->userCan(
'move-target', $this->user ) );
880 $this->
title->mInterwiki =
"no";
881 $this->assertEquals( [ [
'immobile-target-page' ] ],
882 $this->
title->getUserPermissionsErrors(
'move-target', $this->user ) );
883 $this->assertEquals(
false,
884 $this->
title->userCan(
'move-target', $this->user ) );
892 'wgEmailConfirmToEdit' =>
true,
893 'wgEmailAuthentication' =>
true,
897 $this->
setUserPerm( [
'createpage',
'edit',
'move',
'rollback',
'patrol',
'upload',
'purge' ] );
900 # $wgEmailConfirmToEdit only applies to 'edit' action
901 $this->assertEquals( [],
902 $this->
title->getUserPermissionsErrors(
'move-target', $this->user ) );
903 $this->assertContains( [
'confirmedittext' ],
904 $this->
title->getUserPermissionsErrors(
'edit', $this->user ) );
909 $this->assertNotContains( [
'confirmedittext' ],
910 $this->
title->getUserPermissionsErrors(
'edit', $this->user ) );
912 # $wgEmailConfirmToEdit && !$user->isEmailConfirmed() && $action != 'createaccount'
913 $this->assertEquals( [],
914 $this->
title->getUserPermissionsErrors(
'move-target',
920 $this->
user->mBlockedby = $this->
user->getId();
922 'address' =>
'127.0.8.1',
923 'by' => $this->
user->getId(),
924 'reason' =>
'no reason given',
925 'timestamp' => $prev + 3600,
929 $this->
user->mBlock->setTimestamp( 0 );
930 $this->assertEquals( [ [
'autoblockedtext',
931 '[[User:Useruser|Useruser]]',
'no reason given',
'127.0.0.1',
932 'Useruser',
null,
'infinite',
'127.0.8.1',
934 $this->
title->getUserPermissionsErrors(
'move-target',
937 $this->assertEquals(
false, $this->
title->userCan(
'move-target', $this->user ) );
939 $this->assertEquals(
true, $this->
title->quickUserCan(
'move-target', $this->user ) );
943 $this->
user->mBlockedby = $this->
user->getName();
945 'address' =>
'127.0.8.1',
946 'by' => $this->
user->getId(),
947 'reason' =>
'no reason given',
952 $this->assertEquals( [ [
'blockedtext',
953 '[[User:Useruser|Useruser]]',
'no reason given',
'127.0.0.1',
954 'Useruser',
null,
'23:00, 31 December 1969',
'127.0.8.1',
956 $this->
title->getUserPermissionsErrors(
'move-target', $this->
user ) );
957 # $action != 'read' && $action != 'createaccount' && $user->isBlockedFrom( $this )
958 # $user->blockedFor() == ''
959 # $user->mBlock->mExpiry == 'infinity'
961 $this->
user->mBlockedby = $this->
user->getName();
963 'address' =>
'127.0.8.1',
964 'by' => $this->
user->getId(),
965 'reason' =>
'no reason given',
969 'systemBlock' =>
'test',
972 $errors = [ [
'systemblockedtext',
973 '[[User:Useruser|Useruser]]',
'no reason given',
'127.0.0.1',
974 'Useruser',
'test',
'23:00, 31 December 1969',
'127.0.8.1',
977 $this->assertEquals( $errors,
978 $this->
title->getUserPermissionsErrors(
'edit', $this->user ) );
979 $this->assertEquals( $errors,
980 $this->
title->getUserPermissionsErrors(
'move-target', $this->user ) );
981 $this->assertEquals( $errors,
982 $this->
title->getUserPermissionsErrors(
'rollback', $this->user ) );
983 $this->assertEquals( $errors,
984 $this->
title->getUserPermissionsErrors(
'patrol', $this->user ) );
985 $this->assertEquals( $errors,
986 $this->
title->getUserPermissionsErrors(
'upload', $this->user ) );
987 $this->assertEquals( [],
988 $this->
title->getUserPermissionsErrors(
'purge', $this->user ) );
991 $this->
user->mBlockedby = $this->
user->getName();
993 'address' =>
'127.0.8.1',
994 'by' => $this->
user->getId(),
995 'reason' =>
'no reason given',
1001 $this->assertEquals( [],
1002 $this->
title->getUserPermissionsErrors(
'edit', $this->user ) );
1003 $this->assertEquals( [],
1004 $this->
title->getUserPermissionsErrors(
'move-target', $this->user ) );
1005 $this->assertEquals( [],
1006 $this->
title->getUserPermissionsErrors(
'rollback', $this->user ) );
1007 $this->assertEquals( [],
1008 $this->
title->getUserPermissionsErrors(
'patrol', $this->user ) );
1009 $this->assertEquals( [],
1010 $this->
title->getUserPermissionsErrors(
'upload', $this->user ) );
1011 $this->assertEquals( [],
1012 $this->
title->getUserPermissionsErrors(
'purge', $this->user ) );
1014 $this->
user->mBlock->setRestrictions( [
1018 $errors = [ [
'blockedtext-partial',
1019 '[[User:Useruser|Useruser]]',
'no reason given',
'127.0.0.1',
1020 'Useruser',
null,
'23:00, 31 December 1969',
'127.0.8.1',
1023 $this->assertEquals( $errors,
1024 $this->
title->getUserPermissionsErrors(
'edit', $this->user ) );
1025 $this->assertEquals( $errors,
1026 $this->
title->getUserPermissionsErrors(
'move-target', $this->user ) );
1027 $this->assertEquals( $errors,
1028 $this->
title->getUserPermissionsErrors(
'rollback', $this->user ) );
1029 $this->assertEquals( $errors,
1030 $this->
title->getUserPermissionsErrors(
'patrol', $this->user ) );
1031 $this->assertEquals( [],
1032 $this->
title->getUserPermissionsErrors(
'upload', $this->user ) );
1033 $this->assertEquals( [],
1034 $this->
title->getUserPermissionsErrors(
'purge', $this->user ) );
1037 $this->
user->mBlockedby =
null;
1038 $this->
user->mBlock =
null;
1040 $this->assertEquals( [],
1041 $this->
title->getUserPermissionsErrors(
'edit', $this->user ) );
1054 ->disableOriginalConstructor()
1056 $tester->method(
'getName' )
1057 ->willReturn(
'tester' );
1058 $tester->method(
'getRestriction' )
1059 ->willReturn(
'test' );
1060 $tester->method(
'requiresUnblock' )
1061 ->willReturn(
false );
1065 'tester' => $tester,
1067 'wgGroupPermissions' => [
1075 $this->
user->mBlockedby = $this->
user->getName();
1077 'address' =>
'127.0.8.1',
1078 'by' => $this->
user->getId(),
1079 'reason' =>
'no reason given',
1080 'timestamp' => $now,
1082 'expiry' =>
'infinity',
1085 $errors = [ [
'blockedtext',
1086 '[[User:Useruser|Useruser]]',
'no reason given',
'127.0.0.1',
1087 'Useruser',
null,
'infinite',
'127.0.8.1',
1090 $this->assertEquals( $errors,
1091 $this->
title->getUserPermissionsErrors(
'tester', $this->user ) );