28 $this->tablesUsed[] =
'logging';
29 $this->tablesUsed[] =
'recentchanges';
43 $row = $this->db->selectRow(
46 [
'rc_this_oldid' => $revId ],
68 $oldStats = $this->db->selectRow(
'site_stats',
'*',
'1=1' );
70 $this->assertFalse(
$updater->wasCommitted(),
'wasCommitted' );
71 $this->assertFalse(
$updater->getOriginalRevisionId(),
'getOriginalRevisionId' );
72 $this->assertSame( 0,
$updater->getUndidRevisionId(),
'getUndidRevisionId' );
75 $updater->addTags( [
'bar',
'qux' ] );
79 $this->assertSame( [
'bar',
'foo',
'qux' ], $tags,
'getExplicitTags' );
87 $this->assertNull(
$parent,
'getParentRevision' );
88 $this->assertFalse(
$updater->wasCommitted(),
'wasCommitted' );
91 $this->assertFalse(
$updater->hasEditConflict( 0 ),
'hasEditConflict' );
92 $this->assertTrue(
$updater->hasEditConflict( 1 ),
'hasEditConflict' );
99 $this->assertNotNull(
$rev );
100 $this->assertSame( 0,
$rev->getParentId() );
104 $this->assertTrue(
$updater->wasCommitted(),
'wasCommitted()' );
105 $this->assertTrue(
$updater->wasSuccessful(),
'wasSuccessful()' );
106 $this->assertTrue(
$updater->getStatus()->isOK(),
'getStatus()->isOK()' );
107 $this->assertTrue(
$updater->isNew(),
'isNew()' );
108 $this->assertFalse(
$updater->isUnchanged(),
'isUnchanged()' );
109 $this->assertNotNull(
$updater->getNewRevision(),
'getNewRevision()' );
114 $this->assertSame(
'Lorem Ipsum', $revContent->serialize(),
'revision content' );
117 $this->assertTrue( $page->exists(),
'WikiPage::exists()' );
118 $this->assertTrue(
$title->exists(),
'Title::exists()' );
119 $this->assertSame(
$rev->getId(), $page->getLatest(),
'WikiPage::getRevision()' );
120 $this->assertNotNull( $page->getRevision(),
'WikiPage::getRevision()' );
124 $this->assertTrue( $page2->exists(),
'WikiPage::exists()' );
125 $this->assertSame(
$rev->getId(), $page2->getLatest(),
'WikiPage::getRevision()' );
126 $this->assertNotNull( $page2->getRevision(),
'WikiPage::getRevision()' );
130 $this->assertNotNull( $rc,
'RecentChange' );
133 $stats = $this->db->selectRow(
'site_stats',
'*',
'1=1' );
134 $this->assertSame( $oldStats->ss_total_pages + 1, (
int)$stats->ss_total_pages );
135 $this->assertSame( $oldStats->ss_total_edits + 1, (
int)$stats->ss_total_edits );
145 $this->assertNull(
$rev,
'getNewRevision()' );
146 $this->assertNull(
$updater->getNewRevision(),
'getNewRevision()' );
147 $this->assertTrue(
$updater->isUnchanged(),
'isUnchanged' );
148 $this->assertTrue(
$updater->wasSuccessful(),
'wasSuccessful()' );
149 $this->assertTrue(
$status->isOK(),
'getStatus()->isOK()' );
150 $this->assertTrue(
$status->hasMessage(
'edit-no-change' ),
'edit-no-change' );
164 $parentId = $page->getLatest();
168 $oldStats = $this->db->selectRow(
'site_stats',
'*',
'1=1' );
170 $updater->setOriginalRevisionId( 7 );
171 $this->assertSame( 7,
$updater->getOriginalRevisionId(),
'getOriginalRevisionId' );
173 $this->assertFalse(
$updater->hasEditConflict( $parentId ),
'hasEditConflict' );
174 $this->assertTrue(
$updater->hasEditConflict( $parentId - 1 ),
'hasEditConflict' );
175 $this->assertTrue(
$updater->hasEditConflict( 0 ),
'hasEditConflict' );
184 $this->assertNotNull(
$rev );
185 $this->assertSame( $parentId,
$rev->getParentId() );
189 $this->assertTrue(
$updater->wasCommitted(),
'wasCommitted()' );
190 $this->assertTrue(
$updater->wasSuccessful(),
'wasSuccessful()' );
191 $this->assertTrue(
$updater->getStatus()->isOK(),
'getStatus()->isOK()' );
192 $this->assertFalse(
$updater->isNew(),
'isNew()' );
193 $this->assertNotNull(
$updater->getNewRevision(),
'getNewRevision()' );
195 $this->assertFalse(
$updater->isUnchanged(),
'isUnchanged()' );
201 $this->assertSame(
'Lorem Ipsum', $revContent->serialize(),
'revision content' );
204 $this->assertTrue( $page->exists(),
'WikiPage::exists()' );
205 $this->assertTrue(
$title->exists(),
'Title::exists()' );
206 $this->assertSame(
$rev->getId(), $page->getLatest(),
'WikiPage::getRevision()' );
207 $this->assertNotNull( $page->getRevision(),
'WikiPage::getRevision()' );
211 $this->assertTrue( $page2->exists(),
'WikiPage::exists()' );
212 $this->assertSame(
$rev->getId(), $page2->getLatest(),
'WikiPage::getRevision()' );
213 $this->assertNotNull( $page2->getRevision(),
'WikiPage::getRevision()' );
217 $this->assertNotNull( $rc,
'RecentChange' );
225 $this->assertTrue(
$updater->wasSuccessful(),
'wasSuccessful()' );
226 $this->assertTrue(
$updater->getStatus()->isOK(),
'getStatus()->isOK()' );
229 $stats = $this->db->selectRow(
'site_stats',
'*',
'1=1' );
230 $this->assertNotNull( $stats,
'site_stats' );
231 $this->assertSame( $oldStats->ss_total_pages + 0, (
int)$stats->ss_total_pages );
232 $this->assertSame( $oldStats->ss_total_edits + 2, (
int)$stats->ss_total_edits );
282 $this->assertFalse(
$updater->wasSuccessful(),
'wasSuccessful()' );
283 $this->assertNull(
$updater->getNewRevision(),
'getNewRevision()' );
284 $this->assertFalse(
$status->isOK(),
'getStatus()->isOK()' );
285 $this->assertTrue(
$status->hasMessage(
'edit-already-exists' ),
'edit-conflict' );
302 $this->assertFalse(
$updater->wasSuccessful(),
'wasSuccessful()' );
303 $this->assertNull(
$updater->getNewRevision(),
'getNewRevision()' );
304 $this->assertFalse(
$status->isOK(),
'getStatus()->isOK()' );
305 $this->assertTrue(
$status->hasMessage(
'edit-conflict' ),
'edit-conflict' );
326 $this->assertFalse(
$updater->wasSuccessful(),
'wasSuccessful()' );
327 $this->assertNull(
$updater->getNewRevision(),
'getNewRevision()' );
328 $this->assertFalse(
$status->isOK(),
'getStatus()->isOK()' );
329 $this->assertTrue(
$status->hasMessage(
'edit-gone-missing' ),
'edit-gone-missing' );
341 $this->assertFalse(
$updater->wasSuccessful(),
'wasSuccessful()' );
342 $this->assertNull(
$updater->getNewRevision(),
'getNewRevision()' );
343 $this->assertFalse(
$status->isOK(),
'getStatus()->isOK()' );
344 $this->assertTrue(
$status->hasMessage(
'edit-already-exists' ),
'edit-already-exists' );
368 $updater->setRcPatrolStatus( $patrolled );
371 $rc = $revisionStore->getRecentChange(
$rev );
372 $this->assertEquals( $patrolled, $rc->getAttribute(
'rc_patrolled' ) );
399 $this->assertNotSame( $rev1->getId(), $rev3->getId() );
400 $this->assertNotSame( $rev2->getId(), $rev3->getId() );
405 $this->assertNotSame( $main1->getRevision(), $main3->getRevision() );
406 $this->assertSame( $main1->getAddress(), $main3->getAddress() );
407 $this->assertTrue( $main1->getContent()->equals( $main3->getContent() ) );
420 $updater->setUseAutomaticEditSummaries(
true );
429 $this->assertSame(
'(autosumm-new: Lorem Ipsum)', $comment->text,
'comment text' );
433 $updater->setUseAutomaticEditSummaries(
true );
441 $this->assertSame(
'(autosumm-blank)', $comment->text,
'comment text' );
448 $updater->setUseAutomaticEditSummaries(
false );
456 $this->assertSame(
'', $comment->text,
'comment text should still be lank' );
460 $updater->setUseAutomaticEditSummaries(
true );
464 $updater->saveRevision( $summary, 0 );
468 $this->assertSame(
'', $comment->text,
'comment text' );
472 yield [
true, [ [
'create',
'create' ] ] ];
486 $updater->setUsePageCreationLog( $use );
494 [
'log_type',
'log_action' ],
495 [
'log_page' =>
$rev->getPageId() ],
502 'Test {{PAGEID}} Test',
504 return $rev->getPageId();
508 yield
'REVISIONID' => [
509 'Test {{REVISIONID}} Test',
511 return $rev->getId();
515 yield
'REVISIONUSER' => [
516 'Test {{REVISIONUSER}} Test',
518 return $rev->getUser()->getName();
522 yield
'REVISIONTIMESTAMP' => [
523 'Test {{REVISIONTIMESTAMP}} Test',
525 return $rev->getTimestamp();
529 yield
'subst:REVISIONUSER' => [
530 'Test {{subst:REVISIONUSER}} Test',
532 return $rev->getUser()->getName();
537 yield
'subst:PAGENAME' => [
538 'Test {{subst:PAGENAME}} Test',
540 return 'PageUpdaterTest::testMagicWords';
558 $user->addToDatabase();
572 $this->fail(
$updater->getStatus()->getWikiText() );
575 $expected = strval( $callback(
$rev ) );
582 $this->assertContains( $expected, $text,
'In Wikitext' );
585 $this->assertContains( $expected,
$html,
'In HTML' );