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

tests/phpunit/includes/RevisionIntegrationTest.php

index 5d96abf..4904f02 100644 (file)
@@ -260,6 +260,46 @@ class RevisionIntegrationTest extends MediaWikiTestCase {
                $this->assertRevEquals( $orig, $rev );
        }
 
+       /**
+        * @covers Revision::newFromPageId
+        */
+       public function testNewFromPageId() {
+               $rev = Revision::newFromPageId( $this->testPage->getId() );
+               $this->assertRevEquals(
+                       $this->testPage->getRevision(),
+                       $rev
+               );
+       }
+
+       /**
+        * @covers Revision::newFromPageId
+        */
+       public function testNewFromPageIdWithLatestId() {
+               $rev = Revision::newFromPageId(
+                       $this->testPage->getId(),
+                       $this->testPage->getLatest()
+               );
+               $this->assertRevEquals(
+                       $this->testPage->getRevision(),
+                       $rev
+               );
+       }
+
+       /**
+        * @covers Revision::newFromPageId
+        */
+       public function testNewFromPageIdWithNotLatestId() {
+               $this->testPage->doEditContent( new WikitextContent( __METHOD__ ), __METHOD__ );
+               $rev = Revision::newFromPageId(
+                       $this->testPage->getId(),
+                       $this->testPage->getRevision()->getPrevious()->getId()
+               );
+               $this->assertRevEquals(
+                       $this->testPage->getRevision()->getPrevious(),
+                       $rev
+               );
+       }
+
        /**
         * @covers Revision::fetchRevision
         */