3 use MediaWiki\MediaWikiServices
;
4 use MediaWiki\Revision\MutableRevisionRecord
;
5 use MediaWiki\Revision\RevisionStore
;
6 use MediaWiki\Revision\IncompleteRevisionException
;
7 use MediaWiki\Revision\RevisionRecord
;
8 use MediaWiki\Revision\SlotRecord
;
11 * RevisionDbTestBase contains test cases for the Revision class that have Database interactions.
16 abstract class RevisionDbTestBase
extends MediaWikiTestCase
{
19 * @var WikiPage $testPage
23 public function __construct( $name = null, array $data = [], $dataName = '' ) {
24 parent
::__construct( $name, $data, $dataName );
26 $this->tablesUsed
= array_merge( $this->tablesUsed
,
50 protected function addCoreDBData() {
51 // Blank out. This would fail with a modified schema, and we don't need it.
57 abstract protected function getMcrMigrationStage();
62 abstract protected function getMcrTablesToReset();
64 protected function setUp() {
65 $this->tablesUsed +
= $this->getMcrTablesToReset();
69 $this->mergeMwGlobalArrayValue(
73 12313 => 'Dummy_talk',
77 $this->mergeMwGlobalArrayValue(
78 'wgNamespaceContentModels',
80 12312 => DummyContentForTesting
::MODEL_ID
,
84 $this->mergeMwGlobalArrayValue(
87 DummyContentForTesting
::MODEL_ID
=> 'DummyContentHandlerForTesting',
88 RevisionTestModifyableContent
::MODEL_ID
=> 'RevisionTestModifyableContentHandler',
92 $this->setMwGlobals( [
93 'wgMultiContentRevisionSchemaMigrationStage' => $this->getMcrMigrationStage(),
94 'wgContentHandlerUseDB' => $this->getContentHandlerUseDB(),
95 'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_NEW
,
98 $this->overrideMwServices();
100 if ( !$this->testPage
) {
102 * We have to create a new page for each subclass as the page creation may result
103 * in different DB fields being filled based on configuration.
105 $this->testPage
= $this->createPage( __CLASS__
, __CLASS__
);
110 * @param string $model
113 protected function getMockTitle() {
114 $mock = $this->getMockBuilder( Title
::class )
115 ->disableOriginalConstructor()
117 $mock->expects( $this->any() )
118 ->method( 'getNamespace' )
119 ->will( $this->returnValue( $this->getDefaultWikitextNS() ) );
120 $mock->expects( $this->any() )
121 ->method( 'getPrefixedText' )
122 ->will( $this->returnValue( __CLASS__
) );
123 $mock->expects( $this->any() )
124 ->method( 'getDBkey' )
125 ->will( $this->returnValue( __CLASS__
) );
126 $mock->expects( $this->any() )
127 ->method( 'getArticleID' )
128 ->will( $this->returnValue( 23 ) );
133 abstract protected function getContentHandlerUseDB();
135 private function makeRevisionWithProps( $props = null ) {
136 if ( $props === null ) {
140 if ( !isset( $props['content'] ) && !isset( $props['text'] ) ) {
141 $props['text'] = 'Lorem Ipsum';
144 if ( !isset( $props['user_text'] ) ) {
145 $user = $this->getTestUser()->getUser();
146 $props['user_text'] = $user->getName();
147 $props['user'] = $user->getId();
150 if ( !isset( $props['user'] ) ) {
154 if ( !isset( $props['comment'] ) ) {
155 $props['comment'] = 'just a test';
158 if ( !isset( $props['page'] ) ) {
159 $props['page'] = $this->testPage
->getId();
162 if ( !isset( $props['content_model'] ) ) {
163 $props['content_model'] = CONTENT_MODEL_WIKITEXT
;
166 $rev = new Revision( $props );
168 $dbw = wfGetDB( DB_MASTER
);
169 $rev->insertOn( $dbw );
175 * @param string $titleString
176 * @param string $text
177 * @param string|null $model
181 private function createPage( $titleString, $text, $model = null ) {
182 if ( !preg_match( '/:/', $titleString ) &&
183 ( $model === null ||
$model === CONTENT_MODEL_WIKITEXT
)
185 $ns = $this->getDefaultWikitextNS();
186 $titleString = MediaWikiServices
::getInstance()->getNamespaceInfo()->
187 getCanonicalName( $ns ) . ':' . $titleString;
190 $title = Title
::newFromText( $titleString );
191 $wikipage = new WikiPage( $title );
193 // Delete the article if it already exists
194 if ( $wikipage->exists() ) {
195 $wikipage->doDeleteArticle( "done" );
198 $content = ContentHandler
::makeContent( $text, $title, $model );
199 $wikipage->doEditContent( $content, __METHOD__
, EDIT_NEW
);
204 private function assertRevEquals( Revision
$orig, Revision
$rev = null ) {
205 $this->assertNotNull( $rev, 'missing revision' );
207 $this->assertEquals( $orig->getId(), $rev->getId() );
208 $this->assertEquals( $orig->getPage(), $rev->getPage() );
209 $this->assertEquals( $orig->getTimestamp(), $rev->getTimestamp() );
210 $this->assertEquals( $orig->getUser(), $rev->getUser() );
211 $this->assertEquals( $orig->getContentModel(), $rev->getContentModel() );
212 $this->assertEquals( $orig->getContentFormat(), $rev->getContentFormat() );
213 $this->assertEquals( $orig->getSha1(), $rev->getSha1() );
217 * @covers Revision::getRecentChange
219 public function testGetRecentChange() {
220 $rev = $this->testPage
->getRevision();
221 $recentChange = $rev->getRecentChange();
223 // Make sure various attributes look right / the correct entry has been retrieved.
224 $this->assertEquals( $rev->getTimestamp(), $recentChange->getAttribute( 'rc_timestamp' ) );
226 $rev->getTitle()->getNamespace(),
227 $recentChange->getAttribute( 'rc_namespace' )
230 $rev->getTitle()->getDBkey(),
231 $recentChange->getAttribute( 'rc_title' )
233 $this->assertEquals( $rev->getUser(), $recentChange->getAttribute( 'rc_user' ) );
234 $this->assertEquals( $rev->getUserText(), $recentChange->getAttribute( 'rc_user_text' ) );
235 $this->assertEquals( $rev->getComment(), $recentChange->getAttribute( 'rc_comment' ) );
236 $this->assertEquals( $rev->getPage(), $recentChange->getAttribute( 'rc_cur_id' ) );
237 $this->assertEquals( $rev->getId(), $recentChange->getAttribute( 'rc_this_oldid' ) );
241 * @covers Revision::insertOn
243 public function testInsertOn_success() {
244 $parentId = $this->testPage
->getLatest();
246 // If an ExternalStore is set don't use it.
247 $this->setMwGlobals( 'wgDefaultExternalStore', false );
249 $rev = new Revision( [
250 'page' => $this->testPage
->getId(),
251 'title' => $this->testPage
->getTitle(),
252 'text' => 'Revision Text',
253 'comment' => 'Revision comment',
256 $revId = $rev->insertOn( wfGetDB( DB_MASTER
) );
258 $this->assertInternalType( 'integer', $revId );
259 $this->assertSame( $revId, $rev->getId() );
261 // getTextId() must be an int!
262 $this->assertInternalType( 'integer', $rev->getTextId() );
264 $mainSlot = $rev->getRevisionRecord()->getSlot( SlotRecord
::MAIN
, RevisionRecord
::RAW
);
266 // we currently only support storage in the text table
267 $textId = MediaWikiServices
::getInstance()
269 ->getTextIdFromAddress( $mainSlot->getAddress() );
273 [ 'old_id', 'old_text' ],
275 [ [ strval( $textId ), 'Revision Text' ] ]
288 "rev_id = {$rev->getId()}",
290 strval( $rev->getId() ),
291 strval( $this->testPage
->getId() ),
296 's0ngbdoxagreuf2vjtuxzwdz64n29xm',
301 public function provideInsertOn_exceptionOnIncomplete() {
302 $content = new TextContent( '' );
303 $user = User
::newFromName( 'Foo' );
305 yield
'no parent' => [
307 'content' => $content,
311 IncompleteRevisionException
::class,
312 "rev_page field must not be 0!"
315 yield
'no comment' => [
317 'content' => $content,
321 IncompleteRevisionException
::class,
322 "comment must not be NULL!"
325 yield
'no content' => [
331 IncompleteRevisionException
::class,
332 "Uninitialized field: content_address" // XXX: message may change
337 * @dataProvider provideInsertOn_exceptionOnIncomplete
338 * @covers Revision::insertOn
340 public function testInsertOn_exceptionOnIncomplete( $array, $expException, $expMessage ) {
341 // If an ExternalStore is set don't use it.
342 $this->setMwGlobals( 'wgDefaultExternalStore', false );
343 $this->setExpectedException( $expException, $expMessage );
345 $title = Title
::newFromText( 'Nonexistant-' . __METHOD__
);
346 $rev = new Revision( $array, 0, $title );
348 $rev->insertOn( wfGetDB( DB_MASTER
) );
352 * @covers Revision::newFromTitle
354 public function testNewFromTitle_withoutId() {
355 $latestRevId = $this->testPage
->getLatest();
357 $rev = Revision
::newFromTitle( $this->testPage
->getTitle() );
359 $this->assertTrue( $this->testPage
->getTitle()->equals( $rev->getTitle() ) );
360 $this->assertEquals( $latestRevId, $rev->getId() );
364 * @covers Revision::newFromTitle
366 public function testNewFromTitle_withId() {
367 $latestRevId = $this->testPage
->getLatest();
369 $rev = Revision
::newFromTitle( $this->testPage
->getTitle(), $latestRevId );
371 $this->assertTrue( $this->testPage
->getTitle()->equals( $rev->getTitle() ) );
372 $this->assertEquals( $latestRevId, $rev->getId() );
376 * @covers Revision::newFromTitle
378 public function testNewFromTitle_withBadId() {
379 $latestRevId = $this->testPage
->getLatest();
381 $rev = Revision
::newFromTitle( $this->testPage
->getTitle(), $latestRevId +
1 );
383 $this->assertNull( $rev );
387 * @covers Revision::newFromRow
389 public function testNewFromRow() {
390 $orig = $this->makeRevisionWithProps();
392 $dbr = wfGetDB( DB_REPLICA
);
393 $revQuery = Revision
::getQueryInfo();
394 $res = $dbr->select( $revQuery['tables'], $revQuery['fields'], [ 'rev_id' => $orig->getId() ],
395 __METHOD__
, [], $revQuery['joins'] );
396 $this->assertTrue( is_object( $res ), 'query failed' );
398 $row = $res->fetchObject();
401 $rev = Revision
::newFromRow( $row );
403 $this->assertRevEquals( $orig, $rev );
406 public function provideNewFromArchiveRow() {
414 return $f +
[ 'ar_namespace', 'ar_title' ];
419 unset( $f['ar_text_id'] );
425 unset( $f['ar_page_id'] );
431 unset( $f['ar_parent_id'] );
437 unset( $f['ar_rev_id'] );
443 unset( $f['ar_sha1'] );
450 * @dataProvider provideNewFromArchiveRow
451 * @covers Revision::newFromArchiveRow
453 public function testNewFromArchiveRow( $selectModifier ) {
454 $services = MediaWikiServices
::getInstance();
456 $store = new RevisionStore(
457 $services->getDBLoadBalancer(),
458 $services->getService( '_SqlBlobStore' ),
459 $services->getMainWANObjectCache(),
460 $services->getCommentStore(),
461 $services->getContentModelStore(),
462 $services->getSlotRoleStore(),
463 $services->getSlotRoleRegistry(),
464 $this->getMcrMigrationStage(),
465 $services->getActorMigration()
468 $store->setContentHandlerUseDB( $this->getContentHandlerUseDB() );
469 $this->setService( 'RevisionStore', $store );
471 $page = $this->createPage(
472 'RevisionStorageTest_testNewFromArchiveRow',
474 CONTENT_MODEL_WIKITEXT
476 $orig = $page->getRevision();
477 $page->doDeleteArticle( 'test Revision::newFromArchiveRow' );
479 $dbr = wfGetDB( DB_REPLICA
);
480 $arQuery = Revision
::getArchiveQueryInfo();
481 $arQuery['fields'] = $selectModifier( $arQuery['fields'] );
483 $arQuery['tables'], $arQuery['fields'], [ 'ar_rev_id' => $orig->getId() ],
484 __METHOD__
, [], $arQuery['joins']
486 $this->assertTrue( is_object( $res ), 'query failed' );
488 $row = $res->fetchObject();
491 // MCR migration note: $row is now required to contain ar_title and ar_namespace.
492 // Alternatively, a Title object can be passed to RevisionStore::newRevisionFromArchiveRow
493 $rev = Revision
::newFromArchiveRow( $row );
495 $this->assertRevEquals( $orig, $rev );
499 * @covers Revision::newFromArchiveRow
501 public function testNewFromArchiveRowOverrides() {
502 $page = $this->createPage(
503 'RevisionStorageTest_testNewFromArchiveRow',
505 CONTENT_MODEL_WIKITEXT
507 $orig = $page->getRevision();
508 $page->doDeleteArticle( 'test Revision::newFromArchiveRow' );
510 $dbr = wfGetDB( DB_REPLICA
);
511 $arQuery = Revision
::getArchiveQueryInfo();
513 $arQuery['tables'], $arQuery['fields'], [ 'ar_rev_id' => $orig->getId() ],
514 __METHOD__
, [], $arQuery['joins']
516 $this->assertTrue( is_object( $res ), 'query failed' );
518 $row = $res->fetchObject();
521 $rev = Revision
::newFromArchiveRow( $row, [ 'comment_text' => 'SOMEOVERRIDE' ] );
523 $this->assertNotEquals( $orig->getComment(), $rev->getComment() );
524 $this->assertEquals( 'SOMEOVERRIDE', $rev->getComment() );
528 * @covers Revision::newFromId
530 public function testNewFromId() {
531 $orig = $this->testPage
->getRevision();
532 $rev = Revision
::newFromId( $orig->getId() );
533 $this->assertRevEquals( $orig, $rev );
537 * @covers Revision::newFromPageId
539 public function testNewFromPageId() {
540 $rev = Revision
::newFromPageId( $this->testPage
->getId() );
541 $this->assertRevEquals(
542 $this->testPage
->getRevision(),
548 * @covers Revision::newFromPageId
550 public function testNewFromPageIdWithLatestId() {
551 $rev = Revision
::newFromPageId(
552 $this->testPage
->getId(),
553 $this->testPage
->getLatest()
555 $this->assertRevEquals(
556 $this->testPage
->getRevision(),
562 * @covers Revision::newFromPageId
564 public function testNewFromPageIdWithNotLatestId() {
565 $content = new WikitextContent( __METHOD__
);
566 $this->testPage
->doEditContent( $content, __METHOD__
);
567 $rev = Revision
::newFromPageId(
568 $this->testPage
->getId(),
569 $this->testPage
->getRevision()->getPrevious()->getId()
571 $this->assertRevEquals(
572 $this->testPage
->getRevision()->getPrevious(),
578 * @covers Revision::getPage
580 public function testGetPage() {
581 $page = $this->testPage
;
583 $orig = $this->makeRevisionWithProps( [ 'page' => $page->getId() ] );
584 $rev = Revision
::newFromId( $orig->getId() );
586 $this->assertEquals( $page->getId(), $rev->getPage() );
590 * @covers Revision::isCurrent
592 public function testIsCurrent() {
593 $rev1 = $this->testPage
->getRevision();
595 # @todo find out if this should be true
596 # $this->assertTrue( $rev1->isCurrent() );
598 $rev1x = Revision
::newFromId( $rev1->getId() );
599 $this->assertTrue( $rev1x->isCurrent() );
601 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
602 $rev2 = $this->testPage
->getRevision();
604 # @todo find out if this should be true
605 # $this->assertTrue( $rev2->isCurrent() );
607 $rev1x = Revision
::newFromId( $rev1->getId() );
608 $this->assertFalse( $rev1x->isCurrent() );
610 $rev2x = Revision
::newFromId( $rev2->getId() );
611 $this->assertTrue( $rev2x->isCurrent() );
615 * @covers Revision::getPrevious
617 public function testGetPrevious() {
618 $oldestRevision = $this->testPage
->getOldestRevision();
619 $latestRevision = $this->testPage
->getLatest();
621 $this->assertNull( $oldestRevision->getPrevious() );
623 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
624 $newRevision = $this->testPage
->getRevision();
626 $this->assertNotNull( $newRevision->getPrevious() );
627 $this->assertEquals( $latestRevision, $newRevision->getPrevious()->getId() );
631 * @covers Title::getPreviousRevisionID
632 * @covers Title::getRelativeRevisionID
633 * @covers MediaWiki\Revision\RevisionStore::getPreviousRevision
634 * @covers MediaWiki\Revision\RevisionStore::getRelativeRevision
636 public function testTitleGetPreviousRevisionID() {
637 $oldestId = $this->testPage
->getOldestRevision()->getId();
638 $latestId = $this->testPage
->getLatest();
640 $title = $this->testPage
->getTitle();
642 $this->assertFalse( $title->getPreviousRevisionID( $oldestId ) );
644 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
645 $newId = $this->testPage
->getRevision()->getId();
647 $this->assertEquals( $latestId, $title->getPreviousRevisionID( $newId ) );
651 * @covers Title::getPreviousRevisionID
652 * @covers Title::getRelativeRevisionID
654 public function testTitleGetPreviousRevisionID_invalid() {
655 $this->assertFalse( $this->testPage
->getTitle()->getPreviousRevisionID( 123456789 ) );
659 * @covers Revision::getNext
661 public function testGetNext() {
662 $rev1 = $this->testPage
->getRevision();
664 $this->assertNull( $rev1->getNext() );
666 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
667 $rev2 = $this->testPage
->getRevision();
669 $this->assertNotNull( $rev1->getNext() );
670 $this->assertEquals( $rev2->getId(), $rev1->getNext()->getId() );
674 * @covers Title::getNextRevisionID
675 * @covers Title::getRelativeRevisionID
676 * @covers MediaWiki\Revision\RevisionStore::getNextRevision
677 * @covers MediaWiki\Revision\RevisionStore::getRelativeRevision
679 public function testTitleGetNextRevisionID() {
680 $title = $this->testPage
->getTitle();
682 $origId = $this->testPage
->getLatest();
684 $this->assertFalse( $title->getNextRevisionID( $origId ) );
686 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
687 $newId = $this->testPage
->getLatest();
689 $this->assertSame( $this->testPage
->getLatest(), $title->getNextRevisionID( $origId ) );
693 * @covers Title::getNextRevisionID
694 * @covers Title::getRelativeRevisionID
696 public function testTitleGetNextRevisionID_invalid() {
697 $this->assertFalse( $this->testPage
->getTitle()->getNextRevisionID( 123456789 ) );
701 * @covers Revision::newNullRevision
703 public function testNewNullRevision() {
704 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
705 $orig = $this->testPage
->getRevision();
707 $dbw = wfGetDB( DB_MASTER
);
708 $rev = Revision
::newNullRevision( $dbw, $this->testPage
->getId(), 'a null revision', false );
710 $this->assertNotEquals( $orig->getId(), $rev->getId(),
711 'new null revision should have a different id from the original revision' );
712 $this->assertEquals( $orig->getTextId(), $rev->getTextId(),
713 'new null revision should have the same text id as the original revision' );
714 $this->assertEquals( $orig->getSha1(), $rev->getSha1(),
715 'new null revision should have the same SHA1 as the original revision' );
716 $this->assertTrue( $orig->getRevisionRecord()->hasSameContent( $rev->getRevisionRecord() ),
717 'new null revision should have the same content as the original revision' );
718 $this->assertEquals( __METHOD__
, $rev->getContent()->getText() );
722 * @covers Revision::newNullRevision
724 public function testNewNullRevision_badPage() {
725 $dbw = wfGetDB( DB_MASTER
);
726 $rev = Revision
::newNullRevision( $dbw, -1, 'a null revision', false );
728 $this->assertNull( $rev );
732 * @covers Revision::insertOn
734 public function testInsertOn() {
735 $ip = '2600:387:ed7:947e:8c16:a1ad:dd34:1dd7';
737 $orig = $this->makeRevisionWithProps( [
741 // Make sure the revision was copied to ip_changes
742 $dbr = wfGetDB( DB_REPLICA
);
743 $res = $dbr->select( 'ip_changes', '*', [ 'ipc_rev_id' => $orig->getId() ] );
744 $row = $res->fetchObject();
746 $this->assertEquals( IP
::toHex( $ip ), $row->ipc_hex
);
748 $orig->getTimestamp(),
749 wfTimestamp( TS_MW
, $row->ipc_rev_timestamp
)
753 public static function provideUserWasLastToEdit() {
754 yield
'actually the last edit' => [ 3, true ];
755 yield
'not the current edit, but still by this user' => [ 2, true ];
756 yield
'edit by another user' => [ 1, false ];
757 yield
'first edit, by this user, but another user edited in the mean time' => [ 0, false ];
761 * @covers Revision::userWasLastToEdit
762 * @dataProvider provideUserWasLastToEdit
764 public function testUserWasLastToEdit( $sinceIdx, $expectedLast ) {
765 $userA = User
::newFromName( "RevisionStorageTest_userA" );
766 $userB = User
::newFromName( "RevisionStorageTest_userB" );
768 if ( $userA->getId() === 0 ) {
769 $userA = User
::createNew( $userA->getName() );
772 if ( $userB->getId() === 0 ) {
773 $userB = User
::createNew( $userB->getName() );
776 $ns = $this->getDefaultWikitextNS();
778 $dbw = wfGetDB( DB_MASTER
);
781 // create revisions -----------------------------
782 $page = WikiPage
::factory( Title
::newFromText(
783 'RevisionStorageTest_testUserWasLastToEdit', $ns ) );
784 $page->insertOn( $dbw );
786 $revisions[0] = new Revision( [
787 'page' => $page->getId(),
788 // we need the title to determine the page's default content model
789 'title' => $page->getTitle(),
790 'timestamp' => '20120101000000',
791 'user' => $userA->getId(),
793 'content_model' => CONTENT_MODEL_WIKITEXT
,
794 'comment' => 'edit zero'
796 $revisions[0]->insertOn( $dbw );
798 $revisions[1] = new Revision( [
799 'page' => $page->getId(),
800 // still need the title, because $page->getId() is 0 (there's no entry in the page table)
801 'title' => $page->getTitle(),
802 'timestamp' => '20120101000100',
803 'user' => $userA->getId(),
805 'content_model' => CONTENT_MODEL_WIKITEXT
,
806 'comment' => 'edit one'
808 $revisions[1]->insertOn( $dbw );
810 $revisions[2] = new Revision( [
811 'page' => $page->getId(),
812 'title' => $page->getTitle(),
813 'timestamp' => '20120101000200',
814 'user' => $userB->getId(),
816 'content_model' => CONTENT_MODEL_WIKITEXT
,
817 'comment' => 'edit two'
819 $revisions[2]->insertOn( $dbw );
821 $revisions[3] = new Revision( [
822 'page' => $page->getId(),
823 'title' => $page->getTitle(),
824 'timestamp' => '20120101000300',
825 'user' => $userA->getId(),
827 'content_model' => CONTENT_MODEL_WIKITEXT
,
828 'comment' => 'edit three'
830 $revisions[3]->insertOn( $dbw );
832 $revisions[4] = new Revision( [
833 'page' => $page->getId(),
834 'title' => $page->getTitle(),
835 'timestamp' => '20120101000200',
836 'user' => $userA->getId(),
838 'content_model' => CONTENT_MODEL_WIKITEXT
,
839 'comment' => 'edit four'
841 $revisions[4]->insertOn( $dbw );
843 // test it ---------------------------------
844 $since = $revisions[$sinceIdx]->getTimestamp();
846 $revQuery = Revision
::getQueryInfo();
847 $allRows = iterator_to_array( $dbw->select(
849 [ 'rev_id', 'rev_timestamp', 'rev_user' => $revQuery['fields']['rev_user'] ],
851 'rev_page' => $page->getId(),
852 //'rev_timestamp > ' . $dbw->addQuotes( $dbw->timestamp( $since ) )
855 [ 'ORDER BY' => 'rev_timestamp ASC', 'LIMIT' => 50 ],
859 $wasLast = Revision
::userWasLastToEdit( $dbw, $page->getId(), $userA->getId(), $since );
861 $this->assertEquals( $expectedLast, $wasLast );
865 * @param string $text
866 * @param string $title
867 * @param string $model
868 * @param string $format
872 private function newTestRevision( $text, $title = "Test",
873 $model = CONTENT_MODEL_WIKITEXT
, $format = null
875 if ( is_string( $title ) ) {
876 $title = Title
::newFromText( $title );
879 $content = ContentHandler
::makeContent( $text, $title, $model, $format );
887 'content' => $content,
888 'length' => $content->getSize(),
889 'comment' => "testing",
890 'minor_edit' => false,
892 'content_format' => $format,
899 public function provideGetContentModel() {
900 // NOTE: we expect the help namespace to always contain wikitext
902 [ 'hello world', 'Help:Hello', null, null, CONTENT_MODEL_WIKITEXT
],
903 [ 'hello world', 'User:hello/there.css', null, null, CONTENT_MODEL_CSS
],
904 [ serialize( 'hello world' ), 'Dummy:Hello', null, null, DummyContentForTesting
::MODEL_ID
],
909 * @dataProvider provideGetContentModel
910 * @covers Revision::getContentModel
912 public function testGetContentModel( $text, $title, $model, $format, $expectedModel ) {
913 $rev = $this->newTestRevision( $text, $title, $model, $format );
915 $this->assertEquals( $expectedModel, $rev->getContentModel() );
918 public function provideGetContentFormat() {
919 // NOTE: we expect the help namespace to always contain wikitext
921 [ 'hello world', 'Help:Hello', null, null, CONTENT_FORMAT_WIKITEXT
],
922 [ 'hello world', 'Help:Hello', CONTENT_MODEL_CSS
, null, CONTENT_FORMAT_CSS
],
923 [ 'hello world', 'User:hello/there.css', null, null, CONTENT_FORMAT_CSS
],
924 [ serialize( 'hello world' ), 'Dummy:Hello', null, null, DummyContentForTesting
::MODEL_ID
],
929 * @dataProvider provideGetContentFormat
930 * @covers Revision::getContentFormat
932 public function testGetContentFormat( $text, $title, $model, $format, $expectedFormat ) {
933 $rev = $this->newTestRevision( $text, $title, $model, $format );
935 $this->assertEquals( $expectedFormat, $rev->getContentFormat() );
938 public function provideGetContentHandler() {
939 // NOTE: we expect the help namespace to always contain wikitext
941 [ 'hello world', 'Help:Hello', null, null, WikitextContentHandler
::class ],
942 [ 'hello world', 'User:hello/there.css', null, null, CssContentHandler
::class ],
943 [ serialize( 'hello world' ), 'Dummy:Hello', null, null, DummyContentHandlerForTesting
::class ],
948 * @dataProvider provideGetContentHandler
949 * @covers Revision::getContentHandler
951 public function testGetContentHandler( $text, $title, $model, $format, $expectedClass ) {
952 $rev = $this->newTestRevision( $text, $title, $model, $format );
954 $this->assertEquals( $expectedClass, get_class( $rev->getContentHandler() ) );
957 public function provideGetContent() {
958 // NOTE: we expect the help namespace to always contain wikitext
960 [ 'hello world', 'Help:Hello', null, null, Revision
::FOR_PUBLIC
, 'hello world' ],
962 serialize( 'hello world' ),
964 DummyContentForTesting
::MODEL_ID
,
966 Revision
::FOR_PUBLIC
,
967 serialize( 'hello world' )
970 serialize( 'hello world' ),
974 Revision
::FOR_PUBLIC
,
975 serialize( 'hello world' )
981 * @dataProvider provideGetContent
982 * @covers Revision::getContent
984 public function testGetContent( $text, $title, $model, $format,
985 $audience, $expectedSerialization
987 $rev = $this->newTestRevision( $text, $title, $model, $format );
988 $content = $rev->getContent( $audience );
991 $expectedSerialization,
992 is_null( $content ) ?
null : $content->serialize( $format )
997 * @covers Revision::getContent
999 public function testGetContent_failure() {
1000 $rev = new Revision( [
1001 'page' => $this->testPage
->getId(),
1002 'content_model' => $this->testPage
->getContentModel(),
1003 'id' => 123456789, // not in the test DB
1006 Wikimedia\
suppressWarnings(); // bad text_id will trigger a warning.
1008 $this->assertNull( $rev->getContent(),
1009 "getContent() should return null if the revision's text blob could not be loaded." );
1011 // NOTE: check this twice, once for lazy initialization, and once with the cached value.
1012 $this->assertNull( $rev->getContent(),
1013 "getContent() should return null if the revision's text blob could not be loaded." );
1015 Wikimedia\restoreWarnings
();
1018 public function provideGetSize() {
1020 [ "hello world.", CONTENT_MODEL_WIKITEXT
, 12 ],
1021 [ serialize( "hello world." ), DummyContentForTesting
::MODEL_ID
, 12 ],
1026 * @covers Revision::getSize
1027 * @dataProvider provideGetSize
1029 public function testGetSize( $text, $model, $expected_size ) {
1030 $rev = $this->newTestRevision( $text, 'RevisionTest_testGetSize', $model );
1031 $this->assertEquals( $expected_size, $rev->getSize() );
1034 public function provideGetSha1() {
1036 [ "hello world.", CONTENT_MODEL_WIKITEXT
, Revision
::base36Sha1( "hello world." ) ],
1038 serialize( "hello world." ),
1039 DummyContentForTesting
::MODEL_ID
,
1040 Revision
::base36Sha1( serialize( "hello world." ) )
1046 * @covers Revision::getSha1
1047 * @dataProvider provideGetSha1
1049 public function testGetSha1( $text, $model, $expected_hash ) {
1050 $rev = $this->newTestRevision( $text, 'RevisionTest_testGetSha1', $model );
1051 $this->assertEquals( $expected_hash, $rev->getSha1() );
1055 * Tests whether $rev->getContent() returns a clone when needed.
1057 * @covers Revision::getContent
1059 public function testGetContentClone() {
1060 $content = new RevisionTestModifyableContent( "foo" );
1062 $rev = new Revision(
1066 'title' => Title
::newFromText( "testGetContentClone_dummy" ),
1068 'content' => $content,
1069 'length' => $content->getSize(),
1070 'comment' => "testing",
1071 'minor_edit' => false,
1075 /** @var RevisionTestModifyableContent $content */
1076 $content = $rev->getContent( Revision
::RAW
);
1077 $content->setText( "bar" );
1079 /** @var RevisionTestModifyableContent $content2 */
1080 $content2 = $rev->getContent( Revision
::RAW
);
1081 // content is mutable, expect clone
1082 $this->assertNotSame( $content, $content2, "expected a clone" );
1083 // clone should contain the original text
1084 $this->assertEquals( "foo", $content2->getText() );
1086 $content2->setText( "bla bla" );
1087 // clones should be independent
1088 $this->assertEquals( "bar", $content->getText() );
1092 * Tests whether $rev->getContent() returns the same object repeatedly if appropriate.
1093 * @covers Revision::getContent
1095 public function testGetContentUncloned() {
1096 $rev = $this->newTestRevision( "hello", "testGetContentUncloned_dummy", CONTENT_MODEL_WIKITEXT
);
1097 $content = $rev->getContent( Revision
::RAW
);
1098 $content2 = $rev->getContent( Revision
::RAW
);
1100 // for immutable content like wikitext, this should be the same object
1101 $this->assertSame( $content, $content2 );
1105 * @covers Revision::loadFromId
1107 public function testLoadFromId() {
1108 $rev = $this->testPage
->getRevision();
1109 $this->hideDeprecated( 'Revision::loadFromId' );
1110 $this->assertRevEquals(
1112 Revision
::loadFromId( wfGetDB( DB_MASTER
), $rev->getId() )
1117 * @covers Revision::loadFromPageId
1119 public function testLoadFromPageId() {
1120 $this->assertRevEquals(
1121 $this->testPage
->getRevision(),
1122 Revision
::loadFromPageId( wfGetDB( DB_MASTER
), $this->testPage
->getId() )
1127 * @covers Revision::loadFromPageId
1129 public function testLoadFromPageIdWithLatestRevId() {
1130 $this->assertRevEquals(
1131 $this->testPage
->getRevision(),
1132 Revision
::loadFromPageId(
1133 wfGetDB( DB_MASTER
),
1134 $this->testPage
->getId(),
1135 $this->testPage
->getLatest()
1141 * @covers Revision::loadFromPageId
1143 public function testLoadFromPageIdWithNotLatestRevId() {
1144 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
1145 $this->assertRevEquals(
1146 $this->testPage
->getRevision()->getPrevious(),
1147 Revision
::loadFromPageId(
1148 wfGetDB( DB_MASTER
),
1149 $this->testPage
->getId(),
1150 $this->testPage
->getRevision()->getPrevious()->getId()
1156 * @covers Revision::loadFromTitle
1158 public function testLoadFromTitle() {
1159 $this->assertRevEquals(
1160 $this->testPage
->getRevision(),
1161 Revision
::loadFromTitle( wfGetDB( DB_MASTER
), $this->testPage
->getTitle() )
1166 * @covers Revision::loadFromTitle
1168 public function testLoadFromTitleWithLatestRevId() {
1169 $this->assertRevEquals(
1170 $this->testPage
->getRevision(),
1171 Revision
::loadFromTitle(
1172 wfGetDB( DB_MASTER
),
1173 $this->testPage
->getTitle(),
1174 $this->testPage
->getLatest()
1180 * @covers Revision::loadFromTitle
1182 public function testLoadFromTitleWithNotLatestRevId() {
1183 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
1184 $this->assertRevEquals(
1185 $this->testPage
->getRevision()->getPrevious(),
1186 Revision
::loadFromTitle(
1187 wfGetDB( DB_MASTER
),
1188 $this->testPage
->getTitle(),
1189 $this->testPage
->getRevision()->getPrevious()->getId()
1195 * @covers Revision::loadFromTimestamp()
1197 public function testLoadFromTimestamp() {
1198 $this->assertRevEquals(
1199 $this->testPage
->getRevision(),
1200 Revision
::loadFromTimestamp(
1201 wfGetDB( DB_MASTER
),
1202 $this->testPage
->getTitle(),
1203 $this->testPage
->getRevision()->getTimestamp()
1209 * @covers Revision::getParentLengths
1211 public function testGetParentLengths_noRevIds() {
1214 Revision
::getParentLengths(
1215 wfGetDB( DB_MASTER
),
1222 * @covers Revision::getParentLengths
1224 public function testGetParentLengths_oneRevId() {
1225 $text = '831jr091jr0921kr21kr0921kjr0921j09rj1';
1226 $textLength = strlen( $text );
1228 $this->testPage
->doEditContent( new WikitextContent( $text ), __METHOD__
);
1229 $rev[1] = $this->testPage
->getLatest();
1232 [ $rev[1] => $textLength ],
1233 Revision
::getParentLengths(
1234 wfGetDB( DB_MASTER
),
1241 * @covers Revision::getParentLengths
1243 public function testGetParentLengths_multipleRevIds() {
1244 $textOne = '831jr091jr0921kr21kr0921kjr0921j09rj1';
1245 $textOneLength = strlen( $textOne );
1246 $textTwo = '831jr091jr092121j09rj1';
1247 $textTwoLength = strlen( $textTwo );
1249 $this->testPage
->doEditContent( new WikitextContent( $textOne ), __METHOD__
);
1250 $rev[1] = $this->testPage
->getLatest();
1251 $this->testPage
->doEditContent( new WikitextContent( $textTwo ), __METHOD__
);
1252 $rev[2] = $this->testPage
->getLatest();
1255 [ $rev[1] => $textOneLength, $rev[2] => $textTwoLength ],
1256 Revision
::getParentLengths(
1257 wfGetDB( DB_MASTER
),
1258 [ $rev[1], $rev[2] ]
1264 * @covers Revision::getTitle
1266 public function testGetTitle_fromExistingRevision() {
1268 $this->testPage
->getTitle()->equals(
1269 $this->testPage
->getRevision()->getTitle()
1275 * @covers Revision::getTitle
1277 public function testGetTitle_fromRevisionWhichWillLoadTheTitle() {
1278 $rev = new Revision( [ 'id' => $this->testPage
->getLatest() ] );
1280 $this->testPage
->getTitle()->equals(
1287 * @covers Revision::isMinor
1289 public function testIsMinor_true() {
1290 // Use a sysop to ensure we can mark edits as minor
1291 $sysop = $this->getTestSysop()->getUser();
1293 $this->testPage
->doEditContent(
1294 new WikitextContent( __METHOD__
),
1300 $rev = $this->testPage
->getRevision();
1302 $this->assertSame( true, $rev->isMinor() );
1306 * @covers Revision::isMinor
1308 public function testIsMinor_false() {
1309 $this->testPage
->doEditContent(
1310 new WikitextContent( __METHOD__
),
1314 $rev = $this->testPage
->getRevision();
1316 $this->assertSame( false, $rev->isMinor() );
1320 * @covers Revision::getTimestamp
1322 public function testGetTimestamp() {
1323 $testTimestamp = wfTimestampNow();
1325 $this->testPage
->doEditContent(
1326 new WikitextContent( __METHOD__
),
1329 $rev = $this->testPage
->getRevision();
1331 $this->assertInternalType( 'string', $rev->getTimestamp() );
1332 $this->assertTrue( strlen( $rev->getTimestamp() ) == strlen( 'YYYYMMDDHHMMSS' ) );
1333 $this->assertContains( substr( $testTimestamp, 0, 10 ), $rev->getTimestamp() );
1337 * @covers Revision::getUser
1338 * @covers Revision::getUserText
1340 public function testGetUserAndText() {
1341 $sysop = $this->getTestSysop()->getUser();
1343 $this->testPage
->doEditContent(
1344 new WikitextContent( __METHOD__
),
1350 $rev = $this->testPage
->getRevision();
1352 $this->assertSame( $sysop->getId(), $rev->getUser() );
1353 $this->assertSame( $sysop->getName(), $rev->getUserText() );
1357 * @covers Revision::isDeleted
1359 public function testIsDeleted_nothingDeleted() {
1360 $rev = $this->testPage
->getRevision();
1362 $this->assertSame( false, $rev->isDeleted( Revision
::DELETED_TEXT
) );
1363 $this->assertSame( false, $rev->isDeleted( Revision
::DELETED_COMMENT
) );
1364 $this->assertSame( false, $rev->isDeleted( Revision
::DELETED_RESTRICTED
) );
1365 $this->assertSame( false, $rev->isDeleted( Revision
::DELETED_USER
) );
1369 * @covers Revision::getVisibility
1371 public function testGetVisibility_nothingDeleted() {
1372 $rev = $this->testPage
->getRevision();
1374 $this->assertSame( 0, $rev->getVisibility() );
1378 * @covers Revision::getComment
1380 public function testGetComment_notDeleted() {
1381 $expectedSummary = 'goatlicious summary';
1383 $this->testPage
->doEditContent(
1384 new WikitextContent( __METHOD__
),
1387 $rev = $this->testPage
->getRevision();
1389 $this->assertSame( $expectedSummary, $rev->getComment() );
1393 * @covers Revision::isUnpatrolled
1395 public function testIsUnpatrolled_returnsRecentChangesId() {
1396 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
1397 $rev = $this->testPage
->getRevision();
1399 $this->assertGreaterThan( 0, $rev->isUnpatrolled() );
1400 $this->assertSame( $rev->getRecentChange()->getAttribute( 'rc_id' ), $rev->isUnpatrolled() );
1404 * @covers Revision::isUnpatrolled
1406 public function testIsUnpatrolled_returnsZeroIfPatrolled() {
1407 // This assumes that sysops are auto patrolled
1408 $sysop = $this->getTestSysop()->getUser();
1409 $this->testPage
->doEditContent(
1410 new WikitextContent( __METHOD__
),
1416 $rev = $this->testPage
->getRevision();
1418 $this->assertSame( 0, $rev->isUnpatrolled() );
1422 * This is a simple blanket test for all simple content getters and is methods to provide some
1423 * coverage before the split of Revision into multiple classes for MCR work.
1424 * @covers Revision::getContent
1425 * @covers Revision::getSerializedData
1426 * @covers Revision::getContentModel
1427 * @covers Revision::getContentFormat
1428 * @covers Revision::getContentHandler
1430 public function testSimpleContentGetters() {
1431 $expectedText = 'testSimpleContentGetters in Revision. Goats love MCR...';
1432 $expectedSummary = 'goatlicious testSimpleContentGetters summary';
1434 $this->testPage
->doEditContent(
1435 new WikitextContent( $expectedText ),
1438 $rev = $this->testPage
->getRevision();
1440 $this->assertSame( $expectedText, $rev->getContent()->getText() );
1441 $this->assertSame( $expectedText, $rev->getSerializedData() );
1442 $this->assertSame( $this->testPage
->getContentModel(), $rev->getContentModel() );
1443 $this->assertSame( $this->testPage
->getContent()->getDefaultFormat(), $rev->getContentFormat() );
1444 $this->assertSame( $this->testPage
->getContentHandler(), $rev->getContentHandler() );
1448 * @covers Revision::newKnownCurrent
1450 public function testNewKnownCurrent() {
1451 // Setup the services
1452 $this->overrideMwServices();
1453 $cache = new WANObjectCache( [ 'cache' => new HashBagOStuff() ] );
1454 $this->setService( 'MainWANObjectCache', $cache );
1455 $db = wfGetDB( DB_MASTER
);
1458 $cache->setMockTime( $now );
1460 // Get a fresh revision to use during testing
1461 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
1462 $rev = $this->testPage
->getRevision();
1464 // Clear any previous cache for the revision during creation
1465 $key = $cache->makeGlobalKey(
1466 RevisionStore
::ROW_CACHE_KEY
,
1471 $cache->delete( $key, WANObjectCache
::HOLDOFF_NONE
);
1472 $this->assertFalse( $cache->get( $key ) );
1476 // Get the new revision and make sure it is in the cache and correct
1477 $newRev = Revision
::newKnownCurrent( $db, $rev->getPage(), $rev->getId() );
1478 $this->assertRevEquals( $rev, $newRev );
1480 $cachedRow = $cache->get( $key );
1481 $this->assertNotFalse( $cachedRow );
1482 $this->assertEquals( $rev->getId(), $cachedRow->rev_id
);
1485 public function testNewKnownCurrent_withPageId() {
1486 $db = wfGetDB( DB_MASTER
);
1488 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
1489 $rev = $this->testPage
->getRevision();
1491 $pageId = $this->testPage
->getId();
1493 $newRev = Revision
::newKnownCurrent( $db, $pageId, $rev->getId() );
1494 $this->assertRevEquals( $rev, $newRev );
1497 public function testNewKnownCurrent_returnsFalseWhenTitleDoesntExist() {
1498 $db = wfGetDB( DB_MASTER
);
1500 $this->assertFalse( Revision
::newKnownCurrent( $db, 0 ) );
1503 public function provideUserCanBitfield() {
1504 yield
[ 0, 0, [], null, true ];
1505 // Bitfields match, user has no permissions
1506 yield
[ Revision
::DELETED_TEXT
, Revision
::DELETED_TEXT
, [], null, false ];
1507 yield
[ Revision
::DELETED_COMMENT
, Revision
::DELETED_COMMENT
, [], null, false ];
1508 yield
[ Revision
::DELETED_USER
, Revision
::DELETED_USER
, [], null, false ];
1509 yield
[ Revision
::DELETED_RESTRICTED
, Revision
::DELETED_RESTRICTED
, [], null, false ];
1510 // Bitfields match, user (admin) does have permissions
1511 yield
[ Revision
::DELETED_TEXT
, Revision
::DELETED_TEXT
, [ 'sysop' ], null, true ];
1512 yield
[ Revision
::DELETED_COMMENT
, Revision
::DELETED_COMMENT
, [ 'sysop' ], null, true ];
1513 yield
[ Revision
::DELETED_USER
, Revision
::DELETED_USER
, [ 'sysop' ], null, true ];
1514 // Bitfields match, user (admin) does not have permissions
1515 yield
[ Revision
::DELETED_RESTRICTED
, Revision
::DELETED_RESTRICTED
, [ 'sysop' ], null, false ];
1516 // Bitfields match, user (oversight) does have permissions
1517 yield
[ Revision
::DELETED_RESTRICTED
, Revision
::DELETED_RESTRICTED
, [ 'oversight' ], null, true ];
1518 // Check permissions using the title
1520 Revision
::DELETED_TEXT
,
1521 Revision
::DELETED_TEXT
,
1527 Revision
::DELETED_TEXT
,
1528 Revision
::DELETED_TEXT
,
1536 * @dataProvider provideUserCanBitfield
1537 * @covers Revision::userCanBitfield
1539 public function testUserCanBitfield( $bitField, $field, $userGroups, $title, $expected ) {
1540 $title = Title
::newFromText( $title );
1542 $this->setGroupPermissions(
1545 'deletedtext' => true,
1546 'deletedhistory' => true,
1549 'viewsuppressed' => true,
1550 'suppressrevision' => true,
1554 $user = $this->getTestUser( $userGroups )->getUser();
1558 Revision
::userCanBitfield( $bitField, $field, $user, $title )
1561 // Fallback to $wgUser
1562 $this->setMwGlobals(
1568 Revision
::userCanBitfield( $bitField, $field, null, $title )
1572 public function provideUserCan() {
1573 yield
[ 0, 0, [], true ];
1574 // Bitfields match, user has no permissions
1575 yield
[ Revision
::DELETED_TEXT
, Revision
::DELETED_TEXT
, [], false ];
1576 yield
[ Revision
::DELETED_COMMENT
, Revision
::DELETED_COMMENT
, [], false ];
1577 yield
[ Revision
::DELETED_USER
, Revision
::DELETED_USER
, [], false ];
1578 yield
[ Revision
::DELETED_RESTRICTED
, Revision
::DELETED_RESTRICTED
, [], false ];
1579 // Bitfields match, user (admin) does have permissions
1580 yield
[ Revision
::DELETED_TEXT
, Revision
::DELETED_TEXT
, [ 'sysop' ], true ];
1581 yield
[ Revision
::DELETED_COMMENT
, Revision
::DELETED_COMMENT
, [ 'sysop' ], true ];
1582 yield
[ Revision
::DELETED_USER
, Revision
::DELETED_USER
, [ 'sysop' ], true ];
1583 // Bitfields match, user (admin) does not have permissions
1584 yield
[ Revision
::DELETED_RESTRICTED
, Revision
::DELETED_RESTRICTED
, [ 'sysop' ], false ];
1585 // Bitfields match, user (oversight) does have permissions
1586 yield
[ Revision
::DELETED_RESTRICTED
, Revision
::DELETED_RESTRICTED
, [ 'oversight' ], true ];
1590 * @dataProvider provideUserCan
1591 * @covers Revision::userCan
1593 public function testUserCan( $bitField, $field, $userGroups, $expected ) {
1594 $this->setGroupPermissions(
1597 'deletedtext' => true,
1598 'deletedhistory' => true,
1601 'viewsuppressed' => true,
1602 'suppressrevision' => true,
1606 $user = $this->getTestUser( $userGroups )->getUser();
1607 $revision = new Revision( [ 'deleted' => $bitField ], 0, $this->testPage
->getTitle() );
1611 $revision->userCan( $field, $user )
1615 public function provideGetTextId() {
1618 $slot = new SlotRecord( (object)[
1619 'slot_revision_id' => 42,
1620 'slot_content_id' => 1,
1621 'content_address' => 'tt:789',
1622 'model_name' => CONTENT_MODEL_WIKITEXT
,
1623 'role_name' => SlotRecord
::MAIN
,
1625 ], new WikitextContent( 'Test' ) );
1627 $rec = new MutableRevisionRecord( $this->testPage
->getTitle() );
1629 $rec->setSlot( $slot );
1631 yield
[ $rec, 789 ];
1635 * @dataProvider provideGetTextId
1636 * @covers Revision::getTextId()
1638 public function testGetTextId( $spec, $expected ) {
1639 $rev = new Revision( $spec, 0, $this->testPage
->getTitle() );
1640 $this->assertSame( $expected, $rev->getTextId() );
1643 abstract public function provideGetRevisionText();
1646 * @dataProvider provideGetRevisionText
1647 * @covers Revision::getRevisionText
1649 public function testGetRevisionText( array $queryInfoOptions, array $queryInfoExtra = [] ) {
1650 $rev = $this->testPage
->getRevisionRecord();
1652 $queryInfo = Revision
::getQueryInfo( $queryInfoOptions );
1653 $queryInfo['tables'] = array_merge( $queryInfo['tables'], $queryInfoExtra['tables'] ??
[] );
1654 $queryInfo['fields'] = array_merge( $queryInfo['fields'], $queryInfoExtra['fields'] ??
[] );
1655 $queryInfo['joins'] = array_merge( $queryInfo['joins'], $queryInfoExtra['joins'] ??
[] );
1657 $conds = [ 'rev_id' => $rev->getId() ];
1658 $row = $this->db
->selectRow(
1659 $queryInfo['tables'],
1660 $queryInfo['fields'],
1667 $expected = $rev->getContent( SlotRecord
::MAIN
)->serialize();
1669 $this->hideDeprecated( 'Revision::getRevisionText (MCR without SCHEMA_COMPAT_WRITE_OLD)' );
1670 $this->assertSame( $expected, Revision
::getRevisionText( $row ) );