2 use MediaWiki\MediaWikiServices
;
3 use MediaWiki\Revision\MutableRevisionRecord
;
4 use MediaWiki\Revision\RevisionStore
;
5 use MediaWiki\Revision\IncompleteRevisionException
;
6 use MediaWiki\Revision\RevisionRecord
;
7 use MediaWiki\Revision\SlotRecord
;
10 * RevisionDbTestBase contains test cases for the Revision class that have Database interactions.
15 abstract class RevisionDbTestBase
extends MediaWikiTestCase
{
18 * @var WikiPage $testPage
22 public function __construct( $name = null, array $data = [], $dataName = '' ) {
23 parent
::__construct( $name, $data, $dataName );
25 $this->tablesUsed
= array_merge( $this->tablesUsed
,
49 protected function addCoreDBData() {
50 // Blank out. This would fail with a modified schema, and we don't need it.
56 abstract protected function getMcrMigrationStage();
61 abstract protected function getMcrTablesToReset();
63 protected function setUp() {
64 $this->tablesUsed +
= $this->getMcrTablesToReset();
68 $this->mergeMwGlobalArrayValue(
72 12313 => 'Dummy_talk',
76 $this->mergeMwGlobalArrayValue(
77 'wgNamespaceContentModels',
79 12312 => DummyContentForTesting
::MODEL_ID
,
83 $this->mergeMwGlobalArrayValue(
86 DummyContentForTesting
::MODEL_ID
=> 'DummyContentHandlerForTesting',
87 RevisionTestModifyableContent
::MODEL_ID
=> 'RevisionTestModifyableContentHandler',
91 $this->setMwGlobals( [
92 'wgMultiContentRevisionSchemaMigrationStage' => $this->getMcrMigrationStage(),
93 'wgContentHandlerUseDB' => $this->getContentHandlerUseDB(),
94 'wgActorTableSchemaMigrationStage' => SCHEMA_COMPAT_NEW
,
97 $this->overrideMwServices();
99 if ( !$this->testPage
) {
101 * We have to create a new page for each subclass as the page creation may result
102 * in different DB fields being filled based on configuration.
104 $this->testPage
= $this->createPage( __CLASS__
, __CLASS__
);
109 * @param string $model
112 protected function getMockTitle() {
113 $mock = $this->getMockBuilder( Title
::class )
114 ->disableOriginalConstructor()
116 $mock->expects( $this->any() )
117 ->method( 'getNamespace' )
118 ->will( $this->returnValue( $this->getDefaultWikitextNS() ) );
119 $mock->expects( $this->any() )
120 ->method( 'getPrefixedText' )
121 ->will( $this->returnValue( __CLASS__
) );
122 $mock->expects( $this->any() )
123 ->method( 'getDBkey' )
124 ->will( $this->returnValue( __CLASS__
) );
125 $mock->expects( $this->any() )
126 ->method( 'getArticleID' )
127 ->will( $this->returnValue( 23 ) );
132 abstract protected function getContentHandlerUseDB();
134 private function makeRevisionWithProps( $props = null ) {
135 if ( $props === null ) {
139 if ( !isset( $props['content'] ) && !isset( $props['text'] ) ) {
140 $props['text'] = 'Lorem Ipsum';
143 if ( !isset( $props['user_text'] ) ) {
144 $user = $this->getTestUser()->getUser();
145 $props['user_text'] = $user->getName();
146 $props['user'] = $user->getId();
149 if ( !isset( $props['user'] ) ) {
153 if ( !isset( $props['comment'] ) ) {
154 $props['comment'] = 'just a test';
157 if ( !isset( $props['page'] ) ) {
158 $props['page'] = $this->testPage
->getId();
161 if ( !isset( $props['content_model'] ) ) {
162 $props['content_model'] = CONTENT_MODEL_WIKITEXT
;
165 $rev = new Revision( $props );
167 $dbw = wfGetDB( DB_MASTER
);
168 $rev->insertOn( $dbw );
174 * @param string $titleString
175 * @param string $text
176 * @param string|null $model
180 private function createPage( $titleString, $text, $model = null ) {
181 if ( !preg_match( '/:/', $titleString ) &&
182 ( $model === null ||
$model === CONTENT_MODEL_WIKITEXT
)
184 $ns = $this->getDefaultWikitextNS();
185 $titleString = MediaWikiServices
::getInstance()->getNamespaceInfo()->
186 getCanonicalName( $ns ) . ':' . $titleString;
189 $title = Title
::newFromText( $titleString );
190 $wikipage = new WikiPage( $title );
192 // Delete the article if it already exists
193 if ( $wikipage->exists() ) {
194 $wikipage->doDeleteArticle( "done" );
197 $content = ContentHandler
::makeContent( $text, $title, $model );
198 $wikipage->doEditContent( $content, __METHOD__
, EDIT_NEW
);
203 private function assertRevEquals( Revision
$orig, Revision
$rev = null ) {
204 $this->assertNotNull( $rev, 'missing revision' );
206 $this->assertEquals( $orig->getId(), $rev->getId() );
207 $this->assertEquals( $orig->getPage(), $rev->getPage() );
208 $this->assertEquals( $orig->getTimestamp(), $rev->getTimestamp() );
209 $this->assertEquals( $orig->getUser(), $rev->getUser() );
210 $this->assertEquals( $orig->getContentModel(), $rev->getContentModel() );
211 $this->assertEquals( $orig->getContentFormat(), $rev->getContentFormat() );
212 $this->assertEquals( $orig->getSha1(), $rev->getSha1() );
216 * @covers Revision::getRecentChange
218 public function testGetRecentChange() {
219 $rev = $this->testPage
->getRevision();
220 $recentChange = $rev->getRecentChange();
222 // Make sure various attributes look right / the correct entry has been retrieved.
223 $this->assertEquals( $rev->getTimestamp(), $recentChange->getAttribute( 'rc_timestamp' ) );
225 $rev->getTitle()->getNamespace(),
226 $recentChange->getAttribute( 'rc_namespace' )
229 $rev->getTitle()->getDBkey(),
230 $recentChange->getAttribute( 'rc_title' )
232 $this->assertEquals( $rev->getUser(), $recentChange->getAttribute( 'rc_user' ) );
233 $this->assertEquals( $rev->getUserText(), $recentChange->getAttribute( 'rc_user_text' ) );
234 $this->assertEquals( $rev->getComment(), $recentChange->getAttribute( 'rc_comment' ) );
235 $this->assertEquals( $rev->getPage(), $recentChange->getAttribute( 'rc_cur_id' ) );
236 $this->assertEquals( $rev->getId(), $recentChange->getAttribute( 'rc_this_oldid' ) );
240 * @covers Revision::insertOn
242 public function testInsertOn_success() {
243 $parentId = $this->testPage
->getLatest();
245 // If an ExternalStore is set don't use it.
246 $this->setMwGlobals( 'wgDefaultExternalStore', false );
248 $rev = new Revision( [
249 'page' => $this->testPage
->getId(),
250 'title' => $this->testPage
->getTitle(),
251 'text' => 'Revision Text',
252 'comment' => 'Revision comment',
255 $revId = $rev->insertOn( wfGetDB( DB_MASTER
) );
257 $this->assertInternalType( 'integer', $revId );
258 $this->assertSame( $revId, $rev->getId() );
260 // getTextId() must be an int!
261 $this->assertInternalType( 'integer', $rev->getTextId() );
263 $mainSlot = $rev->getRevisionRecord()->getSlot( SlotRecord
::MAIN
, RevisionRecord
::RAW
);
265 // we currently only support storage in the text table
266 $textId = MediaWikiServices
::getInstance()
268 ->getTextIdFromAddress( $mainSlot->getAddress() );
272 [ 'old_id', 'old_text' ],
274 [ [ strval( $textId ), 'Revision Text' ] ]
287 "rev_id = {$rev->getId()}",
289 strval( $rev->getId() ),
290 strval( $this->testPage
->getId() ),
295 's0ngbdoxagreuf2vjtuxzwdz64n29xm',
300 public function provideInsertOn_exceptionOnIncomplete() {
301 $content = new TextContent( '' );
302 $user = User
::newFromName( 'Foo' );
304 yield
'no parent' => [
306 'content' => $content,
310 IncompleteRevisionException
::class,
311 "rev_page field must not be 0!"
314 yield
'no comment' => [
316 'content' => $content,
320 IncompleteRevisionException
::class,
321 "comment must not be NULL!"
324 yield
'no content' => [
330 IncompleteRevisionException
::class,
331 "Uninitialized field: content_address" // XXX: message may change
336 * @dataProvider provideInsertOn_exceptionOnIncomplete
337 * @covers Revision::insertOn
339 public function testInsertOn_exceptionOnIncomplete( $array, $expException, $expMessage ) {
340 // If an ExternalStore is set don't use it.
341 $this->setMwGlobals( 'wgDefaultExternalStore', false );
342 $this->setExpectedException( $expException, $expMessage );
344 $title = Title
::newFromText( 'Nonexistant-' . __METHOD__
);
345 $rev = new Revision( $array, 0, $title );
347 $rev->insertOn( wfGetDB( DB_MASTER
) );
351 * @covers Revision::newFromTitle
353 public function testNewFromTitle_withoutId() {
354 $latestRevId = $this->testPage
->getLatest();
356 $rev = Revision
::newFromTitle( $this->testPage
->getTitle() );
358 $this->assertTrue( $this->testPage
->getTitle()->equals( $rev->getTitle() ) );
359 $this->assertEquals( $latestRevId, $rev->getId() );
363 * @covers Revision::newFromTitle
365 public function testNewFromTitle_withId() {
366 $latestRevId = $this->testPage
->getLatest();
368 $rev = Revision
::newFromTitle( $this->testPage
->getTitle(), $latestRevId );
370 $this->assertTrue( $this->testPage
->getTitle()->equals( $rev->getTitle() ) );
371 $this->assertEquals( $latestRevId, $rev->getId() );
375 * @covers Revision::newFromTitle
377 public function testNewFromTitle_withBadId() {
378 $latestRevId = $this->testPage
->getLatest();
380 $rev = Revision
::newFromTitle( $this->testPage
->getTitle(), $latestRevId +
1 );
382 $this->assertNull( $rev );
386 * @covers Revision::newFromRow
388 public function testNewFromRow() {
389 $orig = $this->makeRevisionWithProps();
391 $dbr = wfGetDB( DB_REPLICA
);
392 $revQuery = Revision
::getQueryInfo();
393 $res = $dbr->select( $revQuery['tables'], $revQuery['fields'], [ 'rev_id' => $orig->getId() ],
394 __METHOD__
, [], $revQuery['joins'] );
395 $this->assertTrue( is_object( $res ), 'query failed' );
397 $row = $res->fetchObject();
400 $rev = Revision
::newFromRow( $row );
402 $this->assertRevEquals( $orig, $rev );
405 public function provideNewFromArchiveRow() {
413 return $f +
[ 'ar_namespace', 'ar_title' ];
418 unset( $f['ar_text_id'] );
424 unset( $f['ar_page_id'] );
430 unset( $f['ar_parent_id'] );
436 unset( $f['ar_rev_id'] );
442 unset( $f['ar_sha1'] );
449 * @dataProvider provideNewFromArchiveRow
450 * @covers Revision::newFromArchiveRow
452 public function testNewFromArchiveRow( $selectModifier ) {
453 $services = MediaWikiServices
::getInstance();
455 $store = new RevisionStore(
456 $services->getDBLoadBalancer(),
457 $services->getService( '_SqlBlobStore' ),
458 $services->getMainWANObjectCache(),
459 $services->getCommentStore(),
460 $services->getContentModelStore(),
461 $services->getSlotRoleStore(),
462 $services->getSlotRoleRegistry(),
463 $this->getMcrMigrationStage(),
464 $services->getActorMigration()
467 $store->setContentHandlerUseDB( $this->getContentHandlerUseDB() );
468 $this->setService( 'RevisionStore', $store );
470 $page = $this->createPage(
471 'RevisionStorageTest_testNewFromArchiveRow',
473 CONTENT_MODEL_WIKITEXT
475 $orig = $page->getRevision();
476 $page->doDeleteArticle( 'test Revision::newFromArchiveRow' );
478 $dbr = wfGetDB( DB_REPLICA
);
479 $arQuery = Revision
::getArchiveQueryInfo();
480 $arQuery['fields'] = $selectModifier( $arQuery['fields'] );
482 $arQuery['tables'], $arQuery['fields'], [ 'ar_rev_id' => $orig->getId() ],
483 __METHOD__
, [], $arQuery['joins']
485 $this->assertTrue( is_object( $res ), 'query failed' );
487 $row = $res->fetchObject();
490 // MCR migration note: $row is now required to contain ar_title and ar_namespace.
491 // Alternatively, a Title object can be passed to RevisionStore::newRevisionFromArchiveRow
492 $rev = Revision
::newFromArchiveRow( $row );
494 $this->assertRevEquals( $orig, $rev );
498 * @covers Revision::newFromArchiveRow
500 public function testNewFromArchiveRowOverrides() {
501 $page = $this->createPage(
502 'RevisionStorageTest_testNewFromArchiveRow',
504 CONTENT_MODEL_WIKITEXT
506 $orig = $page->getRevision();
507 $page->doDeleteArticle( 'test Revision::newFromArchiveRow' );
509 $dbr = wfGetDB( DB_REPLICA
);
510 $arQuery = Revision
::getArchiveQueryInfo();
512 $arQuery['tables'], $arQuery['fields'], [ 'ar_rev_id' => $orig->getId() ],
513 __METHOD__
, [], $arQuery['joins']
515 $this->assertTrue( is_object( $res ), 'query failed' );
517 $row = $res->fetchObject();
520 $rev = Revision
::newFromArchiveRow( $row, [ 'comment_text' => 'SOMEOVERRIDE' ] );
522 $this->assertNotEquals( $orig->getComment(), $rev->getComment() );
523 $this->assertEquals( 'SOMEOVERRIDE', $rev->getComment() );
527 * @covers Revision::newFromId
529 public function testNewFromId() {
530 $orig = $this->testPage
->getRevision();
531 $rev = Revision
::newFromId( $orig->getId() );
532 $this->assertRevEquals( $orig, $rev );
536 * @covers Revision::newFromPageId
538 public function testNewFromPageId() {
539 $rev = Revision
::newFromPageId( $this->testPage
->getId() );
540 $this->assertRevEquals(
541 $this->testPage
->getRevision(),
547 * @covers Revision::newFromPageId
549 public function testNewFromPageIdWithLatestId() {
550 $rev = Revision
::newFromPageId(
551 $this->testPage
->getId(),
552 $this->testPage
->getLatest()
554 $this->assertRevEquals(
555 $this->testPage
->getRevision(),
561 * @covers Revision::newFromPageId
563 public function testNewFromPageIdWithNotLatestId() {
564 $content = new WikitextContent( __METHOD__
);
565 $this->testPage
->doEditContent( $content, __METHOD__
);
566 $rev = Revision
::newFromPageId(
567 $this->testPage
->getId(),
568 $this->testPage
->getRevision()->getPrevious()->getId()
570 $this->assertRevEquals(
571 $this->testPage
->getRevision()->getPrevious(),
577 * @covers Revision::getPage
579 public function testGetPage() {
580 $page = $this->testPage
;
582 $orig = $this->makeRevisionWithProps( [ 'page' => $page->getId() ] );
583 $rev = Revision
::newFromId( $orig->getId() );
585 $this->assertEquals( $page->getId(), $rev->getPage() );
589 * @covers Revision::isCurrent
591 public function testIsCurrent() {
592 $rev1 = $this->testPage
->getRevision();
594 # @todo find out if this should be true
595 # $this->assertTrue( $rev1->isCurrent() );
597 $rev1x = Revision
::newFromId( $rev1->getId() );
598 $this->assertTrue( $rev1x->isCurrent() );
600 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
601 $rev2 = $this->testPage
->getRevision();
603 # @todo find out if this should be true
604 # $this->assertTrue( $rev2->isCurrent() );
606 $rev1x = Revision
::newFromId( $rev1->getId() );
607 $this->assertFalse( $rev1x->isCurrent() );
609 $rev2x = Revision
::newFromId( $rev2->getId() );
610 $this->assertTrue( $rev2x->isCurrent() );
614 * @covers Revision::getPrevious
616 public function testGetPrevious() {
617 $oldestRevision = $this->testPage
->getOldestRevision();
618 $latestRevision = $this->testPage
->getLatest();
620 $this->assertNull( $oldestRevision->getPrevious() );
622 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
623 $newRevision = $this->testPage
->getRevision();
625 $this->assertNotNull( $newRevision->getPrevious() );
626 $this->assertEquals( $latestRevision, $newRevision->getPrevious()->getId() );
630 * @covers Title::getPreviousRevisionID
631 * @covers Title::getRelativeRevisionID
632 * @covers MediaWiki\Revision\RevisionStore::getPreviousRevision
633 * @covers MediaWiki\Revision\RevisionStore::getRelativeRevision
635 public function testTitleGetPreviousRevisionID() {
636 $oldestId = $this->testPage
->getOldestRevision()->getId();
637 $latestId = $this->testPage
->getLatest();
639 $title = $this->testPage
->getTitle();
641 $this->assertFalse( $title->getPreviousRevisionID( $oldestId ) );
643 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
644 $newId = $this->testPage
->getRevision()->getId();
646 $this->assertEquals( $latestId, $title->getPreviousRevisionID( $newId ) );
650 * @covers Title::getPreviousRevisionID
651 * @covers Title::getRelativeRevisionID
653 public function testTitleGetPreviousRevisionID_invalid() {
654 $this->assertFalse( $this->testPage
->getTitle()->getPreviousRevisionID( 123456789 ) );
658 * @covers Revision::getNext
660 public function testGetNext() {
661 $rev1 = $this->testPage
->getRevision();
663 $this->assertNull( $rev1->getNext() );
665 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
666 $rev2 = $this->testPage
->getRevision();
668 $this->assertNotNull( $rev1->getNext() );
669 $this->assertEquals( $rev2->getId(), $rev1->getNext()->getId() );
673 * @covers Title::getNextRevisionID
674 * @covers Title::getRelativeRevisionID
675 * @covers MediaWiki\Revision\RevisionStore::getNextRevision
676 * @covers MediaWiki\Revision\RevisionStore::getRelativeRevision
678 public function testTitleGetNextRevisionID() {
679 $title = $this->testPage
->getTitle();
681 $origId = $this->testPage
->getLatest();
683 $this->assertFalse( $title->getNextRevisionID( $origId ) );
685 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
686 $newId = $this->testPage
->getLatest();
688 $this->assertSame( $this->testPage
->getLatest(), $title->getNextRevisionID( $origId ) );
692 * @covers Title::getNextRevisionID
693 * @covers Title::getRelativeRevisionID
695 public function testTitleGetNextRevisionID_invalid() {
696 $this->assertFalse( $this->testPage
->getTitle()->getNextRevisionID( 123456789 ) );
700 * @covers Revision::newNullRevision
702 public function testNewNullRevision() {
703 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
704 $orig = $this->testPage
->getRevision();
706 $dbw = wfGetDB( DB_MASTER
);
707 $rev = Revision
::newNullRevision( $dbw, $this->testPage
->getId(), 'a null revision', false );
709 $this->assertNotEquals( $orig->getId(), $rev->getId(),
710 'new null revision should have a different id from the original revision' );
711 $this->assertEquals( $orig->getTextId(), $rev->getTextId(),
712 'new null revision should have the same text id as the original revision' );
713 $this->assertEquals( $orig->getSha1(), $rev->getSha1(),
714 'new null revision should have the same SHA1 as the original revision' );
715 $this->assertTrue( $orig->getRevisionRecord()->hasSameContent( $rev->getRevisionRecord() ),
716 'new null revision should have the same content as the original revision' );
717 $this->assertEquals( __METHOD__
, $rev->getContent()->getText() );
721 * @covers Revision::newNullRevision
723 public function testNewNullRevision_badPage() {
724 $dbw = wfGetDB( DB_MASTER
);
725 $rev = Revision
::newNullRevision( $dbw, -1, 'a null revision', false );
727 $this->assertNull( $rev );
731 * @covers Revision::insertOn
733 public function testInsertOn() {
734 $ip = '2600:387:ed7:947e:8c16:a1ad:dd34:1dd7';
736 $orig = $this->makeRevisionWithProps( [
740 // Make sure the revision was copied to ip_changes
741 $dbr = wfGetDB( DB_REPLICA
);
742 $res = $dbr->select( 'ip_changes', '*', [ 'ipc_rev_id' => $orig->getId() ] );
743 $row = $res->fetchObject();
745 $this->assertEquals( IP
::toHex( $ip ), $row->ipc_hex
);
747 $orig->getTimestamp(),
748 wfTimestamp( TS_MW
, $row->ipc_rev_timestamp
)
752 public static function provideUserWasLastToEdit() {
753 yield
'actually the last edit' => [ 3, true ];
754 yield
'not the current edit, but still by this user' => [ 2, true ];
755 yield
'edit by another user' => [ 1, false ];
756 yield
'first edit, by this user, but another user edited in the mean time' => [ 0, false ];
760 * @covers Revision::userWasLastToEdit
761 * @dataProvider provideUserWasLastToEdit
763 public function testUserWasLastToEdit( $sinceIdx, $expectedLast ) {
764 $userA = User
::newFromName( "RevisionStorageTest_userA" );
765 $userB = User
::newFromName( "RevisionStorageTest_userB" );
767 if ( $userA->getId() === 0 ) {
768 $userA = User
::createNew( $userA->getName() );
771 if ( $userB->getId() === 0 ) {
772 $userB = User
::createNew( $userB->getName() );
775 $ns = $this->getDefaultWikitextNS();
777 $dbw = wfGetDB( DB_MASTER
);
780 // create revisions -----------------------------
781 $page = WikiPage
::factory( Title
::newFromText(
782 'RevisionStorageTest_testUserWasLastToEdit', $ns ) );
783 $page->insertOn( $dbw );
785 $revisions[0] = new Revision( [
786 'page' => $page->getId(),
787 // we need the title to determine the page's default content model
788 'title' => $page->getTitle(),
789 'timestamp' => '20120101000000',
790 'user' => $userA->getId(),
792 'content_model' => CONTENT_MODEL_WIKITEXT
,
793 'comment' => 'edit zero'
795 $revisions[0]->insertOn( $dbw );
797 $revisions[1] = new Revision( [
798 'page' => $page->getId(),
799 // still need the title, because $page->getId() is 0 (there's no entry in the page table)
800 'title' => $page->getTitle(),
801 'timestamp' => '20120101000100',
802 'user' => $userA->getId(),
804 'content_model' => CONTENT_MODEL_WIKITEXT
,
805 'comment' => 'edit one'
807 $revisions[1]->insertOn( $dbw );
809 $revisions[2] = new Revision( [
810 'page' => $page->getId(),
811 'title' => $page->getTitle(),
812 'timestamp' => '20120101000200',
813 'user' => $userB->getId(),
815 'content_model' => CONTENT_MODEL_WIKITEXT
,
816 'comment' => 'edit two'
818 $revisions[2]->insertOn( $dbw );
820 $revisions[3] = new Revision( [
821 'page' => $page->getId(),
822 'title' => $page->getTitle(),
823 'timestamp' => '20120101000300',
824 'user' => $userA->getId(),
826 'content_model' => CONTENT_MODEL_WIKITEXT
,
827 'comment' => 'edit three'
829 $revisions[3]->insertOn( $dbw );
831 $revisions[4] = new Revision( [
832 'page' => $page->getId(),
833 'title' => $page->getTitle(),
834 'timestamp' => '20120101000200',
835 'user' => $userA->getId(),
837 'content_model' => CONTENT_MODEL_WIKITEXT
,
838 'comment' => 'edit four'
840 $revisions[4]->insertOn( $dbw );
842 // test it ---------------------------------
843 $since = $revisions[$sinceIdx]->getTimestamp();
845 $revQuery = Revision
::getQueryInfo();
846 $allRows = iterator_to_array( $dbw->select(
848 [ 'rev_id', 'rev_timestamp', 'rev_user' => $revQuery['fields']['rev_user'] ],
850 'rev_page' => $page->getId(),
851 //'rev_timestamp > ' . $dbw->addQuotes( $dbw->timestamp( $since ) )
854 [ 'ORDER BY' => 'rev_timestamp ASC', 'LIMIT' => 50 ],
858 $wasLast = Revision
::userWasLastToEdit( $dbw, $page->getId(), $userA->getId(), $since );
860 $this->assertEquals( $expectedLast, $wasLast );
864 * @param string $text
865 * @param string $title
866 * @param string $model
867 * @param string $format
871 private function newTestRevision( $text, $title = "Test",
872 $model = CONTENT_MODEL_WIKITEXT
, $format = null
874 if ( is_string( $title ) ) {
875 $title = Title
::newFromText( $title );
878 $content = ContentHandler
::makeContent( $text, $title, $model, $format );
886 'content' => $content,
887 'length' => $content->getSize(),
888 'comment' => "testing",
889 'minor_edit' => false,
891 'content_format' => $format,
898 public function provideGetContentModel() {
899 // NOTE: we expect the help namespace to always contain wikitext
901 [ 'hello world', 'Help:Hello', null, null, CONTENT_MODEL_WIKITEXT
],
902 [ 'hello world', 'User:hello/there.css', null, null, CONTENT_MODEL_CSS
],
903 [ serialize( 'hello world' ), 'Dummy:Hello', null, null, DummyContentForTesting
::MODEL_ID
],
908 * @dataProvider provideGetContentModel
909 * @covers Revision::getContentModel
911 public function testGetContentModel( $text, $title, $model, $format, $expectedModel ) {
912 $rev = $this->newTestRevision( $text, $title, $model, $format );
914 $this->assertEquals( $expectedModel, $rev->getContentModel() );
917 public function provideGetContentFormat() {
918 // NOTE: we expect the help namespace to always contain wikitext
920 [ 'hello world', 'Help:Hello', null, null, CONTENT_FORMAT_WIKITEXT
],
921 [ 'hello world', 'Help:Hello', CONTENT_MODEL_CSS
, null, CONTENT_FORMAT_CSS
],
922 [ 'hello world', 'User:hello/there.css', null, null, CONTENT_FORMAT_CSS
],
923 [ serialize( 'hello world' ), 'Dummy:Hello', null, null, DummyContentForTesting
::MODEL_ID
],
928 * @dataProvider provideGetContentFormat
929 * @covers Revision::getContentFormat
931 public function testGetContentFormat( $text, $title, $model, $format, $expectedFormat ) {
932 $rev = $this->newTestRevision( $text, $title, $model, $format );
934 $this->assertEquals( $expectedFormat, $rev->getContentFormat() );
937 public function provideGetContentHandler() {
938 // NOTE: we expect the help namespace to always contain wikitext
940 [ 'hello world', 'Help:Hello', null, null, WikitextContentHandler
::class ],
941 [ 'hello world', 'User:hello/there.css', null, null, CssContentHandler
::class ],
942 [ serialize( 'hello world' ), 'Dummy:Hello', null, null, DummyContentHandlerForTesting
::class ],
947 * @dataProvider provideGetContentHandler
948 * @covers Revision::getContentHandler
950 public function testGetContentHandler( $text, $title, $model, $format, $expectedClass ) {
951 $rev = $this->newTestRevision( $text, $title, $model, $format );
953 $this->assertEquals( $expectedClass, get_class( $rev->getContentHandler() ) );
956 public function provideGetContent() {
957 // NOTE: we expect the help namespace to always contain wikitext
959 [ 'hello world', 'Help:Hello', null, null, Revision
::FOR_PUBLIC
, 'hello world' ],
961 serialize( 'hello world' ),
963 DummyContentForTesting
::MODEL_ID
,
965 Revision
::FOR_PUBLIC
,
966 serialize( 'hello world' )
969 serialize( 'hello world' ),
973 Revision
::FOR_PUBLIC
,
974 serialize( 'hello world' )
980 * @dataProvider provideGetContent
981 * @covers Revision::getContent
983 public function testGetContent( $text, $title, $model, $format,
984 $audience, $expectedSerialization
986 $rev = $this->newTestRevision( $text, $title, $model, $format );
987 $content = $rev->getContent( $audience );
990 $expectedSerialization,
991 is_null( $content ) ?
null : $content->serialize( $format )
996 * @covers Revision::getContent
998 public function testGetContent_failure() {
999 $rev = new Revision( [
1000 'page' => $this->testPage
->getId(),
1001 'content_model' => $this->testPage
->getContentModel(),
1002 'id' => 123456789, // not in the test DB
1005 Wikimedia\
suppressWarnings(); // bad text_id will trigger a warning.
1007 $this->assertNull( $rev->getContent(),
1008 "getContent() should return null if the revision's text blob could not be loaded." );
1010 // NOTE: check this twice, once for lazy initialization, and once with the cached value.
1011 $this->assertNull( $rev->getContent(),
1012 "getContent() should return null if the revision's text blob could not be loaded." );
1014 Wikimedia\restoreWarnings
();
1017 public function provideGetSize() {
1019 [ "hello world.", CONTENT_MODEL_WIKITEXT
, 12 ],
1020 [ serialize( "hello world." ), DummyContentForTesting
::MODEL_ID
, 12 ],
1025 * @covers Revision::getSize
1026 * @dataProvider provideGetSize
1028 public function testGetSize( $text, $model, $expected_size ) {
1029 $rev = $this->newTestRevision( $text, 'RevisionTest_testGetSize', $model );
1030 $this->assertEquals( $expected_size, $rev->getSize() );
1033 public function provideGetSha1() {
1035 [ "hello world.", CONTENT_MODEL_WIKITEXT
, Revision
::base36Sha1( "hello world." ) ],
1037 serialize( "hello world." ),
1038 DummyContentForTesting
::MODEL_ID
,
1039 Revision
::base36Sha1( serialize( "hello world." ) )
1045 * @covers Revision::getSha1
1046 * @dataProvider provideGetSha1
1048 public function testGetSha1( $text, $model, $expected_hash ) {
1049 $rev = $this->newTestRevision( $text, 'RevisionTest_testGetSha1', $model );
1050 $this->assertEquals( $expected_hash, $rev->getSha1() );
1054 * Tests whether $rev->getContent() returns a clone when needed.
1056 * @covers Revision::getContent
1058 public function testGetContentClone() {
1059 $content = new RevisionTestModifyableContent( "foo" );
1061 $rev = new Revision(
1065 'title' => Title
::newFromText( "testGetContentClone_dummy" ),
1067 'content' => $content,
1068 'length' => $content->getSize(),
1069 'comment' => "testing",
1070 'minor_edit' => false,
1074 /** @var RevisionTestModifyableContent $content */
1075 $content = $rev->getContent( Revision
::RAW
);
1076 $content->setText( "bar" );
1078 /** @var RevisionTestModifyableContent $content2 */
1079 $content2 = $rev->getContent( Revision
::RAW
);
1080 // content is mutable, expect clone
1081 $this->assertNotSame( $content, $content2, "expected a clone" );
1082 // clone should contain the original text
1083 $this->assertEquals( "foo", $content2->getText() );
1085 $content2->setText( "bla bla" );
1086 // clones should be independent
1087 $this->assertEquals( "bar", $content->getText() );
1091 * Tests whether $rev->getContent() returns the same object repeatedly if appropriate.
1092 * @covers Revision::getContent
1094 public function testGetContentUncloned() {
1095 $rev = $this->newTestRevision( "hello", "testGetContentUncloned_dummy", CONTENT_MODEL_WIKITEXT
);
1096 $content = $rev->getContent( Revision
::RAW
);
1097 $content2 = $rev->getContent( Revision
::RAW
);
1099 // for immutable content like wikitext, this should be the same object
1100 $this->assertSame( $content, $content2 );
1104 * @covers Revision::loadFromId
1106 public function testLoadFromId() {
1107 $rev = $this->testPage
->getRevision();
1108 $this->hideDeprecated( 'Revision::loadFromId' );
1109 $this->assertRevEquals(
1111 Revision
::loadFromId( wfGetDB( DB_MASTER
), $rev->getId() )
1116 * @covers Revision::loadFromPageId
1118 public function testLoadFromPageId() {
1119 $this->assertRevEquals(
1120 $this->testPage
->getRevision(),
1121 Revision
::loadFromPageId( wfGetDB( DB_MASTER
), $this->testPage
->getId() )
1126 * @covers Revision::loadFromPageId
1128 public function testLoadFromPageIdWithLatestRevId() {
1129 $this->assertRevEquals(
1130 $this->testPage
->getRevision(),
1131 Revision
::loadFromPageId(
1132 wfGetDB( DB_MASTER
),
1133 $this->testPage
->getId(),
1134 $this->testPage
->getLatest()
1140 * @covers Revision::loadFromPageId
1142 public function testLoadFromPageIdWithNotLatestRevId() {
1143 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
1144 $this->assertRevEquals(
1145 $this->testPage
->getRevision()->getPrevious(),
1146 Revision
::loadFromPageId(
1147 wfGetDB( DB_MASTER
),
1148 $this->testPage
->getId(),
1149 $this->testPage
->getRevision()->getPrevious()->getId()
1155 * @covers Revision::loadFromTitle
1157 public function testLoadFromTitle() {
1158 $this->assertRevEquals(
1159 $this->testPage
->getRevision(),
1160 Revision
::loadFromTitle( wfGetDB( DB_MASTER
), $this->testPage
->getTitle() )
1165 * @covers Revision::loadFromTitle
1167 public function testLoadFromTitleWithLatestRevId() {
1168 $this->assertRevEquals(
1169 $this->testPage
->getRevision(),
1170 Revision
::loadFromTitle(
1171 wfGetDB( DB_MASTER
),
1172 $this->testPage
->getTitle(),
1173 $this->testPage
->getLatest()
1179 * @covers Revision::loadFromTitle
1181 public function testLoadFromTitleWithNotLatestRevId() {
1182 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
1183 $this->assertRevEquals(
1184 $this->testPage
->getRevision()->getPrevious(),
1185 Revision
::loadFromTitle(
1186 wfGetDB( DB_MASTER
),
1187 $this->testPage
->getTitle(),
1188 $this->testPage
->getRevision()->getPrevious()->getId()
1194 * @covers Revision::loadFromTimestamp()
1196 public function testLoadFromTimestamp() {
1197 $this->assertRevEquals(
1198 $this->testPage
->getRevision(),
1199 Revision
::loadFromTimestamp(
1200 wfGetDB( DB_MASTER
),
1201 $this->testPage
->getTitle(),
1202 $this->testPage
->getRevision()->getTimestamp()
1208 * @covers Revision::getParentLengths
1210 public function testGetParentLengths_noRevIds() {
1213 Revision
::getParentLengths(
1214 wfGetDB( DB_MASTER
),
1221 * @covers Revision::getParentLengths
1223 public function testGetParentLengths_oneRevId() {
1224 $text = '831jr091jr0921kr21kr0921kjr0921j09rj1';
1225 $textLength = strlen( $text );
1227 $this->testPage
->doEditContent( new WikitextContent( $text ), __METHOD__
);
1228 $rev[1] = $this->testPage
->getLatest();
1231 [ $rev[1] => $textLength ],
1232 Revision
::getParentLengths(
1233 wfGetDB( DB_MASTER
),
1240 * @covers Revision::getParentLengths
1242 public function testGetParentLengths_multipleRevIds() {
1243 $textOne = '831jr091jr0921kr21kr0921kjr0921j09rj1';
1244 $textOneLength = strlen( $textOne );
1245 $textTwo = '831jr091jr092121j09rj1';
1246 $textTwoLength = strlen( $textTwo );
1248 $this->testPage
->doEditContent( new WikitextContent( $textOne ), __METHOD__
);
1249 $rev[1] = $this->testPage
->getLatest();
1250 $this->testPage
->doEditContent( new WikitextContent( $textTwo ), __METHOD__
);
1251 $rev[2] = $this->testPage
->getLatest();
1254 [ $rev[1] => $textOneLength, $rev[2] => $textTwoLength ],
1255 Revision
::getParentLengths(
1256 wfGetDB( DB_MASTER
),
1257 [ $rev[1], $rev[2] ]
1263 * @covers Revision::getTitle
1265 public function testGetTitle_fromExistingRevision() {
1267 $this->testPage
->getTitle()->equals(
1268 $this->testPage
->getRevision()->getTitle()
1274 * @covers Revision::getTitle
1276 public function testGetTitle_fromRevisionWhichWillLoadTheTitle() {
1277 $rev = new Revision( [ 'id' => $this->testPage
->getLatest() ] );
1279 $this->testPage
->getTitle()->equals(
1286 * @covers Revision::isMinor
1288 public function testIsMinor_true() {
1289 // Use a sysop to ensure we can mark edits as minor
1290 $sysop = $this->getTestSysop()->getUser();
1292 $this->testPage
->doEditContent(
1293 new WikitextContent( __METHOD__
),
1299 $rev = $this->testPage
->getRevision();
1301 $this->assertSame( true, $rev->isMinor() );
1305 * @covers Revision::isMinor
1307 public function testIsMinor_false() {
1308 $this->testPage
->doEditContent(
1309 new WikitextContent( __METHOD__
),
1313 $rev = $this->testPage
->getRevision();
1315 $this->assertSame( false, $rev->isMinor() );
1319 * @covers Revision::getTimestamp
1321 public function testGetTimestamp() {
1322 $testTimestamp = wfTimestampNow();
1324 $this->testPage
->doEditContent(
1325 new WikitextContent( __METHOD__
),
1328 $rev = $this->testPage
->getRevision();
1330 $this->assertInternalType( 'string', $rev->getTimestamp() );
1331 $this->assertTrue( strlen( $rev->getTimestamp() ) == strlen( 'YYYYMMDDHHMMSS' ) );
1332 $this->assertContains( substr( $testTimestamp, 0, 10 ), $rev->getTimestamp() );
1336 * @covers Revision::getUser
1337 * @covers Revision::getUserText
1339 public function testGetUserAndText() {
1340 $sysop = $this->getTestSysop()->getUser();
1342 $this->testPage
->doEditContent(
1343 new WikitextContent( __METHOD__
),
1349 $rev = $this->testPage
->getRevision();
1351 $this->assertSame( $sysop->getId(), $rev->getUser() );
1352 $this->assertSame( $sysop->getName(), $rev->getUserText() );
1356 * @covers Revision::isDeleted
1358 public function testIsDeleted_nothingDeleted() {
1359 $rev = $this->testPage
->getRevision();
1361 $this->assertSame( false, $rev->isDeleted( Revision
::DELETED_TEXT
) );
1362 $this->assertSame( false, $rev->isDeleted( Revision
::DELETED_COMMENT
) );
1363 $this->assertSame( false, $rev->isDeleted( Revision
::DELETED_RESTRICTED
) );
1364 $this->assertSame( false, $rev->isDeleted( Revision
::DELETED_USER
) );
1368 * @covers Revision::getVisibility
1370 public function testGetVisibility_nothingDeleted() {
1371 $rev = $this->testPage
->getRevision();
1373 $this->assertSame( 0, $rev->getVisibility() );
1377 * @covers Revision::getComment
1379 public function testGetComment_notDeleted() {
1380 $expectedSummary = 'goatlicious summary';
1382 $this->testPage
->doEditContent(
1383 new WikitextContent( __METHOD__
),
1386 $rev = $this->testPage
->getRevision();
1388 $this->assertSame( $expectedSummary, $rev->getComment() );
1392 * @covers Revision::isUnpatrolled
1394 public function testIsUnpatrolled_returnsRecentChangesId() {
1395 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
1396 $rev = $this->testPage
->getRevision();
1398 $this->assertGreaterThan( 0, $rev->isUnpatrolled() );
1399 $this->assertSame( $rev->getRecentChange()->getAttribute( 'rc_id' ), $rev->isUnpatrolled() );
1403 * @covers Revision::isUnpatrolled
1405 public function testIsUnpatrolled_returnsZeroIfPatrolled() {
1406 // This assumes that sysops are auto patrolled
1407 $sysop = $this->getTestSysop()->getUser();
1408 $this->testPage
->doEditContent(
1409 new WikitextContent( __METHOD__
),
1415 $rev = $this->testPage
->getRevision();
1417 $this->assertSame( 0, $rev->isUnpatrolled() );
1421 * This is a simple blanket test for all simple content getters and is methods to provide some
1422 * coverage before the split of Revision into multiple classes for MCR work.
1423 * @covers Revision::getContent
1424 * @covers Revision::getSerializedData
1425 * @covers Revision::getContentModel
1426 * @covers Revision::getContentFormat
1427 * @covers Revision::getContentHandler
1429 public function testSimpleContentGetters() {
1430 $expectedText = 'testSimpleContentGetters in Revision. Goats love MCR...';
1431 $expectedSummary = 'goatlicious testSimpleContentGetters summary';
1433 $this->testPage
->doEditContent(
1434 new WikitextContent( $expectedText ),
1437 $rev = $this->testPage
->getRevision();
1439 $this->assertSame( $expectedText, $rev->getContent()->getText() );
1440 $this->assertSame( $expectedText, $rev->getSerializedData() );
1441 $this->assertSame( $this->testPage
->getContentModel(), $rev->getContentModel() );
1442 $this->assertSame( $this->testPage
->getContent()->getDefaultFormat(), $rev->getContentFormat() );
1443 $this->assertSame( $this->testPage
->getContentHandler(), $rev->getContentHandler() );
1447 * @covers Revision::newKnownCurrent
1449 public function testNewKnownCurrent() {
1450 // Setup the services
1451 $this->overrideMwServices();
1452 $cache = new WANObjectCache( [ 'cache' => new HashBagOStuff() ] );
1453 $this->setService( 'MainWANObjectCache', $cache );
1454 $db = wfGetDB( DB_MASTER
);
1457 $cache->setMockTime( $now );
1459 // Get a fresh revision to use during testing
1460 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
1461 $rev = $this->testPage
->getRevision();
1463 // Clear any previous cache for the revision during creation
1464 $key = $cache->makeGlobalKey(
1465 RevisionStore
::ROW_CACHE_KEY
,
1470 $cache->delete( $key, WANObjectCache
::HOLDOFF_NONE
);
1471 $this->assertFalse( $cache->get( $key ) );
1475 // Get the new revision and make sure it is in the cache and correct
1476 $newRev = Revision
::newKnownCurrent( $db, $rev->getPage(), $rev->getId() );
1477 $this->assertRevEquals( $rev, $newRev );
1479 $cachedRow = $cache->get( $key );
1480 $this->assertNotFalse( $cachedRow );
1481 $this->assertEquals( $rev->getId(), $cachedRow->rev_id
);
1484 public function testNewKnownCurrent_withPageId() {
1485 $db = wfGetDB( DB_MASTER
);
1487 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
1488 $rev = $this->testPage
->getRevision();
1490 $pageId = $this->testPage
->getId();
1492 $newRev = Revision
::newKnownCurrent( $db, $pageId, $rev->getId() );
1493 $this->assertRevEquals( $rev, $newRev );
1496 public function testNewKnownCurrent_returnsFalseWhenTitleDoesntExist() {
1497 $db = wfGetDB( DB_MASTER
);
1499 $this->assertFalse( Revision
::newKnownCurrent( $db, 0 ) );
1502 public function provideUserCanBitfield() {
1503 yield
[ 0, 0, [], null, true ];
1504 // Bitfields match, user has no permissions
1505 yield
[ Revision
::DELETED_TEXT
, Revision
::DELETED_TEXT
, [], null, false ];
1506 yield
[ Revision
::DELETED_COMMENT
, Revision
::DELETED_COMMENT
, [], null, false ];
1507 yield
[ Revision
::DELETED_USER
, Revision
::DELETED_USER
, [], null, false ];
1508 yield
[ Revision
::DELETED_RESTRICTED
, Revision
::DELETED_RESTRICTED
, [], null, false ];
1509 // Bitfields match, user (admin) does have permissions
1510 yield
[ Revision
::DELETED_TEXT
, Revision
::DELETED_TEXT
, [ 'sysop' ], null, true ];
1511 yield
[ Revision
::DELETED_COMMENT
, Revision
::DELETED_COMMENT
, [ 'sysop' ], null, true ];
1512 yield
[ Revision
::DELETED_USER
, Revision
::DELETED_USER
, [ 'sysop' ], null, true ];
1513 // Bitfields match, user (admin) does not have permissions
1514 yield
[ Revision
::DELETED_RESTRICTED
, Revision
::DELETED_RESTRICTED
, [ 'sysop' ], null, false ];
1515 // Bitfields match, user (oversight) does have permissions
1516 yield
[ Revision
::DELETED_RESTRICTED
, Revision
::DELETED_RESTRICTED
, [ 'oversight' ], null, true ];
1517 // Check permissions using the title
1519 Revision
::DELETED_TEXT
,
1520 Revision
::DELETED_TEXT
,
1526 Revision
::DELETED_TEXT
,
1527 Revision
::DELETED_TEXT
,
1535 * @dataProvider provideUserCanBitfield
1536 * @covers Revision::userCanBitfield
1538 public function testUserCanBitfield( $bitField, $field, $userGroups, $title, $expected ) {
1539 $title = Title
::newFromText( $title );
1541 $this->setMwGlobals(
1542 'wgGroupPermissions',
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->setMwGlobals(
1595 'wgGroupPermissions',
1598 'deletedtext' => true,
1599 'deletedhistory' => true,
1602 'viewsuppressed' => true,
1603 'suppressrevision' => true,
1607 $user = $this->getTestUser( $userGroups )->getUser();
1608 $revision = new Revision( [ 'deleted' => $bitField ], 0, $this->testPage
->getTitle() );
1612 $revision->userCan( $field, $user )
1616 public function provideGetTextId() {
1619 $slot = new SlotRecord( (object)[
1620 'slot_revision_id' => 42,
1621 'slot_content_id' => 1,
1622 'content_address' => 'tt:789',
1623 'model_name' => CONTENT_MODEL_WIKITEXT
,
1624 'role_name' => SlotRecord
::MAIN
,
1626 ], new WikitextContent( 'Test' ) );
1628 $rec = new MutableRevisionRecord( $this->testPage
->getTitle() );
1630 $rec->setSlot( $slot );
1632 yield
[ $rec, 789 ];
1636 * @dataProvider provideGetTextId
1637 * @covers Revision::getTextId()
1639 public function testGetTextId( $spec, $expected ) {
1640 $rev = new Revision( $spec, 0, $this->testPage
->getTitle() );
1641 $this->assertSame( $expected, $rev->getTextId() );
1644 abstract public function provideGetRevisionText();
1647 * @dataProvider provideGetRevisionText
1648 * @covers Revision::getRevisionText
1650 public function testGetRevisionText( array $queryInfoOptions, array $queryInfoExtra = [] ) {
1651 $rev = $this->testPage
->getRevisionRecord();
1653 $queryInfo = Revision
::getQueryInfo( $queryInfoOptions );
1654 $queryInfo['tables'] = array_merge( $queryInfo['tables'], $queryInfoExtra['tables'] ??
[] );
1655 $queryInfo['fields'] = array_merge( $queryInfo['fields'], $queryInfoExtra['fields'] ??
[] );
1656 $queryInfo['joins'] = array_merge( $queryInfo['joins'], $queryInfoExtra['joins'] ??
[] );
1658 $conds = [ 'rev_id' => $rev->getId() ];
1659 $row = $this->db
->selectRow(
1660 $queryInfo['tables'],
1661 $queryInfo['fields'],
1668 $expected = $rev->getContent( SlotRecord
::MAIN
)->serialize();
1670 $this->hideDeprecated( 'Revision::getRevisionText (MCR without SCHEMA_COMPAT_WRITE_OLD)' );
1671 $this->assertSame( $expected, Revision
::getRevisionText( $row ) );