Debian Codegraph @

tests/phpunit/includes/editpage/EditPageConstraintsTest.php

raw symbols SCIP
1 <?php
2
3 use MediaWiki\Content\ContentHandler;
4 use MediaWiki\Content\TextContent;
5 use MediaWiki\Context\RequestContext;
6 use MediaWiki\EditPage\EditPage;
7 use MediaWiki\EditPage\SpamChecker;
8 use MediaWiki\MainConfigNames;
9 use MediaWiki\Permissions\PermissionManager;
10 use MediaWiki\Request\FauxRequest;
11 use MediaWiki\Tests\User\TempUser\TempUserTestTrait;
12 use MediaWiki\Title\Title;
13 use MediaWiki\User\User;
14 use Wikimedia\Rdbms\ReadOnlyMode;
15
16 /**
17 * Integration tests for the various edit constraints, ensuring
18 * that they result in failures as expected
19 *
20 * @covers \MediaWiki\EditPage\EditPage::internalAttemptSave
21 * @covers \MediaWiki\EditPage\EditPage::internalAttemptSavePrivate
22 *
23 * @group Editing
24 * @group Database
25 * @group medium
26 */
27 class EditPageConstraintsTest extends MediaWikiLangTestCase {
28
29 use TempUserTestTrait;
30
31 protected function setUp(): void {
32 parent::setUp();
33
34 $contLang = $this->getServiceContainer()->getContentLanguage();
35 $this->overrideConfigValues( [
36 MainConfigNames::ExtraNamespaces => [
37 12312 => 'Dummy',
38 12313 => 'Dummy_talk',
39 ],
40 MainConfigNames::NamespaceContentModels => [ 12312 => 'testing' ],
41 MainConfigNames::LanguageCode => $contLang->getCode(),
42 ] );
43 $this->mergeMwGlobalArrayValue(
44 'wgContentHandlers',
45 [ 'testing' => 'DummyContentHandlerForTesting' ]
46 );
47 }
48
49 /**
50 * Based on method in EditPageTest
51 * Performs an edit and checks the result matches the expected failure code
52 *
53 * @param string|Title $title The title of the page to edit
54 * @param string|null $baseText Some text to create the page with before attempting the edit.
55 * @param User|null $user The user to perform the edit as.
56 * @param array $edit An array of request parameters used to define the edit to perform.
57 * Some well known fields are:
58 * * wpTextbox1: the text to submit
59 * * wpSummary: the edit summary
60 * * wpEditToken: the edit token (will be inserted if not provided)
61 * * wpEdittime: timestamp of the edit's base revision (will be inserted
62 * if not provided)
63 * * editRevId: revision ID of the edit's base revision (optional)
64 * * wpStarttime: timestamp when the edit started (will be inserted if not provided)
65 * * wpSectionTitle: the section to edit
66 * * wpMinorEdit: mark as minor edit
67 * * wpWatchthis: whether to watch the page
68 * @param int $expectedCode The expected result code (EditPage::AS_XXX constants).
69 * @param string $message Message to show along with any error message.
70 *
71 * @return WikiPage The page that was just edited, useful for getting the edit's rev_id, etc.
72 */
73 protected function assertEdit(
74 $title,
75 $baseText,
76 ?User $user,
77 array $edit,
78 $expectedCode,
79 $message
80 ) {
81 if ( is_string( $title ) ) {
82 $ns = $this->getDefaultWikitextNS();
83 $title = Title::newFromText( $title, $ns );
84 }
85 $this->assertNotNull( $title );
86
87 $wikiPageFactory = $this->getServiceContainer()->getWikiPageFactory();
88 $page = $wikiPageFactory->newFromTitle( $title );
89
90 $user ??= $this->getTestUser()->getUser();
91
92 if ( $baseText !== null ) {
93 $content = ContentHandler::makeContent( $baseText, $title );
94 $page->doUserEditContent( $content, $user, "base text for test" );
95
96 // Set the latest timestamp back a while
97 $dbw = $this->getDb();
98 $dbw->newUpdateQueryBuilder()
99 ->update( 'revision' )
100 ->set( [ 'rev_timestamp' => $dbw->timestamp( '20120101000000' ) ] )
101 ->where( [ 'rev_id' => $page->getLatest() ] )
102 ->execute();
103 $page->clear();
104
105 $content = $page->getContent();
106 $this->assertInstanceOf( TextContent::class, $content );
107 $currentText = $content->getText();
108
109 # EditPage rtrim() the user input, so we alter our expected text
110 # to reflect that.
111 $this->assertEquals(
112 rtrim( $baseText ),
113 rtrim( $currentText ),
114 'page should have the text specified'
115 );
116 }
117
118 if ( !isset( $edit['wpEditToken'] ) ) {
119 $edit['wpEditToken'] = $user->getEditToken();
120 }
121
122 if ( !isset( $edit['wpEdittime'] ) && !isset( $edit['editRevId'] ) ) {
123 $edit['wpEdittime'] = $page->exists() ? $page->getTimestamp() : '';
124 }
125
126 if ( !isset( $edit['wpStarttime'] ) ) {
127 $edit['wpStarttime'] = wfTimestampNow();
128 }
129
130 if ( !isset( $edit['wpUnicodeCheck'] ) ) {
131 $edit['wpUnicodeCheck'] = EditPage::UNICODE_CHECK;
132 }
133
134 $req = new FauxRequest( $edit, true ); // session ??
135
136 $context = new RequestContext();
137 $context->setRequest( $req );
138 $context->setTitle( $title );
139 $context->setUser( $user );
140 $article = new Article( $title );
141 $article->setContext( $context );
142 $ep = new EditPage( $article );
143 $ep->setContextTitle( $title );
144 $ep->importFormData( $req );
145
146 // this is where the edit happens!
147 $status = $ep->attemptSave( $result );
148
149 // check edit code
150 $this->assertSame(
151 $expectedCode,
152 $status->value,
153 "Expected result code mismatch. $message"
154 );
155
156 return $wikiPageFactory->newFromTitle( $title );
157 }
158
159 /** AccidentalRecreationConstraint integration */
160 public function testAccidentalRecreationConstraint() {
161 // Make sure it exists
162 $this->getExistingTestPage( 'AccidentalRecreationConstraintPage' );
163
164 // And now delete it, so that there is a deletion log
165 $page = $this->getNonexistingTestPage( 'AccidentalRecreationConstraintPage' );
166 $title = $page->getTitle();
167
168 // Set the time of the deletion to be a specific time, so we can be sure to start the
169 // edit before it. Since the constraint will query for the most recent timestamp,
170 // update *all* deletion logs for the page to the same timestamp (1 January 2020)
171 $dbw = $this->getDb();
172 $dbw->newUpdateQueryBuilder()
173 ->update( 'logging' )
174 ->set( [ 'log_timestamp' => $dbw->timestamp( '20200101000000' ) ] )
175 ->where( [
176 'log_namespace' => $title->getNamespace(),
177 'log_title' => $title->getDBkey(),
178 'log_type' => 'delete',
179 'log_action' => 'delete',
180 ] )
181 ->caller( __METHOD__ )->execute();
182
183 $user = $this->getTestUser()->getUser();
184
185 $permissionManager = $this->getServiceContainer()->getPermissionManager();
186 // Needs edit rights to pass EditRightConstraint and reach AccidentalRecreationConstraint
187 $permissionManager->overrideUserRightsForTesting( $user, [ 'edit' ] );
188
189 // Started the edit on 1 January 2019, page was deleted on 1 January 2020
190 $edit = [
191 'wpTextbox1' => 'New content',
192 'wpStarttime' => '20190101000000'
193 ];
194 $this->assertEdit(
195 $title,
196 null,
197 $user,
198 $edit,
199 EditPage::AS_ARTICLE_WAS_DELETED,
200 'expected AS_ARTICLE_WAS_DELETED update'
201 );
202 }
203
204 /** ExistingSectionEditConstraint integration */
205 public function testExistingSectionEditConstraint() {
206 // Require the summary
207 $this->mergeMwGlobalArrayValue(
208 'wgDefaultUserOptions',
209 [ 'forceeditsummary' => 1 ]
210 );
211
212 $page = $this->getExistingTestPage( 'ExistingSectionEditConstraint page does exist' );
213 $title = $page->getTitle();
214
215 $user = $this->getTestUser()->getUser();
216
217 $permissionManager = $this->getServiceContainer()->getPermissionManager();
218 // Needs edit rights to pass EditRightConstraint and reach NewSectionMissingSubjectConstraint
219 $permissionManager->overrideUserRightsForTesting( $user, [ 'edit' ] );
220
221 $edit = [
222 'wpTextbox1' => 'New content, different from base content',
223 'wpSummary' => 'SameAsAutoSummary',
224 'wpAutoSummary' => md5( 'SameAsAutoSummary' )
225 ];
226 $this->assertEdit(
227 $title,
228 'Base content, different from new content',
229 $user,
230 $edit,
231 EditPage::AS_SUMMARY_NEEDED,
232 'expected AS_SUMMARY_NEEDED update'
233 );
234 }
235
236 /** ChangeTagsConstraint integration */
237 public function testChangeTagsConstraint() {
238 // Remove rights
239 $this->mergeMwGlobalArrayValue(
240 'wgRevokePermissions',
241 [ 'user' => [ 'applychangetags' => true ] ]
242 );
243 $edit = [
244 'wpTextbox1' => 'Text',
245 'wpChangeTags' => 'tag-name'
246 ];
247 $this->assertEdit(
248 'EditPageTest_changeTagsConstraint',
249 null,
250 null,
251 $edit,
252 EditPage::AS_CHANGE_TAG_ERROR,
253 'expected AS_CHANGE_TAG_ERROR update'
254 );
255 }
256
257 /** ContentModelChangeConstraint integration */
258 public function testContentModelChangeConstraint() {
259 $user = $this->getTestUser()->getUser();
260 $permissionManager = $this->getServiceContainer()->getPermissionManager();
261 // Needs edit rights to pass EditRightConstraint and reach ContentModelChangeConstraint
262 $permissionManager->overrideUserRightsForTesting( $user, [ 'edit' ] );
263
264 $edit = [
265 'wpTextbox1' => 'New text goes here',
266 'wpSummary' => 'Summary',
267 'model' => CONTENT_MODEL_TEXT,
268 'format' => CONTENT_FORMAT_TEXT,
269 ];
270
271 $title = Title::makeTitle( NS_MAIN, 'Example' );
272 $this->assertSame(
273 CONTENT_MODEL_WIKITEXT,
274 $title->getContentModel(),
275 'title should start as wikitext content model'
276 );
277
278 $this->assertEdit(
279 $title,
280 'Base text',
281 $user,
282 $edit,
283 EditPage::AS_NO_CHANGE_CONTENT_MODEL,
284 'expected AS_NO_CHANGE_CONTENT_MODEL update'
285 );
286 }
287
288 /** CreationPermissionConstraint integration */
289 public function testCreationPermissionConstraint() {
290 $page = $this->getNonexistingTestPage( 'CreationPermissionConstraint page does not exist' );
291 $title = $page->getTitle();
292
293 $user = $this->getTestUser()->getUser();
294 $permissionManager = $this->getServiceContainer()->getPermissionManager();
295 // Needs edit rights to pass EditRightConstraint and reach CreationPermissionConstraint
296 $permissionManager->overrideUserRightsForTesting( $user, [ 'edit' ] );
297
298 $edit = [
299 'wpTextbox1' => 'Page content',
300 'wpSummary' => 'Summary'
301 ];
302 $this->assertEdit(
303 $title,
304 null,
305 $user,
306 $edit,
307 EditPage::AS_NO_CREATE_PERMISSION,
308 'expected AS_NO_CREATE_PERMISSION creation'
309 );
310 }
311
312 /** DefaultTextConstraint integration */
313 public function testDefaultTextConstraint() {
314 $page = $this->getNonexistingTestPage( 'DefaultTextConstraint page does not exist' );
315 $title = $page->getTitle();
316
317 $user = $this->getTestUser()->getUser();
318 $permissionManager = $this->getServiceContainer()->getPermissionManager();
319 // Needs edit and createpage rights to pass EditRightConstraint and CreationPermissionConstraint
320 $permissionManager->overrideUserRightsForTesting( $user, [ 'edit', 'createpage' ] );
321
322 $edit = [
323 'wpTextbox1' => '',
324 'wpSummary' => 'Summary'
325 ];
326 $this->assertEdit(
327 $title,
328 null,
329 $user,
330 $edit,
331 EditPage::AS_BLANK_ARTICLE,
332 'expected AS_BLANK_ARTICLE creation'
333 );
334 }
335
336 /**
337 * EditFilterMergedContentHookConstraint integration
338 * @dataProvider provideTestEditFilterMergedContentHookConstraint
339 * @param bool $hookReturn
340 * @param ?int $statusValue
341 * @param bool $statusFatal
342 * @param int $expectedFailure
343 * @param string $expectedFailureStr
344 */
345 public function testEditFilterMergedContentHookConstraint(
346 bool $hookReturn,
347 $statusValue,
348 bool $statusFatal,
349 int $expectedFailure,
350 string $expectedFailureStr
351 ) {
352 $this->setTemporaryHook(
353 'EditFilterMergedContent',
354 static function ( $context, $content, $status, $summary, $user, $minorEdit )
355 use ( $hookReturn, $statusValue, $statusFatal )
356 {
357 if ( $statusValue !== null ) {
358 $status->value = $statusValue;
359 }
360 if ( $statusFatal ) {
361 $status->fatal( 'SomeErrorInTheHook' );
362 }
363 return $hookReturn;
364 }
365 );
366
367 $user = $this->getTestUser()->getUser();
368 $permissionManager = $this->getServiceContainer()->getPermissionManager();
369 // Needs edit and createpage rights to pass EditRightConstraint and CreationPermissionConstraint
370 $permissionManager->overrideUserRightsForTesting( $user, [ 'edit', 'createpage' ] );
371
372 $edit = [
373 'wpTextbox1' => 'Text',
374 'wpSummary' => 'Summary'
375 ];
376 $this->assertEdit(
377 'EditPageTest_testEditFilterMergedContentHookConstraint',
378 null,
379 $user,
380 $edit,
381 $expectedFailure,
382 "expected $expectedFailureStr creation"
383 );
384 }
385
386 public static function provideTestEditFilterMergedContentHookConstraint() {
387 yield 'Hook returns false, status is good, no value set' => [
388 false, null, false, EditPage::AS_HOOK_ERROR_EXPECTED, 'AS_HOOK_ERROR_EXPECTED'
389 ];
390 yield 'Hook returns false, status is good, value set' => [
391 false, 1234567, false, 1234567, 'custom value 1234567'
392 ];
393 yield 'Hook returns false, status is not good' => [
394 false, null, true, EditPage::AS_HOOK_ERROR_EXPECTED, 'AS_HOOK_ERROR_EXPECTED'
395 ];
396 yield 'Hook returns true, status is not ok' => [
397 true, null, true, EditPage::AS_HOOK_ERROR_EXPECTED, 'AS_HOOK_ERROR_EXPECTED'
398 ];
399 }
400
401 /**
402 * EditRightConstraint integration
403 * @dataProvider provideTestEditRightConstraint
404 * @param bool $anon
405 * @param int $expectedErrorCode
406 */
407 public function testEditRightConstraint( $anon, $expectedErrorCode ) {
408 if ( $anon ) {
409 $this->disableAutoCreateTempUser();
410 $user = $this->getServiceContainer()->getUserFactory()->newAnonymous( '127.0.0.1' );
411 } else {
412 $user = $this->getTestUser()->getUser();
413 }
414 $permissionManager = $this->getServiceContainer()->getPermissionManager();
415 $permissionManager->overrideUserRightsForTesting( $user, [] );
416
417 $edit = [
418 'wpTextbox1' => 'Page content',
419 'wpSummary' => 'Summary'
420 ];
421 $this->assertEdit(
422 'EditPageTest_noEditRight',
423 'base text',
424 $user,
425 $edit,
426 $expectedErrorCode,
427 'expected AS_READ_ONLY_PAGE_* update'
428 );
429 }
430
431 public static function provideTestEditRightConstraint() {
432 yield 'Anonymous user' => [ true, EditPage::AS_READ_ONLY_PAGE_ANON ];
433 yield 'Registered user' => [ false, EditPage::AS_READ_ONLY_PAGE_LOGGED ];
434 }
435
436 /**
437 * ImageRedirectConstraint integration
438 * @dataProvider provideTestImageRedirectConstraint
439 * @param bool $anon
440 * @param int $expectedErrorCode
441 */
442 public function testImageRedirectConstraint( $anon, $expectedErrorCode ) {
443 if ( $anon ) {
444 $this->disableAutoCreateTempUser();
445 $user = $this->getServiceContainer()->getUserFactory()->newAnonymous( '127.0.0.1' );
446 } else {
447 $user = $this->getTestUser()->getUser();
448 }
449
450 $permissionManager = $this->getServiceContainer()->getPermissionManager();
451 // Needs edit rights to pass EditRightConstraint and reach ImageRedirectConstraint
452 $permissionManager->overrideUserRightsForTesting( $user, [ 'edit' ] );
453
454 $edit = [
455 'wpTextbox1' => '#REDIRECT [[File:Example other file.jpg]]',
456 'wpSummary' => 'Summary'
457 ];
458
459 $title = Title::makeTitle( NS_FILE, 'Example.jpg' );
460 $this->assertEdit(
461 $title,
462 null,
463 $user,
464 $edit,
465 $expectedErrorCode,
466 'expected AS_IMAGE_REDIRECT_* update'
467 );
468 }
469
470 public static function provideTestImageRedirectConstraint() {
471 yield 'Anonymous user' => [ true, EditPage::AS_IMAGE_REDIRECT_ANON ];
472 yield 'Registered user' => [ false, EditPage::AS_IMAGE_REDIRECT_LOGGED ];
473 }
474
475 /** MissingCommentConstraint integration */
476 public function testMissingCommentConstraint() {
477 $page = $this->getExistingTestPage( 'MissingCommentConstraint page does exist' );
478 $title = $page->getTitle();
479
480 $user = $this->getTestUser()->getUser();
481
482 $permissionManager = $this->getServiceContainer()->getPermissionManager();
483 // Needs edit rights to pass EditRightConstraint and reach MissingCommentConstraint
484 $permissionManager->overrideUserRightsForTesting( $user, [ 'edit' ] );
485
486 $edit = [
487 'wpTextbox1' => '',
488 'wpSection' => 'new',
489 'wpSummary' => 'Summary'
490 ];
491 $this->assertEdit(
492 $title,
493 null,
494 $user,
495 $edit,
496 EditPage::AS_TEXTBOX_EMPTY,
497 'expected AS_TEXTBOX_EMPTY update'
498 );
499 }
500
501 /** NewSectionMissingSubjectConstraint integration */
502 public function testNewSectionMissingSubjectConstraint() {
503 // Require the summary
504 $this->mergeMwGlobalArrayValue(
505 'wgDefaultUserOptions',
506 [ 'forceeditsummary' => 1 ]
507 );
508
509 $page = $this->getExistingTestPage( 'NewSectionMissingSubjectConstraint page does exist' );
510 $title = $page->getTitle();
511
512 $user = $this->getTestUser()->getUser();
513
514 $permissionManager = $this->getServiceContainer()->getPermissionManager();
515 // Needs edit rights to pass EditRightConstraint and reach NewSectionMissingSubjectConstraint
516 $permissionManager->overrideUserRightsForTesting( $user, [ 'edit' ] );
517
518 $edit = [
519 'wpTextbox1' => 'Comment',
520 'wpSection' => 'new',
521 'wpSummary' => ''
522 ];
523 $this->assertEdit(
524 $title,
525 null,
526 $user,
527 $edit,
528 EditPage::AS_SUMMARY_NEEDED,
529 'expected AS_SUMMARY_NEEDED update'
530 );
531 }
532
533 /** PageSizeConstraint integration */
534 public function testPageSizeConstraintBeforeMerge() {
535 // Max size: 1 kibibyte
536 $this->overrideConfigValue( MainConfigNames::MaxArticleSize, 1 );
537
538 $edit = [
539 'wpTextbox1' => str_repeat( 'text', 1000 )
540 ];
541 $this->assertEdit(
542 'EditPageTest_pageSizeConstraintBeforeMerge',
543 null,
544 null,
545 $edit,
546 EditPage::AS_CONTENT_TOO_BIG,
547 'expected AS_CONTENT_TOO_BIG update'
548 );
549 }
550
551 /** PageSizeConstraint integration */
552 public function testPageSizeConstraintAfterMerge() {
553 // Max size: 1 kibibyte
554 $this->overrideConfigValue( MainConfigNames::MaxArticleSize, 1 );
555
556 $edit = [
557 'wpSection' => 'new',
558 'wpTextbox1' => str_repeat( 'b', 600 )
559 ];
560 $this->assertEdit(
561 'EditPageTest_pageSizeConstraintAfterMerge',
562 str_repeat( 'a', 600 ),
563 null,
564 $edit,
565 EditPage::AS_MAX_ARTICLE_SIZE_EXCEEDED,
566 'expected AS_MAX_ARTICLE_SIZE_EXCEEDED update'
567 );
568 }
569
570 /** ReadOnlyConstraint integration */
571 public function testReadOnlyConstraint() {
572 $readOnlyMode = $this->createMock( ReadOnlyMode::class );
573 $readOnlyMode->method( 'isReadOnly' )->willReturn( true );
574 $this->setService( 'ReadOnlyMode', $readOnlyMode );
575
576 $edit = [
577 'wpTextbox1' => 'Text goes here'
578 ];
579 $this->assertEdit(
580 'EditPageTest_readOnlyConstraint',
581 null,
582 null,
583 $edit,
584 EditPage::AS_READ_ONLY_PAGE,
585 'expected AS_READ_ONLY_PAGE update'
586 );
587 }
588
589 /** SelfRedirectConstraint integration */
590 public function testSelfRedirectConstraint() {
591 // Use a page that does not exist to be sure that it is not already a self redirect
592 $page = $this->getNonexistingTestPage( 'SelfRedirectConstraint page does not exist' );
593 $title = $page->getTitle();
594
595 $edit = [
596 'wpTextbox1' => '#REDIRECT [[SelfRedirectConstraint page does not exist]]',
597 'wpSummary' => 'Redirect to self'
598 ];
599 $this->assertEdit(
600 $title,
601 'zero',
602 null,
603 $edit,
604 EditPage::AS_SELF_REDIRECT,
605 'expected AS_SELF_REDIRECT update'
606 );
607 }
608
609 /** SimpleAntiSpamConstraint integration */
610 public function testSimpleAntiSpamConstraint() {
611 $edit = [
612 'wpTextbox1' => 'one',
613 'wpSummary' => 'first update',
614 'wpAntispam' => 'tatata'
615 ];
616 $this->assertEdit(
617 'EditPageTest_testUpdatePageSpamError',
618 'zero',
619 null,
620 $edit,
621 EditPage::AS_SPAM_ERROR,
622 'expected AS_SPAM_ERROR update'
623 );
624 }
625
626 /** SpamRegexConstraint integration */
627 public function testSpamRegexConstraint() {
628 $spamChecker = $this->createMock( SpamChecker::class );
629 $spamChecker->method( 'checkContent' )
630 ->willReturnArgument( 0 );
631 $spamChecker->method( 'checkSummary' )
632 ->willReturnArgument( 0 );
633 $this->setService( 'SpamChecker', $spamChecker );
634
635 $edit = [
636 'wpTextbox1' => 'two',
637 'wpSummary' => 'spam summary'
638 ];
639 $this->assertEdit(
640 'EditPageTest_testUpdatePageSpamRegexError',
641 'zero',
642 null,
643 $edit,
644 EditPage::AS_SPAM_ERROR,
645 'expected AS_SPAM_ERROR update'
646 );
647 }
648
649 /** UserBlockConstraint integration */
650 public function testUserBlockConstraint() {
651 $user = $this->createMock( User::class );
652 $user->method( 'getName' )->willReturn( 'NameGoesHere' );
653 $user->method( 'getId' )->willReturn( 12345 );
654
655 $permissionManager = $this->createMock( PermissionManager::class );
656 // Needs edit rights to pass EditRightConstraint and reach UserBlockConstraint
657 $permissionManager->method( 'userHasRight' )->willReturn( true );
658 $permissionManager->method( 'userCan' )->willReturn( true );
659
660 // Not worried about the specifics of the method call, those are tested in
661 // the UserBlockConstraintTest
662 $permissionManager->method( 'isBlockedFrom' )->willReturn( true );
663
664 $this->setService( 'PermissionManager', $permissionManager );
665
666 $edit = [
667 'wpTextbox1' => 'Page content',
668 'wpSummary' => 'Summary'
669 ];
670 $this->assertEdit(
671 'EditPageTest_userBlocked',
672 'base text',
673 null,
674 $edit,
675 EditPage::AS_BLOCKED_PAGE_FOR_USER,
676 'expected AS_BLOCKED_PAGE_FOR_USER update'
677 );
678 }
679
680 /** UserRateLimitConstraint integration */
681 public function testUserRateLimitConstraint() {
682 $this->setTemporaryHook(
683 'PingLimiter',
684 static function ( $user, $action, &$result, $incrBy ) {
685 // Always fail
686 $result = true;
687 return false;
688 }
689 );
690
691 $edit = [
692 'wpTextbox1' => 'Text goes here'
693 ];
694 $this->assertEdit(
695 'EditPageTest_userRateLimitConstraint',
696 null,
697 null,
698 $edit,
699 EditPage::AS_RATE_LIMITED,
700 'expected AS_RATE_LIMITED update'
701 );
702 }
703
704 }