Merge "Update jQuery from v3.2.1 to v3.3.1"
[lhc/web/wiklou.git] / tests / phpunit / includes / Storage / PageUpdaterTest.php
1 <?php
2
3 namespace MediaWiki\Tests\Storage;
4
5 use CommentStoreComment;
6 use Content;
7 use MediaWiki\MediaWikiServices;
8 use MediaWiki\Storage\RevisionRecord;
9 use MediaWikiTestCase;
10 use ParserOptions;
11 use RecentChange;
12 use Revision;
13 use TextContent;
14 use Title;
15 use WikiPage;
16
17 /**
18 * @covers \MediaWiki\Storage\PageUpdater
19 * @group Database
20 */
21 class PageUpdaterTest extends MediaWikiTestCase {
22 private function getDummyTitle( $method ) {
23 return Title::newFromText( $method, $this->getDefaultWikitextNS() );
24 }
25
26 /**
27 * @param int $revId
28 *
29 * @return null|RecentChange
30 */
31 private function getRecentChangeFor( $revId ) {
32 $qi = RecentChange::getQueryInfo();
33 $row = $this->db->selectRow(
34 $qi['tables'],
35 $qi['fields'],
36 [ 'rc_this_oldid' => $revId ],
37 __METHOD__,
38 [],
39 $qi['joins']
40 );
41
42 return $row ? RecentChange::newFromRow( $row ) : null;
43 }
44
45 // TODO: test setAjaxEditStash();
46
47 /**
48 * @covers \MediaWiki\Storage\PageUpdater::saveRevision()
49 * @covers \WikiPage::newPageUpdater()
50 */
51 public function testCreatePage() {
52 $user = $this->getTestUser()->getUser();
53
54 $title = $this->getDummyTitle( __METHOD__ );
55 $page = WikiPage::factory( $title );
56 $updater = $page->newPageUpdater( $user );
57
58 $oldStats = $this->db->selectRow( 'site_stats', '*', '1=1' );
59
60 $this->assertFalse( $updater->wasCommitted(), 'wasCommitted' );
61 $this->assertFalse( $updater->getOriginalRevisionId(), 'getOriginalRevisionId' );
62 $this->assertSame( 0, $updater->getUndidRevisionId(), 'getUndidRevisionId' );
63
64 $updater->addTag( 'foo' );
65 $updater->addTags( [ 'bar', 'qux' ] );
66
67 $tags = $updater->getExplicitTags();
68 sort( $tags );
69 $this->assertSame( [ 'bar', 'foo', 'qux' ], $tags, 'getExplicitTags' );
70
71 // TODO: MCR: test additional slots
72 $content = new TextContent( 'Lorem Ipsum' );
73 $updater->setContent( 'main', $content );
74
75 $parent = $updater->grabParentRevision();
76
77 $this->assertNull( $parent, 'getParentRevision' );
78 $this->assertFalse( $updater->wasCommitted(), 'wasCommitted' );
79
80 // TODO: test that hasEditConflict() grabs the parent revision
81 $this->assertFalse( $updater->hasEditConflict( 0 ), 'hasEditConflict' );
82 $this->assertTrue( $updater->hasEditConflict( 1 ), 'hasEditConflict' );
83
84 // TODO: test failure with EDIT_UPDATE
85 // TODO: test EDIT_MINOR, EDIT_BOT, etc
86 $summary = CommentStoreComment::newUnsavedComment( 'Just a test' );
87 $rev = $updater->saveRevision( $summary );
88
89 $this->assertNotNull( $rev );
90 $this->assertSame( 0, $rev->getParentId() );
91 $this->assertSame( $summary->text, $rev->getComment( RevisionRecord::RAW )->text );
92 $this->assertSame( $user->getName(), $rev->getUser( RevisionRecord::RAW )->getName() );
93
94 $this->assertTrue( $updater->wasCommitted(), 'wasCommitted()' );
95 $this->assertTrue( $updater->wasSuccessful(), 'wasSuccessful()' );
96 $this->assertTrue( $updater->getStatus()->isOK(), 'getStatus()->isOK()' );
97 $this->assertTrue( $updater->isNew(), 'isNew()' );
98 $this->assertFalse( $updater->isUnchanged(), 'isUnchanged()' );
99 $this->assertNotNull( $updater->getNewRevision(), 'getNewRevision()' );
100 $this->assertInstanceOf( Revision::class, $updater->getStatus()->value['revision'] );
101
102 $rev = $updater->getNewRevision();
103 $revContent = $rev->getContent( 'main' );
104 $this->assertSame( 'Lorem Ipsum', $revContent->serialize(), 'revision content' );
105
106 // were the WikiPage and Title objects updated?
107 $this->assertTrue( $page->exists(), 'WikiPage::exists()' );
108 $this->assertTrue( $title->exists(), 'Title::exists()' );
109 $this->assertSame( $rev->getId(), $page->getLatest(), 'WikiPage::getRevision()' );
110 $this->assertNotNull( $page->getRevision(), 'WikiPage::getRevision()' );
111
112 // re-load
113 $page2 = WikiPage::factory( $title );
114 $this->assertTrue( $page2->exists(), 'WikiPage::exists()' );
115 $this->assertSame( $rev->getId(), $page2->getLatest(), 'WikiPage::getRevision()' );
116 $this->assertNotNull( $page2->getRevision(), 'WikiPage::getRevision()' );
117
118 // Check RC entry
119 $rc = $this->getRecentChangeFor( $rev->getId() );
120 $this->assertNotNull( $rc, 'RecentChange' );
121
122 // check site stats - this asserts that derived data updates where run.
123 $stats = $this->db->selectRow( 'site_stats', '*', '1=1' );
124 $this->assertSame( $oldStats->ss_total_pages + 1, (int)$stats->ss_total_pages );
125 $this->assertSame( $oldStats->ss_total_edits + 1, (int)$stats->ss_total_edits );
126
127 // re-edit with same content - should be a "null-edit"
128 $updater = $page->newPageUpdater( $user );
129 $updater->setContent( 'main', $content );
130
131 $summary = CommentStoreComment::newUnsavedComment( 'to to re-edit' );
132 $rev = $updater->saveRevision( $summary );
133 $status = $updater->getStatus();
134
135 $this->assertNull( $rev, 'getNewRevision()' );
136 $this->assertNull( $updater->getNewRevision(), 'getNewRevision()' );
137 $this->assertTrue( $updater->isUnchanged(), 'isUnchanged' );
138 $this->assertTrue( $updater->wasSuccessful(), 'wasSuccessful()' );
139 $this->assertTrue( $status->isOK(), 'getStatus()->isOK()' );
140 $this->assertTrue( $status->hasMessage( 'edit-no-change' ), 'edit-no-change' );
141 }
142
143 /**
144 * @covers \MediaWiki\Storage\PageUpdater::saveRevision()
145 * @covers \WikiPage::newPageUpdater()
146 */
147 public function testUpdatePage() {
148 $user = $this->getTestUser()->getUser();
149
150 $title = $this->getDummyTitle( __METHOD__ );
151 $this->insertPage( $title );
152
153 $page = WikiPage::factory( $title );
154 $parentId = $page->getLatest();
155
156 $updater = $page->newPageUpdater( $user );
157
158 $oldStats = $this->db->selectRow( 'site_stats', '*', '1=1' );
159
160 $updater->setOriginalRevisionId( 7 );
161 $this->assertSame( 7, $updater->getOriginalRevisionId(), 'getOriginalRevisionId' );
162
163 $this->assertFalse( $updater->hasEditConflict( $parentId ), 'hasEditConflict' );
164 $this->assertTrue( $updater->hasEditConflict( $parentId - 1 ), 'hasEditConflict' );
165 $this->assertTrue( $updater->hasEditConflict( 0 ), 'hasEditConflict' );
166
167 // TODO: MCR: test additional slots
168 $updater->setContent( 'main', new TextContent( 'Lorem Ipsum' ) );
169
170 // TODO: test all flags for saveRevision()!
171 $summary = CommentStoreComment::newUnsavedComment( 'Just a test' );
172 $rev = $updater->saveRevision( $summary );
173
174 $this->assertNotNull( $rev );
175 $this->assertSame( $parentId, $rev->getParentId() );
176 $this->assertSame( $summary->text, $rev->getComment( RevisionRecord::RAW )->text );
177 $this->assertSame( $user->getName(), $rev->getUser( RevisionRecord::RAW )->getName() );
178
179 $this->assertTrue( $updater->wasCommitted(), 'wasCommitted()' );
180 $this->assertTrue( $updater->wasSuccessful(), 'wasSuccessful()' );
181 $this->assertTrue( $updater->getStatus()->isOK(), 'getStatus()->isOK()' );
182 $this->assertFalse( $updater->isNew(), 'isNew()' );
183 $this->assertNotNull( $updater->getNewRevision(), 'getNewRevision()' );
184 $this->assertInstanceOf( Revision::class, $updater->getStatus()->value['revision'] );
185 $this->assertFalse( $updater->isUnchanged(), 'isUnchanged()' );
186
187 // TODO: Test null revision (with different user): new revision!
188
189 $rev = $updater->getNewRevision();
190 $revContent = $rev->getContent( 'main' );
191 $this->assertSame( 'Lorem Ipsum', $revContent->serialize(), 'revision content' );
192
193 // were the WikiPage and Title objects updated?
194 $this->assertTrue( $page->exists(), 'WikiPage::exists()' );
195 $this->assertTrue( $title->exists(), 'Title::exists()' );
196 $this->assertSame( $rev->getId(), $page->getLatest(), 'WikiPage::getRevision()' );
197 $this->assertNotNull( $page->getRevision(), 'WikiPage::getRevision()' );
198
199 // re-load
200 $page2 = WikiPage::factory( $title );
201 $this->assertTrue( $page2->exists(), 'WikiPage::exists()' );
202 $this->assertSame( $rev->getId(), $page2->getLatest(), 'WikiPage::getRevision()' );
203 $this->assertNotNull( $page2->getRevision(), 'WikiPage::getRevision()' );
204
205 // Check RC entry
206 $rc = $this->getRecentChangeFor( $rev->getId() );
207 $this->assertNotNull( $rc, 'RecentChange' );
208
209 // re-edit
210 $updater = $page->newPageUpdater( $user );
211 $updater->setContent( 'main', new TextContent( 'dolor sit amet' ) );
212
213 $summary = CommentStoreComment::newUnsavedComment( 're-edit' );
214 $updater->saveRevision( $summary );
215 $this->assertTrue( $updater->wasSuccessful(), 'wasSuccessful()' );
216 $this->assertTrue( $updater->getStatus()->isOK(), 'getStatus()->isOK()' );
217
218 // check site stats - this asserts that derived data updates where run.
219 $stats = $this->db->selectRow( 'site_stats', '*', '1=1' );
220 $this->assertNotNull( $stats, 'site_stats' );
221 $this->assertSame( $oldStats->ss_total_pages + 0, (int)$stats->ss_total_pages );
222 $this->assertSame( $oldStats->ss_total_edits + 2, (int)$stats->ss_total_edits );
223 }
224
225 /**
226 * Creates a revision in the database.
227 *
228 * @param WikiPage $page
229 * @param $summary
230 * @param null|string|Content $content
231 *
232 * @return RevisionRecord|null
233 */
234 private function createRevision( WikiPage $page, $summary, $content = null ) {
235 $user = $this->getTestUser()->getUser();
236 $comment = CommentStoreComment::newUnsavedComment( $summary );
237
238 if ( !$content instanceof Content ) {
239 $content = new TextContent( $content ?? $summary );
240 }
241
242 $updater = $page->newPageUpdater( $user );
243 $updater->setContent( 'main', $content );
244 $rev = $updater->saveRevision( $comment );
245 return $rev;
246 }
247
248 /**
249 * @covers \MediaWiki\Storage\PageUpdater::grabParentRevision()
250 * @covers \MediaWiki\Storage\PageUpdater::saveRevision()
251 */
252 public function testCompareAndSwapFailure() {
253 $user = $this->getTestUser()->getUser();
254
255 $title = $this->getDummyTitle( __METHOD__ );
256
257 // start editing non-existing page
258 $page = WikiPage::factory( $title );
259 $updater = $page->newPageUpdater( $user );
260 $updater->grabParentRevision();
261
262 // create page concurrently
263 $concurrentPage = WikiPage::factory( $title );
264 $this->createRevision( $concurrentPage, __METHOD__ . '-one' );
265
266 // try creating the page - should trigger CAS failure.
267 $summary = CommentStoreComment::newUnsavedComment( 'create?!' );
268 $updater->setContent( 'main', new TextContent( 'Lorem ipsum' ) );
269 $updater->saveRevision( $summary );
270 $status = $updater->getStatus();
271
272 $this->assertFalse( $updater->wasSuccessful(), 'wasSuccessful()' );
273 $this->assertNull( $updater->getNewRevision(), 'getNewRevision()' );
274 $this->assertFalse( $status->isOK(), 'getStatus()->isOK()' );
275 $this->assertTrue( $status->hasMessage( 'edit-already-exists' ), 'edit-conflict' );
276
277 // start editing existing page
278 $page = WikiPage::factory( $title );
279 $updater = $page->newPageUpdater( $user );
280 $updater->grabParentRevision();
281
282 // update page concurrently
283 $concurrentPage = WikiPage::factory( $title );
284 $this->createRevision( $concurrentPage, __METHOD__ . '-two' );
285
286 // try creating the page - should trigger CAS failure.
287 $summary = CommentStoreComment::newUnsavedComment( 'edit?!' );
288 $updater->setContent( 'main', new TextContent( 'dolor sit amet' ) );
289 $updater->saveRevision( $summary );
290 $status = $updater->getStatus();
291
292 $this->assertFalse( $updater->wasSuccessful(), 'wasSuccessful()' );
293 $this->assertNull( $updater->getNewRevision(), 'getNewRevision()' );
294 $this->assertFalse( $status->isOK(), 'getStatus()->isOK()' );
295 $this->assertTrue( $status->hasMessage( 'edit-conflict' ), 'edit-conflict' );
296 }
297
298 /**
299 * @covers \MediaWiki\Storage\PageUpdater::saveRevision()
300 */
301 public function testFailureOnEditFlags() {
302 $user = $this->getTestUser()->getUser();
303
304 $title = $this->getDummyTitle( __METHOD__ );
305
306 // start editing non-existing page
307 $page = WikiPage::factory( $title );
308 $updater = $page->newPageUpdater( $user );
309
310 // update with EDIT_UPDATE flag should fail
311 $summary = CommentStoreComment::newUnsavedComment( 'udpate?!' );
312 $updater->setContent( 'main', new TextContent( 'Lorem ipsum' ) );
313 $updater->saveRevision( $summary, EDIT_UPDATE );
314 $status = $updater->getStatus();
315
316 $this->assertFalse( $updater->wasSuccessful(), 'wasSuccessful()' );
317 $this->assertNull( $updater->getNewRevision(), 'getNewRevision()' );
318 $this->assertFalse( $status->isOK(), 'getStatus()->isOK()' );
319 $this->assertTrue( $status->hasMessage( 'edit-gone-missing' ), 'edit-gone-missing' );
320
321 // create the page
322 $this->createRevision( $page, __METHOD__ );
323
324 // update with EDIT_NEW flag should fail
325 $summary = CommentStoreComment::newUnsavedComment( 'create?!' );
326 $updater = $page->newPageUpdater( $user );
327 $updater->setContent( 'main', new TextContent( 'dolor sit amet' ) );
328 $updater->saveRevision( $summary, EDIT_NEW );
329 $status = $updater->getStatus();
330
331 $this->assertFalse( $updater->wasSuccessful(), 'wasSuccessful()' );
332 $this->assertNull( $updater->getNewRevision(), 'getNewRevision()' );
333 $this->assertFalse( $status->isOK(), 'getStatus()->isOK()' );
334 $this->assertTrue( $status->hasMessage( 'edit-already-exists' ), 'edit-already-exists' );
335 }
336
337 public function provideSetRcPatrolStatus( $patrolled ) {
338 yield [ RecentChange::PRC_UNPATROLLED ];
339 yield [ RecentChange::PRC_AUTOPATROLLED ];
340 }
341
342 /**
343 * @dataProvider provideSetRcPatrolStatus
344 * @covers \MediaWiki\Storage\PageUpdater::setRcPatrolStatus()
345 */
346 public function testSetRcPatrolStatus( $patrolled ) {
347 $revisionStore = MediaWikiServices::getInstance()->getRevisionStore();
348
349 $user = $this->getTestUser()->getUser();
350
351 $title = $this->getDummyTitle( __METHOD__ );
352
353 $page = WikiPage::factory( $title );
354 $updater = $page->newPageUpdater( $user );
355
356 $summary = CommentStoreComment::newUnsavedComment( 'Lorem ipsum ' . $patrolled );
357 $updater->setContent( 'main', new TextContent( 'Lorem ipsum ' . $patrolled ) );
358 $updater->setRcPatrolStatus( $patrolled );
359 $rev = $updater->saveRevision( $summary );
360
361 $rc = $revisionStore->getRecentChange( $rev );
362 $this->assertEquals( $patrolled, $rc->getAttribute( 'rc_patrolled' ) );
363 }
364
365 /**
366 * @covers \MediaWiki\Storage\PageUpdater::inheritSlot()
367 * @covers \MediaWiki\Storage\PageUpdater::setContent()
368 */
369 public function testInheritSlot() {
370 $user = $this->getTestUser()->getUser();
371 $title = $this->getDummyTitle( __METHOD__ );
372 $page = WikiPage::factory( $title );
373
374 $updater = $page->newPageUpdater( $user );
375 $summary = CommentStoreComment::newUnsavedComment( 'one' );
376 $updater->setContent( 'main', new TextContent( 'Lorem ipsum' ) );
377 $rev1 = $updater->saveRevision( $summary, EDIT_NEW );
378
379 $updater = $page->newPageUpdater( $user );
380 $summary = CommentStoreComment::newUnsavedComment( 'two' );
381 $updater->setContent( 'main', new TextContent( 'Foo Bar' ) );
382 $rev2 = $updater->saveRevision( $summary, EDIT_UPDATE );
383
384 $updater = $page->newPageUpdater( $user );
385 $summary = CommentStoreComment::newUnsavedComment( 'three' );
386 $updater->inheritSlot( $rev1->getSlot( 'main' ) );
387 $rev3 = $updater->saveRevision( $summary, EDIT_UPDATE );
388
389 $this->assertNotSame( $rev1->getId(), $rev3->getId() );
390 $this->assertNotSame( $rev2->getId(), $rev3->getId() );
391
392 $main1 = $rev1->getSlot( 'main' );
393 $main3 = $rev3->getSlot( 'main' );
394
395 $this->assertNotSame( $main1->getRevision(), $main3->getRevision() );
396 $this->assertSame( $main1->getAddress(), $main3->getAddress() );
397 $this->assertTrue( $main1->getContent()->equals( $main3->getContent() ) );
398 }
399
400 // TODO: MCR: test adding multiple slots, inheriting parent slots, and removing slots.
401
402 public function testSetUseAutomaticEditSummaries() {
403 $this->setContentLang( 'qqx' );
404 $user = $this->getTestUser()->getUser();
405
406 $title = $this->getDummyTitle( __METHOD__ );
407 $page = WikiPage::factory( $title );
408
409 $updater = $page->newPageUpdater( $user );
410 $updater->setUseAutomaticEditSummaries( true );
411 $updater->setContent( 'main', new TextContent( 'Lorem Ipsum' ) );
412
413 // empty comment triggers auto-summary
414 $summary = CommentStoreComment::newUnsavedComment( '' );
415 $updater->saveRevision( $summary, EDIT_AUTOSUMMARY );
416
417 $rev = $updater->getNewRevision();
418 $comment = $rev->getComment( RevisionRecord::RAW );
419 $this->assertSame( '(autosumm-new: Lorem Ipsum)', $comment->text, 'comment text' );
420
421 // check that this also works when blanking the page
422 $updater = $page->newPageUpdater( $user );
423 $updater->setUseAutomaticEditSummaries( true );
424 $updater->setContent( 'main', new TextContent( '' ) );
425
426 $summary = CommentStoreComment::newUnsavedComment( '' );
427 $updater->saveRevision( $summary, EDIT_AUTOSUMMARY );
428
429 $rev = $updater->getNewRevision();
430 $comment = $rev->getComment( RevisionRecord::RAW );
431 $this->assertSame( '(autosumm-blank)', $comment->text, 'comment text' );
432
433 // check that we can also disable edit-summaries
434 $title2 = $this->getDummyTitle( __METHOD__ . '/2' );
435 $page2 = WikiPage::factory( $title2 );
436
437 $updater = $page2->newPageUpdater( $user );
438 $updater->setUseAutomaticEditSummaries( false );
439 $updater->setContent( 'main', new TextContent( 'Lorem Ipsum' ) );
440
441 $summary = CommentStoreComment::newUnsavedComment( '' );
442 $updater->saveRevision( $summary, EDIT_AUTOSUMMARY );
443
444 $rev = $updater->getNewRevision();
445 $comment = $rev->getComment( RevisionRecord::RAW );
446 $this->assertSame( '', $comment->text, 'comment text should still be lank' );
447
448 // check that we don't do auto.summaries without the EDIT_AUTOSUMMARY flag
449 $updater = $page2->newPageUpdater( $user );
450 $updater->setUseAutomaticEditSummaries( true );
451 $updater->setContent( 'main', new TextContent( '' ) );
452
453 $summary = CommentStoreComment::newUnsavedComment( '' );
454 $updater->saveRevision( $summary, 0 );
455
456 $rev = $updater->getNewRevision();
457 $comment = $rev->getComment( RevisionRecord::RAW );
458 $this->assertSame( '', $comment->text, 'comment text' );
459 }
460
461 public function provideSetUsePageCreationLog() {
462 yield [ true, [ [ 'create', 'create' ] ] ];
463 yield [ false, [] ];
464 }
465
466 /**
467 * @dataProvider provideSetUsePageCreationLog
468 * @param bool $use
469 */
470 public function testSetUsePageCreationLog( $use, $expected ) {
471 $user = $this->getTestUser()->getUser();
472 $title = $this->getDummyTitle( __METHOD__ . ( $use ? '_logged' : '_unlogged' ) );
473 $page = WikiPage::factory( $title );
474
475 $updater = $page->newPageUpdater( $user );
476 $updater->setUsePageCreationLog( $use );
477 $summary = CommentStoreComment::newUnsavedComment( 'cmt' );
478 $updater->setContent( 'main', new TextContent( 'Lorem Ipsum' ) );
479 $updater->saveRevision( $summary, EDIT_NEW );
480
481 $rev = $updater->getNewRevision();
482 $this->assertSelect(
483 'logging',
484 [ 'log_type', 'log_action' ],
485 [ 'log_page' => $rev->getPageId() ],
486 $expected
487 );
488 }
489
490 public function provideMagicWords() {
491 yield 'PAGEID' => [
492 'Test {{PAGEID}} Test',
493 function ( RevisionRecord $rev ) {
494 return $rev->getPageId();
495 }
496 ];
497
498 yield 'REVISIONID' => [
499 'Test {{REVISIONID}} Test',
500 function ( RevisionRecord $rev ) {
501 return $rev->getId();
502 }
503 ];
504
505 yield 'REVISIONUSER' => [
506 'Test {{REVISIONUSER}} Test',
507 function ( RevisionRecord $rev ) {
508 return $rev->getUser()->getName();
509 }
510 ];
511
512 yield 'REVISIONTIMESTAMP' => [
513 'Test {{REVISIONTIMESTAMP}} Test',
514 function ( RevisionRecord $rev ) {
515 return $rev->getTimestamp();
516 }
517 ];
518
519 yield 'subst:REVISIONUSER' => [
520 'Test {{subst:REVISIONUSER}} Test',
521 function ( RevisionRecord $rev ) {
522 return $rev->getUser()->getName();
523 }
524 ];
525
526 yield 'subst:PAGENAME' => [
527 'Test {{subst:PAGENAME}} Test',
528 function ( RevisionRecord $rev ) {
529 return 'PageUpdaterTest::testMagicWords';
530 }
531 ];
532 }
533
534 /**
535 * @covers \MediaWiki\Storage\PageUpdater::saveRevision()
536 *
537 * Integration test for PageUpdater, DerivedPageDataUpdater, RevisionRenderer
538 * and RenderedRevision, that ensures that magic words depending on revision meta-data
539 * are handled correctly. Note that each magic word needs to be tested separately,
540 * to assert correct behavior for each "vary" flag in the ParserOutput.
541 *
542 * @dataProvider provideMagicWords
543 */
544 public function testMagicWords( $wikitext, $callback ) {
545 $user = $this->getTestUser()->getUser();
546
547 $title = $this->getDummyTitle( __METHOD__ . '-' . $this->getName() );
548 $page = WikiPage::factory( $title );
549 $updater = $page->newPageUpdater( $user );
550
551 $updater->setContent( 'main', new \WikitextContent( $wikitext ) );
552
553 $summary = CommentStoreComment::newUnsavedComment( 'Just a test' );
554 $rev = $updater->saveRevision( $summary, EDIT_NEW );
555
556 if ( !$rev ) {
557 $this->fail( $updater->getStatus()->getWikiText() );
558 }
559
560 $expected = strval( $callback( $rev ) );
561
562 $cache = MediaWikiServices::getInstance()->getParserCache();
563 $output = $cache->get(
564 $page,
565 ParserOptions::newCanonical(
566 'canonical'
567 )
568 );
569
570 $this->assertNotNull( $output, 'ParserCache::get' );
571
572 $this->assertContains( $expected, $output->getText() );
573 }
574
575 }