4 * @group ContentHandler
9 class RevisionIntegrationTest
extends MediaWikiTestCase
{
12 * @var WikiPage $testPage
16 public function __construct( $name = null, array $data = [], $dataName = '' ) {
17 parent
::__construct( $name, $data, $dataName );
19 $this->tablesUsed
= array_merge( $this->tablesUsed
,
42 protected function setUp() {
47 $this->mergeMwGlobalArrayValue(
51 12313 => 'Dummy_talk',
55 $this->mergeMwGlobalArrayValue(
56 'wgNamespaceContentModels',
58 12312 => DummyContentForTesting
::MODEL_ID
,
62 $this->mergeMwGlobalArrayValue(
65 DummyContentForTesting
::MODEL_ID
=> 'DummyContentHandlerForTesting',
66 RevisionTestModifyableContent
::MODEL_ID
=> 'RevisionTestModifyableContentHandler',
70 MWNamespace
::clearCaches();
71 // Reset namespace cache
72 $wgContLang->resetNamespaces();
73 if ( !$this->testPage
) {
74 $this->testPage
= WikiPage
::factory( Title
::newFromText( 'UTPage' ) );
78 protected function tearDown() {
83 MWNamespace
::clearCaches();
84 // Reset namespace cache
85 $wgContLang->resetNamespaces();
88 private function makeRevisionWithProps( $props = null ) {
89 if ( $props === null ) {
93 if ( !isset( $props['content'] ) && !isset( $props['text'] ) ) {
94 $props['text'] = 'Lorem Ipsum';
97 if ( !isset( $props['comment'] ) ) {
98 $props['comment'] = 'just a test';
101 if ( !isset( $props['page'] ) ) {
102 $props['page'] = $this->testPage
->getId();
105 $rev = new Revision( $props );
107 $dbw = wfGetDB( DB_MASTER
);
108 $rev->insertOn( $dbw );
114 * @param string $titleString
115 * @param string $text
116 * @param string|null $model
120 private function createPage( $titleString, $text, $model = null ) {
121 if ( !preg_match( '/:/', $titleString ) &&
122 ( $model === null ||
$model === CONTENT_MODEL_WIKITEXT
)
124 $ns = $this->getDefaultWikitextNS();
125 $titleString = MWNamespace
::getCanonicalName( $ns ) . ':' . $titleString;
128 $title = Title
::newFromText( $titleString );
129 $wikipage = new WikiPage( $title );
131 // Delete the article if it already exists
132 if ( $wikipage->exists() ) {
133 $wikipage->doDeleteArticle( "done" );
136 $content = ContentHandler
::makeContent( $text, $title, $model );
137 $wikipage->doEditContent( $content, __METHOD__
, EDIT_NEW
);
142 private function assertRevEquals( Revision
$orig, Revision
$rev = null ) {
143 $this->assertNotNull( $rev, 'missing revision' );
145 $this->assertEquals( $orig->getId(), $rev->getId() );
146 $this->assertEquals( $orig->getPage(), $rev->getPage() );
147 $this->assertEquals( $orig->getTimestamp(), $rev->getTimestamp() );
148 $this->assertEquals( $orig->getUser(), $rev->getUser() );
149 $this->assertEquals( $orig->getContentModel(), $rev->getContentModel() );
150 $this->assertEquals( $orig->getContentFormat(), $rev->getContentFormat() );
151 $this->assertEquals( $orig->getSha1(), $rev->getSha1() );
155 * @covers Revision::insertOn
157 public function testInsertOn_success() {
158 $parentId = $this->testPage
->getLatest();
160 // If an ExternalStore is set don't use it.
161 $this->setMwGlobals( 'wgDefaultExternalStore', false );
163 $rev = new Revision( [
164 'page' => $this->testPage
->getId(),
165 'title' => $this->testPage
->getTitle(),
166 'text' => 'Revision Text',
167 'comment' => 'Revision comment',
170 $revId = $rev->insertOn( wfGetDB( DB_MASTER
) );
172 $this->assertInternalType( 'integer', $revId );
173 $this->assertInternalType( 'integer', $rev->getTextId() );
174 $this->assertSame( $revId, $rev->getId() );
178 [ 'old_id', 'old_text' ],
179 "old_id = {$rev->getTextId()}",
180 [ [ strval( $rev->getTextId() ), 'Revision Text' ] ]
195 "rev_id = {$rev->getId()}",
197 strval( $rev->getId() ),
198 strval( $this->testPage
->getId() ),
199 strval( $rev->getTextId() ),
205 's0ngbdoxagreuf2vjtuxzwdz64n29xm',
211 * @covers Revision::insertOn
213 public function testInsertOn_exceptionOnNoPage() {
214 // If an ExternalStore is set don't use it.
215 $this->setMwGlobals( 'wgDefaultExternalStore', false );
216 $this->setExpectedException(
218 "Cannot insert revision: page ID must be nonzero"
221 $rev = new Revision( [] );
223 $rev->insertOn( wfGetDB( DB_MASTER
) );
227 * @covers Revision::newFromTitle
229 public function testNewFromTitle_withoutId() {
230 $latestRevId = $this->testPage
->getLatest();
232 $rev = Revision
::newFromTitle( $this->testPage
->getTitle() );
234 $this->assertTrue( $this->testPage
->getTitle()->equals( $rev->getTitle() ) );
235 $this->assertEquals( $latestRevId, $rev->getId() );
239 * @covers Revision::newFromTitle
241 public function testNewFromTitle_withId() {
242 $latestRevId = $this->testPage
->getLatest();
244 $rev = Revision
::newFromTitle( $this->testPage
->getTitle(), $latestRevId );
246 $this->assertTrue( $this->testPage
->getTitle()->equals( $rev->getTitle() ) );
247 $this->assertEquals( $latestRevId, $rev->getId() );
251 * @covers Revision::newFromTitle
253 public function testNewFromTitle_withBadId() {
254 $latestRevId = $this->testPage
->getLatest();
256 $rev = Revision
::newFromTitle( $this->testPage
->getTitle(), $latestRevId +
1 );
258 $this->assertNull( $rev );
262 * @covers Revision::newFromRow
264 public function testNewFromRow() {
265 $orig = $this->makeRevisionWithProps();
267 $dbr = wfGetDB( DB_REPLICA
);
268 $res = $dbr->select( 'revision', Revision
::selectFields(), [ 'rev_id' => $orig->getId() ] );
269 $this->assertTrue( is_object( $res ), 'query failed' );
271 $row = $res->fetchObject();
274 $rev = Revision
::newFromRow( $row );
276 $this->assertRevEquals( $orig, $rev );
279 public function provideNewFromArchiveRow() {
295 return $f +
[ 'ar_namespace', 'ar_title' ];
301 return $f +
[ 'ar_namespace', 'ar_title' ];
307 unset( $f['ar_text_id'] );
314 unset( $f['ar_text_id'] );
321 * @dataProvider provideNewFromArchiveRow
322 * @covers Revision::newFromArchiveRow
324 public function testNewFromArchiveRow( $contentHandlerUseDB, $selectModifier ) {
325 $this->setMwGlobals( 'wgContentHandlerUseDB', $contentHandlerUseDB );
327 $page = $this->createPage(
328 'RevisionStorageTest_testNewFromArchiveRow',
330 CONTENT_MODEL_WIKITEXT
332 $orig = $page->getRevision();
333 $page->doDeleteArticle( 'test Revision::newFromArchiveRow' );
335 $dbr = wfGetDB( DB_REPLICA
);
336 $selectFields = $selectModifier( Revision
::selectArchiveFields() );
338 'archive', $selectFields, [ 'ar_rev_id' => $orig->getId() ]
340 $this->assertTrue( is_object( $res ), 'query failed' );
342 $row = $res->fetchObject();
345 $rev = Revision
::newFromArchiveRow( $row );
347 $this->assertRevEquals( $orig, $rev );
351 * @covers Revision::newFromArchiveRow
353 public function testNewFromArchiveRowOverrides() {
354 $page = $this->createPage(
355 'RevisionStorageTest_testNewFromArchiveRow',
357 CONTENT_MODEL_WIKITEXT
359 $orig = $page->getRevision();
360 $page->doDeleteArticle( 'test Revision::newFromArchiveRow' );
362 $dbr = wfGetDB( DB_REPLICA
);
364 'archive', Revision
::selectArchiveFields(), [ 'ar_rev_id' => $orig->getId() ]
366 $this->assertTrue( is_object( $res ), 'query failed' );
368 $row = $res->fetchObject();
371 $rev = Revision
::newFromArchiveRow( $row, [ 'comment' => 'SOMEOVERRIDE' ] );
373 $this->assertNotEquals( $orig->getComment(), $rev->getComment() );
374 $this->assertEquals( 'SOMEOVERRIDE', $rev->getComment() );
378 * @covers Revision::newFromId
380 public function testNewFromId() {
381 $orig = $this->testPage
->getRevision();
382 $rev = Revision
::newFromId( $orig->getId() );
383 $this->assertRevEquals( $orig, $rev );
387 * @covers Revision::newFromPageId
389 public function testNewFromPageId() {
390 $rev = Revision
::newFromPageId( $this->testPage
->getId() );
391 $this->assertRevEquals(
392 $this->testPage
->getRevision(),
398 * @covers Revision::newFromPageId
400 public function testNewFromPageIdWithLatestId() {
401 $rev = Revision
::newFromPageId(
402 $this->testPage
->getId(),
403 $this->testPage
->getLatest()
405 $this->assertRevEquals(
406 $this->testPage
->getRevision(),
412 * @covers Revision::newFromPageId
414 public function testNewFromPageIdWithNotLatestId() {
415 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
416 $rev = Revision
::newFromPageId(
417 $this->testPage
->getId(),
418 $this->testPage
->getRevision()->getPrevious()->getId()
420 $this->assertRevEquals(
421 $this->testPage
->getRevision()->getPrevious(),
427 * @covers Revision::fetchRevision
429 public function testFetchRevision() {
430 // Hidden process cache assertion below
431 $this->testPage
->getRevision()->getId();
433 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
434 $id = $this->testPage
->getRevision()->getId();
436 $res = Revision
::fetchRevision( $this->testPage
->getTitle() );
438 # note: order is unspecified
440 while ( ( $row = $res->fetchObject() ) ) {
441 $rows[$row->rev_id
] = $row;
444 $this->assertEquals( 1, count( $rows ), 'expected exactly one revision' );
445 $this->assertArrayHasKey( $id, $rows, 'missing revision with id ' . $id );
449 * @covers Revision::getPage
451 public function testGetPage() {
452 $page = $this->testPage
;
454 $orig = $this->makeRevisionWithProps( [ 'page' => $page->getId() ] );
455 $rev = Revision
::newFromId( $orig->getId() );
457 $this->assertEquals( $page->getId(), $rev->getPage() );
461 * @covers Revision::isCurrent
463 public function testIsCurrent() {
464 $rev1 = $this->testPage
->getRevision();
466 # @todo find out if this should be true
467 # $this->assertTrue( $rev1->isCurrent() );
469 $rev1x = Revision
::newFromId( $rev1->getId() );
470 $this->assertTrue( $rev1x->isCurrent() );
472 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
473 $rev2 = $this->testPage
->getRevision();
475 # @todo find out if this should be true
476 # $this->assertTrue( $rev2->isCurrent() );
478 $rev1x = Revision
::newFromId( $rev1->getId() );
479 $this->assertFalse( $rev1x->isCurrent() );
481 $rev2x = Revision
::newFromId( $rev2->getId() );
482 $this->assertTrue( $rev2x->isCurrent() );
486 * @covers Revision::getPrevious
488 public function testGetPrevious() {
489 $oldestRevision = $this->testPage
->getOldestRevision();
490 $latestRevision = $this->testPage
->getLatest();
492 $this->assertNull( $oldestRevision->getPrevious() );
494 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
495 $newRevision = $this->testPage
->getRevision();
497 $this->assertNotNull( $newRevision->getPrevious() );
498 $this->assertEquals( $latestRevision, $newRevision->getPrevious()->getId() );
502 * @covers Revision::getNext
504 public function testGetNext() {
505 $rev1 = $this->testPage
->getRevision();
507 $this->assertNull( $rev1->getNext() );
509 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
510 $rev2 = $this->testPage
->getRevision();
512 $this->assertNotNull( $rev1->getNext() );
513 $this->assertEquals( $rev2->getId(), $rev1->getNext()->getId() );
517 * @covers Revision::newNullRevision
519 public function testNewNullRevision() {
520 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
521 $orig = $this->testPage
->getRevision();
523 $dbw = wfGetDB( DB_MASTER
);
524 $rev = Revision
::newNullRevision( $dbw, $this->testPage
->getId(), 'a null revision', false );
526 $this->assertNotEquals( $orig->getId(), $rev->getId(),
527 'new null revision should have a different id from the original revision' );
528 $this->assertEquals( $orig->getTextId(), $rev->getTextId(),
529 'new null revision should have the same text id as the original revision' );
530 $this->assertEquals( __METHOD__
, $rev->getContent()->getNativeData() );
534 * @covers Revision::insertOn
536 public function testInsertOn() {
537 $ip = '2600:387:ed7:947e:8c16:a1ad:dd34:1dd7';
539 $orig = $this->makeRevisionWithProps( [
543 // Make sure the revision was copied to ip_changes
544 $dbr = wfGetDB( DB_REPLICA
);
545 $res = $dbr->select( 'ip_changes', '*', [ 'ipc_rev_id' => $orig->getId() ] );
546 $row = $res->fetchObject();
548 $this->assertEquals( IP
::toHex( $ip ), $row->ipc_hex
);
549 $this->assertEquals( $orig->getTimestamp(), $row->ipc_rev_timestamp
);
552 public static function provideUserWasLastToEdit() {
553 yield
'actually the last edit' => [ 3, true ];
554 yield
'not the current edit, but still by this user' => [ 2, true ];
555 yield
'edit by another user' => [ 1, false ];
556 yield
'first edit, by this user, but another user edited in the mean time' => [ 0, false ];
560 * @dataProvider provideUserWasLastToEdit
562 public function testUserWasLastToEdit( $sinceIdx, $expectedLast ) {
563 $userA = User
::newFromName( "RevisionStorageTest_userA" );
564 $userB = User
::newFromName( "RevisionStorageTest_userB" );
566 if ( $userA->getId() === 0 ) {
567 $userA = User
::createNew( $userA->getName() );
570 if ( $userB->getId() === 0 ) {
571 $userB = User
::createNew( $userB->getName() );
574 $ns = $this->getDefaultWikitextNS();
576 $dbw = wfGetDB( DB_MASTER
);
579 // create revisions -----------------------------
580 $page = WikiPage
::factory( Title
::newFromText(
581 'RevisionStorageTest_testUserWasLastToEdit', $ns ) );
582 $page->insertOn( $dbw );
584 $revisions[0] = new Revision( [
585 'page' => $page->getId(),
586 // we need the title to determine the page's default content model
587 'title' => $page->getTitle(),
588 'timestamp' => '20120101000000',
589 'user' => $userA->getId(),
591 'content_model' => CONTENT_MODEL_WIKITEXT
,
592 'summary' => 'edit zero'
594 $revisions[0]->insertOn( $dbw );
596 $revisions[1] = new Revision( [
597 'page' => $page->getId(),
598 // still need the title, because $page->getId() is 0 (there's no entry in the page table)
599 'title' => $page->getTitle(),
600 'timestamp' => '20120101000100',
601 'user' => $userA->getId(),
603 'content_model' => CONTENT_MODEL_WIKITEXT
,
604 'summary' => 'edit one'
606 $revisions[1]->insertOn( $dbw );
608 $revisions[2] = new Revision( [
609 'page' => $page->getId(),
610 'title' => $page->getTitle(),
611 'timestamp' => '20120101000200',
612 'user' => $userB->getId(),
614 'content_model' => CONTENT_MODEL_WIKITEXT
,
615 'summary' => 'edit two'
617 $revisions[2]->insertOn( $dbw );
619 $revisions[3] = new Revision( [
620 'page' => $page->getId(),
621 'title' => $page->getTitle(),
622 'timestamp' => '20120101000300',
623 'user' => $userA->getId(),
625 'content_model' => CONTENT_MODEL_WIKITEXT
,
626 'summary' => 'edit three'
628 $revisions[3]->insertOn( $dbw );
630 $revisions[4] = new Revision( [
631 'page' => $page->getId(),
632 'title' => $page->getTitle(),
633 'timestamp' => '20120101000200',
634 'user' => $userA->getId(),
636 'content_model' => CONTENT_MODEL_WIKITEXT
,
637 'summary' => 'edit four'
639 $revisions[4]->insertOn( $dbw );
641 // test it ---------------------------------
642 $since = $revisions[$sinceIdx]->getTimestamp();
644 $wasLast = Revision
::userWasLastToEdit( $dbw, $page->getId(), $userA->getId(), $since );
646 $this->assertEquals( $expectedLast, $wasLast );
650 * @param string $text
651 * @param string $title
652 * @param string $model
653 * @param string $format
657 private function newTestRevision( $text, $title = "Test",
658 $model = CONTENT_MODEL_WIKITEXT
, $format = null
660 if ( is_string( $title ) ) {
661 $title = Title
::newFromText( $title );
664 $content = ContentHandler
::makeContent( $text, $title, $model, $format );
672 'content' => $content,
673 'length' => $content->getSize(),
674 'comment' => "testing",
675 'minor_edit' => false,
677 'content_format' => $format,
684 public function provideGetContentModel() {
685 // NOTE: we expect the help namespace to always contain wikitext
687 [ 'hello world', 'Help:Hello', null, null, CONTENT_MODEL_WIKITEXT
],
688 [ 'hello world', 'User:hello/there.css', null, null, CONTENT_MODEL_CSS
],
689 [ serialize( 'hello world' ), 'Dummy:Hello', null, null, DummyContentForTesting
::MODEL_ID
],
694 * @dataProvider provideGetContentModel
695 * @covers Revision::getContentModel
697 public function testGetContentModel( $text, $title, $model, $format, $expectedModel ) {
698 $rev = $this->newTestRevision( $text, $title, $model, $format );
700 $this->assertEquals( $expectedModel, $rev->getContentModel() );
703 public function provideGetContentFormat() {
704 // NOTE: we expect the help namespace to always contain wikitext
706 [ 'hello world', 'Help:Hello', null, null, CONTENT_FORMAT_WIKITEXT
],
707 [ 'hello world', 'Help:Hello', CONTENT_MODEL_CSS
, null, CONTENT_FORMAT_CSS
],
708 [ 'hello world', 'User:hello/there.css', null, null, CONTENT_FORMAT_CSS
],
709 [ serialize( 'hello world' ), 'Dummy:Hello', null, null, DummyContentForTesting
::MODEL_ID
],
714 * @dataProvider provideGetContentFormat
715 * @covers Revision::getContentFormat
717 public function testGetContentFormat( $text, $title, $model, $format, $expectedFormat ) {
718 $rev = $this->newTestRevision( $text, $title, $model, $format );
720 $this->assertEquals( $expectedFormat, $rev->getContentFormat() );
723 public function provideGetContentHandler() {
724 // NOTE: we expect the help namespace to always contain wikitext
726 [ 'hello world', 'Help:Hello', null, null, 'WikitextContentHandler' ],
727 [ 'hello world', 'User:hello/there.css', null, null, 'CssContentHandler' ],
728 [ serialize( 'hello world' ), 'Dummy:Hello', null, null, 'DummyContentHandlerForTesting' ],
733 * @dataProvider provideGetContentHandler
734 * @covers Revision::getContentHandler
736 public function testGetContentHandler( $text, $title, $model, $format, $expectedClass ) {
737 $rev = $this->newTestRevision( $text, $title, $model, $format );
739 $this->assertEquals( $expectedClass, get_class( $rev->getContentHandler() ) );
742 public function provideGetContent() {
743 // NOTE: we expect the help namespace to always contain wikitext
745 [ 'hello world', 'Help:Hello', null, null, Revision
::FOR_PUBLIC
, 'hello world' ],
747 serialize( 'hello world' ),
749 DummyContentForTesting
::MODEL_ID
,
751 Revision
::FOR_PUBLIC
,
752 serialize( 'hello world' )
755 serialize( 'hello world' ),
759 Revision
::FOR_PUBLIC
,
760 serialize( 'hello world' )
766 * @dataProvider provideGetContent
767 * @covers Revision::getContent
769 public function testGetContent( $text, $title, $model, $format,
770 $audience, $expectedSerialization
772 $rev = $this->newTestRevision( $text, $title, $model, $format );
773 $content = $rev->getContent( $audience );
776 $expectedSerialization,
777 is_null( $content ) ?
null : $content->serialize( $format )
782 * @covers Revision::getContent
784 public function testGetContent_failure() {
785 $rev = new Revision( [
786 'page' => $this->testPage
->getId(),
787 'content_model' => $this->testPage
->getContentModel(),
788 'text_id' => 123456789, // not in the test DB
791 $this->assertNull( $rev->getContent(),
792 "getContent() should return null if the revision's text blob could not be loaded." );
794 // NOTE: check this twice, once for lazy initialization, and once with the cached value.
795 $this->assertNull( $rev->getContent(),
796 "getContent() should return null if the revision's text blob could not be loaded." );
799 public function provideGetSize() {
801 [ "hello world.", CONTENT_MODEL_WIKITEXT
, 12 ],
802 [ serialize( "hello world." ), DummyContentForTesting
::MODEL_ID
, 12 ],
807 * @covers Revision::getSize
808 * @dataProvider provideGetSize
810 public function testGetSize( $text, $model, $expected_size ) {
811 $rev = $this->newTestRevision( $text, 'RevisionTest_testGetSize', $model );
812 $this->assertEquals( $expected_size, $rev->getSize() );
815 public function provideGetSha1() {
817 [ "hello world.", CONTENT_MODEL_WIKITEXT
, Revision
::base36Sha1( "hello world." ) ],
819 serialize( "hello world." ),
820 DummyContentForTesting
::MODEL_ID
,
821 Revision
::base36Sha1( serialize( "hello world." ) )
827 * @covers Revision::getSha1
828 * @dataProvider provideGetSha1
830 public function testGetSha1( $text, $model, $expected_hash ) {
831 $rev = $this->newTestRevision( $text, 'RevisionTest_testGetSha1', $model );
832 $this->assertEquals( $expected_hash, $rev->getSha1() );
836 * Tests whether $rev->getContent() returns a clone when needed.
838 * @covers Revision::getContent
840 public function testGetContentClone() {
841 $content = new RevisionTestModifyableContent( "foo" );
847 'title' => Title
::newFromText( "testGetContentClone_dummy" ),
849 'content' => $content,
850 'length' => $content->getSize(),
851 'comment' => "testing",
852 'minor_edit' => false,
856 /** @var RevisionTestModifyableContent $content */
857 $content = $rev->getContent( Revision
::RAW
);
858 $content->setText( "bar" );
860 /** @var RevisionTestModifyableContent $content2 */
861 $content2 = $rev->getContent( Revision
::RAW
);
862 // content is mutable, expect clone
863 $this->assertNotSame( $content, $content2, "expected a clone" );
864 // clone should contain the original text
865 $this->assertEquals( "foo", $content2->getText() );
867 $content2->setText( "bla bla" );
868 // clones should be independent
869 $this->assertEquals( "bar", $content->getText() );
873 * Tests whether $rev->getContent() returns the same object repeatedly if appropriate.
874 * @covers Revision::getContent
876 public function testGetContentUncloned() {
877 $rev = $this->newTestRevision( "hello", "testGetContentUncloned_dummy", CONTENT_MODEL_WIKITEXT
);
878 $content = $rev->getContent( Revision
::RAW
);
879 $content2 = $rev->getContent( Revision
::RAW
);
881 // for immutable content like wikitext, this should be the same object
882 $this->assertSame( $content, $content2 );
886 * @covers Revision::loadFromId
888 public function testLoadFromId() {
889 $rev = $this->testPage
->getRevision();
890 $this->assertRevEquals(
892 Revision
::loadFromId( wfGetDB( DB_MASTER
), $rev->getId() )
897 * @covers Revision::loadFromPageId
899 public function testLoadFromPageId() {
900 $this->assertRevEquals(
901 $this->testPage
->getRevision(),
902 Revision
::loadFromPageId( wfGetDB( DB_MASTER
), $this->testPage
->getId() )
907 * @covers Revision::loadFromPageId
909 public function testLoadFromPageIdWithLatestRevId() {
910 $this->assertRevEquals(
911 $this->testPage
->getRevision(),
912 Revision
::loadFromPageId(
913 wfGetDB( DB_MASTER
),
914 $this->testPage
->getId(),
915 $this->testPage
->getLatest()
921 * @covers Revision::loadFromPageId
923 public function testLoadFromPageIdWithNotLatestRevId() {
924 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
925 $this->assertRevEquals(
926 $this->testPage
->getRevision()->getPrevious(),
927 Revision
::loadFromPageId(
928 wfGetDB( DB_MASTER
),
929 $this->testPage
->getId(),
930 $this->testPage
->getRevision()->getPrevious()->getId()
936 * @covers Revision::loadFromTitle
938 public function testLoadFromTitle() {
939 $this->assertRevEquals(
940 $this->testPage
->getRevision(),
941 Revision
::loadFromTitle( wfGetDB( DB_MASTER
), $this->testPage
->getTitle() )
946 * @covers Revision::loadFromTitle
948 public function testLoadFromTitleWithLatestRevId() {
949 $this->assertRevEquals(
950 $this->testPage
->getRevision(),
951 Revision
::loadFromTitle(
952 wfGetDB( DB_MASTER
),
953 $this->testPage
->getTitle(),
954 $this->testPage
->getLatest()
960 * @covers Revision::loadFromTitle
962 public function testLoadFromTitleWithNotLatestRevId() {
963 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
964 $this->assertRevEquals(
965 $this->testPage
->getRevision()->getPrevious(),
966 Revision
::loadFromTitle(
967 wfGetDB( DB_MASTER
),
968 $this->testPage
->getTitle(),
969 $this->testPage
->getRevision()->getPrevious()->getId()
975 * @covers Revision::loadFromTimestamp()
977 public function testLoadFromTimestamp() {
978 $this->assertRevEquals(
979 $this->testPage
->getRevision(),
980 Revision
::loadFromTimestamp(
981 wfGetDB( DB_MASTER
),
982 $this->testPage
->getTitle(),
983 $this->testPage
->getRevision()->getTimestamp()