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(),
97 if ( !$this->testPage
) {
99 * We have to create a new page for each subclass as the page creation may result
100 * in different DB fields being filled based on configuration.
102 $this->testPage
= $this->createPage( __CLASS__
, __CLASS__
);
107 * @param string $model
110 protected function getMockTitle() {
111 $mock = $this->getMockBuilder( Title
::class )
112 ->disableOriginalConstructor()
114 $mock->expects( $this->any() )
115 ->method( 'getNamespace' )
116 ->will( $this->returnValue( $this->getDefaultWikitextNS() ) );
117 $mock->expects( $this->any() )
118 ->method( 'getPrefixedText' )
119 ->will( $this->returnValue( __CLASS__
) );
120 $mock->expects( $this->any() )
121 ->method( 'getDBkey' )
122 ->will( $this->returnValue( __CLASS__
) );
123 $mock->expects( $this->any() )
124 ->method( 'getArticleID' )
125 ->will( $this->returnValue( 23 ) );
130 abstract protected function getContentHandlerUseDB();
132 private function makeRevisionWithProps( $props = null ) {
133 if ( $props === null ) {
137 if ( !isset( $props['content'] ) && !isset( $props['text'] ) ) {
138 $props['text'] = 'Lorem Ipsum';
141 if ( !isset( $props['user_text'] ) ) {
142 $user = $this->getTestUser()->getUser();
143 $props['user_text'] = $user->getName();
144 $props['user'] = $user->getId();
147 if ( !isset( $props['user'] ) ) {
151 if ( !isset( $props['comment'] ) ) {
152 $props['comment'] = 'just a test';
155 if ( !isset( $props['page'] ) ) {
156 $props['page'] = $this->testPage
->getId();
159 if ( !isset( $props['content_model'] ) ) {
160 $props['content_model'] = CONTENT_MODEL_WIKITEXT
;
163 $rev = new Revision( $props );
165 $dbw = wfGetDB( DB_MASTER
);
166 $rev->insertOn( $dbw );
172 * @param string $titleString
173 * @param string $text
174 * @param string|null $model
178 private function createPage( $titleString, $text, $model = null ) {
179 if ( !preg_match( '/:/', $titleString ) &&
180 ( $model === null ||
$model === CONTENT_MODEL_WIKITEXT
)
182 $ns = $this->getDefaultWikitextNS();
183 $titleString = MediaWikiServices
::getInstance()->getNamespaceInfo()->
184 getCanonicalName( $ns ) . ':' . $titleString;
187 $title = Title
::newFromText( $titleString );
188 $wikipage = new WikiPage( $title );
190 // Delete the article if it already exists
191 if ( $wikipage->exists() ) {
192 $wikipage->doDeleteArticle( "done" );
195 $content = ContentHandler
::makeContent( $text, $title, $model );
196 $wikipage->doEditContent( $content, __METHOD__
, EDIT_NEW
);
201 private function assertRevEquals( Revision
$orig, Revision
$rev = null ) {
202 $this->assertNotNull( $rev, 'missing revision' );
204 $this->assertEquals( $orig->getId(), $rev->getId() );
205 $this->assertEquals( $orig->getPage(), $rev->getPage() );
206 $this->assertEquals( $orig->getTimestamp(), $rev->getTimestamp() );
207 $this->assertEquals( $orig->getUser(), $rev->getUser() );
208 $this->assertEquals( $orig->getContentModel(), $rev->getContentModel() );
209 $this->assertEquals( $orig->getContentFormat(), $rev->getContentFormat() );
210 $this->assertEquals( $orig->getSha1(), $rev->getSha1() );
214 * @covers Revision::getRecentChange
216 public function testGetRecentChange() {
217 $rev = $this->testPage
->getRevision();
218 $recentChange = $rev->getRecentChange();
220 // Make sure various attributes look right / the correct entry has been retrieved.
221 $this->assertEquals( $rev->getTimestamp(), $recentChange->getAttribute( 'rc_timestamp' ) );
223 $rev->getTitle()->getNamespace(),
224 $recentChange->getAttribute( 'rc_namespace' )
227 $rev->getTitle()->getDBkey(),
228 $recentChange->getAttribute( 'rc_title' )
230 $this->assertEquals( $rev->getUser(), $recentChange->getAttribute( 'rc_user' ) );
231 $this->assertEquals( $rev->getUserText(), $recentChange->getAttribute( 'rc_user_text' ) );
232 $this->assertEquals( $rev->getComment(), $recentChange->getAttribute( 'rc_comment' ) );
233 $this->assertEquals( $rev->getPage(), $recentChange->getAttribute( 'rc_cur_id' ) );
234 $this->assertEquals( $rev->getId(), $recentChange->getAttribute( 'rc_this_oldid' ) );
238 * @covers Revision::insertOn
240 public function testInsertOn_success() {
241 $parentId = $this->testPage
->getLatest();
243 // If an ExternalStore is set don't use it.
244 $this->setMwGlobals( 'wgDefaultExternalStore', false );
246 $rev = new Revision( [
247 'page' => $this->testPage
->getId(),
248 'title' => $this->testPage
->getTitle(),
249 'text' => 'Revision Text',
250 'comment' => 'Revision comment',
253 $revId = $rev->insertOn( wfGetDB( DB_MASTER
) );
255 $this->assertInternalType( 'integer', $revId );
256 $this->assertSame( $revId, $rev->getId() );
258 // getTextId() must be an int!
259 $this->assertInternalType( 'integer', $rev->getTextId() );
261 $mainSlot = $rev->getRevisionRecord()->getSlot( SlotRecord
::MAIN
, RevisionRecord
::RAW
);
263 // we currently only support storage in the text table
264 $textId = MediaWikiServices
::getInstance()
266 ->getTextIdFromAddress( $mainSlot->getAddress() );
270 [ 'old_id', 'old_text' ],
272 [ [ strval( $textId ), 'Revision Text' ] ]
285 "rev_id = {$rev->getId()}",
287 strval( $rev->getId() ),
288 strval( $this->testPage
->getId() ),
293 's0ngbdoxagreuf2vjtuxzwdz64n29xm',
298 public function provideInsertOn_exceptionOnIncomplete() {
299 $content = new TextContent( '' );
300 $user = User
::newFromName( 'Foo' );
302 yield
'no parent' => [
304 'content' => $content,
308 IncompleteRevisionException
::class,
309 "rev_page field must not be 0!"
312 yield
'no comment' => [
314 'content' => $content,
318 IncompleteRevisionException
::class,
319 "comment must not be NULL!"
322 yield
'no content' => [
328 IncompleteRevisionException
::class,
329 "Uninitialized field: content_address" // XXX: message may change
334 * @dataProvider provideInsertOn_exceptionOnIncomplete
335 * @covers Revision::insertOn
337 public function testInsertOn_exceptionOnIncomplete( $array, $expException, $expMessage ) {
338 // If an ExternalStore is set don't use it.
339 $this->setMwGlobals( 'wgDefaultExternalStore', false );
340 $this->setExpectedException( $expException, $expMessage );
342 $title = Title
::newFromText( 'Nonexistant-' . __METHOD__
);
343 $rev = new Revision( $array, 0, $title );
345 $rev->insertOn( wfGetDB( DB_MASTER
) );
349 * @covers Revision::newFromTitle
351 public function testNewFromTitle_withoutId() {
352 $latestRevId = $this->testPage
->getLatest();
354 $rev = Revision
::newFromTitle( $this->testPage
->getTitle() );
356 $this->assertTrue( $this->testPage
->getTitle()->equals( $rev->getTitle() ) );
357 $this->assertEquals( $latestRevId, $rev->getId() );
361 * @covers Revision::newFromTitle
363 public function testNewFromTitle_withId() {
364 $latestRevId = $this->testPage
->getLatest();
366 $rev = Revision
::newFromTitle( $this->testPage
->getTitle(), $latestRevId );
368 $this->assertTrue( $this->testPage
->getTitle()->equals( $rev->getTitle() ) );
369 $this->assertEquals( $latestRevId, $rev->getId() );
373 * @covers Revision::newFromTitle
375 public function testNewFromTitle_withBadId() {
376 $latestRevId = $this->testPage
->getLatest();
378 $rev = Revision
::newFromTitle( $this->testPage
->getTitle(), $latestRevId +
1 );
380 $this->assertNull( $rev );
384 * @covers Revision::newFromRow
386 public function testNewFromRow() {
387 $orig = $this->makeRevisionWithProps();
389 $dbr = wfGetDB( DB_REPLICA
);
390 $revQuery = Revision
::getQueryInfo();
391 $res = $dbr->select( $revQuery['tables'], $revQuery['fields'], [ 'rev_id' => $orig->getId() ],
392 __METHOD__
, [], $revQuery['joins'] );
393 $this->assertTrue( is_object( $res ), 'query failed' );
395 $row = $res->fetchObject();
398 $rev = Revision
::newFromRow( $row );
400 $this->assertRevEquals( $orig, $rev );
403 public function provideNewFromArchiveRow() {
411 return $f +
[ 'ar_namespace', 'ar_title' ];
416 unset( $f['ar_text_id'] );
422 unset( $f['ar_page_id'] );
428 unset( $f['ar_parent_id'] );
434 unset( $f['ar_rev_id'] );
440 unset( $f['ar_sha1'] );
447 * @dataProvider provideNewFromArchiveRow
448 * @covers Revision::newFromArchiveRow
450 public function testNewFromArchiveRow( $selectModifier ) {
451 $services = MediaWikiServices
::getInstance();
453 $store = new RevisionStore(
454 $services->getDBLoadBalancer(),
455 $services->getService( '_SqlBlobStore' ),
456 $services->getMainWANObjectCache(),
457 $services->getCommentStore(),
458 $services->getContentModelStore(),
459 $services->getSlotRoleStore(),
460 $services->getSlotRoleRegistry(),
461 $this->getMcrMigrationStage(),
462 $services->getActorMigration()
465 $store->setContentHandlerUseDB( $this->getContentHandlerUseDB() );
466 $this->setService( 'RevisionStore', $store );
468 $page = $this->createPage(
469 'RevisionStorageTest_testNewFromArchiveRow',
471 CONTENT_MODEL_WIKITEXT
473 $orig = $page->getRevision();
474 $page->doDeleteArticle( 'test Revision::newFromArchiveRow' );
476 $dbr = wfGetDB( DB_REPLICA
);
477 $arQuery = Revision
::getArchiveQueryInfo();
478 $arQuery['fields'] = $selectModifier( $arQuery['fields'] );
480 $arQuery['tables'], $arQuery['fields'], [ 'ar_rev_id' => $orig->getId() ],
481 __METHOD__
, [], $arQuery['joins']
483 $this->assertTrue( is_object( $res ), 'query failed' );
485 $row = $res->fetchObject();
488 // MCR migration note: $row is now required to contain ar_title and ar_namespace.
489 // Alternatively, a Title object can be passed to RevisionStore::newRevisionFromArchiveRow
490 $rev = Revision
::newFromArchiveRow( $row );
492 $this->assertRevEquals( $orig, $rev );
496 * @covers Revision::newFromArchiveRow
498 public function testNewFromArchiveRowOverrides() {
499 $page = $this->createPage(
500 'RevisionStorageTest_testNewFromArchiveRow',
502 CONTENT_MODEL_WIKITEXT
504 $orig = $page->getRevision();
505 $page->doDeleteArticle( 'test Revision::newFromArchiveRow' );
507 $dbr = wfGetDB( DB_REPLICA
);
508 $arQuery = Revision
::getArchiveQueryInfo();
510 $arQuery['tables'], $arQuery['fields'], [ 'ar_rev_id' => $orig->getId() ],
511 __METHOD__
, [], $arQuery['joins']
513 $this->assertTrue( is_object( $res ), 'query failed' );
515 $row = $res->fetchObject();
518 $rev = Revision
::newFromArchiveRow( $row, [ 'comment_text' => 'SOMEOVERRIDE' ] );
520 $this->assertNotEquals( $orig->getComment(), $rev->getComment() );
521 $this->assertEquals( 'SOMEOVERRIDE', $rev->getComment() );
525 * @covers Revision::newFromId
527 public function testNewFromId() {
528 $orig = $this->testPage
->getRevision();
529 $rev = Revision
::newFromId( $orig->getId() );
530 $this->assertRevEquals( $orig, $rev );
534 * @covers Revision::newFromPageId
536 public function testNewFromPageId() {
537 $rev = Revision
::newFromPageId( $this->testPage
->getId() );
538 $this->assertRevEquals(
539 $this->testPage
->getRevision(),
545 * @covers Revision::newFromPageId
547 public function testNewFromPageIdWithLatestId() {
548 $rev = Revision
::newFromPageId(
549 $this->testPage
->getId(),
550 $this->testPage
->getLatest()
552 $this->assertRevEquals(
553 $this->testPage
->getRevision(),
559 * @covers Revision::newFromPageId
561 public function testNewFromPageIdWithNotLatestId() {
562 $content = new WikitextContent( __METHOD__
);
563 $this->testPage
->doEditContent( $content, __METHOD__
);
564 $rev = Revision
::newFromPageId(
565 $this->testPage
->getId(),
566 $this->testPage
->getRevision()->getPrevious()->getId()
568 $this->assertRevEquals(
569 $this->testPage
->getRevision()->getPrevious(),
575 * @covers Revision::getPage
577 public function testGetPage() {
578 $page = $this->testPage
;
580 $orig = $this->makeRevisionWithProps( [ 'page' => $page->getId() ] );
581 $rev = Revision
::newFromId( $orig->getId() );
583 $this->assertEquals( $page->getId(), $rev->getPage() );
587 * @covers Revision::isCurrent
589 public function testIsCurrent() {
590 $rev1 = $this->testPage
->getRevision();
592 # @todo find out if this should be true
593 # $this->assertTrue( $rev1->isCurrent() );
595 $rev1x = Revision
::newFromId( $rev1->getId() );
596 $this->assertTrue( $rev1x->isCurrent() );
598 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
599 $rev2 = $this->testPage
->getRevision();
601 # @todo find out if this should be true
602 # $this->assertTrue( $rev2->isCurrent() );
604 $rev1x = Revision
::newFromId( $rev1->getId() );
605 $this->assertFalse( $rev1x->isCurrent() );
607 $rev2x = Revision
::newFromId( $rev2->getId() );
608 $this->assertTrue( $rev2x->isCurrent() );
612 * @covers Revision::getPrevious
614 public function testGetPrevious() {
615 $oldestRevision = $this->testPage
->getOldestRevision();
616 $latestRevision = $this->testPage
->getLatest();
618 $this->assertNull( $oldestRevision->getPrevious() );
620 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
621 $newRevision = $this->testPage
->getRevision();
623 $this->assertNotNull( $newRevision->getPrevious() );
624 $this->assertEquals( $latestRevision, $newRevision->getPrevious()->getId() );
628 * @covers Title::getPreviousRevisionID
629 * @covers Title::getRelativeRevisionID
630 * @covers MediaWiki\Revision\RevisionStore::getPreviousRevision
631 * @covers MediaWiki\Revision\RevisionStore::getRelativeRevision
633 public function testTitleGetPreviousRevisionID() {
634 $oldestId = $this->testPage
->getOldestRevision()->getId();
635 $latestId = $this->testPage
->getLatest();
637 $title = $this->testPage
->getTitle();
639 $this->assertFalse( $title->getPreviousRevisionID( $oldestId ) );
641 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
642 $newId = $this->testPage
->getRevision()->getId();
644 $this->assertEquals( $latestId, $title->getPreviousRevisionID( $newId ) );
648 * @covers Title::getPreviousRevisionID
649 * @covers Title::getRelativeRevisionID
651 public function testTitleGetPreviousRevisionID_invalid() {
652 $this->assertFalse( $this->testPage
->getTitle()->getPreviousRevisionID( 123456789 ) );
656 * @covers Revision::getNext
658 public function testGetNext() {
659 $rev1 = $this->testPage
->getRevision();
661 $this->assertNull( $rev1->getNext() );
663 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
664 $rev2 = $this->testPage
->getRevision();
666 $this->assertNotNull( $rev1->getNext() );
667 $this->assertEquals( $rev2->getId(), $rev1->getNext()->getId() );
671 * @covers Title::getNextRevisionID
672 * @covers Title::getRelativeRevisionID
673 * @covers MediaWiki\Revision\RevisionStore::getNextRevision
674 * @covers MediaWiki\Revision\RevisionStore::getRelativeRevision
676 public function testTitleGetNextRevisionID() {
677 $title = $this->testPage
->getTitle();
679 $origId = $this->testPage
->getLatest();
681 $this->assertFalse( $title->getNextRevisionID( $origId ) );
683 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
684 $newId = $this->testPage
->getLatest();
686 $this->assertSame( $this->testPage
->getLatest(), $title->getNextRevisionID( $origId ) );
690 * @covers Title::getNextRevisionID
691 * @covers Title::getRelativeRevisionID
693 public function testTitleGetNextRevisionID_invalid() {
694 $this->assertFalse( $this->testPage
->getTitle()->getNextRevisionID( 123456789 ) );
698 * @covers Revision::newNullRevision
700 public function testNewNullRevision() {
701 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
702 $orig = $this->testPage
->getRevision();
704 $dbw = wfGetDB( DB_MASTER
);
705 $rev = Revision
::newNullRevision( $dbw, $this->testPage
->getId(), 'a null revision', false );
707 $this->assertNotEquals( $orig->getId(), $rev->getId(),
708 'new null revision should have a different id from the original revision' );
709 $this->assertEquals( $orig->getTextId(), $rev->getTextId(),
710 'new null revision should have the same text id as the original revision' );
711 $this->assertEquals( $orig->getSha1(), $rev->getSha1(),
712 'new null revision should have the same SHA1 as the original revision' );
713 $this->assertTrue( $orig->getRevisionRecord()->hasSameContent( $rev->getRevisionRecord() ),
714 'new null revision should have the same content as the original revision' );
715 $this->assertEquals( __METHOD__
, $rev->getContent()->getText() );
719 * @covers Revision::newNullRevision
721 public function testNewNullRevision_badPage() {
722 $dbw = wfGetDB( DB_MASTER
);
723 $rev = Revision
::newNullRevision( $dbw, -1, 'a null revision', false );
725 $this->assertNull( $rev );
729 * @covers Revision::insertOn
731 public function testInsertOn() {
732 $ip = '2600:387:ed7:947e:8c16:a1ad:dd34:1dd7';
734 $orig = $this->makeRevisionWithProps( [
738 // Make sure the revision was copied to ip_changes
739 $dbr = wfGetDB( DB_REPLICA
);
740 $res = $dbr->select( 'ip_changes', '*', [ 'ipc_rev_id' => $orig->getId() ] );
741 $row = $res->fetchObject();
743 $this->assertEquals( IP
::toHex( $ip ), $row->ipc_hex
);
745 $orig->getTimestamp(),
746 wfTimestamp( TS_MW
, $row->ipc_rev_timestamp
)
750 public static function provideUserWasLastToEdit() {
751 yield
'actually the last edit' => [ 3, true ];
752 yield
'not the current edit, but still by this user' => [ 2, true ];
753 yield
'edit by another user' => [ 1, false ];
754 yield
'first edit, by this user, but another user edited in the mean time' => [ 0, false ];
758 * @covers Revision::userWasLastToEdit
759 * @dataProvider provideUserWasLastToEdit
761 public function testUserWasLastToEdit( $sinceIdx, $expectedLast ) {
762 $userA = User
::newFromName( "RevisionStorageTest_userA" );
763 $userB = User
::newFromName( "RevisionStorageTest_userB" );
765 if ( $userA->getId() === 0 ) {
766 $userA = User
::createNew( $userA->getName() );
769 if ( $userB->getId() === 0 ) {
770 $userB = User
::createNew( $userB->getName() );
773 $ns = $this->getDefaultWikitextNS();
775 $dbw = wfGetDB( DB_MASTER
);
778 // create revisions -----------------------------
779 $page = WikiPage
::factory( Title
::newFromText(
780 'RevisionStorageTest_testUserWasLastToEdit', $ns ) );
781 $page->insertOn( $dbw );
783 $revisions[0] = new Revision( [
784 'page' => $page->getId(),
785 // we need the title to determine the page's default content model
786 'title' => $page->getTitle(),
787 'timestamp' => '20120101000000',
788 'user' => $userA->getId(),
790 'content_model' => CONTENT_MODEL_WIKITEXT
,
791 'comment' => 'edit zero'
793 $revisions[0]->insertOn( $dbw );
795 $revisions[1] = new Revision( [
796 'page' => $page->getId(),
797 // still need the title, because $page->getId() is 0 (there's no entry in the page table)
798 'title' => $page->getTitle(),
799 'timestamp' => '20120101000100',
800 'user' => $userA->getId(),
802 'content_model' => CONTENT_MODEL_WIKITEXT
,
803 'comment' => 'edit one'
805 $revisions[1]->insertOn( $dbw );
807 $revisions[2] = new Revision( [
808 'page' => $page->getId(),
809 'title' => $page->getTitle(),
810 'timestamp' => '20120101000200',
811 'user' => $userB->getId(),
813 'content_model' => CONTENT_MODEL_WIKITEXT
,
814 'comment' => 'edit two'
816 $revisions[2]->insertOn( $dbw );
818 $revisions[3] = new Revision( [
819 'page' => $page->getId(),
820 'title' => $page->getTitle(),
821 'timestamp' => '20120101000300',
822 'user' => $userA->getId(),
824 'content_model' => CONTENT_MODEL_WIKITEXT
,
825 'comment' => 'edit three'
827 $revisions[3]->insertOn( $dbw );
829 $revisions[4] = new Revision( [
830 'page' => $page->getId(),
831 'title' => $page->getTitle(),
832 'timestamp' => '20120101000200',
833 'user' => $userA->getId(),
835 'content_model' => CONTENT_MODEL_WIKITEXT
,
836 'comment' => 'edit four'
838 $revisions[4]->insertOn( $dbw );
840 // test it ---------------------------------
841 $since = $revisions[$sinceIdx]->getTimestamp();
843 $revQuery = Revision
::getQueryInfo();
844 $allRows = iterator_to_array( $dbw->select(
846 [ 'rev_id', 'rev_timestamp', 'rev_user' => $revQuery['fields']['rev_user'] ],
848 'rev_page' => $page->getId(),
849 //'rev_timestamp > ' . $dbw->addQuotes( $dbw->timestamp( $since ) )
852 [ 'ORDER BY' => 'rev_timestamp ASC', 'LIMIT' => 50 ],
856 $wasLast = Revision
::userWasLastToEdit( $dbw, $page->getId(), $userA->getId(), $since );
858 $this->assertEquals( $expectedLast, $wasLast );
862 * @param string $text
863 * @param string $title
864 * @param string $model
865 * @param string $format
869 private function newTestRevision( $text, $title = "Test",
870 $model = CONTENT_MODEL_WIKITEXT
, $format = null
872 if ( is_string( $title ) ) {
873 $title = Title
::newFromText( $title );
876 $content = ContentHandler
::makeContent( $text, $title, $model, $format );
884 'content' => $content,
885 'length' => $content->getSize(),
886 'comment' => "testing",
887 'minor_edit' => false,
889 'content_format' => $format,
896 public function provideGetContentModel() {
897 // NOTE: we expect the help namespace to always contain wikitext
899 [ 'hello world', 'Help:Hello', null, null, CONTENT_MODEL_WIKITEXT
],
900 [ 'hello world', 'User:hello/there.css', null, null, CONTENT_MODEL_CSS
],
901 [ serialize( 'hello world' ), 'Dummy:Hello', null, null, DummyContentForTesting
::MODEL_ID
],
906 * @dataProvider provideGetContentModel
907 * @covers Revision::getContentModel
909 public function testGetContentModel( $text, $title, $model, $format, $expectedModel ) {
910 $rev = $this->newTestRevision( $text, $title, $model, $format );
912 $this->assertEquals( $expectedModel, $rev->getContentModel() );
915 public function provideGetContentFormat() {
916 // NOTE: we expect the help namespace to always contain wikitext
918 [ 'hello world', 'Help:Hello', null, null, CONTENT_FORMAT_WIKITEXT
],
919 [ 'hello world', 'Help:Hello', CONTENT_MODEL_CSS
, null, CONTENT_FORMAT_CSS
],
920 [ 'hello world', 'User:hello/there.css', null, null, CONTENT_FORMAT_CSS
],
921 [ serialize( 'hello world' ), 'Dummy:Hello', null, null, DummyContentForTesting
::MODEL_ID
],
926 * @dataProvider provideGetContentFormat
927 * @covers Revision::getContentFormat
929 public function testGetContentFormat( $text, $title, $model, $format, $expectedFormat ) {
930 $rev = $this->newTestRevision( $text, $title, $model, $format );
932 $this->assertEquals( $expectedFormat, $rev->getContentFormat() );
935 public function provideGetContentHandler() {
936 // NOTE: we expect the help namespace to always contain wikitext
938 [ 'hello world', 'Help:Hello', null, null, WikitextContentHandler
::class ],
939 [ 'hello world', 'User:hello/there.css', null, null, CssContentHandler
::class ],
940 [ serialize( 'hello world' ), 'Dummy:Hello', null, null, DummyContentHandlerForTesting
::class ],
945 * @dataProvider provideGetContentHandler
946 * @covers Revision::getContentHandler
948 public function testGetContentHandler( $text, $title, $model, $format, $expectedClass ) {
949 $rev = $this->newTestRevision( $text, $title, $model, $format );
951 $this->assertEquals( $expectedClass, get_class( $rev->getContentHandler() ) );
954 public function provideGetContent() {
955 // NOTE: we expect the help namespace to always contain wikitext
957 [ 'hello world', 'Help:Hello', null, null, Revision
::FOR_PUBLIC
, 'hello world' ],
959 serialize( 'hello world' ),
961 DummyContentForTesting
::MODEL_ID
,
963 Revision
::FOR_PUBLIC
,
964 serialize( 'hello world' )
967 serialize( 'hello world' ),
971 Revision
::FOR_PUBLIC
,
972 serialize( 'hello world' )
978 * @dataProvider provideGetContent
979 * @covers Revision::getContent
981 public function testGetContent( $text, $title, $model, $format,
982 $audience, $expectedSerialization
984 $rev = $this->newTestRevision( $text, $title, $model, $format );
985 $content = $rev->getContent( $audience );
988 $expectedSerialization,
989 is_null( $content ) ?
null : $content->serialize( $format )
994 * @covers Revision::getContent
996 public function testGetContent_failure() {
997 $rev = new Revision( [
998 'page' => $this->testPage
->getId(),
999 'content_model' => $this->testPage
->getContentModel(),
1000 'id' => 123456789, // not in the test DB
1003 Wikimedia\
suppressWarnings(); // bad text_id will trigger a warning.
1005 $this->assertNull( $rev->getContent(),
1006 "getContent() should return null if the revision's text blob could not be loaded." );
1008 // NOTE: check this twice, once for lazy initialization, and once with the cached value.
1009 $this->assertNull( $rev->getContent(),
1010 "getContent() should return null if the revision's text blob could not be loaded." );
1012 Wikimedia\restoreWarnings
();
1015 public function provideGetSize() {
1017 [ "hello world.", CONTENT_MODEL_WIKITEXT
, 12 ],
1018 [ serialize( "hello world." ), DummyContentForTesting
::MODEL_ID
, 12 ],
1023 * @covers Revision::getSize
1024 * @dataProvider provideGetSize
1026 public function testGetSize( $text, $model, $expected_size ) {
1027 $rev = $this->newTestRevision( $text, 'RevisionTest_testGetSize', $model );
1028 $this->assertEquals( $expected_size, $rev->getSize() );
1031 public function provideGetSha1() {
1033 [ "hello world.", CONTENT_MODEL_WIKITEXT
, Revision
::base36Sha1( "hello world." ) ],
1035 serialize( "hello world." ),
1036 DummyContentForTesting
::MODEL_ID
,
1037 Revision
::base36Sha1( serialize( "hello world." ) )
1043 * @covers Revision::getSha1
1044 * @dataProvider provideGetSha1
1046 public function testGetSha1( $text, $model, $expected_hash ) {
1047 $rev = $this->newTestRevision( $text, 'RevisionTest_testGetSha1', $model );
1048 $this->assertEquals( $expected_hash, $rev->getSha1() );
1052 * Tests whether $rev->getContent() returns a clone when needed.
1054 * @covers Revision::getContent
1056 public function testGetContentClone() {
1057 $content = new RevisionTestModifyableContent( "foo" );
1059 $rev = new Revision(
1063 'title' => Title
::newFromText( "testGetContentClone_dummy" ),
1065 'content' => $content,
1066 'length' => $content->getSize(),
1067 'comment' => "testing",
1068 'minor_edit' => false,
1072 /** @var RevisionTestModifyableContent $content */
1073 $content = $rev->getContent( Revision
::RAW
);
1074 $content->setText( "bar" );
1076 /** @var RevisionTestModifyableContent $content2 */
1077 $content2 = $rev->getContent( Revision
::RAW
);
1078 // content is mutable, expect clone
1079 $this->assertNotSame( $content, $content2, "expected a clone" );
1080 // clone should contain the original text
1081 $this->assertEquals( "foo", $content2->getText() );
1083 $content2->setText( "bla bla" );
1084 // clones should be independent
1085 $this->assertEquals( "bar", $content->getText() );
1089 * Tests whether $rev->getContent() returns the same object repeatedly if appropriate.
1090 * @covers Revision::getContent
1092 public function testGetContentUncloned() {
1093 $rev = $this->newTestRevision( "hello", "testGetContentUncloned_dummy", CONTENT_MODEL_WIKITEXT
);
1094 $content = $rev->getContent( Revision
::RAW
);
1095 $content2 = $rev->getContent( Revision
::RAW
);
1097 // for immutable content like wikitext, this should be the same object
1098 $this->assertSame( $content, $content2 );
1102 * @covers Revision::loadFromId
1104 public function testLoadFromId() {
1105 $rev = $this->testPage
->getRevision();
1106 $this->hideDeprecated( 'Revision::loadFromId' );
1107 $this->assertRevEquals(
1109 Revision
::loadFromId( wfGetDB( DB_MASTER
), $rev->getId() )
1114 * @covers Revision::loadFromPageId
1116 public function testLoadFromPageId() {
1117 $this->assertRevEquals(
1118 $this->testPage
->getRevision(),
1119 Revision
::loadFromPageId( wfGetDB( DB_MASTER
), $this->testPage
->getId() )
1124 * @covers Revision::loadFromPageId
1126 public function testLoadFromPageIdWithLatestRevId() {
1127 $this->assertRevEquals(
1128 $this->testPage
->getRevision(),
1129 Revision
::loadFromPageId(
1130 wfGetDB( DB_MASTER
),
1131 $this->testPage
->getId(),
1132 $this->testPage
->getLatest()
1138 * @covers Revision::loadFromPageId
1140 public function testLoadFromPageIdWithNotLatestRevId() {
1141 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
1142 $this->assertRevEquals(
1143 $this->testPage
->getRevision()->getPrevious(),
1144 Revision
::loadFromPageId(
1145 wfGetDB( DB_MASTER
),
1146 $this->testPage
->getId(),
1147 $this->testPage
->getRevision()->getPrevious()->getId()
1153 * @covers Revision::loadFromTitle
1155 public function testLoadFromTitle() {
1156 $this->assertRevEquals(
1157 $this->testPage
->getRevision(),
1158 Revision
::loadFromTitle( wfGetDB( DB_MASTER
), $this->testPage
->getTitle() )
1163 * @covers Revision::loadFromTitle
1165 public function testLoadFromTitleWithLatestRevId() {
1166 $this->assertRevEquals(
1167 $this->testPage
->getRevision(),
1168 Revision
::loadFromTitle(
1169 wfGetDB( DB_MASTER
),
1170 $this->testPage
->getTitle(),
1171 $this->testPage
->getLatest()
1177 * @covers Revision::loadFromTitle
1179 public function testLoadFromTitleWithNotLatestRevId() {
1180 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
1181 $this->assertRevEquals(
1182 $this->testPage
->getRevision()->getPrevious(),
1183 Revision
::loadFromTitle(
1184 wfGetDB( DB_MASTER
),
1185 $this->testPage
->getTitle(),
1186 $this->testPage
->getRevision()->getPrevious()->getId()
1192 * @covers Revision::loadFromTimestamp()
1194 public function testLoadFromTimestamp() {
1195 $this->assertRevEquals(
1196 $this->testPage
->getRevision(),
1197 Revision
::loadFromTimestamp(
1198 wfGetDB( DB_MASTER
),
1199 $this->testPage
->getTitle(),
1200 $this->testPage
->getRevision()->getTimestamp()
1206 * @covers Revision::getParentLengths
1208 public function testGetParentLengths_noRevIds() {
1211 Revision
::getParentLengths(
1212 wfGetDB( DB_MASTER
),
1219 * @covers Revision::getParentLengths
1221 public function testGetParentLengths_oneRevId() {
1222 $text = '831jr091jr0921kr21kr0921kjr0921j09rj1';
1223 $textLength = strlen( $text );
1225 $this->testPage
->doEditContent( new WikitextContent( $text ), __METHOD__
);
1226 $rev[1] = $this->testPage
->getLatest();
1229 [ $rev[1] => $textLength ],
1230 Revision
::getParentLengths(
1231 wfGetDB( DB_MASTER
),
1238 * @covers Revision::getParentLengths
1240 public function testGetParentLengths_multipleRevIds() {
1241 $textOne = '831jr091jr0921kr21kr0921kjr0921j09rj1';
1242 $textOneLength = strlen( $textOne );
1243 $textTwo = '831jr091jr092121j09rj1';
1244 $textTwoLength = strlen( $textTwo );
1246 $this->testPage
->doEditContent( new WikitextContent( $textOne ), __METHOD__
);
1247 $rev[1] = $this->testPage
->getLatest();
1248 $this->testPage
->doEditContent( new WikitextContent( $textTwo ), __METHOD__
);
1249 $rev[2] = $this->testPage
->getLatest();
1252 [ $rev[1] => $textOneLength, $rev[2] => $textTwoLength ],
1253 Revision
::getParentLengths(
1254 wfGetDB( DB_MASTER
),
1255 [ $rev[1], $rev[2] ]
1261 * @covers Revision::getTitle
1263 public function testGetTitle_fromExistingRevision() {
1265 $this->testPage
->getTitle()->equals(
1266 $this->testPage
->getRevision()->getTitle()
1272 * @covers Revision::getTitle
1274 public function testGetTitle_fromRevisionWhichWillLoadTheTitle() {
1275 $rev = new Revision( [ 'id' => $this->testPage
->getLatest() ] );
1277 $this->testPage
->getTitle()->equals(
1284 * @covers Revision::isMinor
1286 public function testIsMinor_true() {
1287 // Use a sysop to ensure we can mark edits as minor
1288 $sysop = $this->getTestSysop()->getUser();
1290 $this->testPage
->doEditContent(
1291 new WikitextContent( __METHOD__
),
1297 $rev = $this->testPage
->getRevision();
1299 $this->assertSame( true, $rev->isMinor() );
1303 * @covers Revision::isMinor
1305 public function testIsMinor_false() {
1306 $this->testPage
->doEditContent(
1307 new WikitextContent( __METHOD__
),
1311 $rev = $this->testPage
->getRevision();
1313 $this->assertSame( false, $rev->isMinor() );
1317 * @covers Revision::getTimestamp
1319 public function testGetTimestamp() {
1320 $testTimestamp = wfTimestampNow();
1322 $this->testPage
->doEditContent(
1323 new WikitextContent( __METHOD__
),
1326 $rev = $this->testPage
->getRevision();
1328 $this->assertInternalType( 'string', $rev->getTimestamp() );
1329 $this->assertTrue( strlen( $rev->getTimestamp() ) == strlen( 'YYYYMMDDHHMMSS' ) );
1330 $this->assertContains( substr( $testTimestamp, 0, 10 ), $rev->getTimestamp() );
1334 * @covers Revision::getUser
1335 * @covers Revision::getUserText
1337 public function testGetUserAndText() {
1338 $sysop = $this->getTestSysop()->getUser();
1340 $this->testPage
->doEditContent(
1341 new WikitextContent( __METHOD__
),
1347 $rev = $this->testPage
->getRevision();
1349 $this->assertSame( $sysop->getId(), $rev->getUser() );
1350 $this->assertSame( $sysop->getName(), $rev->getUserText() );
1354 * @covers Revision::isDeleted
1356 public function testIsDeleted_nothingDeleted() {
1357 $rev = $this->testPage
->getRevision();
1359 $this->assertSame( false, $rev->isDeleted( Revision
::DELETED_TEXT
) );
1360 $this->assertSame( false, $rev->isDeleted( Revision
::DELETED_COMMENT
) );
1361 $this->assertSame( false, $rev->isDeleted( Revision
::DELETED_RESTRICTED
) );
1362 $this->assertSame( false, $rev->isDeleted( Revision
::DELETED_USER
) );
1366 * @covers Revision::getVisibility
1368 public function testGetVisibility_nothingDeleted() {
1369 $rev = $this->testPage
->getRevision();
1371 $this->assertSame( 0, $rev->getVisibility() );
1375 * @covers Revision::getComment
1377 public function testGetComment_notDeleted() {
1378 $expectedSummary = 'goatlicious summary';
1380 $this->testPage
->doEditContent(
1381 new WikitextContent( __METHOD__
),
1384 $rev = $this->testPage
->getRevision();
1386 $this->assertSame( $expectedSummary, $rev->getComment() );
1390 * @covers Revision::isUnpatrolled
1392 public function testIsUnpatrolled_returnsRecentChangesId() {
1393 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
1394 $rev = $this->testPage
->getRevision();
1396 $this->assertGreaterThan( 0, $rev->isUnpatrolled() );
1397 $this->assertSame( $rev->getRecentChange()->getAttribute( 'rc_id' ), $rev->isUnpatrolled() );
1401 * @covers Revision::isUnpatrolled
1403 public function testIsUnpatrolled_returnsZeroIfPatrolled() {
1404 // This assumes that sysops are auto patrolled
1405 $sysop = $this->getTestSysop()->getUser();
1406 $this->testPage
->doEditContent(
1407 new WikitextContent( __METHOD__
),
1413 $rev = $this->testPage
->getRevision();
1415 $this->assertSame( 0, $rev->isUnpatrolled() );
1419 * This is a simple blanket test for all simple content getters and is methods to provide some
1420 * coverage before the split of Revision into multiple classes for MCR work.
1421 * @covers Revision::getContent
1422 * @covers Revision::getSerializedData
1423 * @covers Revision::getContentModel
1424 * @covers Revision::getContentFormat
1425 * @covers Revision::getContentHandler
1427 public function testSimpleContentGetters() {
1428 $expectedText = 'testSimpleContentGetters in Revision. Goats love MCR...';
1429 $expectedSummary = 'goatlicious testSimpleContentGetters summary';
1431 $this->testPage
->doEditContent(
1432 new WikitextContent( $expectedText ),
1435 $rev = $this->testPage
->getRevision();
1437 $this->assertSame( $expectedText, $rev->getContent()->getText() );
1438 $this->assertSame( $expectedText, $rev->getSerializedData() );
1439 $this->assertSame( $this->testPage
->getContentModel(), $rev->getContentModel() );
1440 $this->assertSame( $this->testPage
->getContent()->getDefaultFormat(), $rev->getContentFormat() );
1441 $this->assertSame( $this->testPage
->getContentHandler(), $rev->getContentHandler() );
1445 * @covers Revision::newKnownCurrent
1447 public function testNewKnownCurrent() {
1448 // Setup the services
1449 $this->overrideMwServices();
1450 $cache = new WANObjectCache( [ 'cache' => new HashBagOStuff() ] );
1451 $this->setService( 'MainWANObjectCache', $cache );
1452 $db = wfGetDB( DB_MASTER
);
1455 $cache->setMockTime( $now );
1457 // Get a fresh revision to use during testing
1458 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
1459 $rev = $this->testPage
->getRevision();
1461 // Clear any previous cache for the revision during creation
1462 $key = $cache->makeGlobalKey(
1463 RevisionStore
::ROW_CACHE_KEY
,
1468 $cache->delete( $key, WANObjectCache
::HOLDOFF_TTL_NONE
);
1469 $this->assertFalse( $cache->get( $key ) );
1473 // Get the new revision and make sure it is in the cache and correct
1474 $newRev = Revision
::newKnownCurrent( $db, $rev->getPage(), $rev->getId() );
1475 $this->assertRevEquals( $rev, $newRev );
1477 $cachedRow = $cache->get( $key );
1478 $this->assertNotFalse( $cachedRow );
1479 $this->assertEquals( $rev->getId(), $cachedRow->rev_id
);
1482 public function testNewKnownCurrent_withPageId() {
1483 $db = wfGetDB( DB_MASTER
);
1485 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
1486 $rev = $this->testPage
->getRevision();
1488 $pageId = $this->testPage
->getId();
1490 $newRev = Revision
::newKnownCurrent( $db, $pageId, $rev->getId() );
1491 $this->assertRevEquals( $rev, $newRev );
1494 public function testNewKnownCurrent_returnsFalseWhenTitleDoesntExist() {
1495 $db = wfGetDB( DB_MASTER
);
1497 $this->assertFalse( Revision
::newKnownCurrent( $db, 0 ) );
1500 public function provideUserCanBitfield() {
1501 yield
[ 0, 0, [], null, true ];
1502 // Bitfields match, user has no permissions
1503 yield
[ Revision
::DELETED_TEXT
, Revision
::DELETED_TEXT
, [], null, false ];
1504 yield
[ Revision
::DELETED_COMMENT
, Revision
::DELETED_COMMENT
, [], null, false ];
1505 yield
[ Revision
::DELETED_USER
, Revision
::DELETED_USER
, [], null, false ];
1506 yield
[ Revision
::DELETED_RESTRICTED
, Revision
::DELETED_RESTRICTED
, [], null, false ];
1507 // Bitfields match, user (admin) does have permissions
1508 yield
[ Revision
::DELETED_TEXT
, Revision
::DELETED_TEXT
, [ 'sysop' ], null, true ];
1509 yield
[ Revision
::DELETED_COMMENT
, Revision
::DELETED_COMMENT
, [ 'sysop' ], null, true ];
1510 yield
[ Revision
::DELETED_USER
, Revision
::DELETED_USER
, [ 'sysop' ], null, true ];
1511 // Bitfields match, user (admin) does not have permissions
1512 yield
[ Revision
::DELETED_RESTRICTED
, Revision
::DELETED_RESTRICTED
, [ 'sysop' ], null, false ];
1513 // Bitfields match, user (oversight) does have permissions
1514 yield
[ Revision
::DELETED_RESTRICTED
, Revision
::DELETED_RESTRICTED
, [ 'oversight' ], null, true ];
1515 // Check permissions using the title
1517 Revision
::DELETED_TEXT
,
1518 Revision
::DELETED_TEXT
,
1524 Revision
::DELETED_TEXT
,
1525 Revision
::DELETED_TEXT
,
1533 * @dataProvider provideUserCanBitfield
1534 * @covers Revision::userCanBitfield
1536 public function testUserCanBitfield( $bitField, $field, $userGroups, $title, $expected ) {
1537 $title = Title
::newFromText( $title );
1539 $this->setGroupPermissions(
1542 'deletedtext' => true,
1543 'deletedhistory' => true,
1546 'viewsuppressed' => true,
1547 'suppressrevision' => true,
1551 $user = $this->getTestUser( $userGroups )->getUser();
1555 Revision
::userCanBitfield( $bitField, $field, $user, $title )
1558 // Fallback to $wgUser
1559 $this->setMwGlobals(
1565 Revision
::userCanBitfield( $bitField, $field, null, $title )
1569 public function provideUserCan() {
1570 yield
[ 0, 0, [], true ];
1571 // Bitfields match, user has no permissions
1572 yield
[ Revision
::DELETED_TEXT
, Revision
::DELETED_TEXT
, [], false ];
1573 yield
[ Revision
::DELETED_COMMENT
, Revision
::DELETED_COMMENT
, [], false ];
1574 yield
[ Revision
::DELETED_USER
, Revision
::DELETED_USER
, [], false ];
1575 yield
[ Revision
::DELETED_RESTRICTED
, Revision
::DELETED_RESTRICTED
, [], false ];
1576 // Bitfields match, user (admin) does have permissions
1577 yield
[ Revision
::DELETED_TEXT
, Revision
::DELETED_TEXT
, [ 'sysop' ], true ];
1578 yield
[ Revision
::DELETED_COMMENT
, Revision
::DELETED_COMMENT
, [ 'sysop' ], true ];
1579 yield
[ Revision
::DELETED_USER
, Revision
::DELETED_USER
, [ 'sysop' ], true ];
1580 // Bitfields match, user (admin) does not have permissions
1581 yield
[ Revision
::DELETED_RESTRICTED
, Revision
::DELETED_RESTRICTED
, [ 'sysop' ], false ];
1582 // Bitfields match, user (oversight) does have permissions
1583 yield
[ Revision
::DELETED_RESTRICTED
, Revision
::DELETED_RESTRICTED
, [ 'oversight' ], true ];
1587 * @dataProvider provideUserCan
1588 * @covers Revision::userCan
1590 public function testUserCan( $bitField, $field, $userGroups, $expected ) {
1591 $this->setGroupPermissions(
1594 'deletedtext' => true,
1595 'deletedhistory' => true,
1598 'viewsuppressed' => true,
1599 'suppressrevision' => true,
1603 $user = $this->getTestUser( $userGroups )->getUser();
1604 $revision = new Revision( [ 'deleted' => $bitField ], 0, $this->testPage
->getTitle() );
1608 $revision->userCan( $field, $user )
1612 public function provideGetTextId() {
1615 $slot = new SlotRecord( (object)[
1616 'slot_revision_id' => 42,
1617 'slot_content_id' => 1,
1618 'content_address' => 'tt:789',
1619 'model_name' => CONTENT_MODEL_WIKITEXT
,
1620 'role_name' => SlotRecord
::MAIN
,
1622 ], new WikitextContent( 'Test' ) );
1624 $rec = new MutableRevisionRecord( $this->testPage
->getTitle() );
1626 $rec->setSlot( $slot );
1628 yield
[ $rec, 789 ];
1632 * @dataProvider provideGetTextId
1633 * @covers Revision::getTextId()
1635 public function testGetTextId( $spec, $expected ) {
1636 $rev = new Revision( $spec, 0, $this->testPage
->getTitle() );
1637 $this->assertSame( $expected, $rev->getTextId() );
1640 abstract public function provideGetRevisionText();
1643 * @dataProvider provideGetRevisionText
1644 * @covers Revision::getRevisionText
1646 public function testGetRevisionText( array $queryInfoOptions, array $queryInfoExtra = [] ) {
1647 $rev = $this->testPage
->getRevisionRecord();
1649 $queryInfo = Revision
::getQueryInfo( $queryInfoOptions );
1650 $queryInfo['tables'] = array_merge( $queryInfo['tables'], $queryInfoExtra['tables'] ??
[] );
1651 $queryInfo['fields'] = array_merge( $queryInfo['fields'], $queryInfoExtra['fields'] ??
[] );
1652 $queryInfo['joins'] = array_merge( $queryInfo['joins'], $queryInfoExtra['joins'] ??
[] );
1654 $conds = [ 'rev_id' => $rev->getId() ];
1655 $row = $this->db
->selectRow(
1656 $queryInfo['tables'],
1657 $queryInfo['fields'],
1664 $expected = $rev->getContent( SlotRecord
::MAIN
)->serialize();
1666 $this->hideDeprecated( 'Revision::getRevisionText (MCR without SCHEMA_COMPAT_WRITE_OLD)' );
1667 $this->assertSame( $expected, Revision
::getRevisionText( $row ) );