Merge "Revision: Handle all return values of Title::newFromId"
[lhc/web/wiklou.git] / tests / phpunit / includes / RevisionDbTestBase.php
index 9ab76c8..6139524 100644 (file)
@@ -649,6 +649,7 @@ abstract class RevisionDbTestBase extends MediaWikiTestCase {
        }
 
        /**
+        * @covers Revision::userWasLastToEdit
         * @dataProvider provideUserWasLastToEdit
         */
        public function testUserWasLastToEdit( $sinceIdx, $expectedLast ) {
@@ -1363,6 +1364,24 @@ abstract class RevisionDbTestBase extends MediaWikiTestCase {
                $this->assertEquals( $rev->getId(), $cachedRow->rev_id );
        }
 
+       public function testNewKnownCurrent_withPageId() {
+               $db = wfGetDB( DB_MASTER );
+
+               $this->testPage->doEditContent( new WikitextContent( __METHOD__ ), __METHOD__ );
+               $rev = $this->testPage->getRevision();
+
+               $pageId = $this->testPage->getId();
+
+               $newRev = Revision::newKnownCurrent( $db, $pageId, $rev->getId() );
+               $this->assertRevEquals( $rev, $newRev );
+       }
+
+       public function testNewKnownCurrent_returnsFalseWhenTitleDoesntExist() {
+               $db = wfGetDB( DB_MASTER );
+
+               $this->assertFalse( Revision::newKnownCurrent( $db, 0 ) );
+       }
+
        public function provideUserCanBitfield() {
                yield [ 0, 0, [], null, true ];
                // Bitfields match, user has no permissions