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::newFromTitle
157 public function testNewFromTitle_withoutId() {
158 $latestRevId = $this->testPage
->getLatest();
160 $rev = Revision
::newFromTitle( $this->testPage
->getTitle() );
162 $this->assertTrue( $this->testPage
->getTitle()->equals( $rev->getTitle() ) );
163 $this->assertEquals( $latestRevId, $rev->getId() );
167 * @covers Revision::newFromTitle
169 public function testNewFromTitle_withId() {
170 $latestRevId = $this->testPage
->getLatest();
172 $rev = Revision
::newFromTitle( $this->testPage
->getTitle(), $latestRevId );
174 $this->assertTrue( $this->testPage
->getTitle()->equals( $rev->getTitle() ) );
175 $this->assertEquals( $latestRevId, $rev->getId() );
179 * @covers Revision::newFromTitle
181 public function testNewFromTitle_withBadId() {
182 $latestRevId = $this->testPage
->getLatest();
184 $rev = Revision
::newFromTitle( $this->testPage
->getTitle(), $latestRevId +
1 );
186 $this->assertNull( $rev );
190 * @covers Revision::newFromRow
192 public function testNewFromRow() {
193 $orig = $this->makeRevisionWithProps();
195 $dbr = wfGetDB( DB_REPLICA
);
196 $res = $dbr->select( 'revision', Revision
::selectFields(), [ 'rev_id' => $orig->getId() ] );
197 $this->assertTrue( is_object( $res ), 'query failed' );
199 $row = $res->fetchObject();
202 $rev = Revision
::newFromRow( $row );
204 $this->assertRevEquals( $orig, $rev );
207 public function provideNewFromArchiveRow() {
223 return $f +
[ 'ar_namespace', 'ar_title' ];
229 return $f +
[ 'ar_namespace', 'ar_title' ];
235 unset( $f['ar_text_id'] );
242 unset( $f['ar_text_id'] );
249 * @dataProvider provideNewFromArchiveRow
250 * @covers Revision::newFromArchiveRow
252 public function testNewFromArchiveRow( $contentHandlerUseDB, $selectModifier ) {
253 $this->setMwGlobals( 'wgContentHandlerUseDB', $contentHandlerUseDB );
255 $page = $this->createPage(
256 'RevisionStorageTest_testNewFromArchiveRow',
258 CONTENT_MODEL_WIKITEXT
260 $orig = $page->getRevision();
261 $page->doDeleteArticle( 'test Revision::newFromArchiveRow' );
263 $dbr = wfGetDB( DB_REPLICA
);
264 $selectFields = $selectModifier( Revision
::selectArchiveFields() );
266 'archive', $selectFields, [ 'ar_rev_id' => $orig->getId() ]
268 $this->assertTrue( is_object( $res ), 'query failed' );
270 $row = $res->fetchObject();
273 $rev = Revision
::newFromArchiveRow( $row );
275 $this->assertRevEquals( $orig, $rev );
279 * @covers Revision::newFromArchiveRow
281 public function testNewFromArchiveRowOverrides() {
282 $page = $this->createPage(
283 'RevisionStorageTest_testNewFromArchiveRow',
285 CONTENT_MODEL_WIKITEXT
287 $orig = $page->getRevision();
288 $page->doDeleteArticle( 'test Revision::newFromArchiveRow' );
290 $dbr = wfGetDB( DB_REPLICA
);
292 'archive', Revision
::selectArchiveFields(), [ 'ar_rev_id' => $orig->getId() ]
294 $this->assertTrue( is_object( $res ), 'query failed' );
296 $row = $res->fetchObject();
299 $rev = Revision
::newFromArchiveRow( $row, [ 'comment' => 'SOMEOVERRIDE' ] );
301 $this->assertNotEquals( $orig->getComment(), $rev->getComment() );
302 $this->assertEquals( 'SOMEOVERRIDE', $rev->getComment() );
306 * @covers Revision::newFromId
308 public function testNewFromId() {
309 $orig = $this->testPage
->getRevision();
310 $rev = Revision
::newFromId( $orig->getId() );
311 $this->assertRevEquals( $orig, $rev );
315 * @covers Revision::newFromPageId
317 public function testNewFromPageId() {
318 $rev = Revision
::newFromPageId( $this->testPage
->getId() );
319 $this->assertRevEquals(
320 $this->testPage
->getRevision(),
326 * @covers Revision::newFromPageId
328 public function testNewFromPageIdWithLatestId() {
329 $rev = Revision
::newFromPageId(
330 $this->testPage
->getId(),
331 $this->testPage
->getLatest()
333 $this->assertRevEquals(
334 $this->testPage
->getRevision(),
340 * @covers Revision::newFromPageId
342 public function testNewFromPageIdWithNotLatestId() {
343 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
344 $rev = Revision
::newFromPageId(
345 $this->testPage
->getId(),
346 $this->testPage
->getRevision()->getPrevious()->getId()
348 $this->assertRevEquals(
349 $this->testPage
->getRevision()->getPrevious(),
355 * @covers Revision::fetchRevision
357 public function testFetchRevision() {
358 // Hidden process cache assertion below
359 $this->testPage
->getRevision()->getId();
361 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
362 $id = $this->testPage
->getRevision()->getId();
364 $res = Revision
::fetchRevision( $this->testPage
->getTitle() );
366 # note: order is unspecified
368 while ( ( $row = $res->fetchObject() ) ) {
369 $rows[$row->rev_id
] = $row;
372 $this->assertEquals( 1, count( $rows ), 'expected exactly one revision' );
373 $this->assertArrayHasKey( $id, $rows, 'missing revision with id ' . $id );
377 * @covers Revision::getPage
379 public function testGetPage() {
380 $page = $this->testPage
;
382 $orig = $this->makeRevisionWithProps( [ 'page' => $page->getId() ] );
383 $rev = Revision
::newFromId( $orig->getId() );
385 $this->assertEquals( $page->getId(), $rev->getPage() );
389 * @covers Revision::isCurrent
391 public function testIsCurrent() {
392 $rev1 = $this->testPage
->getRevision();
394 # @todo find out if this should be true
395 # $this->assertTrue( $rev1->isCurrent() );
397 $rev1x = Revision
::newFromId( $rev1->getId() );
398 $this->assertTrue( $rev1x->isCurrent() );
400 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
401 $rev2 = $this->testPage
->getRevision();
403 # @todo find out if this should be true
404 # $this->assertTrue( $rev2->isCurrent() );
406 $rev1x = Revision
::newFromId( $rev1->getId() );
407 $this->assertFalse( $rev1x->isCurrent() );
409 $rev2x = Revision
::newFromId( $rev2->getId() );
410 $this->assertTrue( $rev2x->isCurrent() );
414 * @covers Revision::getPrevious
416 public function testGetPrevious() {
417 $oldestRevision = $this->testPage
->getOldestRevision();
418 $latestRevision = $this->testPage
->getLatest();
420 $this->assertNull( $oldestRevision->getPrevious() );
422 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
423 $newRevision = $this->testPage
->getRevision();
425 $this->assertNotNull( $newRevision->getPrevious() );
426 $this->assertEquals( $latestRevision, $newRevision->getPrevious()->getId() );
430 * @covers Revision::getNext
432 public function testGetNext() {
433 $rev1 = $this->testPage
->getRevision();
435 $this->assertNull( $rev1->getNext() );
437 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
438 $rev2 = $this->testPage
->getRevision();
440 $this->assertNotNull( $rev1->getNext() );
441 $this->assertEquals( $rev2->getId(), $rev1->getNext()->getId() );
445 * @covers Revision::newNullRevision
447 public function testNewNullRevision() {
448 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
449 $orig = $this->testPage
->getRevision();
451 $dbw = wfGetDB( DB_MASTER
);
452 $rev = Revision
::newNullRevision( $dbw, $this->testPage
->getId(), 'a null revision', false );
454 $this->assertNotEquals( $orig->getId(), $rev->getId(),
455 'new null revision should have a different id from the original revision' );
456 $this->assertEquals( $orig->getTextId(), $rev->getTextId(),
457 'new null revision should have the same text id as the original revision' );
458 $this->assertEquals( __METHOD__
, $rev->getContent()->getNativeData() );
462 * @covers Revision::insertOn
464 public function testInsertOn() {
465 $ip = '2600:387:ed7:947e:8c16:a1ad:dd34:1dd7';
467 $orig = $this->makeRevisionWithProps( [
471 // Make sure the revision was copied to ip_changes
472 $dbr = wfGetDB( DB_REPLICA
);
473 $res = $dbr->select( 'ip_changes', '*', [ 'ipc_rev_id' => $orig->getId() ] );
474 $row = $res->fetchObject();
476 $this->assertEquals( IP
::toHex( $ip ), $row->ipc_hex
);
477 $this->assertEquals( $orig->getTimestamp(), $row->ipc_rev_timestamp
);
480 public static function provideUserWasLastToEdit() {
481 yield
'actually the last edit' => [ 3, true ];
482 yield
'not the current edit, but still by this user' => [ 2, true ];
483 yield
'edit by another user' => [ 1, false ];
484 yield
'first edit, by this user, but another user edited in the mean time' => [ 0, false ];
488 * @dataProvider provideUserWasLastToEdit
490 public function testUserWasLastToEdit( $sinceIdx, $expectedLast ) {
491 $userA = User
::newFromName( "RevisionStorageTest_userA" );
492 $userB = User
::newFromName( "RevisionStorageTest_userB" );
494 if ( $userA->getId() === 0 ) {
495 $userA = User
::createNew( $userA->getName() );
498 if ( $userB->getId() === 0 ) {
499 $userB = User
::createNew( $userB->getName() );
502 $ns = $this->getDefaultWikitextNS();
504 $dbw = wfGetDB( DB_MASTER
);
507 // create revisions -----------------------------
508 $page = WikiPage
::factory( Title
::newFromText(
509 'RevisionStorageTest_testUserWasLastToEdit', $ns ) );
510 $page->insertOn( $dbw );
512 $revisions[0] = new Revision( [
513 'page' => $page->getId(),
514 // we need the title to determine the page's default content model
515 'title' => $page->getTitle(),
516 'timestamp' => '20120101000000',
517 'user' => $userA->getId(),
519 'content_model' => CONTENT_MODEL_WIKITEXT
,
520 'summary' => 'edit zero'
522 $revisions[0]->insertOn( $dbw );
524 $revisions[1] = new Revision( [
525 'page' => $page->getId(),
526 // still need the title, because $page->getId() is 0 (there's no entry in the page table)
527 'title' => $page->getTitle(),
528 'timestamp' => '20120101000100',
529 'user' => $userA->getId(),
531 'content_model' => CONTENT_MODEL_WIKITEXT
,
532 'summary' => 'edit one'
534 $revisions[1]->insertOn( $dbw );
536 $revisions[2] = new Revision( [
537 'page' => $page->getId(),
538 'title' => $page->getTitle(),
539 'timestamp' => '20120101000200',
540 'user' => $userB->getId(),
542 'content_model' => CONTENT_MODEL_WIKITEXT
,
543 'summary' => 'edit two'
545 $revisions[2]->insertOn( $dbw );
547 $revisions[3] = new Revision( [
548 'page' => $page->getId(),
549 'title' => $page->getTitle(),
550 'timestamp' => '20120101000300',
551 'user' => $userA->getId(),
553 'content_model' => CONTENT_MODEL_WIKITEXT
,
554 'summary' => 'edit three'
556 $revisions[3]->insertOn( $dbw );
558 $revisions[4] = new Revision( [
559 'page' => $page->getId(),
560 'title' => $page->getTitle(),
561 'timestamp' => '20120101000200',
562 'user' => $userA->getId(),
564 'content_model' => CONTENT_MODEL_WIKITEXT
,
565 'summary' => 'edit four'
567 $revisions[4]->insertOn( $dbw );
569 // test it ---------------------------------
570 $since = $revisions[$sinceIdx]->getTimestamp();
572 $wasLast = Revision
::userWasLastToEdit( $dbw, $page->getId(), $userA->getId(), $since );
574 $this->assertEquals( $expectedLast, $wasLast );
578 * @param string $text
579 * @param string $title
580 * @param string $model
581 * @param string $format
585 private function newTestRevision( $text, $title = "Test",
586 $model = CONTENT_MODEL_WIKITEXT
, $format = null
588 if ( is_string( $title ) ) {
589 $title = Title
::newFromText( $title );
592 $content = ContentHandler
::makeContent( $text, $title, $model, $format );
600 'content' => $content,
601 'length' => $content->getSize(),
602 'comment' => "testing",
603 'minor_edit' => false,
605 'content_format' => $format,
612 public function provideGetContentModel() {
613 // NOTE: we expect the help namespace to always contain wikitext
615 [ 'hello world', 'Help:Hello', null, null, CONTENT_MODEL_WIKITEXT
],
616 [ 'hello world', 'User:hello/there.css', null, null, CONTENT_MODEL_CSS
],
617 [ serialize( 'hello world' ), 'Dummy:Hello', null, null, DummyContentForTesting
::MODEL_ID
],
622 * @dataProvider provideGetContentModel
623 * @covers Revision::getContentModel
625 public function testGetContentModel( $text, $title, $model, $format, $expectedModel ) {
626 $rev = $this->newTestRevision( $text, $title, $model, $format );
628 $this->assertEquals( $expectedModel, $rev->getContentModel() );
631 public function provideGetContentFormat() {
632 // NOTE: we expect the help namespace to always contain wikitext
634 [ 'hello world', 'Help:Hello', null, null, CONTENT_FORMAT_WIKITEXT
],
635 [ 'hello world', 'Help:Hello', CONTENT_MODEL_CSS
, null, CONTENT_FORMAT_CSS
],
636 [ 'hello world', 'User:hello/there.css', null, null, CONTENT_FORMAT_CSS
],
637 [ serialize( 'hello world' ), 'Dummy:Hello', null, null, DummyContentForTesting
::MODEL_ID
],
642 * @dataProvider provideGetContentFormat
643 * @covers Revision::getContentFormat
645 public function testGetContentFormat( $text, $title, $model, $format, $expectedFormat ) {
646 $rev = $this->newTestRevision( $text, $title, $model, $format );
648 $this->assertEquals( $expectedFormat, $rev->getContentFormat() );
651 public function provideGetContentHandler() {
652 // NOTE: we expect the help namespace to always contain wikitext
654 [ 'hello world', 'Help:Hello', null, null, 'WikitextContentHandler' ],
655 [ 'hello world', 'User:hello/there.css', null, null, 'CssContentHandler' ],
656 [ serialize( 'hello world' ), 'Dummy:Hello', null, null, 'DummyContentHandlerForTesting' ],
661 * @dataProvider provideGetContentHandler
662 * @covers Revision::getContentHandler
664 public function testGetContentHandler( $text, $title, $model, $format, $expectedClass ) {
665 $rev = $this->newTestRevision( $text, $title, $model, $format );
667 $this->assertEquals( $expectedClass, get_class( $rev->getContentHandler() ) );
670 public function provideGetContent() {
671 // NOTE: we expect the help namespace to always contain wikitext
673 [ 'hello world', 'Help:Hello', null, null, Revision
::FOR_PUBLIC
, 'hello world' ],
675 serialize( 'hello world' ),
677 DummyContentForTesting
::MODEL_ID
,
679 Revision
::FOR_PUBLIC
,
680 serialize( 'hello world' )
683 serialize( 'hello world' ),
687 Revision
::FOR_PUBLIC
,
688 serialize( 'hello world' )
694 * @dataProvider provideGetContent
695 * @covers Revision::getContent
697 public function testGetContent( $text, $title, $model, $format,
698 $audience, $expectedSerialization
700 $rev = $this->newTestRevision( $text, $title, $model, $format );
701 $content = $rev->getContent( $audience );
704 $expectedSerialization,
705 is_null( $content ) ?
null : $content->serialize( $format )
710 * @covers Revision::getContent
712 public function testGetContent_failure() {
713 $rev = new Revision( [
714 'page' => $this->testPage
->getId(),
715 'content_model' => $this->testPage
->getContentModel(),
716 'text_id' => 123456789, // not in the test DB
719 $this->assertNull( $rev->getContent(),
720 "getContent() should return null if the revision's text blob could not be loaded." );
722 // NOTE: check this twice, once for lazy initialization, and once with the cached value.
723 $this->assertNull( $rev->getContent(),
724 "getContent() should return null if the revision's text blob could not be loaded." );
727 public function provideGetSize() {
729 [ "hello world.", CONTENT_MODEL_WIKITEXT
, 12 ],
730 [ serialize( "hello world." ), DummyContentForTesting
::MODEL_ID
, 12 ],
735 * @covers Revision::getSize
736 * @dataProvider provideGetSize
738 public function testGetSize( $text, $model, $expected_size ) {
739 $rev = $this->newTestRevision( $text, 'RevisionTest_testGetSize', $model );
740 $this->assertEquals( $expected_size, $rev->getSize() );
743 public function provideGetSha1() {
745 [ "hello world.", CONTENT_MODEL_WIKITEXT
, Revision
::base36Sha1( "hello world." ) ],
747 serialize( "hello world." ),
748 DummyContentForTesting
::MODEL_ID
,
749 Revision
::base36Sha1( serialize( "hello world." ) )
755 * @covers Revision::getSha1
756 * @dataProvider provideGetSha1
758 public function testGetSha1( $text, $model, $expected_hash ) {
759 $rev = $this->newTestRevision( $text, 'RevisionTest_testGetSha1', $model );
760 $this->assertEquals( $expected_hash, $rev->getSha1() );
764 * Tests whether $rev->getContent() returns a clone when needed.
766 * @covers Revision::getContent
768 public function testGetContentClone() {
769 $content = new RevisionTestModifyableContent( "foo" );
775 'title' => Title
::newFromText( "testGetContentClone_dummy" ),
777 'content' => $content,
778 'length' => $content->getSize(),
779 'comment' => "testing",
780 'minor_edit' => false,
784 /** @var RevisionTestModifyableContent $content */
785 $content = $rev->getContent( Revision
::RAW
);
786 $content->setText( "bar" );
788 /** @var RevisionTestModifyableContent $content2 */
789 $content2 = $rev->getContent( Revision
::RAW
);
790 // content is mutable, expect clone
791 $this->assertNotSame( $content, $content2, "expected a clone" );
792 // clone should contain the original text
793 $this->assertEquals( "foo", $content2->getText() );
795 $content2->setText( "bla bla" );
796 // clones should be independent
797 $this->assertEquals( "bar", $content->getText() );
801 * Tests whether $rev->getContent() returns the same object repeatedly if appropriate.
802 * @covers Revision::getContent
804 public function testGetContentUncloned() {
805 $rev = $this->newTestRevision( "hello", "testGetContentUncloned_dummy", CONTENT_MODEL_WIKITEXT
);
806 $content = $rev->getContent( Revision
::RAW
);
807 $content2 = $rev->getContent( Revision
::RAW
);
809 // for immutable content like wikitext, this should be the same object
810 $this->assertSame( $content, $content2 );
814 * @covers Revision::loadFromId
816 public function testLoadFromId() {
817 $rev = $this->testPage
->getRevision();
818 $this->assertRevEquals(
820 Revision
::loadFromId( wfGetDB( DB_MASTER
), $rev->getId() )
825 * @covers Revision::loadFromPageId
827 public function testLoadFromPageId() {
828 $this->assertRevEquals(
829 $this->testPage
->getRevision(),
830 Revision
::loadFromPageId( wfGetDB( DB_MASTER
), $this->testPage
->getId() )
835 * @covers Revision::loadFromPageId
837 public function testLoadFromPageIdWithLatestRevId() {
838 $this->assertRevEquals(
839 $this->testPage
->getRevision(),
840 Revision
::loadFromPageId(
841 wfGetDB( DB_MASTER
),
842 $this->testPage
->getId(),
843 $this->testPage
->getLatest()
849 * @covers Revision::loadFromPageId
851 public function testLoadFromPageIdWithNotLatestRevId() {
852 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
853 $this->assertRevEquals(
854 $this->testPage
->getRevision()->getPrevious(),
855 Revision
::loadFromPageId(
856 wfGetDB( DB_MASTER
),
857 $this->testPage
->getId(),
858 $this->testPage
->getRevision()->getPrevious()->getId()
864 * @covers Revision::loadFromTitle
866 public function testLoadFromTitle() {
867 $this->assertRevEquals(
868 $this->testPage
->getRevision(),
869 Revision
::loadFromTitle( wfGetDB( DB_MASTER
), $this->testPage
->getTitle() )
874 * @covers Revision::loadFromTitle
876 public function testLoadFromTitleWithLatestRevId() {
877 $this->assertRevEquals(
878 $this->testPage
->getRevision(),
879 Revision
::loadFromTitle(
880 wfGetDB( DB_MASTER
),
881 $this->testPage
->getTitle(),
882 $this->testPage
->getLatest()
888 * @covers Revision::loadFromTitle
890 public function testLoadFromTitleWithNotLatestRevId() {
891 $this->testPage
->doEditContent( new WikitextContent( __METHOD__
), __METHOD__
);
892 $this->assertRevEquals(
893 $this->testPage
->getRevision()->getPrevious(),
894 Revision
::loadFromTitle(
895 wfGetDB( DB_MASTER
),
896 $this->testPage
->getTitle(),
897 $this->testPage
->getRevision()->getPrevious()->getId()
903 * @covers Revision::loadFromTimestamp()
905 public function testLoadFromTimestamp() {
906 $this->assertRevEquals(
907 $this->testPage
->getRevision(),
908 Revision
::loadFromTimestamp(
909 wfGetDB( DB_MASTER
),
910 $this->testPage
->getTitle(),
911 $this->testPage
->getRevision()->getTimestamp()