RevisionIntegrationTest for loadFromId & loadFromPageId
authoraddshore <addshorewiki@gmail.com>
Sat, 14 Oct 2017 10:35:11 +0000 (11:35 +0100)
committerKunal Mehta <legoktm@member.fsf.org>
Tue, 17 Oct 2017 00:55:24 +0000 (17:55 -0700)
Change-Id: I31431267d761b5d97d7e298c3451341358d54bba

tests/phpunit/includes/RevisionIntegrationTest.php

index 45e33db..7713329 100644 (file)
@@ -791,4 +791,54 @@ class RevisionIntegrationTest extends MediaWikiTestCase {
                $this->assertSame( $content, $content2 );
        }
 
+       /**
+        * @covers Revision::loadFromId
+        */
+       public function testLoadFromId() {
+               $rev = $this->testPage->getRevision();
+               $this->assertRevEquals(
+                       $rev,
+                       Revision::loadFromId( wfGetDB( DB_MASTER ), $rev->getId() )
+               );
+       }
+
+       /**
+        * @covers Revision::loadFromPageId
+        */
+       public function testLoadFromPageId() {
+               $this->assertRevEquals(
+                       $this->testPage->getRevision(),
+                       Revision::loadFromPageId( wfGetDB( DB_MASTER ), $this->testPage->getId() )
+               );
+       }
+
+       /**
+        * @covers Revision::loadFromPageId
+        */
+       public function testLoadFromPageIdWithLatestRevId() {
+               $this->assertRevEquals(
+                       $this->testPage->getRevision(),
+                       Revision::loadFromPageId(
+                               wfGetDB( DB_MASTER ),
+                               $this->testPage->getId(),
+                               $this->testPage->getLatest()
+                       )
+               );
+       }
+
+       /**
+        * @covers Revision::loadFromPageId
+        */
+       public function testLoadFromPageIdWithNotLatestRevId() {
+               $this->testPage->doEditContent( new WikitextContent( __METHOD__ ), __METHOD__ );
+               $this->assertRevEquals(
+                       $this->testPage->getRevision()->getPrevious(),
+                       Revision::loadFromPageId(
+                               wfGetDB( DB_MASTER ),
+                               $this->testPage->getId(),
+                               $this->testPage->getRevision()->getPrevious()->getId()
+                       )
+               );
+       }
+
 }