33 $this->tablesUsed[] =
'logging';
34 $this->tablesUsed[] =
'recentchanges';
48 $row = $this->db->selectRow(
51 [
'rc_this_oldid' => $revId ],
73 $oldStats = $this->db->selectRow(
'site_stats',
'*',
'1=1' );
75 $this->assertFalse(
$updater->wasCommitted(),
'wasCommitted' );
76 $this->assertFalse(
$updater->getOriginalRevisionId(),
'getOriginalRevisionId' );
77 $this->assertSame( 0,
$updater->getUndidRevisionId(),
'getUndidRevisionId' );
80 $updater->addTags( [
'bar',
'qux' ] );
84 $this->assertSame( [
'bar',
'foo',
'qux' ], $tags,
'getExplicitTags' );
92 $this->assertNull(
$parent,
'getParentRevision' );
93 $this->assertFalse(
$updater->wasCommitted(),
'wasCommitted' );
96 $this->assertFalse(
$updater->hasEditConflict( 0 ),
'hasEditConflict' );
97 $this->assertTrue(
$updater->hasEditConflict( 1 ),
'hasEditConflict' );
104 $this->assertNotNull(
$rev );
105 $this->assertSame( 0,
$rev->getParentId() );
109 $this->assertTrue(
$updater->wasCommitted(),
'wasCommitted()' );
110 $this->assertTrue(
$updater->wasSuccessful(),
'wasSuccessful()' );
111 $this->assertTrue(
$updater->getStatus()->isOK(),
'getStatus()->isOK()' );
112 $this->assertTrue(
$updater->isNew(),
'isNew()' );
113 $this->assertFalse(
$updater->isUnchanged(),
'isUnchanged()' );
114 $this->assertNotNull(
$updater->getNewRevision(),
'getNewRevision()' );
119 $this->assertSame(
'Lorem Ipsum', $revContent->serialize(),
'revision content' );
122 $this->assertTrue( $page->exists(),
'WikiPage::exists()' );
123 $this->assertTrue(
$title->exists(),
'Title::exists()' );
124 $this->assertSame(
$rev->getId(), $page->getLatest(),
'WikiPage::getRevision()' );
125 $this->assertNotNull( $page->getRevision(),
'WikiPage::getRevision()' );
129 $this->assertTrue( $page2->exists(),
'WikiPage::exists()' );
130 $this->assertSame(
$rev->getId(), $page2->getLatest(),
'WikiPage::getRevision()' );
131 $this->assertNotNull( $page2->getRevision(),
'WikiPage::getRevision()' );
135 $this->assertNotNull( $rc,
'RecentChange' );
138 $stats = $this->db->selectRow(
'site_stats',
'*',
'1=1' );
139 $this->assertSame( $oldStats->ss_total_pages + 1, (
int)$stats->ss_total_pages );
140 $this->assertSame( $oldStats->ss_total_edits + 1, (
int)$stats->ss_total_edits );
150 $this->assertNull(
$rev,
'getNewRevision()' );
151 $this->assertNull(
$updater->getNewRevision(),
'getNewRevision()' );
152 $this->assertTrue(
$updater->isUnchanged(),
'isUnchanged' );
153 $this->assertTrue(
$updater->wasSuccessful(),
'wasSuccessful()' );
154 $this->assertTrue(
$status->isOK(),
'getStatus()->isOK()' );
155 $this->assertTrue(
$status->hasMessage(
'edit-no-change' ),
'edit-no-change' );
169 $parentId = $page->getLatest();
173 $oldStats = $this->db->selectRow(
'site_stats',
'*',
'1=1' );
175 $updater->setOriginalRevisionId( 7 );
176 $this->assertSame( 7,
$updater->getOriginalRevisionId(),
'getOriginalRevisionId' );
178 $this->assertFalse(
$updater->hasEditConflict( $parentId ),
'hasEditConflict' );
179 $this->assertTrue(
$updater->hasEditConflict( $parentId - 1 ),
'hasEditConflict' );
180 $this->assertTrue(
$updater->hasEditConflict( 0 ),
'hasEditConflict' );
189 $this->assertNotNull(
$rev );
190 $this->assertSame( $parentId,
$rev->getParentId() );
194 $this->assertTrue(
$updater->wasCommitted(),
'wasCommitted()' );
195 $this->assertTrue(
$updater->wasSuccessful(),
'wasSuccessful()' );
196 $this->assertTrue(
$updater->getStatus()->isOK(),
'getStatus()->isOK()' );
197 $this->assertFalse(
$updater->isNew(),
'isNew()' );
198 $this->assertNotNull(
$updater->getNewRevision(),
'getNewRevision()' );
200 $this->assertFalse(
$updater->isUnchanged(),
'isUnchanged()' );
206 $this->assertSame(
'Lorem Ipsum', $revContent->serialize(),
'revision content' );
209 $this->assertTrue( $page->exists(),
'WikiPage::exists()' );
210 $this->assertTrue(
$title->exists(),
'Title::exists()' );
211 $this->assertSame(
$rev->getId(), $page->getLatest(),
'WikiPage::getRevision()' );
212 $this->assertNotNull( $page->getRevision(),
'WikiPage::getRevision()' );
216 $this->assertTrue( $page2->exists(),
'WikiPage::exists()' );
217 $this->assertSame(
$rev->getId(), $page2->getLatest(),
'WikiPage::getRevision()' );
218 $this->assertNotNull( $page2->getRevision(),
'WikiPage::getRevision()' );
222 $this->assertNotNull( $rc,
'RecentChange' );
230 $this->assertTrue(
$updater->wasSuccessful(),
'wasSuccessful()' );
231 $this->assertTrue(
$updater->getStatus()->isOK(),
'getStatus()->isOK()' );
234 $stats = $this->db->selectRow(
'site_stats',
'*',
'1=1' );
235 $this->assertNotNull( $stats,
'site_stats' );
236 $this->assertSame( $oldStats->ss_total_pages + 0, (
int)$stats->ss_total_pages );
237 $this->assertSame( $oldStats->ss_total_edits + 2, (
int)$stats->ss_total_edits );
287 $this->assertFalse(
$updater->wasSuccessful(),
'wasSuccessful()' );
288 $this->assertNull(
$updater->getNewRevision(),
'getNewRevision()' );
289 $this->assertFalse(
$status->isOK(),
'getStatus()->isOK()' );
290 $this->assertTrue(
$status->hasMessage(
'edit-already-exists' ),
'edit-conflict' );
307 $this->assertFalse(
$updater->wasSuccessful(),
'wasSuccessful()' );
308 $this->assertNull(
$updater->getNewRevision(),
'getNewRevision()' );
309 $this->assertFalse(
$status->isOK(),
'getStatus()->isOK()' );
310 $this->assertTrue(
$status->hasMessage(
'edit-conflict' ),
'edit-conflict' );
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-gone-missing' ),
'edit-gone-missing' );
346 $this->assertFalse(
$updater->wasSuccessful(),
'wasSuccessful()' );
347 $this->assertNull(
$updater->getNewRevision(),
'getNewRevision()' );
348 $this->assertFalse(
$status->isOK(),
'getStatus()->isOK()' );
349 $this->assertTrue(
$status->hasMessage(
'edit-already-exists' ),
'edit-already-exists' );
371 $this->assertFalse(
$updater->wasSuccessful(),
'wasSuccessful()' );
372 $this->assertNull(
$updater->getNewRevision(),
'getNewRevision()' );
373 $this->assertFalse(
$status->isOK(),
'getStatus()->isOK()' );
375 $status->hasMessage(
'content-not-allowed-here' ),
376 'content-not-allowed-here'
401 $updater->setRcPatrolStatus( $patrolled );
404 $rc = $revisionStore->getRecentChange(
$rev );
405 $this->assertEquals( $patrolled, $rc->getAttribute(
'rc_patrolled' ) );
432 $this->assertNotSame( $rev1->getId(), $rev3->getId() );
433 $this->assertNotSame( $rev2->getId(), $rev3->getId() );
438 $this->assertNotSame( $main1->getRevision(), $main3->getRevision() );
439 $this->assertSame( $main1->getAddress(), $main3->getAddress() );
440 $this->assertTrue( $main1->getContent()->equals( $main3->getContent() ) );
453 $updater->setUseAutomaticEditSummaries(
true );
462 $this->assertSame(
'(autosumm-new: Lorem Ipsum)', $comment->text,
'comment text' );
466 $updater->setUseAutomaticEditSummaries(
true );
474 $this->assertSame(
'(autosumm-blank)', $comment->text,
'comment text' );
481 $updater->setUseAutomaticEditSummaries(
false );
489 $this->assertSame(
'', $comment->text,
'comment text should still be lank' );
493 $updater->setUseAutomaticEditSummaries(
true );
497 $updater->saveRevision( $summary, 0 );
501 $this->assertSame(
'', $comment->text,
'comment text' );
505 yield [
true, [ [
'create',
'create' ] ] ];
519 $updater->setUsePageCreationLog( $use );
527 [
'log_type',
'log_action' ],
528 [
'log_page' =>
$rev->getPageId() ],
535 'Test {{PAGEID}} Test',
537 return $rev->getPageId();
541 yield
'REVISIONID' => [
542 'Test {{REVISIONID}} Test',
544 return $rev->getId();
548 yield
'REVISIONUSER' => [
549 'Test {{REVISIONUSER}} Test',
551 return $rev->getUser()->getName();
555 yield
'REVISIONTIMESTAMP' => [
556 'Test {{REVISIONTIMESTAMP}} Test',
558 return $rev->getTimestamp();
562 yield
'subst:REVISIONUSER' => [
563 'Test {{subst:REVISIONUSER}} Test',
565 return $rev->getUser()->getName();
570 yield
'subst:PAGENAME' => [
571 'Test {{subst:PAGENAME}} Test',
573 return 'PageUpdaterTest::testMagicWords';
591 $user->addToDatabase();
605 $this->fail(
$updater->getStatus()->getWikiText() );
608 $expected = strval( $callback(
$rev ) );
615 $this->assertContains( $expected, $text,
'In Wikitext' );
618 $this->assertContains( $expected,
$html,
'In HTML' );